一、安装环境设置
1.1 硬件环境
名称 | 最低配置 | 建议配置 | 测试配置 |
服务器数量 |
2 |
略 |
略 |
硬盘 |
* 至少1GB用于安装openGauss的应用程序。 * 每个主机需大约300MB用于元数据存储。 * 预留70%以上的磁盘剩余空间用于数据存储。 |
略 |
略 |
内存 |
>=2G |
略 |
略 |
CPU |
功能调试最小1×8核,2.0GHz |
略 |
略 |
网络 |
300兆以上以太网,生产建议采用bond |
略 |
略 |
1.2 软件环境
软件类型 | 信息描述 |
操作系统 |
openEuler 20.3 LTS / Centos 7.6 |
Linux文件系统 |
剩余inode个数 > 15亿(推荐) |
工具 |
bzip2 |
Python |
* oepnEuler:支持Python 3.7.x * Centos 7.6: 支持Python 3.6.x |
数据库版本 |
opengauss2.0 企业版 |
数据库软件包名称 |
openGauss-2.0.0-CentOS-64bit-all.tar.gz |
1.2.1 安装python 3.6
# 本次选择安装python 3.6.5版本
mkdir /usr/local/python3
cd /usr/local/python3
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar -zxf Python-3.6.5.tgz
cd /usr/local/python3/Python-3.6.5
-- 不加CFLAGS=-fPIC,会在升级3.0的时候遇到编译问题
./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
1.2.2 安装软件依赖包
1.2.2.1 软件依赖要求
所需软件 | 建议版本 |
libaio-devel |
建议版本:0.3.109-13 |
flex |
要求版本:2.5.31 以上 |
bison |
建议版本:2.7-4 |
ncurses-devel |
建议版本:5.9-13.20130511 |
glibc-devel |
建议版本:2.17-111 |
patch |
建议版本:2.7.1-10 |
redhat-lsb-core |
建议版本:4.1 |
readline-devel |
建议版本 :7.0-13 |
libnsl(openeuler+x86环境中) |
建议版本 :2.28-36 |
1.2.2.2 安装软件依赖包
-- 安装依赖包
yum install libaio-devel flex bison ncurses-devel glibc-devel patch lsb_release readline-devel
-- 检查是否已安装
rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" | grep -E "zlib|readline|gcc|python|python-devel|perl-ExtUtils-Embed|readline-devel|zlib-devel"
1.2.3 修改操作系统配置
1.2.3.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: 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
# 预安装过程根据系统参数配置会有相应提示,请按照提示对应系统参数
1.2.3.2 关闭透明大页
-- openGauss默认关闭使用transparent_hugepage服务,并将关闭命令写入操作系统启动文件
cat >> /etc/rc.d/rc.local<<EOF
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
EOF
-- 查看是否关闭:
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
1.2.3.3 关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
1.2.3.4 关闭selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
-- 检查
cat /etc/selinux/config | grep disabled
1.2.3.5 修改字符集
cat>> /etc/profile<<EOF
export LANG=en_US.UTF-8
EOF
source /etc/profile
# 检查
cat /etc/profile | grep LANG
env |grep -i lang
1.2.3.6 修改时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
-- 查看
date
1.2.3.7 关闭SWAP
-- 临时关闭
swapoff -a
-- 永久关闭
注释 swap 行
vim /etc/fstab
-- 查看
free -h 查看 swap一行全是 0 表示swap关闭
1.2.3.8 设置网卡MTU
-- 设置网卡为1500
ifconfig 网卡名 mtu 1500
-- 查看
ifconfig -a |grep -i mtu
1.2.3.9 设置root用户远程登陆
cat >>/etc/ssh/sshd_config<<EOF
PermitRootLogin yes
EOF
-- 检查
cat /etc/ssh/sshd_config |grep PermitRootLogin
1.2.3.10 修改 Banner 配置
cat >>/etc/ssh/sshd_config<<EOF
Banner none
EOF
-- 检查
cat /etc/ssh/sshd_config | grep Banner
-- 重启生效
systemctl restart sshd.service
1.2.3.11 修改DNS配置
-- 节点一
cat >>/etc/resolv.conf<<EOF
nameserver 192.168.17.136
EOF
-- 节点二
cat >>/etc/resolv.conf<<EOF
nameserver 192.168.17.137
EOF
二、安装规划
2.1 主机名-IP地址-端口号规划
项目名称 | 描述说明 | 备注 |
主机名 |
opengauss-node1、opengauss-node2 |
主备主机名 |
IP地址 |
192.168.17.136(opengauss-node1)、192.168.17.137(opengauss-node2) |
主备主机名及IP |
端口号 |
26000 |
|
2.2 用户名规划
项目名称 | 名称 | 所属类型 | 规划建议 |
用户名 |
omm |
操作系统 |
参照官网 |
组名 |
dbgrp |
操作系统 |
参照官网 |
2.3 软件目录规划
目录名称 | 对应名称 | 目录作用 |
/opt/gaussdb/app |
gaussdbAppPath |
安装目录 |
/opt/gaussdb/log |
gaussdbLogPath |
日志目录 |
/opt/gaussdb/tmp |
tmpMppdbPath |
临时目录 |
/opt/gaussdb/gausstools/om |
gaussdbToolPath |
工具目录 |
/opt/gaussdb/corefile |
corePath |
core文件目录 |
三、软件安装
3.1 上传及解压软件包
-- 创建存放安装包目录
mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software
-- 上传软件包
# 上传openGauss-2.0.0-CentOS-64bit-all.tar.gz软件至/opt/software/openGauss目录
# 解压软件包,解压openGauss-2.0.0-CentOS-64bit-all.tar.gz后需保留 .sha256文件,否则执行预检查时会报[GAUSS-50201] : The /opt/software/openGauss/openGauss-2.0.0-RedHat-64bit.sha256 does not exist.
tar -zxvf openGauss-2.0.0-CentOS-64bit-all.tar.gz
tar -zxvf openGauss-2.0.0-CentOS-64bit-om.tar.gz
3.2 创建XML配置文件
3.2.1 配置XML文件
-- 在/opt/software/openGauss 目录下创建 clusterconfig.xml配置文件
cat > clusterconfig.xml<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss 整体信息 -->
<CLUSTER>
<PARAM name="clusterName" value="dbCluster" />
<PARAM name="nodeNames" value="opengauss-node1,opengauss-node2" />
<PARAM name="backIp1s" value="192.168.17.136,192.168.17.137"/>
<PARAM name="gaussdbAppPath" value="/opt/gaussdb/app" />
<PARAM name="gaussdbLogPath" value="/opt/gaussdb/log" />
<PARAM name="tmpMppdbPath" value="/opt/gaussdb/tmp" />
<PARAM name="gaussdbToolPath" value="/opt/gaussdb/gausstools/om" />
<PARAM name="corePath" value="/opt/gaussdb/corefile" />
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- opengauss-node1 上的节点部署信息 -->
<DEVICE sn="1000001">
<PARAM name="name" value="opengauss-node1"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点IP,如果服务器只有一个网卡可用,将 backIP1 和 sshIP1 配置成同一个 IP -->
<PARAM name="backIp1" value="192.168.17.136"/>
<PARAM name="sshIp1" value="192.168.17.136"/>
<!-- dbnode -->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/gaussdb/data/db1,opengauss-node2,/gaussdb/data/db1"/>
</DEVICE>
<!-- opengauss-node2 上的节点部署信息,其中 name 的值配置为主机名称 -->
<DEVICE sn="1000002">
<PARAM name="name" value="opengauss-node2"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点IP,如果服务器只有一个网卡可用,将 backIP1 和 sshIP1 配置成同一个 IP -->
<PARAM name="backIp1" value="192.168.17.137"/>
<PARAM name="sshIp1" value="192.168.17.137"/>
</DEVICE>
</DEVICELIST>
</ROOT>
EOF
3.2.2 参数简介
实例类型 | 参数 | 说明 |
整体信息 |
name |
主机名称。 |
azName |
指定azName(Available Zone Name),字符串(不能含有特殊字符),例如AZ1、AZ2、AZ3。 |
|
azPriority |
指定azPriority的优先级。 |
|
backIp1 |
主机在后端存储网络中的IP地址(内网IP)。所有openGauss主机使用后端存储网络通讯。 |
|
sshIp1 |
设置SSH可信通道IP地址(外网IP)。若无外网,则可以不设置该选项或者同backIp1设置相同IP。 |
|
3.3 初始化安装环境
# 使用root用户在节点一执行
-- 设置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
# 执行过程可查看/opt/gaussdb/log/omm/om 目录下gs_preinstall日志文件
-- 预检查执行结果如下
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. -- 输入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
Please enter password for cluster user. -- 设置omm密码
Password:
Please enter password for cluster user again.
Password:
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.
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.
Setting SCTP service.
Successfully set SCTP service.
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-node1,opengauss-node2 --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.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.
-- 查看预安装结果信息,并根据预检查调整参数
[root@opengauss-node1 openGauss]# /opt/software/openGauss/script/gs_checkos -i A -h opengauss-node1,opengauss-node2 --detail
Checking items:
A1. [ OS version status ] : Normal
[opengauss-node2]
centos_7.6.1810_64bit
[opengauss-node1]
centos_7.6.1810_64bit
A2. [ Kernel version status ] : Normal
The names about all kernel versions are same. The value is "3.10.0-957.27.2.el7.x86_64".
A3. [ Unicode status ] : Normal
The values of all unicode are same. The value is "LANG=en_US.UTF-8".
A4. [ Time zone status ] : Normal
The informations about all timezones are same. The value is "+0800".
A5. [ Swap memory status ] : Normal
The value about swap memory is correct.
A6. [ System control parameters status ] : Warning
[opengauss-node2]
Warning reason: variable 'net.ipv4.ip_local_port_range' RealValue '1024 65000' ExpectedValue '26000 65535'.
Check_SysCtl_Parameter warning.
[opengauss-node1]
Warning reason: variable 'net.ipv4.ip_local_port_range' RealValue '1024 65000' ExpectedValue '26000 65535'.
Check_SysCtl_Parameter warning.
A7. [ File system configuration status ] : Warning
[opengauss-node2]
Warning reason: variable 'open files' RealValue '65536' ExpectedValue '1000000'
Warning reason: variable 'max user processes' RealValue '69632' ExpectedValue 'unlimited'
[opengauss-node1]
Warning reason: variable 'open files' RealValue '65536' ExpectedValue '1000000'
Warning reason: variable 'max user processes' RealValue '69632' ExpectedValue 'unlimited'
A8. [ Disk configuration status ] : Normal
The value about XFS mount parameters is correct.
A9. [ Pre-read block size status ] : Normal
The value about Logical block size is correct.
A10.[ IO scheduler status ] : Normal
The value of IO scheduler is correct.
A11.[ Network card configuration status ] : Warning
[opengauss-node2]
BondMode Null
Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192' -- 可忽略
[opengauss-node1]
BondMode Null
Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192' -- 可忽略
A12.[ Time consistency status ] : Normal
The ntpd service is started, local time is "2022-11-01 19:21:05".
A13.[ Firewall service status ] : Normal
The firewall service is stopped.
A14.[ THP service status ] : Normal
The THP service is stopped.
Total numbers:14. Abnormal numbers:0. Warning numbers:3.
=============================================================================
# 在预检查过程中,遇到如下一些报错
报错一:
[GAUSS-51400] : Failed to execute the command: rm -rf '/tmp/step_preinstall_file.dat'. Result:{'opengauss-node1': 'Failure', 'opengauss-node2': 'Failure'}.
Error:
[FAILURE] opengauss-node1:
[FAILURE] opengauss-node2:
[GAUSS-52200] : Unable to import module: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory.
解决办法:
重新编译python,或者在其它已编译该python版本环境将libpython3.6m.so.1.0拷贝到当前服务器/usr/lib64 目录下
并在/etc/profile里执行 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python3/bin,并source /etc/profile生效
报错二:
再次执行预执行时会因前一次预执行已创建了一些目录和文件,会导致失败。
解决办法:可参照xml文件,将除/opt/software/openGauss之外的其它目录和文件删除即可
3.4 执行集群安装
3.4.1 修改属主
-- 务必确保已在节点一执行预检查
-- root用户节点一操作
chmod -R 755 /opt/software/openGauss/script/
chown -R omm:dbgrp /opt/software/openGauss/script/
3.4.2 执行安装
-- 节点一切换到omm用户执行
su - omm
-- 执行如下命令
gs_install -X /opt/software/openGauss/clusterconfig.xml
# 执行过程可查看/opt/gaussdb/log/omm/om 目录下gs_install日志文件
-- 执行结果如下
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/gaussdb/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..
3.4.3 数据库状态检查
-- omm用户
[omm@opengauss-node1 ~]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state | node node_ip instance state
--------------------------------------------------------------------------------------------------------
1 opengauss-node1 192.168.17.136 6001 /gaussdb/data/db1 P Primary Normal | 2 opengauss-node2 192.168.17.137 6002 /gaussdb/data/db1 S Standby Normal
3.4.4 数据库测试
-- omm用户
[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=# select version();
version
--------------------------------------------------------------------------------------------------------
PostgreSQL 9.2.4 (openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)
-- 节点一测试插入数据
postgres=# create table tb1 (id int, name text);
CREATE TABLE
postgres=# insert into tb1 (id,name) values (10,'Jacky');
INSERT 0 1
postgres=# commit;
WARNING: there is no transaction in progress
COMMIT
postgres=# AUTOCOMMIT
postgres-# \echo :autocommit
:autocommit
postgres-# \echo :AUTOCOMMIT -- 默认开启了自动提交
on
-- 节点二
[root@opengauss-node2 ~]# su - omm
Last login: Wed Nov 2 10:04:22 CST 2022
[omm@opengauss-node2 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=# select * from tb1;
id | name
----+-------
10 | Jacky
(1 row)
postgres=#