OpenStack-cinder服务部署

Posted logansxb

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack-cinder服务部署相关的知识,希望对你有一定的参考价值。

OpenStack Block Storage服务(Cinder)将持久存储添加到虚拟机。块存储提供用于管理卷的基础结构,并与OpenStack Compute交互以为实例提供卷。该服务还可以管理卷快照和卷类型。

块存储服务包含以下组件:

cinderAPI
接受API请求,并将它们路由到cinder-volumefor操作。
cinder卷
直接与Block Storage服务以及诸如之后的进程交互cinder-scheduler它还通过消息队列与这些进程交互。cinder-volume服务响应发送到块存储服务的读写请求以维持状态。它可以通过驱动程序体系结构与各种存储提供程序进行交互。
cinder-scheduler守护进程
选择要在其上创建卷的最佳存储提供程序节点。一个类似的组成部分nova-scheduler
cinder-backup守护进程
cinder-backup服务为备份存储提供程序提供任何类型的备份卷。cinder-volume服务一样,它可以通过驱动程序体系结构与各种存储提供程序进行交互。
消息队列
          消息队列在块存储进程之间路由信息。
我们需要在存储节点添加一块硬盘sdb
我们先配置控制节点
1.创建cinder数据库;
mysql> CREATE DATABASE cinder;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON cinder.* TO cinder@localhost     ->   IDENTIFIED BY 123;
Query OK, 0 rows affected, 1 warning (0.15 sec)

mysql> GRANT ALL PRIVILEGES ON cinder.* TO cinder@%     ->   IDENTIFIED BY 123;
Query OK, 0 rows affected, 1 warning (0.00 sec)

2.创建cinder用户;

[root@sxb1 ~]# openstack user create --domain default --password-prompt cinder
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | c14cbc9906274a968452fbe7a3f67474 |
| name                | cinder                           |
| options             |                                |
| password_expires_at | None                             |
+---------------------+----------------------------------+

3.将admin角色添加到cinder用户;

[root@sxb1 ~]# openstack role add --project service --user cinder admin

4.创建cinder服务cinderv2、cinderv3(因为有两个版本);

[root@sxb1 ~]# openstack service create --name cinderv2 >   --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Block Storage          |
| enabled     | True                             |
| id          | 049c3b344b134b5695a7223658a0c625 |
| name        | cinderv2                         |
| type        | volumev2                         |
+-------------+----------------------------------+
[root@sxb1 ~]# openstack service create --name cinderv3 >   --description "OpenStack Block Storage" volumev3
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Block Storage          |
| enabled     | True                             |
| id          | 896ebdd517f44b45bc9c5beb9e7e3192 |
| name        | cinderv3                         |
| type        | volumev3                         |
+-------------+----------------------------------+

5.创建Block Storage服务API端点;

卷2

[root@sxb1 ~]# openstack endpoint create --region RegionOne   volumev2 public http://192.168.88.101:8776/v2/%\(project_id\)s^C
[root@sxb1 ~]# openstack endpoint create --region RegionOne   volumev2 internal http://192.168.88.101:8776/v2/%\(project_id\)s^C
[root@sxb1 ~]# openstack endpoint create --region RegionOne   volumev2 admin http://192.168.88.101:8776/v2/%\(project_id\)s

卷3

[root@sxb1 ~]# openstack endpoint create --region RegionOne   volumev3 public http://192.168.88.101:8776/v3/%\(project_id\)s^C
[root@sxb1 ~]# openstack endpoint create --region RegionOne   volumev3 internal http://192.168.88.101:8776/v3/%\(project_id\)s^C
[root@sxb1 ~]# openstack endpoint create --region RegionOne   volumev3 admin http://192.168.88.101:8776/v3/%\(project_id\)s

6.安装cinder相关组件;

[root@sxb1 ~]# yum install openstack-cinder -y

7.配置cinder文件;

[root@sxb1 ~]# vim /etc/cinder/cinder.conf 

[DEFAULT]
transport_url = rabbit://openstack:123@192.168.88.101
auth_strategy = keystone

[database]
connection = mysql+pymysql://cinder:123@192.168.88.101/cinder

[keystone_authtoken]
www_authenticate_uri = http://192.168.88.101:5000
auth_url = http://192.168.88.101:5000
memcached_servers = 192.168.88.101:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 123

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

8.初始化数据库(返回信息不用管);

