文章总目录
Cinder详解与安装
1、组件说明
2、构建实验
1、配置controller节点
[root@controller ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 30
Server version: 5.5.37-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@controller ~]# source admin-openrc.sh
[root@controller ~]# keystone user-create --name cinder --pass CINDER_PASS
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| email | |
| enabled | True |
| id | 81e66a4390474085a9d6eec0498ecbc9 |
| name | cinder |
| username | cinder |
+----------+----------------------------------+
[root@controller ~]# keystone user-role-add --user cinder --tenant service --role admin
[root@controller ~]# keystone service-create --name cinder --type volume --description "OpenStackBlock Storage"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStackBlock Storage |
| enabled | True |
| id | e34f25886150411880594b87633536c8 |
| name | cinder |
| type | volume |
+-------------+----------------------------------+
[root@controller ~]# keystone service-create --name cinderv2 --type volumev2 --description "OpenStackBlock Storage"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStackBlock Storage |
| enabled | True |
| id | d5d4326f4fa14a1f960caed8af2d1ff1 |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
[root@controller ~]# keystone endpoint-create --service-id $(keystone service-list | awk '/ volume /{print $2}') --publicurl http://controller.nice.com:8776/v1/%\(tenant_id\)s --internalurl http://controller.nice.com:8776/v1/%\(tenant_id\)s --adminurl http://controller.nice.com:8776/v1/%\(tenant_id\)s --region regionOne
+-------------+--------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------+
| adminurl | http://controller.nice.com:8776/v1/%(tenant_id)s |
| id | 4262968b5b60490583dd4305b02257a6 |
| internalurl | http://controller.nice.com:8776/v1/%(tenant_id)s |
| publicurl | http://controller.nice.com:8776/v1/%(tenant_id)s |
| region | regionOne |
| service_id | e34f25886150411880594b87633536c8 |
+-------------+--------------------------------------------------+
[root@controller ~]# keystone endpoint-create \
> --service-id $(keystone service-list | awk '/ volumev2 / {print $2}') \
> --publicurl http://controller.nice.com:8776/v2/%\(tenant_id\)s \
> --internalurl http://controller.nice.com:8776/v2/%\(tenant_id\)s \
> --adminurl http://controller.nice.com:8776/v2/%\(tenant_id\)s \
> --region regionOne
+-------------+--------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------+
| adminurl | http://controller.nice.com:8776/v2/%(tenant_id)s |
| id | c1b8efc1f40048fa89ef5d7961d1b7da |
| internalurl | http://controller.nice.com:8776/v2/%(tenant_id)s |
| publicurl | http://controller.nice.com:8776/v2/%(tenant_id)s |
| region | regionOne |
| service_id | d5d4326f4fa14a1f960caed8af2d1ff1 |
+-------------+--------------------------------------------------+
2、配置block节点
[root@block1 ~]# yum install -y ntpdate
[root@block1 ~]# ntpdate -u controller.nice.com
24 Jul 09:07:13 ntpdate[11003]: step time server 192.168.222.5 offset 9415.809954 sec
[root@block1 ~]# crontab -e
# 分钟,小时,日,月,周,年
*/1 * * * * ntpdate -u controller.nice.com &> /dev/null
[root@block1 ~]# systemctl restart crond
[root@block1 ~]# systemctl enable crond
[root@block ~]# pvcreate /dev/sdb
[root@block ~]# vgcreate cinder-volumes /dev/sdb
[root@block ~]# systemctl enable openstack-cinder-volume.service target.service
ln -s '/usr/lib/systemd/system/openstack-cinder-volume.service' '/etc/systemd/system/multi-user.target.wants/openstack-cinder-volume.service'
ln -s '/usr/lib/systemd/system/target.service' '/etc/systemd/system/multi-user.target.wants/target.service'
[root@block ~]# systemctl start openstack-cinder-volume.service target.service
3、测试
[root@controller ~]# source admin-openrc.sh
[root@controller ~]# cinder service-list
+------------------+---------------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+---------------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | controller.nice.com | nova | enabled | up | 2020-07-25T11:02:18.000000 | None |
| cinder-volume | block1.nice.com | nova | enabled | up | 2020-07-25T11:02:11.000000 | None |
+------------------+---------------------+------+---------+-------+----------------------------+-----------------+
[root@controller ~]# source demo-openrc.sh
[root@controller ~]# cinder create --display-name demo-volume1 1
+---------------------+--------------------------------------+
| Property | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| created_at | 2020-07-25T11:02:39.663021 |
| display_description | None |
| display_name | demo-volume1 |
| encrypted | False |
| id | 3aea7f1b-21d9-4bcc-988e-ddec3cd12249 |
| metadata | {} |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| volume_type | None |
+---------------------+--------------------------------------+
[root@controller ~]# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 3aea7f1b-21d9-4bcc-988e-ddec3cd12249 | available | demo-volume1 | 1 | None | false | |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
Cinder组件安装完成