cheng029 发表于 2015-7-14 15:50:15

云主机基本环境&Keystone 和 云主机Cinder

云主机基本环境&Keystone 和 云主机Cinder
是样题中“任务三、IaaS运维 ”中的单主机Keystone+Cinder配置。
首先应能够运行云主机,正常获取IP地址,配置安全组启用SSH,确认三层交换机上实现管理和外网两个网段之间的路由互通,才可以做这部分内容。

单独一台云主机
3、块存储服务Cinder

(1)配置Cinder控制服务
yum install openstack-cinder

openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:000000@controller/cinder

su -s /bin/sh -c "cinder-manage db sync" cinder

source admin-openrc.sh

keystone user-create --name=cinder --pass=000000 --email=cinder@localhost
keystone user-role-add --user=cinder --tenant=service --role=admin

openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://controller:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_host controller
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_protocol http
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_port 35357
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_password 000000

openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend qpid
openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname controller

keystone service-create --name=cinder --type=volume --description="OpenStack Block Storage"
keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ volume / {print $2}') \
--publicurl=http://controller:8776/v1/%\(tenant_id\)s \
--internalurl=http://controller:8776/v1/%\(tenant_id\)s \
--adminurl=http://controller:8776/v1/%\(tenant_id\)s

keystone service-create --name=cinderv2 --type=volumev2 --description="OpenStack Block Storage v2"
keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ volumev2 / {print $2}') \
--publicurl=http://controller:8776/v2/%\(tenant_id\)s \
--internalurl=http://controller:8776/v2/%\(tenant_id\)s \
--adminurl=http://controller:8776/v2/%\(tenant_id\)s

service openstack-cinder-api start
service openstack-cinder-scheduler start
chkconfig openstack-cinder-api on
chkconfig openstack-cinder-scheduler on

(2)配置Cinder存储服务
使用fdisk对磁盘分区,创建一个LVM类型分区,在本案例中将使用/dev/sda3。
(注意:云主机中的磁盘名称为vda)
fdisk /dev/vda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p    # 显示当前分区

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c1bda

   Device Boot      Start         End      Blocks   IdSystem
/dev/sda1   *         1          64      512000   83Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2            64      6591    52428800   8eLinux LVM

Command (m for help): n    # 创建新分区
Command action
   e   extended
   p   primary partition (1-4)
p    # 主分区
Partition number (1-4): 3    # 分区编号为3
First cylinder (6591-13054, default 6591):   # 起始柱面直接回车6591往后的
Using default value 6591
Last cylinder, +cylinders or +size{K,M,G} (6591-13054, default 13054):   # 结束柱面直接回车
Using default value 13054

Command (m for help): t    # 转换分区类型
Partition number (1-4): 3    # 分区编号为3
Hex code (type L to list codes): 8e      # 转换为Linux LVM分区
Changed system type of partition 3 to 8e (Linux LVM)

Command (m for help): w    # 保存退出

partx -a /dev/vda

pvcreate /dev/vda3

vgcreate cinder-volumes /dev/vda3

vi /etc/lvm/lvm.conf,在devices部分配置LVM将持续扫描的虚拟机实例所使用的设备。
devices {
...
filter = [ "a/vda2/", "a/vda3/", "r/.*/"]      # 添加这一行
...
}
其中vda2为操作系统所在的物理卷设备,vda3为cinder卷所使用的物理卷设备。

yum install scsi-target-utils

openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 云主机IP

openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_host controller

openstack-config --set /etc/cinder/cinder.conf DEFAULT iscsi_helper tgtadm

vi /etc/tgt/targets.conf
include /etc/cinder/volumes/*

service openstack-cinder-volume start
service tgtd start
chkconfig openstack-cinder-volume on
chkconfig tgtd on

(3)使用cinder命令管理云硬盘
cd
source admin-openrc.sh

使用cinder create创建云硬盘,指定名称为cinder-disk,大小为1GB。
# cinder create --display-name cinder-disk 1
+---------------------+--------------------------------------+
|       Property      |                Value               |
+---------------------+--------------------------------------+
|   attachments   |                  []                  |
|availability_zone|               nova               |
|       bootable      |                false               |
|      created_at   |      2015-05-13T05:49:34.264468      |
| display_description |               None               |
|   display_name    |             cinder-disk            |
|      encrypted      |                False               |
|          id         | 9bf11427-8857-47ff-ae8f-fcccf25efc8f |
|       metadata      |                  {}                  |
|         size      |                  1                   |
|   snapshot_id   |               None               |
|   source_volid    |               None               |
|      status       |               creating               |
|   volume_type   |               None               |
+---------------------+--------------------------------------+

查看云硬盘
# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status| Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 9bf11427-8857-47ff-ae8f-fcccf25efc8f | available | cinder-disk|1   |   None    |false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

将云硬盘cinder-disk扩展为2GB。
# cinder extend cinder-disk 2

显示云硬盘的状态
# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status| Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 9bf11427-8857-47ff-ae8f-fcccf25efc8f | available | cinder-disk|2   |   None    |false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

删除云硬盘
# cinder delete cinder-disk


页: [1]
查看完整版本: 云主机基本环境&Keystone 和 云主机Cinder