- hosts: Main-standby
vars:
- installation_package: openGauss-Lite-3.0.0-openEuler-x86_64.tar.gz
- ansible_ip: 192.168.100.99
tasks:
- name: Install dependencies packages
yum:
name:
- flex
- bison
- ncurses-devel
- glibc-devel
- patch
- readline-devel
- libaio-devel
state: present
- name: Modify system configuration
shell: |
systemctl stop firewalld.service #关闭防火墙
systemctl disable firewalld.service
sed -i '/^SELINUX=.*/ c\SELINUX=disabled' /etc/selinux/config #关闭selinux
echo "export LC_CTYPE=zh_CN.GB18030" >> /etc/profile #统一字符集
echo "export LC_ALL=zh_CN.GB18030" >> /etc/profile
echo "export LANG=zh_CN.GB18030" >> /etc/profile
source /etc/profile
sed -i 's/^server/#server/g' /etc/chrony.conf #时间同步
sed -i "/^#server 0.*/ i\server {{ ansible_ip }} iburst" /etc/chrony.conf
systemctl restart chronyd.service
swapoff -a #关闭交换内存
sed -i 's/^#RemoveIPC/RemoveIPC/' /etc/systemd/logind.conf #关闭RemoveIPC
systemctl daemon-reload
systemctl restart systemd-logind
echo "500 641280 500 500" > /proc/sys/kernel/sem #修改信号集参数
- name: Create omm user
user:
name: omm
state: present
- name: Create installation directory
shell: |
mkdir -p /home/omm/openGauss/data
mkdir -p /home/omm/openGauss/install
- name: Download opengauss-Lite package
get_url:
url: https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/x86_openEuler/{{ installation_package }}
dest: /tmp/
- name: Decompression opengauss-Lite package
unarchive:
src: /tmp/{{ installation_package }}
dest: /home/omm/openGauss/
copy: no
- name: Directory authorization
shell: chown -R omm:omm /home/omm/openGauss/
- hosts: master
vars:
- master_ip: 192.168.100.101
- slave_ip: 192.168.100.102
- master_port: 36999
- slave_port: 36999
- password: password123!
tasks:
- name: Start up opengauss-master
shell: >-
su omm -l -c "echo {{password}} | sh /home/omm/openGauss/install.sh --mode primary -D ~/openGauss/data -R ~/openGauss/install -C
\"replconninfo1='localhost={{master_ip}} localport={{master_port}} remotehost={{slave_ip}} remoteport={{slave_port}}'\" --start"
- hosts: slave
vars:
- master_ip: 192.168.100.101
- slave_ip: 192.168.100.102
- master_port: 36999
- slave_port: 36999
- password: password123!
tasks:
- name: Start up opengauss-slave
shell: >-
su omm -l -c "echo {{password}} | sh /home/omm/openGauss/install.sh --mode standby -D ~/openGauss/data -R ~/openGauss/install -C
\"replconninfo1='localhost={{slave_ip}} localport={{slave_port}} remotehost={{master_ip}} remoteport={{master_port}}'\" --start"