Centos 7 系统 openGauss 3.1.1企业版一主一备集群安装

该文档详细描述了在CentOS7.6环境下配置系统环境,包括内存要求、Python3.6的安装、依赖包的安装、系统参数修改以及防火墙和SELinux的设置。然后,它提供了openGauss数据库的安装过程,包括下载安装包、解压、配置XML文件以及执行安装和初始化。最后,文章提到了主从同步验证的步骤,确保数据库的正确运行。
摘要由CSDN通过智能技术生成

一、环境配置

内存

>=2G

操作系统

centos 7.6

Linux文件系统

剩余inode个数 > 15亿(推荐)

工具

bzip2

Python

centos 7.6:支持python 3.6.x

数据库版本

openGauss_3.1.1 企业版

二、安装python3.6(所有节点)

创建目录
mkdir /usr/local/python3
cd /usr/local/python3

下载python3.6.10
wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz

解压
tar -zxvf Python-3.6.10.tgz

编译安装
./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC 
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

设置环境变量
cat >>/etc/profile<<EOF
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python3/bin
EOF
source /etc/profile
echo "/usr/local/python3/lib/" >> /etc/ld.so.conf
ldconfig

三、安装依赖包(所有节点)

yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel zlib readline gcc perl-ExtUtils-Embed readline-devel zlib-devel expect bzip2

四、修改操作系统配置(所有节点)

4.1 修改操作系统参数

cat>>/etc/sysctl.conf <<EOF
net.ipv4.tcp_fin_timeout=60
net.ipv4.tcp_retries1=5
net.ipv4.tcp_syn_retries=5
net.sctp.path_max_retrans=10
net.sctp.max_init_retransmits=10
EOF

生效
sysctl -p

执行sysctl -p 报一下错误,忽略就行
sysctl: cannot stat /proc/sys/net/sctp/path_max_retrans: No such file or directory
sysctl: cannot stat /proc/sys/net/sctp/max_init_retransmits: No such file or directory

4.2 关闭透明大页

#openGauss默认关闭使用transparent_hugepage服务,并将关闭命令写入操作系统启动文件
vi /etc/rc.d/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
 
chmod +x /etc/rc.d/rc.local
/usr/bin/sh /etc/rc.d/rc.local

查看是否关闭:
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag

4.3 关闭防火墙和selinux

关闭防火墙
systemctl disable firewalld
systemctl stop firewalld

关闭seliunx
sed -i  "s/SELINUX=enforcing/SELINUX=disabled/"  /etc/selinux/config
-- 检查
cat /etc/selinux/config | grep disabled

4.4 修改字符集

cat>> /etc/profile<<EOF
export LANG=en_US.UTF-8
EOF

source /etc/profile

# 检查
cat /etc/profile | grep LANG

4.5修改Banned配置

cat >>/etc/ssh/sshd_config<<EOF
Banner none
EOF
-- 检查
cat /etc/ssh/sshd_config | grep Banner

-- 重启生效
systemctl restart sshd.service

4.6 添加hosts解析

添加所有节点的IP和主机名
cat > /etc/hosts<<EOF
192.168.76.10 node1
192.168.76.20 node2
EOF

#添加用户和用户组(所有节点)
groupadd dbgrp
useradd -g dbgrp -m omm -d /home/omm
passwd omm

4.7 设置root远程登录

cat >>/etc/ssh/sshd_config<<EOF
PermitRootLogin yes
EOF

检查
cat /etc/ssh/sshd_config |grep PermitRootLogin

五、数据库安装(主节点)

目录规划

5.1 下载数据库包

官网:https://www.opengauss.org/zh/download/
下载:openGauss_3.1.1 企业版

5.2 上传并解压安装包

创建存放安装包目录
mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software

上传包
上传openGauss-3.1.1-CentOS-64bit-all.tar.gz到/opt/software/openGauss目录下

解压
tar -zxvf openGauss-3.1.1-CentOS-64bit-all.tar.gz
tar -zxvf openGauss-3.1.1-CentOS-64bit-om.tar.gz

5.3 配置XML文件

