前言:
眼前你们对“oracleom”大约比较注重,咱们都需要知道一些“oracleom”的相关知识。那么小编也在网络上网罗了一些对于“oracleom””的相关内容,希望我们能喜欢,同学们一起来了解一下吧!一、前期准备1. 关闭防火墙,selinux
systemctl disable firewalld.servicesystemctl stop firewalld.servicesetenforce=0sed -i '/^SELINUX=/c'SELINUX=disabled /etc/selinux/config2. 安装依赖包
yum install libaio-devel -y3. 创建相关目录、用户、组
groupadd dbgrp -g 2000useradd omm -g 2000 -u 2000echo "Enmo@123" | passwd --stdin ommmkdir -p /opt/mogdb/softwarechown -R omm:dbgrp /opt/4. 上传并解压二进制文件
[root@mogdb-kernel-0001 software]# pwd/opt/mogdb/software[root@mogdb-kernel-0001 software]# ls -lrttotal 90236-r-------- 1 root root 92401412 Jun 13 06:14 MogDB-2.0.0-openEuler-64bit.tar.bz2chown omm:dbgrp MogDB-2.0.0-openEuler-64bit.tar.bz2 su - ommcd /opt/mogdb/software/tar -xf MogDB-2.0.0-openEuler-64bit.tar.bz2二、初始化数据库(单机)1. 配置环境变量
echo "export GAUSSHOME=/opt/mogdb/software" >> /home/omm/.bashrc && \echo "export PATH=\$GAUSSHOME/bin:\$PATH " >> /home/omm/.bashrc && \echo "export LD_LIBRARY_PATH=\$GAUSSHOME/lib:\$LD_LIBRARY_PATH" >> /home/omm/.bashrcsource /home/omm/.bashrc2. init数据库
bin/gs_initdb --pgdata=/opt/mogdb/data --nodename=primary --pwpasswd=Enmo@123 --encoding=UTF-8 --locale=en_US.UTF-83. 修改初始化参数
echo "port=26000" >> /opt/mogdb/data/postgresql.confecho "listen_addresses = '0.0.0.0'" >> /opt/mogdb/data/postgresql.confecho "password_encryption_type = 0" >> /opt/mogdb/data/postgresql.confecho "log_directory = 'pg_log'" >> /opt/mogdb/data/postgresql.confecho "remote_read_mode=non_authentication" >> /opt/mogdb/data/postgresql.confecho "host all all 0.0.0.0/0 md5" >> /opt/mogdb/data/pg_hba.conf4. 启动数据库
gs_ctl start -D /opt/mogdb/data
至此单机安装完成
三、主备安装1. 主库操作配置连接通道
echo "replconninfo1='localhost=172.16.0.106 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=172.16.0.245 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004' " >> /opt/mogdb/data/postgresql.conf
localhost为主库IP,remotehost为备库IP
将主库以primary方式启动
gs_ctl restart -D /opt/mogdb/data/ -M primary2. 备库操作前期准备工作如上(一)配置环境变量
echo "export GAUSSHOME=/opt/mogdb/software" >> /home/omm/.bashrc && \echo "export PATH=\$GAUSSHOME/bin:\$PATH " >> /home/omm/.bashrc && \echo "export LD_LIBRARY_PATH=\$GAUSSHOME/lib:\$LD_LIBRARY_PATH" >> /home/omm/.bashrcsource /home/omm/.bashrc- 将主库的配置文件传到备库scp /opt/mogdb/data/pg_hba.conf /opt/mogdb/data/postgresql.conf 172.16.0.245:/opt/mogdb/data/配置连接通道,将localhost和remotehost对调.
sed -i “/^replconninfo1/creplconninfo1=‘localhost=172.16.0.245 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=172.16.0.106 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004’” /opt/mogdb/data/postgresql.conf
localhost为备库IP,remotehost为主库IP
构建主备关系
gs_ctl build -D /opt/mogdb/data/ -b full -M standby查询主备状态主库
[omm@mogdb-kernel-0001 data]$ gs_ctl query -D /opt/mogdb/data/ [2021-06-13 07:51:41.119][159054][][gs_ctl]: gs_ctl query ,datadir is /opt/mogdb/data HA state: local_role : Primary static_connections : 1 db_state : Normal detail_information : Normal Senders info: sender_pid : 159041 local_role : Primary peer_role : Standby peer_state : Normal state : Streaming sender_sent_location : 0/14000258 sender_write_location : 0/14000258 sender_flush_location : 0/14000258 sender_replay_location : 0/14000258 receiver_received_location : 0/14000258 receiver_write_location : 0/14000258 receiver_flush_location : 0/14000258 receiver_replay_location : 0/14000258 sync_percent : 100% sync_state : Sync sync_priority : 1 sync_most_available : Off channel : 172.16.0.106:26001-->172.16.0.245:60856 Receiver info: No information备库
[omm@mogdb-kernel-0002 data]$ gs_ctl query -D /opt/mogdb/data/ [2021-06-13 07:51:32.743][123204][][gs_ctl]: gs_ctl query ,datadir is /opt/mogdb/data HA state: local_role : Standby static_connections : 1 db_state : Normal detail_information : Normal Senders info: No information Receiver info: receiver_pid : 123194 local_role : Standby peer_role : Primary peer_state : Normal state : Normal sender_sent_location : 0/14000140 sender_write_location : 0/14000140 sender_flush_location : 0/14000140 sender_replay_location : 0/14000140 receiver_received_location : 0/14000140 receiver_write_location : 0/14000140 receiver_flush_location : 0/14000140 receiver_replay_location : 0/14000140 sync_percent : 100% channel : 172.16.0.245:60856<--172.16.0.106:26001
至此主备已安装完成。
四、主备级联安装1. 主备安装如上(一,二,三)2. 添加复制通道主库操作
gsql -d postgres -p26000 -c “alter system set replconninfo2 to ‘localhost=172.16.0.106 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=172.16.0.127 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004 iscascade=true’;”备库操作
gsql -d postgres -p26000 -c “alter system set replconninfo2 to ‘localhost=172.16.0.245 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=172.16.0.127 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004 iscascade=true’;”3. 级联库操作前期准备工作如上(一)配置环境变量
echo "export GAUSSHOME=/opt/mogdb/software" >> /home/omm/.bashrc && \echo "export PATH=\$GAUSSHOME/bin:\$PATH " >> /home/omm/.bashrc && \echo "export LD_LIBRARY_PATH=\$GAUSSHOME/lib:\$LD_LIBRARY_PATH" >> /home/omm/.bashrcsource /home/omm/.bashrc将备库的配置文件传到备库
scp /opt/mogdb/data/pg_hba.conf /opt/mogdb/data/postgresql.conf 172.16.0.245:/opt/mogdb/data/配置连接通道
sed -i "/^replconninfo1/creplconninfo1='localhost=172.16.0.127 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=172.16.0.106 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004'" /opt/mogdb/data/postgresql.confsed -i "/replconninfo2/creplconninfo2='localhost=172.16.0.127 localport=26001 localheartbeatport=26005 localservice=26004 remotehost=172.16.0.245 remoteport=26001 remoteheartbeatport=26005 remoteservice=26004'" /opt/mogdb/data/postgresql.conf
localhost为级联IP,remotehost为主库IP和备库IP。
构建主备关系
gs_ctl build -D /opt/mogdb/data/ -b full -M cascade_standby4.查看主备级联状态主库
[omm@mogdb-kernel-0001 ~]$ gs_ctl query -D /opt/mogdb/data[2021-06-13 08:37:03.281][207069][][gs_ctl]: gs_ctl query ,datadir is /opt/mogdb/data HA state: local_role : Primary static_connections : 2 db_state : Normal detail_information : Normal Senders info: sender_pid : 206143 local_role : Primary peer_role : Standby peer_state : Normal state : Streaming sender_sent_location : 0/1A000140 sender_write_location : 0/1A000140 sender_flush_location : 0/1A000140 sender_replay_location : 0/1A000140 receiver_received_location : 0/1A000140 receiver_write_location : 0/1A000140 receiver_flush_location : 0/1A000140 receiver_replay_location : 0/1A000140 sync_percent : 100% sync_state : Sync sync_priority : 1 sync_most_available : Off channel : 172.16.0.106:26001-->172.16.0.245:34586 Receiver info: No information备库
[omm@mogdb-kernel-0002 ~]$ gs_ctl query -D /opt/mogdb/data[2021-06-13 08:37:09.128][147065][][gs_ctl]: gs_ctl query ,datadir is /opt/mogdb/data HA state: local_role : Standby static_connections : 2 db_state : Normal detail_information : Normal Senders info: sender_pid : 147043 local_role : Standby peer_role : Cascade Standby peer_state : Normal state : Streaming sender_sent_location : 0/1A000140 sender_write_location : 0/1A000140 sender_flush_location : 0/1A000140 sender_replay_location : 0/1A000140 receiver_received_location : 0/1A000140 receiver_write_location : 0/1A000140 receiver_flush_location : 0/1A000140 receiver_replay_location : 0/1A000140 sync_percent : 100% sync_state : Async sync_priority : 0 sync_most_available : Off channel : 172.16.0.245:26001-->172.16.0.127:49110 Receiver info: receiver_pid : 146771 local_role : Standby peer_role : Primary peer_state : Normal state : Normal sender_sent_location : 0/1A000140 sender_write_location : 0/1A000140 sender_flush_location : 0/1A000140 sender_replay_location : 0/1A000140 receiver_received_location : 0/1A000140 receiver_write_location : 0/1A000140 receiver_flush_location : 0/1A000140 receiver_replay_location : 0/1A000140 sync_percent : 100% channel : 172.16.0.245:34586<--172.16.0.106:26001级联库
[omm@mogdb-kernel-0003 data]$ gs_ctl query -D /opt/mogdb/data[2021-06-13 08:36:56.223][273241][][gs_ctl]: gs_ctl query ,datadir is /opt/mogdb/data HA state: local_role : Cascade Standby static_connections : 2 db_state : Normal detail_information : Normal Senders info: No information Receiver info: receiver_pid : 273237 local_role : Cascade Standby peer_role : Standby peer_state : Normal state : Normal sender_sent_location : 0/1A000140 sender_write_location : 0/1A000140 sender_flush_location : 0/1A000140 sender_replay_location : 0/1A000140 receiver_received_location : 0/1A000140 receiver_write_location : 0/1A000140 receiver_flush_location : 0/1A000140 receiver_replay_location : 0/1A000140 sync_percent : 100% channel : 172.16.0.127:49110<--172.16.0.245:26001
至此主备级联安装完成。
注:本文源自墨天轮”我的国产数据库之路“的征文,原文链接:(复制链接至浏览器或点击MogDB/openGauss 手动部署(非OM工具)单机,主备,主备级联架构 - 墨天轮查看)
关于作者
李宏达,openGauss开源社区commiter,目前主要从事Oracle,openGauss,云服务相关工作。现拥有Oracle OCP,OceanBase OBCA,openGauss OGCA,PostgreSQL PGCA,华为云HCIP(Solutions Architect)认证。
标签: #oracleom