opengauss 数据库-主从搭建

环境说明

软件下载

opengauss 下载地址:https://opengauss.org/zh/download/

环境准备

关闭 SELINUX

修改 /etc/selinux/config 文件中的“SELINUX”值为“disabled

[root@ogpri openGauss]# more /etc/selinux/config

This file controls the state of SELinux on the system.

SELINUX= can take one of these three values:

enforcing - SELinux security policy is enforced.

permissive - SELinux prints warnings instead of enforcing.

disabled - No SELinux policy is loaded.

SELINUX=disabled

SELINUXTYPE= can take one of three values:

targeted - Targeted processes are protected,

minimum - Modification of targeted policy. Only selected processes are protected.

mls - Multi Level Security protection.

SELINUXTYPE=targeted

关闭防火墙并禁止开机重启

systemctl disable firewalld.service

systemctl stop firewalld.service

设置 root 用户远程登陆

将 PermitRootLogin 改为 yes。

vim /etc/ssh/sshd_config

PermitRootLogin yes

修改后生效

systemctl restart sshd.service

关闭透明大页

echo never > /sys/kernel/mm/transparent_hugepage/enabled

数据库安装包依赖

root 用户下执行,所有的节点都要安装,建议配置本地 yum 源

yum -y install libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel

Python3 依赖包

yum install bzip2-devel db4-devel gdbm-devel libpcap-devel openssl openssl-devel sqlite-devel tk-devel xz-devel zlib* gcc*

安装 python3

tar -xvf Python-3.6.8.tar.xz

cd Python-3.6.8/

./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC

make && make install

设置 python3 软连接

ln -s /usr/local/Python3/bin/python3 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

设置 python3 环境变量

vi /etc/profile

安装 python3

export PYTHON_HOME=/usr/local/python3.6.8

export PATH=$PATH:$PYTHON_HOME/bin

:wq

Source /etc/profile

验证安装结果

[root@ogpri ~]# python3

Python 3.6.8 (default, Dec 27 2021, 21:52:53)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux

Type "help", "copyright", "credits" or "license" for more information.

安装 opengaussdb 数据库软件

数据库软件安装,如没有特殊说明,均在主节点执行,执行用户为 root

创建数据库软件目录

mkdir -p /opt/software/openGauss

chmod 755 -R /opt/software

创建 XML 配置文件

如果是验证安装测试使用,建议修改其中的 ip 地址和 hostname,

vi /opt/software/openGauss/cluster_config.xml

</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的部署信息 -->
<DEVICE sn="ogpri">
<!-- 节点1的主机名称 -->
<PARAM name="name" value="ogpri"/>
<!-- 节点1所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="***.***.***.***"/>
<PARAM name="sshIp1" value="***.***.***.***"/> <!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/opt/huawei/install/data/dn,ogsta,/opt/huawei/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE> <!-- 节点2上的部署信息 -->
<DEVICE sn="ogsta">
<!-- 节点2的主机名称 -->
<PARAM name="name" value="ogsta"/>
<!-- 节点2所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="***.***.***.***"/>
<PARAM name="sshIp1" value="***.***.***.***"/>
</DEVICE>
</DEVICELIST>

预安装

在安装过程中请输入 root,omm 两个用户的密码

/opt/software/openGauss/script/gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml

安装日志如下:

[root@ogpri script]# /opt/software/openGauss/script/gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/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:

Creating SSH trust for the root permission user.

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.

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 the root permission user.

Setting pssh path

Successfully set core path.

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

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.

reating 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.

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/openGauss/script/gs_checkos -i A -h ogpri,ogsta --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.

切换用户执行安装

su - ommgs_install -X /opt/software/openGauss/cluster_config.xml

安装日志如下:

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/huawei/install/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@ogpri dn]$ gsql -d postgres -p 26000

gsql ((openGauss 2.1.0 build 590b0f8e) compiled at 2021-09-30 14:29:04 commit 0 last mr )

Non-SSL connection (SSL connection is recommended when requiring high-security)

Type "help" for help.

openGauss=#

查看主从状态

gs_ctl -D /opt/huawei/install/data/dn/ query

信息如下:

[2021-12-29 14:41:33.751][21110][][gs_ctl]: gs_ctl query ,datadir is /opt/huawei/install/data/dn

HA state:

local_role : Primary

static_connections : 1

db_state : Normal

detail_information : Normal

Senders info:

sender_pid : 9716

local_role : Primary

peer_role : Standby

peer_state : Normal

state : Streaming

sender_sent_location : 0/401A080

sender_write_location : 0/401A080

sender_flush_location : 0/401A080

sender_replay_location : 0/401A080

receiver_received_location : 0/401A080

receiver_write_location : 0/401A080

receiver_flush_location : 0/401A080

receiver_replay_location : 0/401A080

sync_percent : 100%

sync_state : Quorum

sync_priority : 1

sync_most_available : Off

channel : ...:26001-->...:35144

Receiver info:

No information

