首页 > 数据库 >opengauss数据库-主从搭建

opengauss数据库-主从搭建

时间:2024-04-01 14:57:09浏览次数:23  
标签:node 数据库 Successfully SSH file opengauss trust local 主从

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

标签:node,数据库,Successfully,SSH,file,opengauss,trust,local,主从
From: https://www.cnblogs.com/helloopenGauss/p/18108386

相关文章

  • MogDB/openGauss关于PL/SQL匿名块调用测试
    MogDB/openGauss关于PL/SQL匿名块调用测试一、原理介绍PL/SQL(ProcedureLanguage/StructureQueryLanguage)是标准SQL语言添加了过程化功能的一门程序设计语言。单一的SQL语句只能进行数据操作,没有流程控制,无法开发复杂的应用。PL/SQL语言是结合了结构化查询与数据库......
  • MogDB/openGauss中merge的语法解析
    MogDB/openGauss中merge的语法解析近期了解学习了MogDB/openGauss中merge的使用,merge语法是根据源表对目标表进行匹配查询,匹配成功时更新,不成功时插入。简单来说就是有则更新,无则插入,语句简洁,效率高。下面展示MogDB/openGauss中merge的语法openGauss=#\hmergeCo......
  • openGauss/MogDB-3.0.0 dcf测试(非om安装)
    openGauss/MogDB-3.0.0dcf测试(非om安装)本文出处:https://www.modb.pro/db/402037IP地址...LERDER...FOLLOWER...FOLLOWER一、安装openGauss安装依赖包yuminstall-ybzip2bzip2-develcurllibaio创建用户、组并创建目录groupaddomma-g20001useraddomm......
  • 关于openGauss中的虚拟索引
    关于openGauss中的虚拟索引作为曾经的Oracle资深使用者,对于Oracle11gR2版本推出的invisibleIndex感觉一直很良好;因为这对于大部分情况下做优化是比较友好的。实际上openGauss2.0版本中也提供了类似的功能,下面我们来进行简单测试。首先我们创建一个测试表用来验证ope......
  • openGauss关于PL/SQL匿名块调用测试
    openGauss关于PL/SQL匿名块调用测试一、原理介绍PL/SQL(ProcedureLanguage/StructureQueryLanguage)是标准SQL语言添加了过程化功能的一门程序设计语言。单一的SQL语句只能进行数据操作,没有流程控制,无法开发复杂的应用。PL/SQL语言是结合了结构化查询与数据库自身过......
  • 用户、组或角色 'xxx 在当前数据库中已存在 Microsoft SQL Server,错误: 15023
    为一个数据库添加一个用户或者映射数据库时,提示以下错误信息:用户、组或角色*****在当前数据库中已存在。(MicrosoftSQLServer,错误:15023)问题原因:在还原数据库的过程中,在其它sqlserver服务器上进行还原之后,会出现一个在原服务器上可以正常的用户在目标服务器上出现无......
  • openGauss数据库将磁盘表转换为MOT
    openGauss数据库将磁盘表转换为MOT一、将磁盘表转换为MOT方法磁盘表直接转换为MOT尚不能实现,这意味着尚不存在将基于磁盘的表转换为MOT的ALTERTABLE语句。目前MOT表也不支持rename,createasselect以及insertselect(普通表)的操作。将基于磁盘的表转换为MOT方......
  • MogDB/openGauss如何实现事务的rollback
    MogDB/openGauss如何实现事务的rollback本文出处:https://www.modb.pro/db/113262数据库最主要的功能就是存储数据,然而我们在进行数据库操作时,却很容易发生误操作数据的情况,那么在MogDB中该如何实现误操作数据恢复呢?本文通过具体示例简要介绍如何通过回滚还原到误操作前的状......
  • 【数据库】使用DBever连接人大金仓数据库
    下载安装DBever首先需要下载并安装DBever,可以在DBever官网上下载最新版的安装程序,根据提示进行安装即可。下载驱动程序首先需要从人大金仓官方网站下载适用于DBever的驱动程序。下载完成后,将驱动程序保存到本地计算机上。添加驱动程序打开DBever软件,在主界面中点击菜单栏中的......
  • 【数据库】[MYSQL][面试题]常见数据库知识整理
    常见数据库:MySQL:是一种关系型数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL使用C和C++编写,并使用了多种编译器进行测试,保证了源代码的可移植性。支持多线程,充分利用CPU资源。提供多语言支持......