GaussDB T 1.0.2 一主一备集群部署实战
source link: https://www.infoq.cn/article/U25VZhwHwPMYRFc5Xpdf
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
本文由 dbaplus 社群授权转载。
GaussDB T 1.0.2 版本已经发布了,此版本为 GA 版本,相比 1.0.1 版本稳定性和功能方面做了加强,华为后续也将要推出 RAC 版本。本文主要介绍当前 GA 版本下的主备集群方式安装。
主备(一主一备)部署方案无 CN,其中 DN 主机所在的节点为主节点,对外提供业务。
集群中各组件功能:
- CM :集群管理模块(ClusterManager)。管理和监控分布式系统中各个功能单元和物理资源的运行状况,确保整个系统的稳定运行。
- DN :数据节点(Datanode)。负责存储业务数据,执行数据查询任务以及返回执行结果。
- ETCD :高可用分布式键值 (key-value) 数据库。负责存储集群各个节点和实例集群状态,便于集群 CM 管理各个实例。
- Storage :服务器的本地存储资源,持久化存储数据。
一、环境准备
- 操作系统 :CentOS Linux release 7.5.1804 (Core)
- 数据库软件 :GaussDB_T_1.0.2-CLUSTER-CentOS-64bit.tar.gz
二、安装步骤
1、root 远程登录权限修改(两个节点均需操作)
复制代码
sed -i's/#PermitRootLogin yes/PermitRootLogin yes/g'/etc/ssh/sshd_config sed -i's/#PasswordAuthentication yes/ PasswordAuthentication yes/g'/etc/ssh/sshd_config
修改完重启 sshd 服务:
复制代码
/bin/systemctlrestart sshd.service
2、关闭防火墙和 SELinux(两个节点均需操作)
复制代码
systemctl stop firewalld.service systemctldisablefirewalld.service sed -i's/SELINUX=enforcing/SELINUX=disabled/g'/etc/selinux/config
3、配置 corefile(两个节点均需操作)
复制代码
echo'ulimit -c unlimited'>>/etc/profile echo'kernel.core_pattern =/opt/gdb/corefile/core-%e-%p-%t'>>/etc/sysctl.conf
使配置生效:
复制代码
source /etc/profile sysctl -p
4、检查 ntp 和 lsof(两个节点均需操作)
复制代码
rpm -qa|grepntp
若没有,使用 yum 安装 ntp:
复制代码
yum installntp which lsof
若没有,使用 yum 安装 lsof:
复制代码
yuminstalllsof
5、创建数据库安装用户组和用户(两个节点均需操作)
复制代码
groupadddbgrp useradd-gdbgrp-d /home/omm -m -s /bin/bashomm
设置密码:
复制代码
passwd omm
6、创建存放软件包的目录 /opt/software/gaussdb 并上传安装包
复制代码
mkdir -p /opt/software/gaussdb [root@gauss1 gaussdb]# tar -zxvf GaussDB_T_1.0.2-CENTOS7.5-X86.tar.gz [root@gauss1 gaussdb]# tar -zxvf GaussDB_T_1.0.2-CLUSTER-CentOS-64bit.tar.gz [root@gauss1 gaussdb]# chmod755/opt/software/ [root@gauss1 gaussdb]# chmod -R755/opt/software/gaussdb/
7、从 /opt/software/gaussdb/template 获取预置的配置文件,根据实际部署需求修改配置
复制代码
[root@gauss1 ~]# vi /opt/software/gaussdb/clusterconfig.xml <?xml version="1.0" encoding="UTF-8"?> <ROOT> <!-- --> <CLUSTER> <PARAMname="clusterName"value="GaussDB_100"/> <PARAMname="nodeNames"value="gauss1,gauss2"/> <PARAMname="gaussdbAppPath"value="/opt/gaussdb/app"/> <PARAMname="gaussdbLogPath"value="/opt/gaussdb/log/"/> <PARAMname="tmpMppdbPath"value="/opt/gaussdb/tmp/gaussdb_mppdb"/> <PARAMname="gaussdbToolPath"value="/opt/gaussdb/huawei/wisequery"/> <PARAMname="datanodeType"value="DN_ZENITH_HA"/> <PARAMname="coordinatorType"value="CN_ZENITH_ZSHARDING"/> <PARAMname="replicationCount"value="2"/> <PARAMname="clusterType"value="mutil-AZ"/> <!-- HA2 --> <PARAMname="Ha2Node"value="true"/> <PARAMname="GatewayIP"value="192.168.238.2"/> <PARAMname="CMAgentPingTryTime"value="3"/> <PARAMname="CMAgentPingInterval"value="5"/> <!--floatip--> <PARAMname="ServiceType"value="SingleService"/> </CLUSTER> <!-- --> <DEVICELIST> <!-- plat1 --> <DEVICEsn="1000001"> <PARAMname="name"value="gauss1"/> <PARAMname="azName"value="AZ1"/> <PARAMname="azPriority"value="1"/> <!-- IP --> <PARAMname="backIp1"value="192.168.238.130"/> <PARAMname="sshIp1"value="192.168.238.130"/> <PARAMname="agentlsnPort"value="7020"/> <!-- GTS --> <!-- ETCD --> <PARAMname="etcdNum"value="2"/> <PARAMname="etcdListenPort"value="22100"/> <PARAMname="etcdHaPort"value="22200"/> <PARAMname="etcdListenIp1"value="192.168.238.130"/> <PARAMname="etcdHaIp1"value="192.168.238.130"/> <PARAMname="etcdDir1"value="/opt/gaussdb/data/data_etcd"/> <PARAMname="etcdDir2"value="/opt/gaussdb/data/data_etcd1"/> <!--cn--> <!-- dn --> <PARAMname="dataNum"value="1"/> <PARAMname="dataPortBase"value="15402"/> <PARAMname="dataNode1"value="/opt/gaussdb/data/data_dn1,gauss2,/opt/gaussdb/data/data_dn1"/> </DEVICE> <!-- plat2 --> <DEVICEsn="1000002"> <PARAMname="name"value="gauss2"/> <PARAMname="azName"value="AZ1"/> <PARAMname="azPriority"value="1"/> <!--IP --> <PARAMname="backIp1"value="192.168.238.131"/> <PARAMname="sshIp1"value="192.168.238.131"/> <PARAMname="agentlsnPort"value="7020"/> <!-- ETCD --> <PARAMname="etcdNum"value="1"/> <PARAMname="etcdListenPort"value="22100"/> <PARAMname="etcdHaPort"value="22200"/> <PARAMname="etcdListenIp1"value="192.168.238.131"/> <PARAMname="etcdHaIp1"value="192.168.238.131"/> <PARAMname="etcdDir1"value="/opt/gaussdb/data/data_etcd"/> <!--cn--> <!-- dn --> <!-- cm --> <PARAMname="cmsNum"value="1"/> <PARAMname="cmServerPortBase"value="21900"/> <PARAMname="cmServerListenIp1"value="192.168.238.131,192.168.238.130"/> <PARAMname="cmServerHaIp1"value="192.168.238.131,192.168.238.130"/> <PARAMname="cmServerlevel"value="1"/> <PARAMname="cmServerRelation"value="gauss2,gauss1"/> </DEVICE> </DEVICELIST> </ROOT>
8、安装 python3.7(如果环境已安装请忽略)
安装依赖包:
复制代码
yum -ygroupinstall"Development tools" yum -yinstall zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel yum install libffi-devel -y yum install -ygcc
下载 python3 安装包:
复制代码
cd/root wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz tar -xvJf Python-3.7.0.tar.xz
编译安装:
复制代码
mkdir/usr/local/python3#创建编译安装目录 cdPython-3.7.0 ./configure --prefix=/usr/local/python3 make&&makeinstall
创建软连接:
复制代码
ln -s/usr/local/python3/bin/python3/usr/local/bin/python3
验证下安装:
复制代码
python3-V pip3–V
9、执行 gs_preinstall 准备环境
复制代码
[root@gauss1gaussdb]# cd /opt/software/gaussdb/script/ [root@gauss1script]# ./gs_preinstall -U omm -G dbgrp –X /opt/software/gaussdb/clusterconfig.xml
10、检测集群时间一致性
复制代码
[root@gauss1script]# ./gs_checkos -i B -h gauss1,gauss2 -X /opt/software/gaussdb/clusterconfig.xml
11、执行安装脚本
复制代码
[root@gauss1script]# su - omm [omm@gauss1~]$gs_install -X /opt/software/gaussdb/clusterconfig.xml
12、检查集群状态
安装完成!
三、安装过程中报错处理
1、执行./gs_preinstall 报 GAUSS-50204
复制代码
[root@gauss1script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig.xml [GAUSS-50204] : FailedtoreadcmServerRelation. ThefirstitemofcmServerRelation must be nodename.
解决:修改 clusterconfig.xml 文件中 cmServerRelation 值为 gauss2,gauss1 与 nodeNames 值对应。
2、执行./gs_preinstall 报 GAUSS-53011
复制代码
[root@gauss1 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig.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. Successfully created SSH trust for the root permission user. All host RAM is consistent Distributing package. Successfully distributed package. Are you sure you want to create the user[omm]andcreate trust for it (yes/no)? yes Installing the tools in the cluster. Successfully installed the tools in the cluster. Checkingsystemresource. [FAILURE] gauss1: [GAUSS-53011]:Failed tocheckgatewayIP [192.168.238.10]. PleasecheckgatewayIP config is vaild in your environment. [FAILURE] gauss2: [GAUSS-53011]:Failed tocheckgatewayIP [192.168.238.10]. PleasecheckgatewayIP config is vaild in your environment.
解决:修改 clusterconfig.xml 文件中 GatewayIP 为虚拟机网关地址 192.168.238.2。
3、检测集群时间一致性有警告
复制代码
[root@gauss1 script]# ./gs_checkos -i A12 -h gauss1,gauss2 -X /opt/software/gaussdb/clusterconfig.xml --detail Root permissionuserhasnotSSH trust, create it whendocheckosinremote node. Creating SSH trustforthe root permission user. Please enter passwordforroot. Password: Successfully creating SSH trustforthe root permission user. Checking items A12.[ Time consistency status ] :Warning [gauss1] The currentsystemtime = (2020-03-06 16:37:43") [gauss2] The current system time = (2020-03-06 16:37:45") Total numbers:1. Abnormal numbers:0.Warningnumbers:1. Clean SSH trustforthe root permission user. Successfully clean SSH trustforthe root permission user.
解决:重新同步系统时间。
复制代码
[root@gauss1 ~]# cd /opt/software/gaussdb/script [root@gauss1 script]# ./gs_checkos -i C1 -h gauss1,gauss2 -X /opt/software/gaussdb/clusterconfig.xml Root permissionuserhasnotSSH trust, create it whendocheckosinremote node. Creating SSH trustforthe root permission user. Please enter passwordforroot. Password: Successfully creating SSH trustforthe root permission user. C1. [SetNTP Service] : Normal NOTICE: MTU valueandsomewarningitems canNOTbe set. Pleasedoit manually. Total numbers:1. Abnormal numbers:0.Warningnumbers:0. Clean SSH trustforthe root permission user. Successfully clean SSH trustforthe root permission user.
四、集群卸载
1、omm 用户执行 gs_uninstall --delete-data -X
复制代码
/opt/software/gaussdb/clusterconfig.xml [omm@gauss1~]$ gs_uninstall --delete-data -X /opt/software/gaussdb/clusterconfig.xml Thedata will be deleted and cannot be recovered. Are you sure you want to uninstall the cluster(yes/no)?yes Checkpreinstall on every node. Successfullychecked preinstall on every node. Stopcluster. Checklogfile path. Cleancrontab. Cleancrontab successfully. Killprocess for components. Killprocess for components successfully. Uninstallcomponents Uninstallcomponents successfully. Modifyinguser's environmental variable. Successfullymodified user's environmental variable. Cleantmp files and logs. Successfullyclean cluster's tmp and logs. Successfuluninstallation
2、清理主机的环境
复制代码
[root@gauss1 script]# ./gs_postuninstall -U omm -X /opt/software/gaussdb/clusterconfig.xml The environment will be cleaned upandcannot be recovered.Are you sure you wanttoclean up the environment(yes/no)?yes Parsing the configuration file. Successfully parsed the configuration file. Checking unpreinstallation. Success checking unpreinstallation. Deleting theinstancepaths. Deleting theinstancepaths successfully. Clean loganddependency. Clean up theuserenvironment variables Clean up theuserenvironment variable successfully Clean up the remotesystem toolenvironment variables Clean up the remotesystem toolenvironment variable successfully Clean up the localsystem toolenvironment variables Clean up the localsystem toolenvironment variable successfully Clean loganddependency successfully. Postuninstall successfully. Please close the terminalandlogin again, ensure that the environment variable takes effect.
作者介绍:
刘滨,中移信息数据库运维专家。拥有 Oracle OCP、OCM 认证,曾多年在银行金融保险行业一线运维,目前正在积极参与国产数据库的研究以及在移动场景下的推广等工作。
原文链接:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK