配置Gnocchi使用Ceph后端存储

1.给gnocchi创建一个专用的ceph pool,用来存放计量数据。

1
# ceph osd pool create gnocchi 128 128

gnocchi pool的pg_num需要根据实际的ceph环境确定。

2.给gnocchi创建一个ceph用户。

1
2
3
# ceph auth get-or-create client.gnocchi mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=gnocchi'
[client.gnocchi]
key = AQB+5xxbZKKQIhAA7FgJKYBQNjF6dD3FZzJvUQ==

3.保存keyring文件

1
ceph auth get-or-create client.gnocchi | tee ceph.client.gnocchi.keyring

4.在gnocchi容器中创建/etc/ceph目录

1
2
3
# docker exec -u root -it gnocchi_api mkdir /etc/ceph
# docker exec -u root -it gnocchi_statsd mkdir /etc/ceph
# docker exec -u root -it gnocchi_metricd mkdir /etc/ceph

5.在ceph节点拷贝相关文件到controller节点

1
2
# scp ceph.client.gnocchi.keyring controller1:/home
# scp /etc/ceph/ceph.conf controller1:/home

6.拷贝gnocchi的keyring文件和ceph配置文件到gnocchi容器的/etc/ceph目录下

1
2
3
4
5
6
7
8
# docker cp /home/ceph.conf gnocchi_api:/etc/ceph/
# docker cp /home/ceph.client.gnocchi.keyring gnocchi_api:/etc/ceph/

# docker cp /home/ceph.conf gnocchi_statsd:/etc/ceph/
# docker cp /home/ceph.client.gnocchi.keyring gnocchi_statsd:/etc/ceph/

# docker cp /home/ceph.conf gnocchi_metricd:/etc/ceph/
# docker cp /home/ceph.client.gnocchi.keyring gnocchi_metricd:/etc/ceph/

7.修改文件gnocchi.conf

1
2
3
4
5
6
7
8
9
10
11
12
# vim /etc/kolla/gnocchi-api/gnocchi.conf 
# vim /etc/kolla/gnocchi-metricd/gnocchi.conf
# vim /etc/kolla/gnocchi-statsd/gnocchi.conf

添加如下内容
[storage]
driver = ceph
ceph_username = gnocchi
ceph_keyring = /etc/ceph/ceph.client.gnocchi.keyring
ceph_conffile = /etc/ceph/ceph.conf
ceph_secret = AQB+5xxbZKKQIhAA7FgJKYBQNjF6dD3FZzJvUQ==
ceph_pool = gnocchi

初始化数据库

1
2
3
# docker exec -it gnocchi_api gnocchi-upgrade
# docker exec -it gnocchi_metricd gnocchi-upgrade
# docker exec -it gnocchi_statsd gnocchi-upgrade

8.设置权限

1
2
3
# docker exec -u root -it gnocchi_api chown -R gnocchi:gnocchi /etc/ceph/
# docker exec -u root -it gnocchi_metricd chown -R gnocchi:gnocchi /etc/ceph/
# docker exec -u root -it gnocchi_statsd chown -R gnocchi:gnocchi /etc/ceph/

9.重启服务生效

1
# docker restart gnocchi_api gnocchi_metricd gnocchi_statsd

0%