enmotech / enmotech-docker-opengauss

Ennotech openGauss Docker Image
GNU General Public License v3.0
49 stars 28 forks source link

关于一主多备的docker部署 #3

Closed GaoBo1997 closed 4 years ago

GaoBo1997 commented 4 years ago

如题,一主多备的docker部署应该如何进行呢,能不能在create_master_slave.sh中增加一个备机数量的输入,然后循环执行增加备机?

kamusis commented 4 years ago

一主多备的功能openGauss也刚发布,我们会在下一个容器版本中增加一主多备的构建功能。

GaoBo1997 commented 4 years ago

好的,谢谢!

ChAnYaNG97 commented 3 years ago

请问现在有一主多备的docker部署支持了吗

lee1057 commented 3 years ago

支持,也可以级联,正式的后续会出,可以先发给你一些命令自己尝试一下。

!/bin/bash -e

Parameters

!/bin/bash

set OG_SUBNET,GS_PASSWORD,MASTER_IP,SLAVE_1_IP,MASTER_HOST_PORT,MASTER_LOCAL_PORT,SLAVE_1_HOST_PORT,SLAVE_1_LOCAL_PORT,MASTER_NODENAME,SLAVE_NODENAME

read -p "Please input OG_SUBNET (容器所在网段) [172.11.0.0/24]: " OG_SUBNET OG_SUBNET=${OG_SUBNET:-172.11.0.0/24} echo "OG_SUBNET set $OG_SUBNET"

read -p "Please input GS_PASSWORD @.: " GS_PASSWORD @.} echo "GS_PASSWORD set $GS_PASSWORD"

read -p "Please input MASTER_IP (主库IP)[172.11.0.101]: " MASTER_IP MASTER_IP=${MASTER_IP:-172.11.0.101} echo "MASTER_IP set $MASTER_IP"

read -p "Please input SLAVE_1_IP (备库IP)[172.11.0.102]: " SLAVE_1_IP SLAVE_1_IP=${SLAVE_1_IP:-172.11.0.102} echo "SLAVE_1_IP set $SLAVE_1_IP"

read -p "Please input MASTER_HOST_PORT (主库数据库服务端口)[5432]: " MASTER_HOST_PORT MASTER_HOST_PORT=${MASTER_HOST_PORT:-5432} echo "MASTER_HOST_PORT set $MASTER_HOST_PORT"

read -p "Please input MASTER_LOCAL_PORT (主库通信端口)[5434]: " MASTER_LOCAL_PORT MASTER_LOCAL_PORT=${MASTER_LOCAL_PORT:-5434} echo "MASTER_LOCAL_PORT set $MASTER_LOCAL_PORT"

read -p "Please input SLAVE_1_HOST_PORT (备库数据库服务端口)[6432]: " SLAVE_1_HOST_PORT SLAVE_1_HOST_PORT=${SLAVE_1_HOST_PORT:-6432} echo "SLAVE_1_HOST_PORT set $SLAVE_1_HOST_PORT"

read -p "Please input SLAVE_1_LOCAL_PORT (备库通信端口)[6434]: " SLAVE_1_LOCAL_PORT SLAVE_1_LOCAL_PORT=${SLAVE_1_LOCAL_PORT:-6434} echo "SLAVE_1_LOCAL_PORT set $SLAVE_1_LOCAL_PORT"

read -p "Please input MASTER_NODENAME [mogdb_master]: " MASTER_NODENAME MASTER_NODENAME=${MASTER_NODENAME:-mogdb_master} echo "MASTER_NODENAME set $MASTER_NODENAME"

read -p "Please input SLAVE_NODENAME [mogdb_slave1]: " SLAVE_NODENAME SLAVE_NODENAME=${SLAVE_NODENAME:-mogdb_slave1} echo "SLAVE_NODENAME set $SLAVE_NODENAME"

read -p "Please input openGauss VERSION [1.1.0]: " VERSION VERSION=${VERSION:-1.1.0} echo "openGauss VERSION set $VERSION"

echo "starting  "

docker network create --subnet=172.16.0.0/16 mogdbnetwork  \ || {   echo ""   echo "ERROR: OpenGauss Database Network was NOT successfully created."   echo "HINT: mogdbnetwork Maybe Already Exsist Please Execute 'docker network rm mogdbnetwork' "   exit 1 } echo "OpenGauss Database Network Created."

docker run --network mogdbnetwork --ip $MASTER_IP --privileged=true \ --name $MASTER_NODENAME -h $MASTER_NODENAME -p $MASTER_HOST_PORT:$MASTER_HOST_PORT -d \ -e GS_PORT=$MASTER_HOST_PORT \ -e OG_SUBNET=$OG_SUBNET \ -e GS_PASSWORD=$GS_PASSWORD \ -e NODE_NAME=$MASTER_NODENAME \ -e REPL_CONN_INFO="replconninfo1 = 'localhost=$MASTER_IP localport=$MASTER_LOCAL_PORT localservice=$MASTER_HOST_PORT remotehost=$SLAVE_1_IP remoteport=$SLAVE_1_LOCAL_PORT remoteservice=$SLAVE_1_HOST_PORT'\n" \ opengauss:$VERSION -M primary \ || {   echo ""   echo "ERROR: OpenGauss Database Master Docker Container was NOT successfully created."   exit 1 } echo "OpenGauss Database Master Docker Container created."

