内存 |
>=2G |
操作系统 |
centos 7.6 |
Linux文件系统 |
剩余inode个数 > 15亿(推荐) |
工具 |
bzip2 |
Python |
centos 7.6:支持python 3.6.x |
数据库版本 |
openGauss_3.1.1 企业版 |
创建目录
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<> /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 <
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<
4.5修改Banned配置
cat >>/etc/ssh/sshd_config<
4.6 添加hosts解析
添加所有节点的IP和主机名
cat > /etc/hosts<
4.7 设置root远程登录
cat >>/etc/ssh/sshd_config<
目录规划
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
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; |