opengauss数据库-主从搭建的更多相关文章

  1. mysql数据库主从搭建

    一.最近一直在学习mysql的东西,刚好看到mysql如何搭建主从数据库,搜集了很多资料后大致了解了mysql主从复置的原理.以下是我的理解: 举例master为主数据库,slave为从数据库. sl ...

  2. Mysql数据库主从配置

    一.为什么要使用数据库主从架构 一个网站损耗资源最厉害的就是数据库,最易崩溃的也是数据库,而数据库崩溃带来的后果是非常严重的.数据库分为读和写操作,在实际的应用中,读操作的损耗远比写操作多太多,因此读 ...

  3. xtrabackup 在线主从搭建

    因为意外导致某个MySQL的从服务器宕机,且不可修复,因为是业务数据库,不能停机和锁表进行从库的搭建,所以考虑了使用xtrabackup 进行在线主从搭建. 一.数据库环境 注意:  主从搭建主库一定 ...

  4. mysql 5.5数据库主从配置步骤详解

    上次给大家介绍了mysql 5.1主从搭建配置教程,这次我们来实现mysql 5.5的主从复制,其实大体上配置是差不多的,只有点细微的差别. 系统:centos 5.x 需要的软件包:mysql-5. ...

  5. mysql数据库主从操作记录

    master数据库已投入生产一段时间后,做主从复制的操作记录 环境: master库:172.18.237.13slave库:172.18.237.14 mysql版本说明: master:mysql ...

  6. mongodb主从搭建

    #tigergao 官网进行下包,可以下载源码包或者二进制包,本次下载的为二进制包,进行试验. 主服务器搭建: mkdir mongomaster cp mongodb-linux-x86_64-rh ...

  7. springboot数据库主从方案

    本篇分享数据库主从方案,案例采用springboot+mysql+mybatis演示:要想在代码中做主从选择,通常需要明白什么时候切换数据源,怎么切换数据源,下面以代码示例来做阐述: 搭建测试环境(1 ...

  8. ### MySQL主从搭建Position

    一.MySQL主从搭建 搭建主从架构的MySQL常用的有两种实现方式: 基于binlog的fileName + postion模式完成主从同步. 基于gtid完成主从同步搭建. 本篇就介绍如何使用第一 ...

  9. SQL Server、MySQL主从搭建,EF Core读写分离代码实现

    一.SQL Server的主从复制搭建 1.1.SQL Server主从复制结构图 SQL Server的主从通过发布订阅来实现 1.2.基于SQL Server2016实现主从 新建一个主库&quo ...

  10. mysql数据库主从同步

    环境: Mater:   CentOS7.1  5.5.52-MariaDB  192.168.108.133 Slave:   CentOS7.1  5.5.52-MariaDB  192.168. ...

随机推荐

  1. 【Azure API 管理】在 Azure API 管理中使用 OAuth 2.0 授权和 Azure AD 保护 Web API 后端,在请求中携带Token访问后报401的错误

    问题描述 在 Azure API 管理中使用 OAuth 2.0 授权和 Azure AD 保护 Web API 后端的文档中操作 "在开发人员门户中启用 OAuth 2.0 用户授权&qu ...

  2. STM32 LwIP学习过程问题总结(一):LwIP ping不通,抓包发现ICMP校验和为0x0000

    一.问题 今天在将之前的STM32 LwIP1.4.1版本程序移植到2.1.2版本上时,发现ping不同,但是开发板有ICMP回复包,黄颜色警告checksum为0x0000.说明LwIP移植应该是没 ...

  3. 阿里二面:如何定位&避免死锁?连着两个面试问到了!

    在面试过程中,死锁是必问的知识点,当然死锁也是我们日常开发中也会遇到的一个问题,同时一些业务场景例如库存扣减,银行转账等都需要去考虑如何避免死锁,一旦线上发生了死锁,那可能年终不保.....下面我们就 ...

  4. modalError.vue 错误提示框 vue2 iview

    需求 一个错误提示框,后台需要有换行,默认没有换行,做一个支持换行的全局错误提示函数. 注意 代码只展示原理,直接不能使用,里面有getAc,有需要参考 https://www.cnblogs.com ...

  5. Android Progressbar进度条样式调整为圆角矩形,且改变颜色

    原文地址: Android Progressbar进度条样式调整为圆角矩形,且改变颜色 美工设计的进度条是圆角矩形的,与Android默认的样式有所区别,可以通过样式progressDrawable属 ...

  6. uniapp 微信对接地图的三种操作

    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 1.uni.getLocation 获取当前经维度 先上代码 let that = this // 获取用户是否开启 授权获取当前的地理位 ...

  7. 从零开始的 dbt 入门教程 (dbt cloud 自动化篇)

    一.引 在前面的几篇文章中,我们从 dbt core 聊到了 dbt 项目工程化,我相信前几篇文章足够各位数据开发师从零快速入门 dbt 开发,那么到现在我们更迫切需要解决的是如何让数据更新做到定时化 ...

  8. 一行代码 python 证件照换底色

    安装所需模块 pip install OpenCV-python pip install cvzone pip install mediapipe 代码 import cv2 import cvzon ...

  9. 数字集成电路设计之CMOS

    数字集成电路设计理论 1.基本的理论结构 现在主流的集成电路器件还是CMOS,所以理论的结构还是基于CMOS.CMOS有N和P两种MOS组合组合在一起.CMOS最简单的器件就是反相器.然后是标准的逻辑 ...

  10. KingbaseESV8R6全局临时表不能进行reindex操作

    背景 我们经常遇到两种情况下会重建索引,reindex 1.索引崩溃,由于软件或硬件问题导致索引内数据失效而不可用. 2.索引膨胀,当索引膨胀会占用过多磁盘空间,reindex可以解决此问题. 对于临 ...