目標
在《Ubuntu16手動安裝OpenStack——修改鏡像》一文中融蹂,我們通過修改鏡像,實現(xiàn)了ssh密碼訪問實例弄企〕迹看上去,這個openstack系統(tǒng)已經(jīng)可以投入使用了拘领,實際上意乓,也確實可以投入使用了。
但是约素,我們總是追求更好更多的服務(wù)届良。所以接下來,我們繼續(xù)安裝openstack的服務(wù)組件圣猎。本文中要安裝配置的是cinder士葫,主要參考OpenStack Queens : Configure Cinder和Cinder Installation Guide。
cinder簡介
塊存儲服務(wù)(cinder)為用戶實例提供塊存儲設(shè)備送悔。配置和使用存儲的方法由塊存儲驅(qū)動程序確定慢显,或者在多后端配置的情況下由驅(qū)動程序確定。有多種驅(qū)動程序可用:NAS / SAN欠啤,NFS荚藻,iSCSI,Ceph等洁段。Block Storage API和調(diào)度程序服務(wù)通常在控制器節(jié)點上運行鞋喇。根據(jù)所使用的驅(qū)動程序,卷服務(wù)可以在控制器節(jié)點眉撵,計算節(jié)點或獨立存儲節(jié)點上運行侦香。
控制節(jié)點
root用戶
為了避免權(quán)限問題,建議切換到root用戶進行操作(否則要加很多sudo)纽疟。
sudo -i
數(shù)據(jù)庫
1罐韩、登錄數(shù)據(jù)庫
mysql -uroot -p
,密碼為openstack污朽。
2散吵、創(chuàng)建cinder數(shù)據(jù)庫
create database cinder;
3、授權(quán)
grant all privileges on cinder.* to cinder@'localhost' identified by 'openstack';
grant all privileges on cinder.* to cinder@'%' identified by 'openstack';
4、退出數(shù)據(jù)庫
flush privileges;
exit;
證書和端點
1矾睦、使admin環(huán)境生效
. admin-openrc
2晦款、創(chuàng)建cinder用戶,密碼為openstack
openstack user create --domain default --project service --password openstack cinder
3枚冗、給cinder用戶添加admin角色
openstack role add --project service --user cinder admin
4缓溅、創(chuàng)建cinder服務(wù)
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
5、創(chuàng)建cinder服務(wù)端點
openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s
安裝配置
1赁温、下載安裝組件
apt-get -y install cinder-api cinder-scheduler python-cinderclient
2坛怪、備份cinder.conf
mv /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
3、vi /etc/cinder/cinder.conf
股囊,新建cinder.conf內(nèi)容為:
# create new
[DEFAULT]
# define own IP address
my_ip = 172.16.0.105
rootwrap_config = /etc/cinder/rootwrap.conf
api_paste_confg = /etc/cinder/api-paste.ini
state_path = /var/lib/cinder
auth_strategy = keystone
# RabbitMQ connection info
transport_url = rabbit://openstack:openstack@controller
# MariaDB connection info
[database]
connection = mysql+pymysql://cinder:openstack@controller/cinder
# Keystone auth info
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = openstack
[oslo_concurrency]
lock_path = $state_path/tmp
4袜匿、更改權(quán)限
chmod 644 /etc/cinder/cinder.conf
chown root:cinder /etc/cinder/cinder.conf
5、生成數(shù)據(jù)庫數(shù)據(jù)
su -s /bin/bash cinder -c "cinder-manage db sync"
6稚疹、重啟cinder-scheduler
systemctl restart cinder-scheduler
7居灯、查看volume
openstack volume service list
存儲節(jié)點
本文中,我們的存儲節(jié)點和計算節(jié)點在同一個節(jié)點内狗,該節(jié)點的IP為172.16.0.106怪嫌。已經(jīng)安裝的服務(wù)和virtualbox計算節(jié)點(192.168.56.111)相同,包括nova-compute和neutron其屏。
root用戶
為了避免權(quán)限問題喇勋,建議切換到root用戶進行操作(否則要加很多sudo)缨该。
sudo -i
安裝配置
1偎行、安裝cinder-volume
apt-get -y install cinder-volume python-mysqldb
2、備份cinder.conf
mv /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
3贰拿、vi /etc/cinder/cinder.conf
蛤袒,新建cinder.conf內(nèi)容為:
# create new
[DEFAULT]
# define own IP address
my_ip = 172.16.0.106
rootwrap_config = /etc/cinder/rootwrap.conf
api_paste_confg = /etc/cinder/api-paste.ini
state_path = /var/lib/cinder
auth_strategy = keystone
# RabbitMQ connection info
transport_url = rabbit://openstack:openstack@controller
# Glance connection info
glance_api_servers = http://controller:9292
# OK with empty value now
enabled_backends =
# MariaDB connection info
[database]
connection = mysql+pymysql://cinder:openstack@controller/cinder
# Keystone auth info
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = openstack
[oslo_concurrency]
lock_path = $state_path/tmp
4、更改權(quán)限
chmod 644 /etc/cinder/cinder.conf
chown root:cinder /etc/cinder/cinder.conf
5膨更、重啟cinder-volume
systemctl restart cinder-volume
使用lvm卷
存儲節(jié)點
1妙真、在存儲節(jié)點添加硬盤,保證至少有兩塊硬盤荚守。
2珍德、創(chuàng)建物理卷
ll /dev/sd*
pvcreate /dev/sdb
3、創(chuàng)建volume group
vgcreate -s 32M vg_volume01 /dev/sdb
4矗漾、安裝lvm相關(guān)組件
apt-get -y install tgt thin-provisioning-tools
5锈候、vi /etc/cinder/cinder.conf
,如下修改cinder.conf:
# add a value for enabled_backends
enabled_backends = lvm
# add follows to the end
[lvm]
iscsi_helper = tgtadm
# volume group name just created
volume_group = vg_volume01
# IP address of Storage Node
iscsi_ip_address = 172.16.0.106
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volumes_dir = $state_path/volumes
iscsi_protocol = iscsi
6敞贡、重啟服務(wù)
systemctl restart cinder-volume tgt
計算節(jié)點
1泵琳、vi /etc/nova/nova.conf
,編輯nova.conf文件:
# add to the end
[cinder]
os_region_name = RegionOne
2、重啟compute服務(wù)
systemctl restart nova-compute
控制節(jié)點
以上获列,已經(jīng)準備好了cinder服務(wù)谷市,我們在控制節(jié)點使用cinder服務(wù)(也可以在其他機器使用)。
1击孩、假設(shè)我們已經(jīng)按照《Ubuntu16手動安裝OpenStack——創(chuàng)建實例》一文迫悠,創(chuàng)建了一個cirros0實例,ip為10.0.0.206溯壶。
2及皂、登錄cirros0
ssh cirros@10.0.0.206
,密碼默認為gocubsgo且改。
3验烧、在cirros0中查看硬盤
df -h
ls -l /dev/vd*
sudo fdisk -l
可以看到,當前虛擬機只有一塊vda硬盤又跛。
4碍拆、控制節(jié)點中修改voidking用戶環(huán)境,并使環(huán)境生效
echo "export OS_VOLUME_API_VERSION=2" >> ~/voidkingrc
. voidkingrc
5慨蓝、創(chuàng)建卷disk01感混,大小為1G
openstack volume create --size 1 disk01
6、查看卷
openstack volume list
7礼烈、把卷disk01添加給cirros0實例
openstack server list
openstack server add volume cirros0 disk01
8弧满、在cirros0中查看硬盤
ls -l /dev/vd*
發(fā)現(xiàn)cirros0中多出了一塊硬盤vdb。
9此熬、在控制節(jié)點查看卷
openstack volume list
顯示disk01已經(jīng)attach到了cirros0的/dev/vdb庭呜,和我們在cirros0中看到的結(jié)果一致。
10犀忱、移除卷
openstack server remove volume cirros0 disk01
后記
關(guān)于NFS(網(wǎng)絡(luò)文件系統(tǒng))的使用募谎,參考OpenStack Queens : Use Cinder Storage (NFS)。
關(guān)于LVM和NFS格式卷的混合使用阴汇,參考OpenStack Queens : Use Cinder Storage (Multi-BackEnds)数冬。
關(guān)于使用cinder備份卷,參考OpenStack Queens : Configure Cinder Backup搀庶。