
opengauss单机可以搭建主备吗?怎么搭建? 有没有相关的资料?

opengauss 在本地搭建 主、备 集群方法。
先编译安装完。进到bin目录下。
1、先初始化主库。 gs_initdb -D 主库目录 --nodename=节点名字 -w密码
2、修改db_p主库的配置文件。
port = 启主机服务的端口3 (备库端口和主库端口要相隔2个,即主库port=5001,则备库只能从Port=5003开始)
most_available_sync = on;
listen_addresses = ‘0.0.0.0’;
remote_read_mode = ‘non_authentication’
replconninfo1 = ‘localhost=192.168.3.83 localport=主机端口1 localheartbeatport=主机端口2 localservice=启主机服务的端口3 remotehost=192.168.3.83 remoteport=备机端口1 remoteheartbeatport=备机端口2 remoteservice=启备机服务的端口3’
3、修改pg_hba.conf 添加host all all 0.0.0.0/0 sha256
4、生成备库目录。mkdir 备机目录; chmod 700 备机目录
gs_basebackup -D 备机目录 -h 192.168.3.83 -p 5001
5、 再修改replconninfo1(和前文主库端口对应)
6、启动主备库。
./gs_ctl -D 主库目录 -M primary start
./gs_ctl -D 备库目录 -M standby start


gs_initdb --pgdata=/opt/gaussdb/data1/ --nodename=node1 --encoding=GBK
gs_initdb: invalid locale settings; check LANG and LC_* environment variables


gs_ctl -D /opt/gaussdb/data1/ -M primary start
[2021-04-08 17:31:00.353][39066][][gs_ctl]: gs_ctl started,datadir is /opt/gaussdb/data1
[2021-04-08 17:31:00.405][39066][][gs_ctl]: waiting for server to start…
.0 LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
0 LOG: [Alarm Module]Host Name: node1
0 LOG: [Alarm Module]Host IP: 192.168.1.28
0 LOG: [Alarm Module]Cluster Name: myCluster
0 LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 52
0 WARNING: failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING: failed to parse feature control file: gaussdb.version.
0 WARNING: Failed to load the product control file, so gaussdb cannot distinguish product version.
0 LOG: Failed to initialze environment for codegen.
0 WARNING: bbox_dump_path is set to /opt/gaussdb/corefile/
2021-04-08 17:31:00.511 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: when starting as multi_standby mode, we couldn’t support data replicaton.
2021-04-08 17:31:00.512 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
2021-04-08 17:31:00.512 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: [Alarm Module]Host Name: node1
2021-04-08 17:31:00.512 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: [Alarm Module]Host IP: 192.168.1.28
2021-04-08 17:31:00.512 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: [Alarm Module]Cluster Name: myCluster
2021-04-08 17:31:00.512 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 52
2021-04-08 17:31:00.512 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: Transparent encryption disabled.
2021-04-08 17:31:00.513 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: loaded library “security_plugin”
2021-04-08 17:31:00.514 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2021-04-08 17:31:00.514 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: reserved memory for backend threads is: 220 MB
2021-04-08 17:31:00.514 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: reserved memory for WAL buffers is: 128 MB
2021-04-08 17:31:00.514 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: Set max backend reserve memory is: 348 MB, max dynamic memory is: 6888 MB
2021-04-08 17:31:00.514 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: shared memory 4539 Mbytes, memory context 7236 Mbytes, max process memory 12288 Mbytes
2021-04-08 17:31:00.636 [unknown] [unknown] localhost 281458685640720 0 0 [CACHE] LOG: set data cache size(402653184)
2021-04-08 17:31:00.677 [unknown] [unknown] localhost 281458685640720 0 0 [CACHE] LOG: set metadata cache size(134217728)
2021-04-08 17:31:00.705 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: gaussdb: fsync file “/opt/gaussdb/data1/gaussdb.state.temp” success
2021-04-08 17:31:00.706 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: create gaussdb state file success: db state(STARTING_STATE), server mode(Primary)
2021-04-08 17:31:00.886 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: max_safe_fds = 979, usable_fds = 1000, already_open = 11
bbox_dump_path is set to /opt/gaussdb/corefile/
2021-04-08 17:31:00.888 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: the configure file /opt/gaussdb/install/app/etc/gscgroup_omm.cfg doesn’t exist or the size of configure file has changed. Please create it by root user!
2021-04-08 17:31:00.888 [unknown] [unknown] localhost 281458685640720 0 0 [BACKEND] LOG: Failed to parse cgroup config file.
[2021-04-08 17:31:01.406][39066][][gs_ctl]: waitpid 39069 failed, exitstatus is 256, ret is 2
[2021-04-08 17:31:01.406][39066][][gs_ctl]: stopped waiting
[2021-04-08 17:31:01.406][39066][][gs_ctl]: could not start server


单机主备? 那你这个应该是个人测试使用。
可以使用openGauss的极简安装,参考文章“https://www.modb.pro/db/48894” , 简单方便。


