0%

山西临汾

设备清单:

  • 刀片服务器:10 台,其中 1 台控制节点,7 台计算节点,1 台存储节点,1 台备用
  • 交换机:三种 5 台,其中分为 A1,A2,C1,C2 和 IB 交换机

IP 地址分为三类:

  • 管理 IP
  • 虚拟机访问外网 IP
  • 存储 IP

备注:管理 IP 连接的是 A1 交换机,虚拟机是 A2 交换机,存储 IP 是 IB 交换机。另,只有存储连接了融合交换机 C1、C2,其他刀片未连接。存储节点连接后端的存储阵列,将虚拟机的数据存入阵列。

7 台计算节点上,每一台都装了 Ceph,用来存储虚拟机的系统盘,而虚拟机的数据盘则通过存储节点由存储阵列提供,存储节点上的 cinder 通过 iscsi 连接存储阵列。

大邑

这个拓扑相对简单,只有 1 个控制节点,1 个存储节点,2 个计算节点,1 台交换机,计算节点上也是 Ceph 存放虚拟机系统盘,这上面的虚拟机主要是 windows 系统,通过 windows 直连 iscsi 存储,没有通过 cinder。

通过 devstack 方式安装的 all-in-one,如果在服务器重启之后,很多 OpenStack 服务是起不来的,这个时候需要执行一些命令。

OpenStack 服务启动失败

1
2
3
4
5
6
7
8
sudo su - stack

sudo losetup -f /opt/stack/data/stack-volumes-default-backing-file
sudo losetup -f /opt/stack/data/stack-volumes-lvmdriver-l-backing-file
script /dev/null
screen -c /opt/stack/devstack/stack-screenrc

ctrl + A,然后 D 退出

之前不知道什么原因,导致我的 hexo 博客不能用了,然后就重新部署了一下,参照我之前的配置:

https://yuanzizhen.github.io/2017/03/11/%E7%94%A8Hexo%E5%9C%A8Github%E4%B8%8A%E9%9D%A2%E9%83%A8%E7%BD%B2%E5%8D%9A%E5%AE%A2/

但是依然遇到了很多坑,特此写在这里。

1、使用 npm 安装 hexo 的时候屡次不成功。解决办法:

使用淘宝 NPM 镜像:

1
2
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g hexo

参考:http://www.runoob.com/nodejs/nodejs-npm.html

2、github 生成 ssh 失败

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ ssh-keygen -t rsa -C C "iyuanzz@qq.com"
Too many arguments.
usage: ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa]
[-N new_passphrase] [-C comment] [-f output_keyfile]
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
ssh-keygen -i [-m key_format] [-f input_keyfile]
ssh-keygen -e [-m key_format] [-f input_keyfile]
ssh-keygen -y [-f input_keyfile]
ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]
ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile]
ssh-keygen -B [-f input_keyfile]
ssh-keygen -D pkcs11
ssh-keygen -F hostname [-f known_hosts_file] [-l]
ssh-keygen -H [-f known_hosts_file]
ssh-keygen -R hostname [-f known_hosts_file]
ssh-keygen -r hostname [-f input_keyfile] [-g]
ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point]
ssh-keygen -T output_file -f input_file [-v] [-a rounds] [-J num_lines]
[-j start_line] [-K checkpt] [-W generator]
ssh-keygen -s ca_key -I certificate_identity [-h] [-U]
[-D pkcs11_provider] [-n principals] [-O option]
[-V validity_interval] [-z serial_number] file ...
ssh-keygen -L [-f input_keyfile]
ssh-keygen -A
ssh-keygen -k -f krl_file [-u] [-s ca_public] [-z version_number]
file ...
ssh-keygen -Q -f krl_file file ...

解决办法:

删除一个 C 解决

2、使用命令hexo d 无法部署

解决办法

重新设置:

1
npm install hexo-deployer-git --save

最终部署成功!

创建存储池

我这里选择 glance 使用控制节点的存储,VM 保存在计算节点上,备份没有配置,所以 Ceph 只作为卷使用。

在 Ceph 节点上面,创建存储池:

1
2
[root@node1 ~]# ceph osd pool create volumes 128
pool 'volumes' created

根据官方文档,这里初始化存储池失败。

1
2
[root@node1 ~]# rbd pool init volumes
error: unknown option 'pool init volumes'

配置 OpenStack 为 Ceph 客户端

运行 glance-api, cinder-volume, nova-compute , cinder-backup 进程的节点都需要 Ceph 客户端。每一个都要有 ceph.conf 文件。

在计算节点和控制节点上创建 Ceph 目录:

1
2
[root@controller ~]# cd /etc
[root@controller etc]# mkdir ceph

将配置文件传到控制节点和计算节点:

1
[root@node1 ~]# ssh root@compute01 sudo tee /etc/ceph/ceph.conf < /etc/ceph/ceph.conf

我部署的 OpenStack 为一个控制节点和一个计算节点。 glance-api 运行在控制节点上,cinder-volume, nova-compute 运行在计算节点上,因此,控制节点和计算节点都需要配置为 Ceph 客户端。