在/opt/software/openGauss 目录下创建 clusterconfig.xml配置文件
vim clusterconfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!-- opengauss整体信息 -->
    <CLUSTER>
        <!-- 数据库名称 -->
        <PARAM name="clusterName" value="dbCluster" />
        <!-- 数据库节点名称(hostname) -->
        <PARAM name="nodeNames" value="node1,node2" />
        <!-- 数据库安装目录-->
        <PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
        <!-- 日志目录-->
        <PARAM name="gaussdbLogPath" value="/var/log/omm" />
        <!-- 临时文件目录-->
        <PARAM name="tmpMppdbPath" value="/opt/huawei/tmp"/>
        <!-- 数据库工具目录-->
        <PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
        <!-- 数据库core文件目录-->
        <PARAM name="corePath" value="/opt/huawei/corefile"/>
        <!-- 节点IP,与数据库节点名称列表一一对应 -->
        <PARAM name="backIp1s" value="192.168.76.10,192.168.76.20"/>
    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
        <!-- 节点1上的部署信息 -->
        <DEVICE sn="1000001">
            <!-- 节点1的主机名称 -->
            <PARAM name="name" value="node1"/>
            <!-- 节点1所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.76.10"/>
            <PARAM name="sshIp1" value="192.168.76.10"/>

    <!--dn-->
            <PARAM name="dataNum" value="1"/>
    <PARAM name="dataPortBase" value="15400"/>
    <PARAM name="dataNode1" value="/opt/gaussdb/install/data/db1,node2,/opt/gaussdb/install/data/db1"/>
            <PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE>

        <!-- 节点2上的节点部署信息,其中“name”的值配置为主机名称 -->
        <DEVICE sn="1000002">
            <!-- 节点2的主机名称 -->
            <PARAM name="name" value="node2"/>
            <!-- 节点2所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.76.20"/>
            <PARAM name="sshIp1" value="192.168.76.20"/>
            <PARAM name="cmDir" value="/opt/gaussdb/install/data/cm" />
</DEVICE>
    </DEVICELIST>
</ROOT>

5.4 初始化安装环境

设置lib库
export LD_LIBRARY_PATH=/opt/software/openGauss/script/gspylib/clib:$LD_LIBRARY_PATH

执行预执行
python3 /opt/software/openGauss/script/gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml
预执行过程中,从日志来看是拷贝了software目录下文件到其它节点,将节点一的scripts下ssh-agent.sh拷贝到其它节点/root/.ssh/目录下,执行完并将其删除,创建了omm用户,每个节点/etc/profile下设置环境变量
预执行详细执行过程可查看 /opt/gaussdb/log/omm/om 目录下 
执行过程可查看/opt/gaussdb/log/omm/om 目录下gs_preinstall日志文件gs_preinstall_xxx.log文件

预检查执行结果如下
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  -- 输入 yes
Please enter password for root
Password:   输入 root 口令
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 -- 输入 yes
Please enter password for cluster user.
Password:  -- 设置 omm 口令
Please enter password for cluster user again.
Password:  -- 再次输入 omm 口令
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:   -- 输入 omm 口令
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/openGauss/script/gs_checkos -i A -h opengauss-db1,opengauss-db2,opengauss-db3 --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.

查看预安装结果信息,并根据预检查调整参数
/opt/software/openGauss/script/gs_checkos -i A -h opengauss-db1,opengauss-db2,opengauss-db3 --detail

5.5 执行集群安装

5.5.1 修改属主

chmod -R 755 /opt/software/openGauss/script/
chown -R omm:dbgrp /opt/software/openGauss/script/

5.5.2 执行安装

切换到omm用户执行
su - omm

执行命令如下
gs_install -X /opt/software/openGauss/clusterconfig.xml
执行过程可查看/opt/gaussdb/log/omm/om及各节点/opt/gaussdb/log/omm/pg_log/ 下日志文件

执行结果如下
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:     -- 设置数据库 口令 如 Passw0rd@1234
Please repeat for database:             -- 再次输入相同口令
begin to create CA cert files
The sslcert will be generated in /opt/gaussdb/install/app/share/sslcert/om
Create CA files for cm beginning.
Create CA files on directory [/opt/gaussdb/install/app_4e931f9a/share/sslcert/cm]. file list: ['client.key.rand', 'server.crt', 'cacert.pem', 'client.crt', 'server.key.rand', 'client.key', 'client.key.cipher', 'server.key', 'server.key.cipher']
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..

5.5.3 查看数据库状态

现在是omm用户,操作
gs_om -t status --detail

6.主从同步验证

#主节点

gsql -d postgres -p 15400

#在主节点上面插入数据

create table tb1 (id int, name text);

insert into tb1 (id,name) values (10,'Jacky');

commit;

#备节点

gsql -d postgres -p 15400

#在备节点上查看数据

select * from tb1;

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值