본 포스트에서는 corosync + pacemaker와 consul을 설치하는 과정을 설명합니다.
corosync+pacemaker와 consul을 시스템의 이상유무를 확인하여 클라우트 환경의 가용성과 안정성을 보장하기 위한 방법의 기초적인 부분입니다. corosync+pacemaker와 consul을 둘 다 설치할 필요는 없으며 openstack의 경우 corosync+pacemaker가 포함되어 있습니다.
호스트 파일 설정
# con01, con02, con03, com01, com03
vi /etc/hosts
192.168.140.101 con01
192.168.140.102 con02
192.168.140.103 con03
192.168.140.104 com01
192.168.140.105 com02
pacemaker 설치 및 설정
# con01, con02, con03, com01, com02
sudo apt install --assume-yes pacemaker corosync pcs
# con01, con02, con03, com01, com02
sudo systemctl start pcsd
# con01, con02, con03, com01, com02
sudo systemctl enable pacemaker corosync pcsd
# con01, con02, con03, com01, com02
passwd hacluster
# con01
pcs cluster auth con01 con02 con03 com01 com02
or
pcs host auth con01 con02 con03 com01 com02
# con01
pcs cluster setup --name cluster1 con01 con02 con03 com01 com02 --force
# con01
pcs cluster enable --all
# con01
pcs cluster start --all
consul 설치 및 설정
consul 패치지 설치
# con01, con02, con03, com01, com02
root@con01:~# wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
# con01, con02, con03, com01, com02
root@con01:~# echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
# con01, con02, con03, com01, com02
root@con01:~# sudo apt update
# con01, con02, con03, com01, com02
root@con01:~# sudo apt install consul
# con01, con02, con03, com01, com02
root@con01:~# consul version
Consul v1.14.4
Revision dae670fe
Build Date 2023-01-26T15:47:10Z
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
consul 설정
# con01, con02, con03
sudo vi /etc/consul.d/consul.json
{
"bind_addr": "192.168.140.101",
"datacenter": "openstack",
"data_dir": "/opt/consul",
"log_level": "INFO",
"server": true,
"bootstrap_expect": 3,
"node_name": "con01",
"addresses": {
"http": "0.0.0.0"
},
"ui_config": {
"enabled": true
},
"ports": {
"http": 8500,
"serf_lan": 8501
},
"retry_join": ["192.168.140.101:8501", "192.168.140.102:8501", "192.168.140.103:8501"]
}
# com01, com02
sudo vi /etc/consul.d/consul.json
{
"datacenter": "openstack",
"data_dir": "/opt/consul",
"log_level": "INFO",
"node_name": "com01",
"client_addr": "0.0.0.0",
"bind_addr": "192.168.140.104",
"addresses": {
"http": "0.0.0.0"
},
"retry_join": ["192.168.140.101:8501", "192.168.140.102:8501", "192.168.140.103:8501"]
}
consul 재시작 및 멤버확인
# con01, con02, con03, com01, com02
root@com02:~# systemctl restart consul
root@com02:~# systemctl status consul
# con01, con02, con03, com01, com02
root@con01:~# consul members -http-addr=192.168.140.101:8500
Node Address Status Type Build Protocol DC Partition Segment
con01 192.168.140.101:8501 alive server 1.14.4 2 management default <all>
con02 192.168.140.102:8501 alive server 1.14.4 2 management default <all>
con03 192.168.140.103:8501 alive server 1.14.4 2 management default <all>
com01 192.168.140.104:8501 alive client 1.14.4 2 management default <default>
com02 192.168.140.105:8501 alive client 1.14.4 2 management default <default>
consul 관리자 접속
http://192.168.140.101:8500 을 웹브라우저를 통해 접속합니다.
consul 오류 로그 확인
아래의 명령을 통해 consul 시스템 로그를 확인할 수 있습니다.
# con01, con02, con03, com01, com02
root@con01:~# sudo journalctl -u consul.service -r
참고 자료
https://www.simplified.guide/pacemaker/install-on-ubuntu-debian
https://clusterlabs.org/pacemaker/doc/deprecated/en-US/Pacemaker/2.0/html/Clusters_from_Scratch/_configure_corosync.html
https://www.server-world.info/en/note?os=Ubuntu_22.04&p=pacemaker&f=1
https://www.atlantic.net/vps-hosting/how-to-install-consul-server-on-ubuntu-20-04/
728x90