Ceph Kurulumu + Dashboard¶
Öncelikle Ceph için 3 adet makine oluşturuyorum. Bu makineleri Proxmox üzerinden oluşturacağım.
İlgili makinelerin IP adresi ve sunucu isimleri:
- 192.168.1.175 ceph-mon-01
- 192.168.1.106 ceph-osd-01
- 192.168.1.160 ceph-osd-02
ceph-mon-01 makinesini monitoring için kullanacağım ve yapılandırmayı ceph-mon-01 makinesinden sağlayacağım.
ceph-mon-01 adlı makinesine SSH bağlantısı sağlayalım ve öncelikle hosts dosyamızı düzenleyelim.
nano /etc/hosts
Aşağıdaki gibi bilgileri girin.
192.168.1.175 ceph-mon-01
192.168.1.106 ceph-osd-01
192.168.1.160 ceph-osd-02
Warning
üstteki bilgileri kendi makinelerinize göre düzenleyiniz.
Sistemimizi güncelleyelim
sudo apt update && sudo apt -y upgrade
Sunucumuza reboot atalım
sudo systemctl reboot
Diğer makinelere yapılandırmayı ansible ile sağlayacağız. Bu yüzden ansibleyi indiriyoruz
sudo apt update
sudo apt -y install software-properties-common git curl vim bash-completion ansible
Ansiblenin kurulduğunu doğrulayın:
[email protected]:~# ansible --version
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
PATH'e /usr/local/bin yolunun eklendiğinden emin olun.
echo "PATH=\$PATH:/usr/local/bin" >>~/.bashrc
source ~/.bashrc
Mevcut PATH'inizi kontrol edin:
[email protected]:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/bin
SSH key oluşturun:
[email protected]:~# ssh-keygen -t rsa -b 4096 -N '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:QU8sCaFlKOc04q0xa/8CCJ90KJRdu1OYh9BqWoLi2FE [email protected]
The key's randomart image is:
+---[RSA 4096]----+
| o.oo=o.o. |
| oo.E==.oo. |
|o. Xo* o... |
|=.B++ + . |
|=*=O o S |
|ooO . |
| . o |
| o |
| o. |
+----[SHA256]-----+
cephadmin indiriyoruz:
curl --silent --remote-name --location https://github.com/ceph/ceph/raw/octopus/src/cephadm/cephadm
chmod +x cephadm
sudo mv cephadm /usr/local/bin/
cephadm kontrol:
cephadm --help
Ana dizine gidelim ve ceph-nodes.yml şeklinde bir dosya oluşturalım.
cd ~/
nano prepare-ceph-nodes.yml
Aşağıdaki içeriği yapıştırın:
---
- name: ceph nodes
hosts: ceph_nodes
become: yes
become_method: sudo
vars:
ceph_admin_user: cephadmin
tasks:
- name: Set timezone
timezone:
name: Europe/Istanbul
- name: Sistem güncellenir
apt:
upgrade: "yes"
update_cache: yes
cache_valid_time: 432000
- name: Gerekli paketler indiriliyor
apt:
name: [vim,git,bash-completion,wget,curl,chrony]
state: present
update_cache: yes
cache_valid_time: 432000
- name: Dosyadan alınan yetkili anahtarı kök kullanıcıya ayarlayın
authorized_key:
user: root
state: present
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
- name: Bağımlılıklar iniyor
apt:
loop: [ 'apt-transport-https', 'ca-certificates', 'curl', 'software-properties-common', 'python3-pip', 'virtualenv', 'python3-setuptools']
- name: Docker indirelim
apt:
name: docker.io
Bulunduğumuz dizine ansible için envanter dosyası oluşturuyoruz
nano hosts
Aşağıdaki içeriği yapıştırın
[ceph_nodes]
ceph-mon-01
ceph-osd-01
ceph-osd-02
Info
nano editöründen CTRL+X > Y > Enter ile kaydedip çıkabilirsiniz
key'i kaydedin.
eval `ssh-agent -s` && ssh-add ~/.ssh/id_rsa
SSH'yi konfigüre edin:
tee -a ~/.ssh/config<<EOF
Host *
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
IdentitiesOnly yes
ConnectTimeout 0
ServerAliveInterval 300
EOF
SSH anahtarınızı diğer makinelere kopyalayın
Info
Aşağıdaki komutu girdiğinizde yes yazıp entere basın. Ardından karşı sunucunun root şifresini girin.
ssh-copy-id [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]
Ansibleyi çalıştırıp gerekli kurulumları sağlayalım.
[email protected]:~# ansible-playbook -i hosts prepare-ceph-nodes.yml --user root
PLAY [ceph nodes] *****************************************************************************************
TASK [Gathering Facts] ************************************************************************************ok: [ceph-osd-01]
ok: [ceph-osd-02]
ok: [ceph-mon-01]
TASK [Set timezone] ***************************************************************************************changed: [ceph-osd-02]
changed: [ceph-osd-01]
ok: [ceph-mon-01]
TASK [Sistem güncellenir] *********************************************************************************ok: [ceph-osd-02]
ok: [ceph-mon-01]
changed: [ceph-osd-01]
TASK [Gerekli paketler indiriliyor] ***********************************************************************changed: [ceph-osd-01]
changed: [ceph-osd-02]
changed: [ceph-mon-01]
TASK [Dosyadan alınan yetkili anahtarı kök kullanıcıya ayarlayın] *****************************************ok: [ceph-osd-01]
ok: [ceph-osd-02]
ok: [ceph-mon-01]
TASK [Bağımlılıklar iniyor] *******************************************************************************ok: [ceph-mon-01] => (item=apt-transport-https)
ok: [ceph-osd-02] => (item=apt-transport-https)
ok: [ceph-osd-01] => (item=apt-transport-https)
ok: [ceph-osd-02] => (item=ca-certificates)
ok: [ceph-osd-01] => (item=ca-certificates)
ok: [ceph-mon-01] => (item=ca-certificates)
ok: [ceph-osd-02] => (item=curl)
ok: [ceph-osd-01] => (item=curl)
ok: [ceph-mon-01] => (item=curl)
ok: [ceph-osd-02] => (item=software-properties-common)
ok: [ceph-osd-01] => (item=software-properties-common)
ok: [ceph-mon-01] => (item=software-properties-common)
ok: [ceph-osd-02] => (item=python3-pip)
ok: [ceph-osd-01] => (item=python3-pip)
ok: [ceph-mon-01] => (item=python3-pip)
ok: [ceph-osd-02] => (item=virtualenv)
ok: [ceph-osd-01] => (item=virtualenv)
ok: [ceph-mon-01] => (item=virtualenv)
ok: [ceph-osd-02] => (item=python3-setuptools)
ok: [ceph-osd-01] => (item=python3-setuptools)
ok: [ceph-mon-01] => (item=python3-setuptools)
TASK [Docker indirelim] ***********************************************************************************changed: [ceph-osd-01]
changed: [ceph-osd-02]
changed: [ceph-mon-01]
PLAY RECAP ************************************************************************************************ceph-mon-01 : ok=7 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ceph-osd-01 : ok=7 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ceph-osd-02 : ok=7 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Ansible için bir dosya daha hazırlıyoruz. Tüm makinelerin hosts dosyalarını düzenleyeceğiz
nano update-hosts.yml
Aşağıdaki içeriği yapıştırın:
---
- name: Prepare ceph nodes
hosts: ceph_nodes
become: yes
become_method: sudo
tasks:
- name: Clean /etc/hosts file
copy:
content: ""
dest: /etc/hosts
- name: Update /etc/hosts file
blockinfile:
path: /etc/hosts
block: |
127.0.0.1 localhost
192.168.1.175 ceph-mon-01
192.168.1.106 ceph-osd-01
192.168.1.160 ceph-osd-02
Dosyayı ansible ile çalıştıralım:
[email protected]:~# ansible-playbook -i hosts update-hosts.yml --private-key ~/.ssh/id_rsa
PLAY [Prepare ceph nodes] *********************************************************************************
TASK [Gathering Facts] ************************************************************************************ok: [ceph-osd-02]
ok: [ceph-osd-01]
ok: [ceph-mon-01]
TASK [Clean /etc/hosts file] ******************************************************************************changed: [ceph-osd-02]
changed: [ceph-osd-01]
changed: [ceph-mon-01]
TASK [Update /etc/hosts file] *****************************************************************************changed: [ceph-osd-02]
changed: [ceph-osd-01]
changed: [ceph-mon-01]
PLAY RECAP ************************************************************************************************ceph-mon-01 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ceph-osd-01 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ceph-osd-02 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Ceph Dashboard¶
sudo mkdir -p /etc/ceph
cephadm bootstrap \
--mon-ip ceph-mon-01 \
--initial-dashboard-user admin \
--initial-dashboard-password [email protected]
Info
Hata alırsanız ceph-mon-01 ifadesini IP adresi ile değiştirin
Çıktı:
[KISALTILMIŞTIR]
.
.
.
.
.
Ceph Dashboard is now available at:
URL: https://ceph-mon-01:8443/
User: admin
Password: [email protected]
You can access the Ceph CLI with:
sudo /usr/local/bin/cephadm shell --fsid f5b5d470-4a41-11eb-9599-3be5c9bf7b71 -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring
Please consider enabling telemetry to help improve Ceph:
ceph telemetry on
For more information see:
https://docs.ceph.com/docs/master/mgr/telemetry/
Bootstrap complete.
Tarayıcımı açıp aşağıdaki linke giriş yapıyorum
https://192.168.1.175:8443/
Warning
Makinenizin ram ve CPU miktarına göre dashboard ekranına girmekte sorun yaşayabilirsiniz.
Giriş bilgilerim ile giriş yapıyorum
Ceph dashboard işte karşımızda.
cephadm araçlarını yükleyelim
cephadm add-repo --release octopus
cephadm install ceph-common
Eğer ekstra monitör eklemek isterseniz:
--- Copy Ceph SSH key ---
ssh-copy-id -f -i /etc/ceph/ceph.pub [email protected]
ssh-copy-id -f -i /etc/ceph/ceph.pub [email protected]
--- Label the nodes with mon ---
ceph orch host label add ceph-mon-01 mon
ceph orch host label add ceph-mon-02 mon
ceph orch host label add ceph-mon-03 mon
--- Add nodes to the cluster ---
ceph orch host add ceph-mon-02
ceph orch host add ceph-mon-03
--- Apply configs ---
ceph orch apply mon ceph-mon-02
ceph orch apply mon ceph-mon-03
Eklediğiniz Monitörleri listeleyin:
ceph orch host ls
Ceph, izleme araçlarını docker konteyneri olarak ayağa kaldırıyor. Aşağıdaki komut ile konteynerleri görebiliriz. Yani ek olarak prometheus, grafana gibi araçlar da mevcuttur.
[email protected]:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c0ca726cb1ec prom/alertmanager:v0.20.0 "/bin/alertmanager -…" 9 minutes ago Up 9 minutes ceph-f5b5d470-4a41-11eb-9599-3be5c9bf7b71-alertmanager.ceph-mon-01
d16a8c82542a ceph/ceph-grafana:6.6.2 "/bin/sh -c 'grafana…" 9 minutes ago Up 9 minutes ceph-f5b5d470-4a41-11eb-9599-3be5c9bf7b71-grafana.ceph-mon-01
66a620414e48 prom/prometheus:v2.18.1 "/bin/prometheus --c…" 9 minutes ago Up 9 minutes ceph-f5b5d470-4a41-11eb-9599-3be5c9bf7b71-prometheus.ceph-mon-01
183e9d8dbc39 ceph/ceph:v15 "/usr/bin/ceph-mon -…" 10 minutes ago Up 9 minutes ceph-f5b5d470-4a41-11eb-9599-3be5c9bf7b71-mon.ceph-mon-01
b3ee4df8e342 prom/node-exporter:v0.18.1 "/bin/node_exporter …" 10 minutes ago Up 9 minutes ceph-f5b5d470-4a41-11eb-9599-3be5c9bf7b71-node-exporter.ceph-mon-01
6b13517395a9 ceph/ceph:v15 "/usr/bin/ceph-crash…" 10 minutes ago Up 9 minutes ceph-f5b5d470-4a41-11eb-9599-3be5c9bf7b71-crash.ceph-mon-01
bb5007ff7102 ceph/ceph:v15 "/usr/bin/ceph-mgr -…" 10 minutes ago Up 9 minutes ceph-f5b5d470-4a41-11eb-9599-3be5c9bf7b71-mgr.ceph-mon-01.xdbdrd
Kümenin genel SSH anahtarını yeni OSD düğümleri kök kullanıcısının yetkili_keys dosyasına yükleyin:
ssh-copy-id -f -i /etc/ceph/ceph.pub [email protected]
ssh-copy-id -f -i /etc/ceph/ceph.pub [email protected]
Ceph'e yeni düğümün kümenin bir parçası olduğunu söyleyin: (kümeye ana bilgisayarları ekleyin)
ceph orch host add ceph-osd-01
ceph orch host add ceph-osd-02
Yeni düğümlere OSD etiketi verin
ceph orch host label add ceph-osd-01 osd
ceph orch host label add ceph-osd-02 osd
Aşağıdaki komutu girdiğinizde ekstra depolama alanlarınızı göreceksiniz.
ceph orch device ls
Şuanda bir çıktı alamıyorum. Çünkü OSD makinelerime ekstra bir disk eklemem gerek. ceph-osd-01 ve ceph-osd-02 makinelerime 50GB 2 adet disk ekliyorum. İlgili işlemi Proxmox üzerinde sağlıyorum.
Şimdi diski ekledik ve ceph-osd-01 ve ceph-osd-02 üzerinde aşağıdaki adımları uygulayarak disklere GPT alanı eklemeliyiz.
Aşağıdaki komutu girin ve yeni eklediğiniz diskin adına bakın
[KISALTILMIŞTIR]
.
.
.
.
Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7284FEB8-CBC4-F648-BC1F-B899431FA90C
Aşağıdaki adımları uygulayın:
[email protected]:~# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x1c69dbfb.
Command (m for help): g
Created a new GPT disklabel (GUID: 7284FEB8-CBC4-F648-BC1F-B899431FA90C).
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[email protected]:~# q
Her iki makinede her iki disk için bunu yaptıktan sonra ceph-mon-01 makineme geliyorum ve aşağıdaki komutları tekrar giriyorum.
ceph orch host add ceph-osd-01
ceph orch host add ceph-osd-02
Yeni düğümlere OSD etiketi verin
ceph orch host label add ceph-osd-01 osd
ceph orch host label add ceph-osd-02 osd
Öncelikle aşağıdaki komut ile eklemiş olduğum monitörleri ve osd'leri görüyorum
[email protected]:~# ceph orch host ls
HOST ADDR LABELS STATUS
ceph-mon-01 ceph-mon-01
ceph-osd-01 ceph-osd-01 osd
ceph-osd-02 ceph-osd-02 osd
Ardından ekstra eklediğim disk alanlarına bakıyorum:
[email protected]:~# ceph orch device ls
Hostname Path Type Serial Size Health Ident Fault Available
ceph-osd-01 /dev/sdb hdd drive-scsi1 53.6G Unknown N/A N/A Yes
ceph-osd-02 /dev/sdb hdd drive-scsi1 53.6G Unknown N/A N/A Yes
ceph dashboard ekranına geliyorum. Dashboard ekranında monitors kısmına tıkladıktan sonra sistemime tanımladığım makineleri görmekteyim.
OSDs > create > Primart devices add adımlarını uyguladığımda disklerimi görmekteyim ve sistemime dahil edebiliyorum.
Disklerimi ekledim ve toplam kapasitemin 100GB olduğunu görmekteyim.