磐维数据库最近发布了新版本V2.0-S3.1.0,不但解决了之前版本中存在的问题,而且还增加了很多新功能,赶快安装体验一下吧!
环境说明
主机名 | ip地址 | OS版本 | 内存、CPU | 节点角色 | 数据库端口 | cmserver端口 |
---|---|---|---|---|---|---|
node1 | 192.*.*.60 | Centos7.9 | 4G 、 1个双核 | 主节点 | 17700 | 18800 |
node2 | 192.*.*.62 | Centos7.9 | 4G 、 1个双核 | 从节点 | 17700 | 18800 |
node3 | 192.*.*.64 | Centos7.9 | 4G 、 1个双核 | 从节点 | 17700 | 18800 |
目录规划
序号 | 文件系统 | 用途 |
---|---|---|
1 | /data/panweidb/data | 存放数据文件。 |
2 | /data/panweidb/data/pg_xlog | 存放 WAL文件。 |
3 | /data/panweidb/log | 存放数据库日志。 |
4 | /data/panweidb/pg_audit | 存放审计日志。 |
5 | /data/panweidb/app | 数据库安装目录。 |
6 | /data/panweidb/cm | cm 目录。 |
7 | /data/panweidb/soft | 软件介质目录。 |
8 | /backup | 备份目录。 |
9 | /archive | 存放归档日志。 |
10 | /data/panweidb/corefile | 存放转储文件。 |
安装要求
硬件环境要求
PanWeiDB 数据库服务器在生产环境中应具备的最低及建议硬件配置要求如下:
软件环境要求
安装包准备
os环境是centos7.9,使用下面的安装包部署:
PanWeiDB_V2.0-S3.1.0_B01-install-centos_7-x86_64-no_mot.tar.gz
软件依赖要求
安装步骤
(一)配置操作系统
注意:本节的操作中除了第17、18步只需在主节点执行外,其他步骤都需要在所有节点执行。
1.检查软件依赖
rpm -q libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel bzip2 expect python3
复制
2.安装软件依赖包
yum -y install libaio-devel flex bison ncurses-devel glibc-devel patch readline-devel python3 expect* bzip2 libnsl gcc gcc-c++ zlib-devel expect
复制
注意:
- openEuler x86 系统中需要安装 libnsl 。
- Kylin 操作系统需要需单独下载安装 readline-devel 和 libnsl 包。
- 对于 BCLinux for Euler 22.10 操作系统,需要手动卸载 flatpak 组件,方法为:
yum remove faltpak
复制
3.检查root权限是否禁止登录
注意事项:检查三台主机的 sshd_config 文件内 PermitRootLogin 是否为 yes,如果不是,需要修改为 yes,并重启 sshd 服务
cat /etc/ssh/sshd_config | grep PermitRootLogin
PermitRootLogin yes
vi /etc/ssh/sshd_config
# 重启sshd服务
systemctl restart sshd
复制
4.关闭SELINUX
查看是否开启SELINUX:
getenforce
复制
临时关闭SELINUX:
setenforce 0
复制
永久关闭SELINUX:
vi /etc/selinux/config
修改SELINUX=disabled
或者
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
修改后,重启系统。
复制
5.关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
systemctl status firewalld
复制
6.设置字符集
# 查看字符集
echo $LANG
# 设置字符集
export LANG=en_US.UTF-8
复制
7.设置时区和时间同步
略
8.系统内核参数配置
cat >>/etc/sysctl.conf<<EOF
fs.aio-max-nr=1048576
fs.file-max= 76724600
kernel.sem = 4096 2097152000 4096 512000
kernel.shmall = 26843545 # pages, 0.8 * MEM/PAGE_SIZE or higher
kernel.shmmax = 68719476736 # bytes, 0.5 * MEM or higher
kernel.shmmni = 819200
net.core.netdev_max_backlog = 10000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 4194304
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 5
vm.dirty_background_bytes = 409600000
vm.dirty_expire_centisecs = 3000
vm.dirty_ratio = 80
vm.dirty_writeback_centisecs = 50
vm.overcommit_memory = 0
vm.swappiness = 0
net.ipv4.ip_local_port_range = 40000 65535
fs.nr_open = 20480000
kernel.core_pattern = /data/panweidb/corefile/core-%e-%p-%t
EOF
#配置生效
sysctl -p
复制
9.(可选)设置网卡MTU值
将各数据库节点和交换机的网卡 MTU 值(最大传输单元)设置为相同大小(MTU 值≥1500),推荐值:8192(MTU 值可根据需要自行修改)。需要连
同交换机一起修改(修改方法请咨询交换机厂商)。
步骤 1 以 root 用户登录操作系统。
步骤 2 执行如下命令,设置网卡 MTU 值。
【须知】
网卡编号可通过 ip a 命令查看。
方法一:
#ifconfig 网卡编号 mtu 值
ifconfig eth0 mtu 8192
方法二:
cat /sys/class/net/网卡编号/mtu
echo "8192" > /sys/class/net/网卡编号/mtu
复制
10.关闭THP
(1)使用 root 用户,通过配置如下系统服务实现永久关闭透明大页的目的。
cat >>/etc/systemd/system/disable-thp.service<<EOF
[Unit]
Description=Disable Transparent Huge Pages (THP)
[Service]
Type=simple
ExecStart=/bin/sh -c "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled && echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
EOF
复制
(2)执行如下命令加载系统服务,并设置开机自启动
systemctl daemon-reload
systemctl start disable-thp
systemctl enable disable-thp
复制
(3)查看 THP 状态,当返回结果均为 always madvise [never]时表示成功设置透明大页永久关闭。
cat /sys/kernel/mm/transparent_hugepage/enabled cat /sys/kernel/mm/transparent_hugepage/defrag
复制
11.关闭RemoveIPC
(1)在各数据库节点上,关闭RemoveIPC。CentOS操作系统默认为关闭,可以跳过该步骤。
(1) 修改/etc/systemd/logind.conf文件中的“RemoveIPC”值为“no”
vim /etc/systemd/logind.conf
RemoveIPC=no
(2) 修改/usr/lib/systemd/system/systemd-logind.service文件中的“RemoveIPC”值为“no”
cat >>/usr/lib/systemd/system/systemd-logind.service<<EOF
RemoveIPC=no
EOF
(3) 重启服务
systemctl daemon-reload
systemctl restart systemd-logind.service
(4) 结果验证确认
由于 CentOS 操作系统环境的 removeIPC 默认为关闭,则执行如下语句是无返回结果的。用户在确保其他步骤已执行的前提下,可正常安装数据库。
loginctl show-session | grep RemoveIPC
systemctl show systemd-logind | grep RemoveIPC
复制
12.检查python3
通过以下函数检查 Python 环境是否为 Python3。
python3 --version
复制
13.配置/etc/hosts文件
cat >>/etc/hosts<<EOF
192.*.*.60 node1
192.*.*.62 node2
192.*.*.64 node3
EOF
复制
14.创建用户及用户组
groupadd -g 1101 dbgrp
useradd -g dbgrp -u 1101 -m omm
#设置omm用户的密码
echo "new密码" | passwd --stdin omm
复制
15、创建目录
mkdir -p /data/panweidb mkdir -p /data/panweidb/archive mkdir -p /data/panweidb/pg_audit
复制
16、创建安装包目录
mkdir -p /data/panweidb/soft
复制
17、上传磐维数据库软件并解压(主节点)
把软件上传到/data/panweidb/soft下。
cd /data/panweidb/soft/
tar -zxvf PanWeiDB_V2.0-S3.1.0_B01-install-centos_7-x86_64-no_mot.tar.gz
tar -zxvf PanWeiDB_V2.0-S3.1.0_B01-CentOS-64bit-om.tar.gz
复制
18、安装目录授权(主节点)
chown -R omm:dbgrp /data/panweidb chmod -R 755 /data/panweidb
复制
(二)预安装磐维数据库
1.编辑panweidb1m2s.xml配置文件
注意:请根据实际情况替换各节点的主机名、ip地址以及安装路径!
vi /data/panweidb/soft/panweidb1m2s.xml
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<CLUSTER>
<PARAM name="clusterName" value="panweidb" />
<PARAM name="nodeNames" value="node1,node2,node3"/>
<PARAM name="gaussdbAppPath" value="/data/panweidb/app" />
<PARAM name="gaussdbLogPath" value="/data/panweidb/log" />
<PARAM name="tmpMppdbPath" value="/data/panweidb/tmp"/>
<PARAM name="gaussdbToolPath" value="/data/panweidb/tool" />
<PARAM name="corePath" value="/data/panweidb/corefile"/>
<PARAM name="backIp1s" value="192.*.*.60,192.*.*.62,192.*.*.64"/>
</CLUSTER>
<DEVICELIST>
<DEVICE sn="node1">
<PARAM name="name" value="node1"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.*.*.60"/>
<PARAM name="sshIp1" value="192.*.*.60"/>
<PARAM name="cmsNum" value="1"/>
<PARAM name="cmServerPortBase" value="18800"/>
<PARAM name="cmServerListenIp1" value="192.*.*.60,192.*.*.62,192.*.*.64"/>
<PARAM name="cmServerHaIp1" value="192.*.*.60,192.*.*.62,192.*.*.64"/>
<PARAM name="cmServerlevel" value="1"/>
<PARAM name="cmServerRelation" value="node1,node2,node3"/>
<PARAM name="cmDir" value="/data/panweidb/cm"/>
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="17700"/>
<PARAM name="dataNode1" value="/data/panweidb/data,node2,/data/panweidb/data,node3,/data/panweidb/data"/>
<PARAM name="dataNode1_syncNum" value="1"/>
</DEVICE>
<DEVICE sn="node2">
<PARAM name="name" value="node2"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.*.*.62"/>
<PARAM name="sshIp1" value="192.*.*.62"/>
<PARAM name="cmServerPortStandby" value="18800"/>
<PARAM name="cmDir" value="/data/panweidb/cm"/>
</DEVICE>
<DEVICE sn="node3">
<PARAM name="name" value="node3"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.*.*.64"/>
<PARAM name="sshIp1" value="192.*.*.64"/>
<PARAM name="cmServerPortStandby" value="18800"/>
<PARAM name="cmDir" value="/data/panweidb/cm"/>
</DEVICE>
</DEVICELIST>
</ROOT>
复制
2.root用户在主节点预安装
cd /data/panweidb/soft/script
./gs_preinstall -U omm -G dbgrp -X /data/panweidb/soft/panweidb1m2s.xml --sep-env-file=/home/omm/panweidb310.env
复制
安装日志如下:
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
Please enter password for current user[root].
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.
Verifying SSH trust on all hosts by ip.
Successfully verified SSH trust on all hosts by ip.
Verifying SSH trust on all hosts by hostname.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
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
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.
Verifying SSH trust on all hosts by ip.
Successfully verified SSH trust on all hosts by ip.
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 "/data/panweidb/soft/script/gs_checkos -i A -h node1,node2,node3 -X /data/panweidb/soft/panweidb1m2s.xml --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.
复制
(三)正式安装磐维数据库
1.安装目录授权(主节点)
chown -R omm:dbgrp /database/ chmod -R 755 /database/
复制
2.omm用户安装(主节点)
source /home/omm/panweidb310.env
su - omm
gs_install -X /data/panweidb/soft/panweidb1m2s.xml \
--gsinit-parameter="--encoding=UTF8" \
--gsinit-parameter="--lc-collate=C" \
--gsinit-parameter="--lc-ctype=C" \
--gsinit-parameter="--dbcompatibility=B"
gs_install -X /database/panweidb/soft/panweidb1m2s.xml \
--gsinit-parameter="--encoding=UTF8" \
--gsinit-parameter="--lc-collate=C" \
--gsinit-parameter="--lc-ctype=C" \
--gsinit-parameter="--dbcompatibility=B"
复制
安装日志如下:
Parsing the configuration file.
Successfully checked gs_uninstall on every node.
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 /data/panweidb/app/share/sslcert/om
Create CA files for cm beginning.
Create CA files on directory [/data/panweidb/app_5d08dc9/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']
Non-dss_ssl_enable, no need to create CA for DSS
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.
Warning: The license file does not exist, so there is no need to copy it to the home directory.
Configuring pg_hba on all nodes.
Configuration is completed.
Starting cluster.
======================================================================
[GAUSS-51607] : Failed to start cluster. Error:
cm_ctl: checking cluster status.
cm_ctl: checking cluster status.
cm_ctl: checking finished in 694 ms.
cm_ctl: start cluster.
cm_ctl: start nodeid: 1
cm_ctl: start nodeid: 2
cm_ctl: start nodeid: 3
...........................................................................................................................................................................................................................................................................................................
cm_ctl: start cluster failed in (300)s!
HINT: Maybe the cluster is continually being started in the background.
You can wait for a while and check whether the cluster starts, or increase the value of parameter "-t", e.g -t 600.
The cluster may continue to start in the background.
If you want to see the cluster status, please try command gs_om -t status.
If you want to stop the cluster, please try command gs_om -t stop.
[GAUSS-51607] : Failed to start cluster. Error:
cm_ctl: checking cluster status.
cm_ctl: checking cluster status.
cm_ctl: checking finished in 694 ms.
cm_ctl: start cluster.
cm_ctl: start nodeid: 1
cm_ctl: start nodeid: 2
cm_ctl: start nodeid: 3
...........................................................................................................................................................................................................................................................................................................
cm_ctl: start cluster failed in (300)s!
HINT: Maybe the cluster is continually being started in the background.
You can wait for a while and check whether the cluster starts, or increase the value of parameter "-t", e.g -t 600.
复制
这里,集群安装成功后无法启动。经查看数据库日志,无法启动的原因是虚拟机内存的问题导致,可以参考文章解决:
虚拟机安装磐维数据库2.0.2结束时,数据库无法成功启动
3.查看集群状态
[omm@node1 ~]$ gs_om -t status --detail [ CMServer State ] node node_ip instance state --------------------------------------------------------------------- 1 node1 192.*.*.60 1 /data/panweidb/cm/cm_server Primary 2 node2 192.*.*.62 2 /data/panweidb/cm/cm_server Standby 3 node3 192.*.*.64 3 /data/panweidb/cm/cm_server Standby [ Cluster State ] cluster_state : Normal redistributing : No balanced : No current_az : AZ_ALL [ Datanode State ] node node_ip instance state ----------------------------------------------------------------------- 1 node1 192.*.*.60 6001 /data/panweidb/data P Primary Normal 2 node2 192.*.*.62 6002 /data/panweidb/data S Standby Normal 3 node3 192.*.*.64 6003 /data/panweidb/data S Standby Normal
复制
至此,数据库集群部署完成。
配置数据库最佳实践参数
注意:需要根据实际情况修改脚本中的各路径信息。
chmod +x gs_guc_v2.11_20240710.sh
sh gs_guc_v2.11_20240710.sh
#数据库最佳实践参数脚本执行成功后,重启数据库集群,检查状态
cm_ctl stop
cm_ctl start
gs_om -t status --detail
复制
gsql客户端使用
[omm@node3 ~]$ gsql -r
gsql ((PanWeiDB_V2.0-S3.1.0_B01) compiled at 2024-12-19 11:44:29 commit 5d08dc9 )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=# select pw_version();
pw_version
-----------------------------------------------------------------------------
(PanWeiDB_V2.0-S3.1.0_B01) compiled at 2024-12-19 11:44:29 commit 5d08dc9 +
product name:PanWeiDB +
version:V2.0-S3.1.0_B01 +
commit:5d08dc9 +
openGauss version:5.0.0 +
host:x86_64-pc-linux-gnu
(1 row)
postgres=# select datname,datcompatibility from pg_database;
datname | datcompatibility
-----------+------------------
template1 | B
template0 | B
panweidb | B
postgres | B
(4 rows)
postgres=#
复制
后续根据实际情况,可能还有这些工作需要做:导入license、部署数据库备份任务、数据库监控任务、设置数据库白名单等,按需实施即可。
总结
磐维数据库集中式V2.0-S3.1.0安装部署和以前版本的安装方式没什么区别,还是非常丝滑的,待后续体验新功能~~~
关于作者:
专注于Oracle、MySQL、PG、OpenGauss和国产数据库的研究,热爱生活,热衷于分享数据库技术。
微信公众号:飞天online
墨天轮:https://www.modb.pro/u/15197
如有任何疑问,欢迎大家留言,共同进步~~~
评论