安装 Ceph 客户端安装包

glance-api 节点(控制节点)上,需要安装 librbd 的 Python 绑定:

1
[root@controller ~]# sudo yum install python-rbd

cinder-volume, nova-compute 节点(计算节点)上,安装 Python 绑定以及 Ceph 命令行工具:

1
2
[root@compute01 ~]# sudo yum install ceph-common
[root@controller ~]# sudo yum install python-rbd

配置 Ceph 客户端授权

从 Ceph monitor 节点,为 Cinder 创建一个新用户。

1
2
3
[root@node1 ~]# ceph auth get-or-create client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes'
[client.cinder]
key = AQDXCvRZ+OpCFBAANnmyibi/4vtZtyu5HJcQvw==

为 client.cinder 添加密钥环并改变所属者。

1
2
3
4
[root@node1 ~]# ceph auth get-or-create client.cinder | ssh root@compute01 sudo tee /etc/ceph/ceph.client.cinder.keyring
root@compute01's password:
[root@node1 ~]# ssh root@compute01 chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring
root@compute01's password:

运行 nova-compute 的节点还需要将 client.cinder 用户的密钥存储在 libvirt 中。在从 Cinder 中添加块设备时,libvirt 进程需要它访问群集。

在运行 nova-compute 的节点上创建密钥的临时副本:

1
[root@node1 ~]# ceph auth get-key client.cinder | ssh root@compute01 tee client.cinder.key

在计算节点上,为密钥生成 UUID, 并保存 UUID,以便待会配置 nova-compute。

1
[root@compute01 ~]# uuidgen > uuid-secret.txt

然后在计算节点上,向 libvirt 中添加密钥,并删除临时副本:

1
2
3
4
5
6
7
8
9
10
11
[root@compute01 ~]# cat > secret.xml <<EOF
> <secret ephemeral='no' private='no'>
> <uuid>`cat uuid-secret.txt`</uuid>
> <usage type='ceph'>
> <name>client.cinder secret</name>
> </usage>
> </secret>
> EOF

[root@compute01 ~]# virsh secret-define --file secret.xml
[root@compute01 ~]# virsh secret-set-value --secret $(cat uuid-secret.txt) --base64 $(cat client.cinder.key) && rm client.cinder.key secret.xml

配置 Cinder

cinder-volume 节点需要 Ceph 块设备,volume 存储池,用户以及密钥的 UUID,才能和 Ceph 块设备连接。要配置 Cinder,请执行以下步骤:

  1. 打开 Cinder 配置文件。

    1
    [root@compute01 ~]# vim /etc/cinder/cinder.conf
  2. [DEFAULT] 选项中,开启 Ceph 作为 Cinder 后端存储。

    1
    enabled_backends = ceph
  3. 确认 Glance API 版本是 2。如果你在enabled_backends 中配置了多后端, glance_api_version = 2 必须在 [DEFAULT] 选项中设置而不是在 [ceph] 选项中。

    1
    glance_api_version = 2
  4. cinder.conf 中创建一个 [ceph] 选项,添加以下部分到 [ceph] 选项中。

  5. 设置 volume_driver 使用 Ceph 后端存储。

    1
    volume_driver = cinder.volume.drivers.rbd.RBDDriver
  6. 设置集群名称以及 Ceph 配置文件的位置。

    1
    2
    rbd_cluster_name = e8b7ae85-8d03-4160-becc-10df8f385c59
    rbd_ceph_conf = /etc/ceph/ceph.conf
  7. 默认情况下,OSP 在 rbd 池中存储 Ceph 卷。

    1
    rbd_pool = volumes
  8. 指定 rbd_user ,把它设置为 cinder 用户。然后指定 rbd_secret_uuid ,UUID 存储在 uuid-secret.txt 文件中。

    1
    2
    rbd_user = cinder
    rbd_secret_uuid = 0fb0bd0a-7926-4c4a-b015-b1cfa3f86456
  9. 指定以下设置。

    1
    2
    3
    4
    rbd_flatten_volume_from_snapshot = false
    rbd_max_clone_depth = 5
    rbd_store_chunk_size = 4
    rados_connect_timeout = -1

最终的设置应该像下面一样:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[DEFAULT]
enabled_backends = ceph
glance_api_version = 2
···
[ceph]
volume_driver = cinder.volume.drivers.rbd.RBDDriver
rbd_cluster_name = e8b7ae85-8d03-4160-becc-10df8f385c59
rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_pool = volumes
rbd_user = cinder
rbd_secret_uuid = 0fb0bd0a-7926-4c4a-b015-b1cfa3f86456
rbd_flatten_volume_from_snapshot = false
rbd_max_clone_depth = 5
rbd_store_chunk_size = 4
rados_connect_timeout = -1

重启 OpenStack 服务

1
2
[root@compute01 ~]# systemctl restart openstack-cinder-volume
[root@compute01 ~]# systemctl restart openstack-nova-compute

参考

https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html-single/ceph_block_device_to_openstack_guide/#restarting_openstack_services

官方文档基本没用。