Cài đặt Cinder với backend LVM.
Kiến thức cần có: LVM
Mô hình cài đặt
- Mô hình cài đặt:
- Controller node:
- eth0: 192.168.30.171/24 - MGMT network
- eth1: 192.168.40.171/24 - Self-service
- eth2: no IP - Provider
- Storage node:
- eth0: 192.168.30.174/24 - MGMT network
- Controller node:
Ở bài này mình sẽ cài đặt Openstack Cinder sử dụng một block device trống /dev/vdb(có thể thay đổi tùy theo môi trường) của Cinder node.
Cài đặt
Trên Controller node.
Chuẩn bị
Trước khi cài đặt Cinder, bạn cần tạo database, thông tin đăng nhập cho dịch vụ, và API endpoint.
- Tạo database:
mysql -uroot -posrootsql << EOF DROP DATABASE IF EXISTS cinder; CREATE DATABASE cinder; GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \ IDENTIFIED BY 'oscindersql'; GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \ IDENTIFIED BY 'oscindersql'; EOF
- Tạo và cấu hình user, service cho cinder:
. admin-openrc
openstack user create --domain default --password=CINDER_PASS cinder
openstack role add --project service --user cinder admin
openstack service create --name cinderv2 \
--description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 \
--description "OpenStack Block Storage" volumev3
openstack endpoint create --region RegionOne \
volumev2 public http://192.168.30.171:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne \
volumev2 internal http://192.168.30.171:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne \
volumev2 admin http://192.168.30.171:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne \
volumev3 public http://192.168.30.171:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne \
volumev3 internal http://192.168.30.171:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne \
volumev3 admin http://192.168.30.171:8776/v3/%\(project_id\)s
Cài đặt gói và cấu hình.
- Cài đặt các gói cần thiết:
yum install openstack-cinder -y
- Cấu hình file
/etc/cinder/cinder.conf
:
cp -p /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak`date +%d-%m-%Y`
cat << EOF > /etc/cinder/cinder.conf
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@192.168.30.171:5672
auth_strategy = keystone
my_ip = 192.168.30.171
[database]
connection = mysql+pymysql://cinder:CINDER_DBPASS@192.168.30.171/cinder
[keystone_authtoken]
www_authenticate_uri = http://192.168.30.171:5000
auth_url = http://192.168.30.171:5000
memcached_servers = 192.168.30.171:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = CINDER_PASS
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
EOF
- Populate database:
su -s /bin/sh -c "cinder-manage db sync" cinder
- Thêm cấu hình region ở mục cinder cho nova: ``` cat « EOF » /etc/nova/nova.conf
[cinder] os_region_name = RegionOne EOF
#### Hoàn tất cài đặt trên controller node.
- Khởi động lại Compute API:
systemctl restart openstack-nova-api.service
- Khởi động và cấu hình tự động khởi động cho các service của Cinder:
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
- Cấu hình firewalld:
firewall-cmd –add-port=8776/tcp –permanent firewall-cmd –reload
### Trên Storage node
#### Chuẩn bị
- Cài một số gói cần thiết:
yum install lvm2 device-mapper-persistent-data -y
- Khởi động dịch vụ LVM metadata và cấu hình nó tự khởi động khi hệ điều hành khởi động:
systemctl enable lvm2-lvmetad.service systemctl start lvm2-lvmetad.service
- Tạo physical volume:
pvcreate /dev/vdb
- Tạo volume group từ pv vừa tạo:
vgcreate cinder-volumes /dev/vdb
- có thể sẽ cần chỉnh sửa /etc/lvm/lvm.conf phần filter.
#### Cài đặt và cấu hình các thành phần
- Cài đặt các gói:
yum install openstack-cinder targetcli python-keystone -y
- Chỉnh sửa file cấu hình của cinder:
```conf
cp -p /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak`date +%d-%m-%Y`
cat << EOF > /etc/cinder/cinder.conf
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@192.168.30.171:5672
auth_strategy = keystone
my_ip = 192.168.30.174
enabled_backends = lvm
glance_api_servers = http://192.168.30.171:9292
[database]
connection = mysql+pymysql://cinder:CINDER_DBPASS@192.168.30.171/cinder
[keystone_authtoken]
www_authenticate_uri = http://192.168.30.171:5000
auth_url = http://192.168.30.171:5000
memcached_servers = 192.168.30.171:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = CINDER_PASS
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
target_protocol = iscsi
target_helper = lioadm
EOF
cp -p /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bakdate +%d-%m-%Y
cat « EOF > /etc/cinder/cinder.conf
[DEFAULT]
transport_url = rabbit://openstack:osrabbitmq@192.168.30.171:5672
auth_strategy = keystone
my_ip = 192.168.30.174
enabled_backends = lvm
glance_api_servers = http://192.168.30.171:9292
[database] connection = mysql+pymysql://cinder:oscindersql@192.168.30.171/cinder
[keystone_authtoken] www_authenticate_uri = http://192.168.30.171:5000 auth_url = http://192.168.30.171:5000 memcached_servers = 192.168.30.171:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = oscinder
[oslo_concurrency] lock_path = /var/lib/cinder/tmp
[lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes target_protocol = iscsi target_helper = lioadm EOF
Hoàn tất cài đặt
systemctl enable openstack-cinder-volume.service target.service
systemctl restart openstack-cinder-volume.service target.service
Tài liệu nguồn:
- https://docs.openstack.org/cinder/train/install/