sleep 30s

docker run --network mogdbnetwork --ip $SLAVE_1_IP --privileged=true \ --name $SLAVE_NODENAME -h $SLAVE_NODENAME -p $SLAVE_1_HOST_PORT:$SLAVE_1_HOST_PORT -d \ -e GS_PORT=$SLAVE_1_HOST_PORT \ -e OG_SUBNET=$OG_SUBNET \ -e GS_PASSWORD=$GS_PASSWORD \ -e NODE_NAME=$SLAVE_NODENAME \ -e REPL_CONN_INFO="replconninfo1 = 'localhost=$SLAVE_1_IP localport=$SLAVE_1_LOCAL_PORT localservice=$SLAVE_1_HOST_PORT remotehost=$MASTER_IP remoteport=$MASTER_LOCAL_PORT remoteservice=$MASTER_HOST_PORT'\n" \ opengauss:$VERSION -M standby \ || {   echo ""   echo "ERROR: OpenGauss Database Slave1 Docker Container was NOT successfully created."   exit 1 } echo "OpenGauss Database Slave1 Docker Container created."

docker run --network mogdbnetwork --ip 172.11.0.103 --privileged=true \ --name mogdb_standby2 -h mogdb_standby2  -p 6432:6432 -d \ -e GS_PORT=6432 \ -e OG_SUBNET=172.11.0.0/24 \ -e @.*** \ -e NODE_NAME=mogdb_standby2 \ -e REPL_CONN_INFO="replconninfo1 = 'localhost=172.11.0.103 localport=6434 localservice=6432 remotehost=172.11.0.101 remoteport=5434 remoteservice=5432'\n" \ opengauss:1.1.0 -M standby

1

 docker network create --subnet=172.16.0.0/16 mogdbnetwork

2

 docker login -u @.*** -p c2ebf043f73720aabada13b8a3ae0f7c152bbe32515389a4f60ceede8857ce51 swr.cn-east-3.myhuaweicloud.com

3 不同操作系统镜像选择不同 (注意一下)

 docker pull swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_amd

4

docker run --network mogdbnetwork --ip 172.16.0.101 --privileged=true --name mogdb_priamry  -h mogdb_priamry  -p 1111:5432 -d -e GS_PORT=5432 -e OG_SUBNET=172.16.0.0/16 -e @. -e NODE_NAME=mogdb_priamry -e 'REPL_CONN_INFO=replconninfo1 = '\''localhost=172.13.0.101 localport=5434 localservice=5432 remotehost=172.16.0.102 remoteport=5434 remoteservice=5432'\''\n' swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_arm -M primary docker run --network mogdbnetwork --ip 172.16.0.102 --privileged=true --name mogdb_standby1 -h mogdb_standby1 -p 1112:5432 -d -e GS_PORT=5432 -e OG_SUBNET=172.16.0.0/16 -e @. -e NODE_NAME=mogdb_standby1 -e 'REPL_CONN_INFO=replconninfo1 = '\''localhost=172.16.0.102 localport=5434 localservice=5432 remotehost=172.16.0.101 remoteport=5434 remoteservice=5432'\''\n' swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_arm -M standby docker run --network mogdbnetwork --ip 172.16.0.103 --privileged=true --name mogdb_standby2 -h mogdb_standby2 -p 1113:5432 -d -e GS_PORT=5432 -e OG_SUBNET=172.16.0.0/16 -e @. -e NODE_NAME=mogdb_standby2 -e 'REPL_CONN_INFO=replconninfo2 = '\''localhost=172.16.0.103 localport=5434 localservice=5432 remotehost=172.16.0.101 remoteport=5434 remoteservice=5432'\''\n' swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_arm -M standby docker run --network mogdbnetwork --ip 172.16.0.104 --privileged=true --name mogdb_standby3 -h mogdb_standby3 -p 1114:5432 -d -e GS_PORT=5432 -e OG_SUBNET=172.16.0.0/16 -e @. -e NODE_NAME=mogdb_standby3 -e 'REPL_CONN_INFO=replconninfo3 = '\''localhost=172.16.0.104 localport=5434 localservice=5432 remotehost=172.16.0.101 remoteport=5434 remoteservice=5432'\''\n' swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_arm -M standby docker run --network mogdbnetwork --ip 172.16.0.105 --privileged=true --name mogdb_standby4 -h mogdb_standby4 -p 1115:5432 -d -e GS_PORT=5432 -e OG_SUBNET=172.16.0.0/16 -e @. -e NODE_NAME=mogdb_standby4 -e 'REPL_CONN_INFO=replconninfo4 = '\''localhost=172.16.0.105 localport=5434 localservice=5432 remotehost=172.16.0.101 remoteport=5434 remoteservice=5432'\''\n' swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_arm -M standby docker run --network mogdbnetwork --ip 172.16.0.106 --privileged=true --name mogdb_standby5 -h mogdb_standby5 -p 1116:5432 -d -e GS_PORT=5432 -e OG_SUBNET=172.16.0.0/16 -e @. -e NODE_NAME=mogdb_standby5 -e 'REPL_CONN_INFO=replconninfo5 = '\''localhost=172.16.0.106 localport=5434 localservice=5432 remotehost=172.16.0.101 remoteport=5434 remoteservice=5432'\''\n' swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_arm -M standby docker run --network mogdbnetwork --ip 172.16.0.107 --privileged=true --name mogdb_cascade1 -h mogdb_cascade1 -p 1117:5432 -d -e GS_PORT=5432 -e OG_SUBNET=172.16.0.0/16 -e @.*** -e NODE_NAME=mogdb_cascade1 -e 'REPL_CONN_INFO=replconninfo6 = '\''localhost=172.16.0.107 localport=5434 localservice=5432 remotehost=172.16.0.101 remoteport=5434 remoteservice=5432'\''\n' swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_arm -M cascade_standby

