▍Ceph¶
Настройка Ceph на трёх серверах¶
Вводная часть¶
hostname | ip | role |
---|---|---|
192.168.0.5 | srv-mainframe | worker |
192.168.0.10 | srv-nas | worker |
192.168.0.20 | srv-k8s | manager |
В качестве хранилища в данном примере будет использоваться директория, а не диск, за что отвечает опция osd_directory у контейнера ceph-osd. По итогу будет кластер из трёх нод на 100Gb.
Docker-compose¶
Подключаемся к srv-k8s и создаем файл docker-compose.yml
# Deploy Monitor module
ceph-mon:
# Mirror has been downloaded to harbor private server
image: quay.io/ceph/daemon:latest-nautilus
network_mode: host
container_name: ceph-mon
restart: always
volumes:
- /etc/localtime:/etc/localtime
- /srv/ceph/etc_ceph:/etc/ceph
- /srv/ceph/var_lib_ceph:/var/lib/ceph
environment:
# The current server IP, don't forget to change the IP when deploying on different servers
MON_IP: 192.168.0.20
CEPH_PUBLIC_NETWORK: 192.168.0.0/24
command: mon
# Deploy Manager daemon module
ceph-mgr:
image: quay.io/ceph/daemon:latest-nautilus
network_mode: host
container_name: ceph-mgr
restart: always
depends_on:
- ceph-mon
volumes:
- /etc/localtime:/etc/localtime
- /srv/ceph/etc_ceph:/etc/ceph
- /srv/ceph/var_lib_ceph:/var/lib/ceph
command: mgr
# Deploy OSD module
ceph-osd:
image: quay.io/ceph/daemon:latest-nautilus
network_mode: host
container_name: ceph-osd
restart: always
privileged: true
# Share the process namespace with the host system. Containers with this option turned on can access and operate on each other through the process ID.
pid: host
depends_on:
- ceph-mgr
volumes:
- /etc/localtime:/etc/localtime
- /srv/ceph/etc_ceph:/etc/ceph
- /srv/ceph/var_lib_ceph:/var/lib/ceph
command: osd_directory
# Deploy MDS module (used to support CephFS file system storage, selected according to actual situation, not required)
ceph-mds:
image: quay.io/ceph/daemon:latest-nautilus
network_mode: host
container_name: ceph-mds
restart: always
depends_on:
- ceph-osd
volumes:
- /etc/localtime:/etc/localtime
- /srv/ceph/etc_ceph:/etc/ceph
- /srv/ceph/var_lib_ceph:/var/lib/ceph
environment:
# 0 means no automatic file system creation (recommended), 1 means automatic creation
CEPHFS_CREATE: 1
command: mds
Этот же файл создаем и на оставшихся двух серверах, только не забываем изменить параметр MON_IP: на IP того серера где этот файл располагается.
Теперь запускаем контейнер ceph-mon и создаем ключ для ceph-osd
cd /srv/docker
docker-compose up -d ceph-mon
docker-compose exec ceph-mon ceph-authtool --print-key /etc/ceph/ceph.client.admin.keyring
Запускаем оставшиеся контейнеры
Смотрим, что все они запущены
53428ccdd196 quay.io/ceph/daemon:latest-nautilus "/opt/ceph-container…" 11 hours ago Up 11 hours ceph-mds
e710d603a2a0 quay.io/ceph/daemon:latest-nautilus "/opt/ceph-container…" 11 hours ago Up 11 hours ceph-osd
934156eef439 quay.io/ceph/daemon:latest-nautilus "/opt/ceph-container…" 11 hours ago Up 11 hours ceph-mgr
02dee810a7f3 quay.io/ceph/daemon:latest-nautilus "/opt/ceph-container…" 11 hours ago Up 11 hours ceph-mon
Сейчас потребуется скопировать директории с настройками и ключами на другие два сервера:
scp -r /srv/ceph/etc_ceph/ srv-nas:/srv/ceph/etc_ceph/
scp -r /srv/ceph/var_lib_ceph/bootstrap-* srv-nas:/srv/ceph/var_lib_ceph/
......
scp -r /srv/ceph/etc_ceph/ srv-mainframe:/srv/ceph/etc_ceph/
scp -r /srv/ceph/var_lib_ceph/bootstrap-* srv-mainframe:/srv/ceph/var_lib_ceph/
Не забудьте изменить параметр mon host в файле /srv/ceph/etc_ceph/ceph.conf.
Запускаем контейнеры ceph на оставшихся серверах:
Если ошибок нет и всё запустилось хорошо, то смотрим статус нашего кластера ceph
┌─( [email protected] ) - ( 22 files, ) - ( /srv/docker )
└─> docker exec -ti ceph-osd ceph -s
cluster:
id: 40788ebe-484f-4f00-b35d-94743d8c6669
health: HEALTH_OK
services:
mon: 3 daemons, quorum srv-k8s,srv-nas,srv-mainframe (age 10h)
mgr: srv-k8s(active, since 11h), standbys: srv-nas, srv-mainframe
mds: cephfs:1 {0=srv-k8s=up:active} 2 up:standby
osd: 3 osds: 3 up (since 10h), 3 in (since 10h)
data:
pools: 2 pools, 16 pgs
objects: 254.09k objects, 38 GiB
usage: 129 GiB used, 171 GiB / 300 GiB avail
pgs: 16 active+clean
io:
client: 1.2 KiB/s rd, 11 KiB/s wr, 0 op/s rd, 2 op/s wr
Инфорамция по дереву устройств хранения osd
┌─( [email protected] ) - ( 22 files, ) - ( /srv/docker )
└─> docker exec -ti ceph-osd ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 0.29306 root default
-3 0.09769 host srv-k8s
0 ssd 0.09769 osd.0 up 1.00000 1.00000
-10 0.09769 host srv-mainframe
2 ssd 0.09769 osd.2 up 1.00000 1.00000
-7 0.09769 host srv-nas
1 hdd 0.09769 osd.1 up 1.00000 1.00000
Статистика кластера
┌─( [email protected] ) - ( 22 files, ) - ( /srv/docker )
└─> docker exec -ti ceph-osd ceph osd df
ID CLASS WEIGHT REWEIGHT SIZE RAW USE DATA OMAP META AVAIL %USE VAR PGS STATUS
0 ssd 0.09769 1.00000 100 GiB 40 GiB 39 GiB 129 MiB 895 MiB 60 GiB 39.91 0.93 16 up
2 ssd 0.09769 1.00000 100 GiB 40 GiB 39 GiB 126 MiB 898 MiB 60 GiB 39.91 0.93 16 up
1 hdd 0.09769 1.00000 100 GiB 49 GiB 48 GiB 128 MiB 896 MiB 51 GiB 49.38 1.15 16 up
TOTAL 300 GiB 129 GiB 126 GiB 383 MiB 2.6 GiB 171 GiB 43.07
MIN/MAX VAR: 0.93/1.15 STDDEV: 4.46
Запускаем dashboard¶
Активируем
Указываем на каком IP и порту слушать:
docker exec -ti ceph-mgr ceph config set mgr mgr/dashboard/server_addr 0.0.0.0
docker exec -ti ceph-mon ceph config set mgr mgr/dashboard/server_port 7000
Добавляем пользователя
sudo echo password > /srv/ceph/etc_ceph/passwd
docker exec -ti ceph-mgr ceph dashboard ac-user-create admin administrator -i /etc/ceph/passwd
Рестартим контейнер, чтобы применились настройки
Смотрим где висит наш дашборд
┌─( [email protected] ) - ( 22 files, ) - ( /srv/docker )
└─> docker exec -ti ceph-mgr ceph mgr services
{
"dashboard": "http://srv-k8s:7000/"
}
Монтирование¶
┌─( [email protected] ) - ( 13 files, ) - ( /srv/docker )
└─> docker exec -ti ceph-mon ceph-authtool --print-key /etc/ceph/ceph.client.admin.keyring > /root/ceph.key
┌─( [email protected] ) - ( 13 files, ) - ( /srv/docker )
└─> chmod 600 /root/ceph.key
Добавляем строку в файл fstab
192.168.0.5:6789,192.168.0.10:6789,192.168.0.20:6789:/ /docker ceph name=admin,secretfile=/root/ceph.key,noatime,_netdev 0 0
Монтируем