sh install.sh -w qcubic@123 -p 15400 --multinode
[step 1]: check parameter
[step 2]: check install env and os setting
[step 3]: change_gausshome_owner
[step 4]: set environment variables
[init primary datanode.]
The files belonging to this database system will be owned by user “omm”.
This user must also own the server process.
The database cluster will be initialized with locale “en_US.UTF-8”.
The default text search configuration will be set to “english”.
fixing permissions on existing directory /home/omm/data/master … ok
creating subdirectories … ok
selecting default max_connections … 10
selecting default shared_buffers … 400kB
creating configuration files … ok
creating template1 database in /home/omm/data/master/base/1 … gs_initdb: removing contents of data directory “/home/omm/data/master”
[init slave datanode.]
The files belonging to this database system will be owned by user “omm”.
This user must also own the server process.
The database cluster will be initialized with locale “en_US.UTF-8”.
The default text search configuration will be set to “english”.
fixing permissions on existing directory /home/omm/data/slave … ok
creating subdirectories … ok
selecting default max_connections … 10
selecting default shared_buffers … 400kB
creating configuration files … ok
creating template1 database in /home/omm/data/slave/base/1 … gs_initdb: removing contents of data directory “/home/omm/data/slave”
[config datanode.]
sed: can’t read /home/omm/data/master/postgresql.conf: No such file or directory
sed: can’t read /home/omm/data/slave/postgresql.conf: No such file or directory
sed: can’t read /home/omm/data/master/postgresql.conf: No such file or directory
sed: can’t read /home/omm/data/slave/postgresql.conf: No such file or directory
sed: can’t read /home/omm/data/master/postgresql.conf: No such file or directory
sed: can’t read /home/omm/data/slave/postgresql.conf: No such file or directory
remote_read_mode = non_authentication
host all all 172.17.0.1/32 trust
[start primary datanode.]
0 LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
0 LOG: [Alarm Module]Host Name: node1
0 LOG: [Alarm Module]Host IP: 192.168.1.28
0 LOG: [Alarm Module]Cluster Name: dbCluster
0 LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 52
0 WARNING: failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING: failed to parse feature control file: gaussdb.version.
0 WARNING: Failed to load the product control file, so gaussdb cannot distinguish product version.
0 LOG: Failed to initialze environment for codegen.
0 WARNING: bbox_dump_path is set to /opt/gaussdb/corefile/
[2021-04-09 11:48:52.659][71076][][gs_ctl]: gs_ctl started,datadir is /home/omm/data/master
[2021-04-09 11:48:52.711][71076][][gs_ctl]: waiting for server to start…
.0 LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
0 LOG: [Alarm Module]Host Name: node1
0 LOG: [Alarm Module]Host IP: 192.168.1.28
0 LOG: [Alarm Module]Cluster Name: dbCluster
0 LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 52
0 WARNING: failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING: failed to parse feature control file: gaussdb.version.
0 WARNING: Failed to load the product control file, so gaussdb cannot distinguish product version.
0 LOG: Failed to initialze environment for codegen.
0 WARNING: bbox_dump_path is set to /opt/gaussdb/corefile/
0 [BACKEND] FATAL: “/home/omm/data/master” is not a valid data directory
0 [BACKEND] DETAIL: File “/home/omm/data/master/PG_VERSION” is missing.
[2021-04-09 11:48:53.712][71076][][gs_ctl]: waitpid 71085 failed, exitstatus is 256, ret is 2
[2021-04-09 11:48:53.712][71076][][gs_ctl]: stopped waiting
[2021-04-09 11:48:53.712][71076][][gs_ctl]: could not start server
Examine the log output.
[build and start slave datanode.]
0 LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
0 LOG: [Alarm Module]Host Name: node1
0 LOG: [Alarm Module]Host IP: 192.168.1.28
0 LOG: [Alarm Module]Cluster Name: dbCluster
0 LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 52
0 WARNING: failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING: failed to parse feature control file: gaussdb.version.
0 WARNING: Failed to load the product control file, so gaussdb cannot distinguish product version.
0 LOG: Failed to initialze environment for codegen.
0 WARNING: bbox_dump_path is set to /opt/gaussdb/corefile/
[2021-04-09 11:48:53.873][71089][][gs_ctl]: gs_ctl full build ,datadir is /home/omm/data/slave
[2021-04-09 11:48:53.873][71089][][gs_ctl]: stop failed, killing gaussdb by force …
[2021-04-09 11:48:53.873][71089][][gs_ctl]: command [ps c -eo pid,euid,cmd | grep gaussdb | grep -v grep | awk ‘{if($2 == curuid && $1!="-n") print “/proc/“1"/cwd"}' curuid=`id -u`| xargs ls -l | awk '{if (NF==”/home/omm/data/slave”) print $(NF-2)}’ | awk -F/ '{print 3 }' | xargs kill -9 >/dev/null 2>&1 ] path: [/home/omm/data/slave]
[2021-04-09 11:48:53.893][71089][][gs_ctl]: server stopped
[2021-04-09 11:48:53.893][71089][][gs_ctl]: current workdir is (/home/omm/simpleInstall).
[2021-04-09 11:48:53.893][71089][][gs_ctl]: fopen build pid file "/home/omm/data/slave/gs_build.pid" success
[2021-04-09 11:48:53.893][71089][][gs_ctl]: fprintf build pid file "/home/omm/data/slave/gs_build.pid" success
[2021-04-09 11:48:53.894][71089][][gs_ctl]: fsync build pid file "/home/omm/data/slave/gs_build.pid" success
[2021-04-09 11:48:53.894][71089][][gs_ctl]: set gaussdb state file when full build:db state(BUILDING_STATE), server mode(STANDBY_MODE), build mode(FULL_BUILD).
[2021-04-09 11:48:53.894][71089][][gs_ctl]: invalid value for parameter "replconninfo" in postgresql.conf.
import sql file
Would you like to create a demo database (yes/no)? yes
Load demoDB failed, you can check load.log for more details.
[omm@node1 simpleInstall] ore load.log
-bash: ore: command not found
[omm@node1 simpleInstall]$ more load.log
failed to connect Unknown:15400.
failed to connect Unknown:15400.