[root@sxb1 ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
Deprecated: Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".

9.配置nova文件;

[root@sxb1 ~]# vim /etc/nova/nova.conf

[cinder]
os_region_name = RegionOne

10.重启nova服务;

[root@sxb1 ~]# systemctl restart openstack-nova-api.service

11.启动控制节点cinder服务(status查看服务状态);

[root@sxb1 ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-api.service to /usr/lib/systemd/system/openstack-cinder-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-scheduler.service to /usr/lib/systemd/system/openstack-cinder-scheduler.service.
[root@sxb1 ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service

我们来配置存储节点

1.安装cinder相关组件;

[root@sxb3 ~]# yum install lvm2 device-mapper-persistent-data -y

2.启动cinder服务;

[root@sxb3 ~]# systemctl enable lvm2-lvmetad.service
[root@sxb3 ~]# systemctl start lvm2-lvmetad.service
[root@sxb3 ~]# systemctl status lvm2-lvmetad.service
● lvm2-lvmetad.service - LVM2 metadata daemon
   Loaded: loaded (/usr/lib/systemd/system/lvm2-lvmetad.service; static; vendor preset: enabled)
   Active: active (running) since Mon 2019-09-09 07:28:32 EDT; 47min ago
     Docs: man:lvmetad(8)
 Main PID: 519 (lvmetad)
   CGroup: /system.slice/lvm2-lvmetad.service
           └─519 /usr/sbin/lvmetad -f

Sep 09 07:28:32 sxb3.103.com systemd[1]: Started LVM2 metadata daemon.

3.创建一个LVM;

[root@sxb3 ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
[root@sxb3 ~]# vgcreate cinder-volumes /dev/sdb
  Volume group "cinder-volumes" successfully created

4.配置lvm文件;

[root@sxb3 ~]# vim /etc/lvm/lvm.conf 

devices 
        filter = [ "a/sdb/", "r/.*/"]

5.安装组件;

[root@sxb3 ~]# yum install openstack-cinder targetcli python-keystone -y

6.配置cinder文件;

[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
target_protocol = iscsi
target_helper = lioadm

[DEFAULT]
transport_url = rabbit://openstack:123@192.168.88.101
auth_strategy = keystone
my_ip = 192.168.88.103
enabled_backends = lvm
glance_api_servers = http://192.168.88.101:9292

[database]
connection = mysql+pymysql://cinder:123@192.168.88.101/cinder

[keystone_authtoken]
www_authenticate_uri = http://192.168.88.101:5000
auth_url = http://192.168.88.101:5000
memcached_servers = 192.168.88.101:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 123

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

7.启动cinder服务(status查看服务状态);

[root@sxb3 ~]# systemctl enable openstack-cinder-volume.service target.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-volume.service to /usr/lib/systemd/system/openstack-cinder-volume.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.
[root@sxb3 ~]# systemctl start openstack-cinder-volume.service target.service
[root@sxb3 ~]# systemctl status openstack-cinder-volume.service target.service
● openstack-cinder-volume.service - OpenStack Cinder Volume Server
   Loaded: loaded (/usr/lib/systemd/system/openstack-cinder-volume.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-09-09 08:53:33 EDT; 7s ago
 Main PID: 2592 (cinder-volume)
   CGroup: /system.slice/openstack-cinder-volume.service
           ├─2592 /usr/bin/python2 /usr/bin/cinder-volume --config-file /usr/sha...
           └─2631 /usr/bin/python2 /usr/bin/cinder-volume --config-file /usr/sha...

Sep 09 08:53:33 sxb3.103.com systemd[1]: Started OpenStack Cinder Volume Server.
Sep 09 08:53:37 sxb3.103.com cinder-volume[2592]: Deprecated: Option "logdir" f....
Sep 09 08:53:39 sxb3.103.com sudo[2632]:   cinder : TTY=unknown ; PWD=/ ; USER...on
Sep 09 08:53:39 sxb3.103.com sudo[2640]:   cinder : TTY=unknown ; PWD=/ ; USER...es
Sep 09 08:53:39 sxb3.103.com sudo[2649]:   cinder : TTY=unknown ; PWD=/ ; USER...ol
Sep 09 08:53:39 sxb3.103.com sudo[2658]:   cinder : TTY=unknown ; PWD=/ ; USER...on
Sep 09 08:53:40 sxb3.103.com sudo[2668]:   cinder : TTY=unknown ; PWD=/ ; USER...es
Sep 09 08:53:40 sxb3.103.com sudo[2677]:   cinder : TTY=unknown ; PWD=/ ; USER...ol

● target.service - Restore LIO kernel target configuration
   Loaded: loaded (/usr/lib/systemd/system/target.service; enabled; vendor preset: disabled)
   Active: active (exited) since Mon 2019-09-09 08:53:33 EDT; 7s ago
  Process: 2593 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/SUCCESS)
 Main PID: 2593 (code=exited, status=0/SUCCESS)

Sep 09 08:53:33 sxb3.103.com systemd[1]: Starting Restore LIO kernel target co.....
Sep 09 08:53:33 sxb3.103.com target[2593]: No saved config file at /etc/target/...g
Sep 09 08:53:33 sxb3.103.com systemd[1]: Started Restore LIO kernel target con...n.
Hint: Some lines were ellipsized, use -l to show in full.

验证:

[root@sxb1 ~]# openstack volume service list
+------------------+------------------+------+---------+-------+----------------------------+
| Binary           | Host             | Zone | Status  | State | Updated At                 |
+------------------+------------------+------+---------+-------+----------------------------+
| cinder-scheduler | sxb1.101.com     | nova | enabled | up    | 2019-09-09T13:31:14.000000 |
| cinder-volume    | sxb3.103.com@lvm | nova | enabled | up    | 2019-09-09T13:31:18.000000 |
+------------------+------------------+------+---------+-------+----------------------------+

 

以上是关于OpenStack-cinder服务部署的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot Admin + Docker 部署服务

如何在Kubernetes上进行微服务部署

SpringCloud 集成 Eureka服务 部署阿里云服务器

Windows部署服务(WDS)

如何在阿里云服务器部署Django

如何在服务器上部署docker