当前位置: 代码迷 >> 综合 >> Set up debian based maas ha env on xenial by hand (by quqi99)
  详细解决方案

Set up debian based maas ha env on xenial by hand (by quqi99)

热度:19   发布时间:2023-12-13 08:50:54.0

准备三个节点

本文将在xenial (ubuntu 16.04)使用debian包手工创建maas ha环境,先快速准备三个节点:

juju deploy ubuntu maas1 --series=xenial --config hostname=maas1 --constraints "mem=8G cores=4 root-disk=32G"
juju deploy ubuntu maas2 --series=xenial --config hostname=maas2 --constraints "mem=8G cores=4 root-disk=32G"
juju deploy ubuntu maas3 --series=xenial --config hostname=maas3 --constraints "mem=8G cores=4 root-disk=32G"declare -A IPS=([maas1]="10.5.3.0"[maas2]="10.5.0.62"[maas3]="10.5.4.25"[maas_vip]="10.5.0.122"[db_vip]="10.5.0.123"
)

三个节点上准备corosync与pacemaker

sudo apt install postgresql corosync pacemaker -y
cat <<EOF |sudo tee /etc/corosync/corosync.conf
totem {version: 2token: 3000token_retransmits_before_loss_const: 10join: 60consensus: 3600vsftype: nonemax_messages: 20clear_node_high_bit: yessecauth: offthreads: 0ip_version: ipv4rrp_mode: nonetransport: udpu
}quorum {provider: corosync_votequorum}nodelist {node {ring0_addr: ${IPS[maas1]}nodeid: 1000}node {ring0_addr: ${IPS[maas2]}nodeid: 1001}node {ring0_addr: ${IPS[maas3]}nodeid: 1002}
}logging {fileline: offto_stderr: yesto_logfile: noto_syslog: yessyslog_facility: daemondebug: offlogger_subsys {subsys: QUORUMdebug: off}
}
EOF
sudo service corosync restart
sudo service pacemaker restart
#make sure all 3 nodes are listed up as online
sudo crm status | grep "Online:"

三个节点上准备postgresql

sudo service postgresql stop
echo manual | sudo tee /etc/postgresql/9.5/main/start.conf
cat <<EOF |sudo tee /etc/postgresql/9.5/main/pg_hba.conf
local   all             postgres                                peer
local   all             all                                     peer
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
host replication repuser ${IPS[maas_vip]}/32 trust
host replication repuser ${IPS[db_vip]}/32 trust
host replication repuser ${IPS[maas1]}/32 trust
host replication repuser ${IPS[maas2]}/32 trust
host replication repuser ${IPS[maas3]}/32 trust
host maasdb maas ${IPS[maas_vip]}/32 md5
host maasdb maas ${IPS[db_vip]}/32 md5
host maasdb maas ${IPS[maas1]}/32 md5
host maasdb maas ${IPS[maas2]}/32 md5
host maasdb maas ${IPS[maas3]}/32 md5
EOF
cat << EOF | sudo tee -a /etc/postgresql/9.5/main/postgresql.conf
listen_addresses = '*'
max_connections = 300
wal_level = hot_standby
synchronous_commit = on
archive_mode = off
max_wal_senders = 10
wal_keep_segments = 256
hot_standby = on
restart_after_crash = off
hot_standby_feedback = on
EOF
sudo install -o postgres -g postgres -m 0700 -d /var/lib/postgresql/9.5/main/pg_archive
sudo install -o postgres -g postgres -m 0700 -d /var/lib/postgresql/9.5/tmp
sudo install -o postgres -g postgres -m 0600 /dev/null /var/lib/postgresql/9.5/tmp/rep_mode.conf

提升maas1节点为db-vip节点

# Run them only on maas1, start postgresql only on the primary node
sudo pg_ctlcluster 9.5 main start
sudo -u postgres createuser -U postgres repuser -P -c 10 --replication# Run them only on maas2 and maas3, start the replication only on non-primary nodes.
sudo mv -v /var/lib/postgresql/9.5/main{,.old}
sudo -u postgres pg_basebackup -h ${IPS[maas1]} -D /var/lib/postgresql/9.5/main -U repuser -v -P --xlog-method=stream# Run it only on maas1, Stop PostgreSQL on the primary node and double check no PostgreSQL is running anywhere.
sudo pg_ctlcluster 9.5 main stop

配置db-vip CRM资源

# sudo crm resource stop pgsql && sudo crm resource delete pgsql && sudo crm configure erase
sudo crm configure property stonith-enabled="false"                  
sudo crm configure rsc_defaults resource-stickiness=INFINITY        
sudo crm configure rsc_defaults migration-threshold=10          
sudo crm configure primitive pgsql ocf:heartbeat:pgsql \params \rep_mode="sync" \pgctl="/usr/lib/postgresql/9.5/bin/pg_ctl" \psql="/usr/bin/psql" \pgdata="/var/lib/postgresql/9.5/main/" \socketdir="/var/run/postgresql" \config="/etc/postgresql/9.
  相关解决方案