主库 alter system set replconninfo1 = 'localhost=172.11.0.101 localport=5434 localservice=5432 remotehost=172.11.0.102 remoteport=5434 remoteservice=5432'; alter system set replconninfo2 = 'localhost=172.11.0.101 localport=5434 localservice=5432 remotehost=172.11.0.103 remoteport=5434 remoteservice=5432'; alter system set replconninfo3 = 'localhost=172.11.0.101 localport=5434 localservice=5432 remotehost=172.11.0.104 remoteport=5434 remoteservice=5432'; alter system set replconninfo4 = 'localhost=172.11.0.101 localport=5434 localservice=5432 remotehost=172.11.0.105 remoteport=5434 remoteservice=5432'; alter system set replconninfo5 = 'localhost=172.11.0.101 localport=5434 localservice=5432 remotehost=172.11.0.106 remoteport=5434 remoteservice=5432'; alter system set replconninfo6 = 'localhost=172.16.0.101 localport=5434 localservice=5432 remotehost=172.16.0.103 remoteport=5434 remoteservice=5432'; alter system set max_wal_senders=16;

级联上游 alter system set replconninfo6 = 'localhost=172.16.0.102 localport=5434 localservice=5432 remotehost=172.16.0.103 remoteport=5434 remoteservice=5432'; alter system set replconninfo6 = 'localhost=172.12.0.107 localport=5434 localservice=5432 remotehost=172.12.0.102 remoteport=5434 remoteservice=5432';

select a.client_addr, b.state, b.sender_sent_location, \                   b.sender_write_location, b.sender_flush_location, \                   b.sender_replay_location, b.receiver_received_location, \                   b.receiver_write_location, b.receiver_flush_location, \                   b.receiver_replay_location, b.sync_percent, b.sync_state  \                   from pg_stat_replication a inner join  \                   pg_stat_get_wal_senders() b on a.pid = b.pid;


该邮件从移动设备发送

--------------原始邮件-------------- 发件人:"ChAnYaNG97 @.>; 发送时间:2021年9月30日(星期四) 下午4:33 收件人:"enmotech/enmotech-docker-opengauss" @.>; 抄送:"Subscribed @.***>; 主题:Re: [enmotech/enmotech-docker-opengauss] 关于一主多备的docker部署 (#3)

请问现在有一主多备的docker部署支持了吗

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

ChAnYaNG97 commented 3 years ago

@lee1057 Thanks a lot!

ChAnYaNG97 commented 3 years ago

3 不同操作系统镜像选择不同 (注意一下)

 docker pull swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_amd

@lee1057 请问这个镜像和enmotech/opengauss:2.1.0是同一个镜像吗?如果不是的话,这个镜像好像需要华为账号才能pull。

lee1057 commented 3 years ago

该镜像是云和恩墨发布的MogDB数据库镜像,可以直接替换成openGauss镜像。

2021年10月10日 下午10:05,ChAnYaNG97 @.***> 写道:

3 https://github.com/enmotech/enmotech-docker-opengauss/issues/3 不同操作系统镜像选择不同 (注意一下)

docker pull swr.cn-east-3.myhuaweicloud.com/enmotech/mogdb:1.1.0_amd

@lee1057 https://github.com/lee1057 请问这个镜像和enmotech/opengauss:2.1.0是同一个镜像吗?如果不是的话,这个镜像好像需要华为账号才能pull。

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/enmotech/enmotech-docker-opengauss/issues/3#issuecomment-939488427, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3W4PFOPXQKY6RQSILKL53UGGMTTANCNFSM4THCW23Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.