mogdb的一主两备
# 一、环境准备
|节点类别|主机名|IP|
|-|-|-|
|主节点|mogdb1 |192.168.3.68|
|备节点1|mogdb2 |192.168.3.69|
|备节点2|mogdb3|192.168.3.70|
# 二、关闭防火墙和透明大页
```
1、修改操作系统配置
1) 关闭 SELINUX
修改 /etc/selinux/config文件中的“SELINUX”值为“disabled”
2) 关闭防火墙并禁止开机重启
systemctl disable firewalld.service
systemctl stop firewalld.service
3) 修改主机名
在每个服务器节点修改hostname,以主机为例:
hostnamectl set-hostname mogdb1
另外两台备机分别设置为mogdb3和mogdb2
4) 关闭透明大页
echo never > /sys/kernel/mm/transparent_hugepage/enabled
```
# 三、安装操作系统依赖包
## 3.1配置yum,安装系统包
```mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
vi /etc/yum.repos.d/oracle.repo
[Server]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=file:///media/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
yum install -y bzip2 libaio-devel flex bison ncurses-devel glibc-devel libxml2-devel patch redhat-lsb-core unzip gcc gcc-c++ perl openssl-devel libffi-devel libtool zlib-devel
yum install -y libaio-devel gcc gcc-c++ zlib-devel expect
```
## 3.2安装Python3
```
# 解压并安装python3
[root@mogdb1 ~]# cd /enmo/soft
[root@mogdb1 soft]# tar -zxvf python3-rpm.tar.gz
# 配置yum源
[root@mogdb1 ~]# cat > /etc/yum.repos.d/enmo.repo << EOF
[Server]
name=Server
baseurl=file:///media/cdrom
enabled=yes
gpgcheck=0
[python3]
name=python3
baseurl=file:///enmo/soft/python3-rpm
enabled=yes
gpgcheck=0
EOF
# 执行yum安装
[root@mogdb1 ~]# yum clean all
[root@mogdb1 ~]# yum install python3 python3-devel -y
# 修改软链接
[root@mogdb1 ~]# rm -f /usr/bin/python
[root@mogdb1 ~]# ln -s /usr/bin/python3 /usr/bin/python
# 查看版本,确认安装成功
[root@mogdb1 ~]# python -V
Python 3.6.8
# 全词匹配替换,python3安装后’yum’命令执行会报错,需要修改以下配置
[root@mogdb1 ~]# sed -i "s:\<python\>:python2:g" /usr/bin/yum
[root@mogdb1 ~]# sed -i "s:\<python\>:python2:g" /usr/libexec/urlgrabber-ext-down
复制
2. 所有节点使用pip3
[root@mogdb1 ~]# cd /enmo/soft
[root@mogdb1 soft]# tar -zxvf pat_2.1.1.tar.gz
[root@mogdb1 soft]# cd
# 按顺序执行安装
[root@mogdb1 ]# pip3 install psutil-5.8.0.tar.gz
[root@mogdb1 ]# pip3 install ydiff-1.2.tar.gz
[root@mogdb1 ]# pip3 install *.whl
[root@mogdb1 ]# pip3 install python-etcd-0.4.5.tar.gz
[root@mogdb1 ]# pip3 install psycopg2-binary-2.9.1.tar.gz
[root@mogdb1 ]# pip3 install psycopg2-2.9.1.tar.gz
# 查看已安装的包
[root@mogdb1 ]# pip3 list
```
# 四、创建安装目录
```
#以root用户登录待安装MogDB的主机,并按规划创建存放安装包的目录(/opt/software/mogdb)
mkdir -p /opt/software/mogdb
chmod 755 -R /opt/software
#进入/opt/software/mogdb,将安装包及配置文件cluster_config.xml上传至此目录。若未创建配置文件,可通过vi cluster_config.xml新建并编辑配置文件。
cd /opt/software/mogdb
#在安装包所在的目录下,依次解压安装包。
```
# 五、安装包准备
```
1、下载并解压安装包
安装包放到 /opt/software 目录下,只在一个节点放安装包就行,安装过程中会把文件推到另外的节点去。
解压安装包到当前目录下并修改权限
[root@mogdb1 mogdb]# tar -xvf MogDB-2.1.0-CentOS-64bit-om.tar.gz
[root@mogdb1 mogdb]# tar -xvf MogDB-2.1.0-CentOS-64bit.tar.bz2
2、为确保openssl版本正确,执行预安装前请加载安装包中lib库
[root@mogdb1 software]# export LD_LIBRARY_PATH=/opt/software/script/gspylib/clib:$LD_LIBRARY_PATH
```
# 六、开始安装
## 6.1 准备配置文件
```
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- MogDB整体信息 -->
<CLUSTER>
<PARAM name="clusterName" value="Cluster_template" />
<PARAM name="nodeNames" value="mogdb1,mogdb2,mogdb3" />
<PARAM name="gaussdbAppPath" value="/opt/mogdb/install/app" />
<PARAM name="gaussdbLogPath" value="/var/log/omm" />
<PARAM name="tmpMppdbPath" value="/opt/mogdb/tmp"/>
<PARAM name="gaussdbToolPath" value="/opt/mogdb/install/om" />
<PARAM name="corePath" value="/opt/mogdb/corefile"/>
<PARAM name="backIp1s" value="192.168.3.68,192.168.3.69,192.168.3.70"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- node1上的节点部署信息 -->
<DEVICE sn="1000001">
<PARAM name="name" value="mogdb1"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.3.68"/>
<PARAM name="sshIp1" value="192.168.3.68"/>
<!--CM节点部署信息-->
<PARAM name="cmsNum" value="1"/>
<PARAM name="cmServerPortBase" value="15000"/>
<PARAM name="cmServerListenIp1" value="192.168.3.68,192.168.3.69,192.168.3.70"/>
<PARAM name="cmServerHaIp1" value="192.168.3.68,192.168.3.69,192.168.3.70"/>
<PARAM name="cmServerlevel" value="1"/>
<PARAM name="cmServerRelation" value="mogdb1,mogdb2,mogdb3"/>
<PARAM name="cmDir" value="/opt/mogdb/data/cmserver"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/opt/mogdb/install/data/dn,mogdb2,/opt/mogdb/install/data/dn,mogdb3,/opt/mogdb/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<!-- node2上的节点部署信息,其中“name”的值配置为主机名称 -->
<DEVICE sn="1000002">
<PARAM name="name" value="mogdb2"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.3.69"/>
<PARAM name="sshIp1" value="192.168.3.69"/>
<!-- cm -->
<PARAM name="cmServerPortStandby" value="15000"/>
<PARAM name="cmDir" value="/opt/mogdb/data/cmserver"/>
</DEVICE>
<!-- node3上的节点部署信息,其中“name”的值配置为主机名称 -->
<DEVICE sn="1000003">
<PARAM name="name" value="mogdb3"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.3.70"/>
<PARAM name="sshIp1" value="192.168.3.70"/>
<!-- cm -->
<PARAM name="cmServerPortStandby" value="15000"/>
<PARAM name="cmDir" value="/opt/mogdb/data/cmserver"/>
</DEVICE>
</DEVICELIST>
</ROOT>
#####注意配置文件中的主机名和ip
```
## 6.2 脚本初始化
```
[root@mogdb1 mogdb]# /opt/software/mogdb/script/gs_preinstall -U omm -G dbgrp -X /opt/software/mogdb/cluster_config.xml
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Are you sure you want to create trust for root (yes/no)?yes
Please enter password for root
Password:
Successfully created SSH trust for the root permission user.
Setting host ip env
Successfully set host ip env.
Distributing package.
Begin to distribute package to tool path.
Successfully distribute package to tool path.
Begin to distribute package to package path.
Successfully distribute package to package path.
Successfully distributed package.
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
Please enter password for cluster user.
Password:
Please enter password for cluster user again.
Password:
Generate cluster user password files successfully.
Successfully created [omm] user on all nodes.
Preparing SSH service.
Successfully prepared SSH service.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [omm] user.
Please enter password for current user[omm].
Password:
Checking network information.
All nodes in the network are Normal.
Successfully checked network information.
Creating SSH trust.
Creating the local key file.
Successfully created the local key files.
Appending local ID to authorized_keys.
Successfully appended local ID to authorized_keys.
Updating the known_hosts file.
Successfully updated the known_hosts file.
Appending authorized_key on the remote node.
Successfully appended authorized_key on all remote node.
Checking common authentication file content.
Successfully checked common authentication content.
Distributing SSH trust file to all node.
Distributing trust keys file to all node successfully.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
Successfully created SSH trust for [omm] user.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
Creating cluster's path.
Successfully created cluster's path.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/opt/software/mogdb/script/gs_checkos -i A -h mogdb1,mogdb2,mogdb3 --detail".
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Setting user environmental variables.
Successfully set user environmental variables.
Setting the dynamic link library.
Successfully set the dynamic link library.
Setting Core file
Successfully set core path.
Setting pssh path
Successfully set pssh path.
Setting Cgroup.
Successfully set Cgroup.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.
###########初始化过程中会建立 root 用户的互信,创建 omm 用户并建立互信。
```
## 6.3 执行安装
```
[root@mogdb1 software]#
[root@mogdb1 software]# chown -R omm: /opt/software/script/
[root@mogdb1 software]# chmod -R 755 /opt/software/script/
[root@mogdb1 software]#
[root@mogdb1 software]# su – omm
[omm@mogdb1 ~]$ /opt/software/script/gs_install -X /opt/mogdb/etc/mogdb_cluster_config.xml --gsinit-parameter="--locale=en_US.UTF-8" --gsinit-parameter="--encoding=UTF-8"
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /opt/mogdb/app/share/sslcert/om
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Successful check consistence of memCheck and coresCheck on all nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Successfully started cluster.
Successfully installed application.
end deploy..
```
# 七、安装验证
安装完成后,可使用omm用户通过“gsql -d postgres -p 26000 -r”命令连接MogDB数据库,其中“-p 26000”为数据库端口号,请根据实际情况替换。键入“\copyright”可查看版权信息
```
[omm@mogdb1 ~]$ gsql -d postgres -p 26000 -r
gsql ((MogDB 2.0.1 build f892ccb7) compiled at 2021-07-09 16:12:59 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=# \copyright
MogDB Database Management System
Copyright (c) Yunhe Enmo (Beijing) Information Technology Co., Ltd. Copyright 2020 , All rights reserved.
postgres=#
[omm@mogdb1 mogdb]$ gs_install -X /opt/software/mogdb/cluster_config.xml --gsinit-parameter="--locale=en_US.UTF-8" --gsinit-parameter="--encoding=UTF-8"
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /opt/mogdb/install/app/share/sslcert/om
Create CA files for cm beginning.
Create CA files on directory [/opt/mogdb/install/app_1a363ea9/share/sslcert/cm]. file list: ['cacert.pem', 'server.key', 'server.crt', 'client.key', 'client.crt', 'server.key.cipher', 'server.key.rand', 'client.key.cipher', 'client.key.rand']
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Successful check consistence of memCheck and coresCheck on all nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Starting cluster.
======================================================================
Successfully started primary instance. Wait for standby instance.
======================================================================
.
Successfully started cluster.
======================================================================
cluster_state : Normal
redistributing : No
node_count : 3
Datanode State
primary : 1
standby : 2
secondary : 0
cascade_standby : 0
building : 0
abnormal : 0
down : 0
Successfully installed application.
end deploy..
[omm@mogdb1 mogdb]$
```
# 八、状态检查
## 8.1检查集群状态
```
[omm@mogdb1 mogdb]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
-------------------------------------------------------------------------
1 mogdb1 192.168.3.68 1 /opt/mogdb/data/cmserver/cm_server Standby
2 mogdb2 192.168.3.69 2 /opt/mogdb/data/cmserver/cm_server Standby
3 mogdb3 192.168.3.70 3 /opt/mogdb/data/cmserver/cm_server Primary
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
---------------------------------------------------------------------------
1 mogdb1 192.168.3.68 6001 /opt/mogdb/install/data/dn P Standby Normal
2 mogdb2 192.168.3.69 6002 /opt/mogdb/install/data/dn S Standby Normal
3 mogdb3 192.168.3.70 6003 /opt/mogdb/install/data/dn S Primary Normal
```
## 8.2 检查同步延迟
```
MogDB=# select * from pg_stat_replication;
pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | state | sender_sent_location | receiver_write_location | receiver_flush_locati
on | receiver_replay_location | sync_priority | sync_state
-----------------+----------+---------+-------------------------------+--------------+-----------------+-------------+-------------------------------+-----------+----------------------+-------------------------+----------------------
---+--------------------------+---------------+------------
140417194297088 | 10 | omm | WalSender to Standby[dn_6002] | 192.168.3.69 | | 57732 | 2022-08-14 11:40:28.278504+08 | Streaming | 0/7804758 | 0/7804758 | 0/7804758
| 0/7804758 | 0 | Async
140417177515776 | 10 | omm | WalSender to Standby[dn_6003] | 192.168.3.70 | | 49866 | 2022-08-14 11:36:48.184737+08 | Streaming | 0/7804758 | 0/7804758 | 0/7804758
| 0/7804758 | 0 | Async
(2 rows)
MogDB=#
```
mogdb的一主两备的更多相关文章
- Centos 7.6 安装部署 openGauss 3.1.0 企业版一主两备集群
一.安装环境设置 1.1 硬件环境 名称 最低配置 建议配置 测试配置 服务器数量 3 略 略 硬盘 * 至少1GB用于安装openGauss的应用程序.* 每个主机需大约300MB用于元数据存储.* ...
- PostgreSQL 一主两备节点(两备节点为同步节点)故障恢复
PostgreSQL 同步复制及故障恢复 10.2.208.10:node1:master 10.2.208.11:node2:standby1 同步 10.2.208.12:node3:stand ...
- Mysql + keepalived 实现双主热备读写分离【转】
Mysql + keepalived 实现双主热备读写分离 2013年6月16日frankwong发表评论阅读评论 架构图 系统:CentOS6.4_X86_64软件版本:Mysql-5.6.12 ...
- 阿里云ECS服务器上搭建keepalived+mha+mysql5.6+gtid+一主两从+脚本判断架构踩的坑
最近,公司项目搭建了一套后端数据库架构,不是在RDS,是在阿里云的ECS服务器上搭建keepalived.mha.mysql5.6.gtid.一主两从架构,目前还没有实现读写分离,以后架构升级,可能代 ...
- Mysql双主热备+LVS+Keepalived高可用部署实施手册
MySQL复制能够保证数据的冗余的同时可以做读写分离来分担系统压力,如果是主主复制还可以很好的避免主节点的单点故障.然而MySQL主主复制存在一些问题无法满足我们的实际需要:未提供统一访问入口来实现负 ...
- Mysql双主互备+keeplived高可用架构介绍
一.Mysql双主互备+keeplived高可用架构介绍 Mysql主从复制架构可以在很大程度保证Mysql的高可用,在一主多从的架构中还可以利用读写分离将读操作分配到从库中,减轻主库压力.但是在这种 ...
- Mysql双主互备+keeplived高可用架构(部分)
一.Mysql双主互备+keeplived高可用架构介绍 Mysql主从复制架构可以在很大程度保证Mysql的高可用,在一主多从的架构中还可以利用读写分离将读操作分配到从库中,减轻主库压力.但是在这种 ...
- Mysql+Keepalived双主热备高可用操作记录
我们通常说的双机热备是指两台机器都在运行,但并不是两台机器都同时在提供服务.当提供服务的一台出现故障的时候,另外一台会马上自动接管并且提供服务,而且切换的时间非常短.MySQL双主复制,即互为Mast ...
- Mysql双主热备+LVS+Keepalived高可用操作记录
MySQL复制能够保证数据的冗余的同时可以做读写分离来分担系统压力,如果是主主复制还可以很好的避免主节点的单点故障.然而MySQL主主复制存在一些问题无法满足我们的实际需要:未提供统一访问入口来实现负 ...
- Docker mysql主主互备和高可用
一.测试环境 1.1 结构图 1.2 版本 操作系统:CentOS 7.3 MySQL版本:5.6.35 Docker版本:18.06.1-ce 使用root用户操作 IP地址说明 IP地址 用途 备 ...
随机推荐
- uni-app 动态修改主题色
老是碰到初版制作完成没多久,就整一出说什么要更改整个项目的色彩体系.真的是宝宝心里苦啊! 起初都是通过uni项目自带的uni.scss中定义,在替换页面上对应的css.以便于达到一次性修改整体布局的样 ...
- 手把手教你玩转 Excel 数据透视表
1. 什么是数据透视表 数据透视表是一种可以快速汇总.分析大量数据表格的交互式分析工具.使用数据透视表可以按照数据表格的不同字段从多个角度进行透视,并建立交叉表格,用以查看数据表格不同层面的汇总信息 ...
- 总结开源项目中的常见坏实践(Bad Practice)
一些开源项目包含了各种编程的最佳实践供人参考学习和借鉴.但是也有一些开源项目虽然初衷是好的.但是包含了一些代码的坏实践.特别是对于一部分刚入行的大学生来说,可能会给到一些错误的示范.于是在此列举一些项 ...
- “It is required that your private key files are NOT accessible by others. This private key will be ignored.”
Windows Terminal 通过密钥登录远程vps时提示: "It is required that your private key files are NOT accessible ...
- test20230109考试总结-2023寒搜索专题
前言 2023 年的第一篇考试总结-- 赛时得分情况: A B C D E F G \(\texttt{Total}\) \(\texttt{Rank}\) \(40\) \(80\) \(0\) \ ...
- Java 进阶P-6.6+P-7.1
接口设计模式 接口 接口是纯抽象类 所有的成员函数都是抽象函数 所有的成员变量都是public static final 接规定了长什么样,但是不管里面有什么 实现接口 类用extends,接口用im ...
- Sundial(一)
Sundial 源码梳理 - v2.5.6 代码目录一览 通过入口点说明 实现IServiceCollection,并返回IServiceCollection(Extensions/ScheduleS ...
- 移动 WEB 开发布局方式 ---- rem 适配布局
一.rem 基础 1. rem 单位 em : 相对于父元素的字体大小来说的 <div> <p></p> </div> div { font-size: ...
- mysql 错误解决大法 Specified key was too long; max key length is 767 bytes
高版本mysql向低版本(5.7以下)导入sql时可能会发生此问题 开启索引最大长度 SET GLOBAL INNODB_LARGE_PREFIX = ON; 将表改为动态表SET GLOBAL in ...
- CentOS安装mysql、MariaDB以及更改数据库存储路径
注意:此方法只适用于新的机器或没有重要数据库表(可随意删除)的机器安装,如需升级版本参考下方链接!!! https://www.jianshu.com/p/955ff6065935 一.安装操作 1. ...