diff --git a/1 b/1 new file mode 100644 index 0000000000000000000000000000000000000000..261cd340193ea0d8ea59e49a15cdf89872adb279 --- /dev/null +++ b/1 @@ -0,0 +1,6 @@ +Merge branch 'master' of https://gitee.com/jia_junfeng1/blog into HEAD +# Please enter a commit message to explain why this merge is necessary, +# especially if it merges an updated upstream into a topic branch. +# +# Lines starting with '#' will be ignored, and an empty message aborts +# the commit. diff --git a/content/zh/post/jiajunfeng/img/DBlogo-20200722.png b/content/zh/post/jiajunfeng/img/DBlogo-20200722.png new file mode 100644 index 0000000000000000000000000000000000000000..79a24699d70a607168693ccf68f251a05c39c59b Binary files /dev/null and b/content/zh/post/jiajunfeng/img/DBlogo-20200722.png differ diff --git a/content/zh/post/jiajunfeng/openGauss Single-inst Deployment (CentOS7.6+openGauss 1.0.0).htm b/content/zh/post/jiajunfeng/openGauss Single-inst Deployment (CentOS7.6+openGauss 1.0.0).htm new file mode 100644 index 0000000000000000000000000000000000000000..f6ce51a465692c610c5b9ea51bc05ebe85373da2 --- /dev/null +++ b/content/zh/post/jiajunfeng/openGauss Single-inst Deployment (CentOS7.6+openGauss 1.0.0).htm @@ -0,0 +1,292 @@ +
+ + +组件 | 最小配置要求 | 备注 |
CPU | 8c | |
内存 | 32GB | 如果小于32GB,需要调整数据库内存参数 |
硬盘 | 1.5GB | 禁用磁盘的Disk Cache Policy |
网卡速率 | 300MB | 建议做网卡bond |
## 检查硬件配置
cat /proc/cpuinfo |grep processor
cat /etc/redhat-release
free -m
## 如果内存小于32GB,会因为内存不足导致数据库无法启动,此时需要修改shared_buffers和max_connections调整openGauss所需的内存
条目 | 要求 |
Linux操作系统 | openEuler 20.3LTS/CentOS 7.6 |
Linux文件系统 | 剩余inode个数>15亿 |
工具 | Huawei JDK 1.8.0、psmisc、bzip2 |
Python | openEuler: 支持Python 3.7.x CentOS 7.6:支持Python 3.6.x |
其他依赖软件包 | 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 lsb_release >= 4.1 |
## 当系统环境仅限内网使用时,可以配置系统镜像ISO作为默认YUM源,但是该YUM源(CentOS 7.6)默认不包含python3,需要手动编译安装。
yum install -y lksctp*
yum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel
yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core
[root@ecs-7777 ~]# rpm -qa java-1.8.0-openjdk psmisc bzip2 libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core lksctp-tools* python3 python3-devel
psmisc-22.20-16.el7.x86_64
flex-2.5.37-6.el7.x86_64
redhat-lsb-core-4.1-27.el7.centos.1.x86_64
bzip2-1.0.6-13.el7.x86_64
java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
libaio-devel-0.3.109-13.el7.x86_64
bison-3.0.4-2.el7.x86_64
ncurses-devel-5.9-14.20130511.el7_4.x86_64
lksctp-tools-devel-1.0.17-2.el7.x86_64
patch-2.7.1-12.el7_7.x86_64
lksctp-tools-1.0.17-2.el7.x86_64
glibc-devel-2.17-307.el7.1.x86_64
lksctp-tools-doc-1.0.17-2.el7.x86_64
[root@ecs-7777 ~]# checksctp
SCTP supported
## Python3 源码编译安装耗时约30分钟
yum install gcc zlib* openssl* -y
tar -zxvf Python-3.6.11.tgz
cd Python-3.6.11
./configure --prefix=/usr/python3.6.11 --enable-optimizations --enable-shared
make
make install
ln -s /usr/python3.6.11/bin/python3.6 /usr/bin/python3
ln -s /usr/python3.6.11/bin/pip3 /usr/bin/pip3
ln -s /usr/python3.6.11/lib/libpython3.6m.so.1.0 /usr/lib64/
export LD_LIBRARY_PATH=/usr/python3.6.11/lib:$LD_LIBRARY_PATH
[root@db1 bin]# python3 -V
Python 3.6.11
vi /etc/hosts
--------------------
192.168.100.11 db1 db1.opengauss.com #Gauss OM IP Hosts Mapping
--------------------
systemctl status firewalld
systemctl disable firewalld.service
systemctl stop firewalld.service
vi /etc/selinux/config
---------------------------
SELINUX=disabled
---------------------------
## SELinux的配置文件需要重启操作系统才可以生效,可以使用setenforce 0 使SELinux临时变更为Permissive状态,降低SELinux的影响。
vi ~/.bash_profile
---------------------------
export LANG=en_US.UTF-8
---------------------------
source ~/.bash_profile
## 检查时区和时间是否正确(建议生产环境开启NTP服务同步时间)
[root@db1 ~]# ll /etc/localtime
lrwxrwxrwx. 1 root root 35 Apr 27 22:06 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
[root@db1 ~]# date
Fri Jul 17 15:49:08 CST 2020
## 如果时区不正确,则copy时区模板至/etc/localtime(此处以上海时间为例)
[root@db1 ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
vi /etc/fstab ## 注释掉swap分区挂载
swapoff -a ## 关闭swap
vi /etc/sysconfig/network-scripts/ifcfg-ens34
---------------------------------------
MTU=8192 ## 可能需要网络工程师协助修改网络设备端口MTU配置
---------------------------------------
# 命令临时修改方法:
ifconfig ens34 mtu 8192
# 检查root登录配置和Banner的配置
cat /etc/ssh/sshd_config |grep -v ^#|grep -E 'PermitRoot|Banner'
# 如果不满足要求,应修改配置如下
vi /etc/ssh/sshd_config
--------------------------
#Banner none ## 注释ssh登录的欢迎信息
PermitRootLogin yes ## 允许root用户远程登录
--------------------------
systemctl restart sshd.service
groupadd dbgrp
# vi /etc/sysctl.conf
---------------------------
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
net.sctp.association_max_retrans = 10
net.sctp.hb_interval = 30000
net.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
net.sctp.sndbuf_policy = 0
net.sctp.rcvbuf_policy = 0
net.sctp.sctp_mem = 94500000 915000000 927000000
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.ipv4.ip_local_port_range = 26000 65535
kernel.sem = 250 6400000 1000 25600
vm.min_free_kbytes = 102400 ## 内存*5%
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.sctp.addip_enable = 0
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
----------------------------------------
# 注意:redhat 6.4&6.5需要打开sctp的checksums,否则可能引起创建表或数据库失败
[root@db1 ~]# echo 0 > /sys/module/sctp/parameters/no_checksums
[root@db1 ~]# cat /sys/module/sctp/parameters/no_checksums
N
vi /etc/security/limits.conf
----------------------------
* soft stack 3072
* hard stack 3072
* soft nofile 1000000 ## gs_preinstall脚本自动设置,可以不手动设置
* hard nofile 1000000 ## gs_preinstall脚本自动设置,可以不手动设置
----------------------------
vi /etc/security/limits.d/90-nproc.conf
----------------------------
* soft nproc unlimited ## 系统支持的最大进程数
----------------------------
## 说明:在使用gs_preinstall脚本后,limits资源虽然已经设置,但可能存在暂时不生效的情况,需要重启系统使之生效。
vi /etc/default/grub
----------------------------
#修改:
GRUB_CMDLINE_LINUX="rhgb quiet transparent_hugepage=never"
----------------------------
grub2-mkconfig -o /boot/grub2/grub.cfg ## 重新编译grub,关闭透明页
cat /proc/meminfo |grep Huge
## 临时关闭透明页方法
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
rx = 4096 # 预安装时是否由脚本自动设置
tx = 4096 # 预安装时是否由脚本自动设置
mtu = 8192 # 推荐值:8192,同时需要协调对网络端口做出相应调整
# vi clusterconfig.xml
---------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="gsCluster" />
<!-- 数据库节点名称(hostname) -->
<PARAM name="nodeNames" value="db1.opengauss.com" />
<!-- 节点后端通讯IP,与nodeNames对应 -->
<PARAM name="backIp1s" value="192.168.0.11"/>
<!-- 数据库安装目录 与其他路径相互独立-->
<PARAM name="gaussdbAppPath" value="/gauss/app" />
<!-- 日志目录,与其他路径相互独立,默认路径"$GAUSSLOG/安装用户名"-->
<PARAM name="gaussdbLogPath" value="/gauss/log/omm" />
<!-- 临时文件目录,默认位置在/opt/huawei/wisequery/perfadm_db-->
<PARAM name="tmpMppdbPath" value="/gauss/tmp" />
<!--数据库工具目录,与其他路径相互独立,默认路径在"/opt/huawei/wisequery"-->
<PARAM name="gaussdbToolPath" value="/gauss/om" />
<!--数据库core文件目录-->
<PARAM name="corePath" value="/gauss/corefile" />
<!-- openGauss类型,此处示例为单机类型,“single-inst”表示单机或单击主备部署形态-->
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- node1上的节点部署信息 -->
<DEVICE sn="1000001">
<PARAM name="name" value="db1.opengauss.com"/>
<!-- 节点所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.0.11"/>
<PARAM name="sshIp1" value="192.168.0.11"/>
<!--dbnode-->
<!--当前主机上需要部署的数据库节点个数-->
<PARAM name="dataNum" value="1"/>
<!--DBnode端口号-->
<PARAM name="dataPortBase" value="26000"/>
<!--DBnode节点数据存储目录-->
<PARAM name="dataNode1" value="/gauss/data/db1"/>
</DEVICE>
</DEVICELIST>
</ROOT>
---------------------------------------------------------
## 创建相关目录
mkdir /gauss
chgrp dbgrp -R /gauss
chmod 775 -R /gauss
## 解压数据库安装包
mkdir -p /soft/openGauss
chmod 775 -R /soft
mv clusterconfig.xml /soft/openGauss
mv openGauss-1.0.0-CentOS-64bit.tar.gz /soft/openGauss
cd /soft/openGauss
tar -zxvf openGauss-1.0.0-CentOS-64bit.tar.gz
export LD_LIBRARY_PATH=/soft/openGauss/script/gspylib/clib:/usr/python3.6.11/lib:$LD_LIBRARY_PATH
cd /soft/openGauss/script
./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/clusterconfig.xml
cd /soft/openGauss/script
./gs_preinstall -U omm -G dbgrp -L -X /soft/openGauss/clusterconfig.xml ##在每个节点手动执行
x
vi /soft/hostfile
-----------------------
192.168.0.11
-----------------------
cd /soft/openGauss/script
./gs_sshexkey -f /soft/hostfile
x
# 手动使用脚本创建互信
vi /soft/hostfile
-----------------------
192.168.0.11
-----------------------
cd /soft/openGauss/script
./gs_sshexkey -f /soft/hostfile
cd /soft/openGauss/script
./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/clusterconfig.xml --non-interactive
x
## 执行安装脚本
chmod -R 775 /soft/
chown omm:dbgrp /soft -R
su - omm
cd /soft/openGauss/script
./gs_install -X /soft/openGauss/clusterconfig.xml ## 密码复杂度要求:大写+小写+数字+特殊字符(任选3类,至少8位)
su - root
cd /soft/openGauss/script/
./gs_checkos -i A
./gs_checkos -i B
x
## 命令示例:
gs_initdb -E UTF-8 --locale=zh_CN.UTF-8 /opt/gaussdb/data/data_n1 --nodename dn1 -w "Bigdata@123"
## 当前测试使用的数据库版本
[omm@db1 ~]$ gaussdb -V
gaussdb (openGauss 1.0.0 build 0bd0ce80) compiled at 2020-06-30 18:19:27 commit 0 last mr
## 初始化命令示例(结束时清空了数据目录,脚本可能存在异常,暂时不使用该方法)
[omm@db1 ~]$ gs_initdb -E UTF-8 --locale=en_US.UTF-8 /gauss/data/db1/tmp --nodename db1.opengauss.com -w "gauss@111"
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
creating directory /gauss/data/db1/tmp ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /gauss/data/db1/tmp/base/1 ... ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... gs_initdb: removing data directory "/gauss/data/db1/tmp"
# gsql -d postgres -p 26000
postgres=# alter role omm identified by 'Gauss@123' replace 'Gauss_111';
postgres=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;
postgres=# select version();
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+-----------+---------+-------+-------------------
mydb | omm | UTF8 | C | C |
postgres | omm | SQL_ASCII | C | C |
template0 | omm | SQL_ASCII | C | C | =c/omm +
| | | | | omm=CTc/omm
template1 | omm | SQL_ASCII | C | C | =c/omm +
| | | | | omm=CTc/omm
## 登录主节点执行
su - omm
gs_uninstall --delete-data # 卸载集群所有数据库
gs_uninstall --delete-data -L # 仅卸载本地数据库
# 如果卸载失败请根据“$GAUSSLOG/om/gs_uninstall-YYYY-MM-DD_HHMMSS.log”中的日志信息排查错误。
cd /opt/software/openGauss/script
./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group
./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group -L ## 仅清理本地环境
## 若为环境变量分离的模式安装的集群需删除之前source的环境变量分离的env参数
+++ title = "openGauss单实例 HA 安装部署 " date = "2020-07-24" tags = ["openGauss安装部署"] archives = "2020-07" author = "贾军锋" summary = "openGauss安装部署" img = "/zh/post/jiajunfeng/img/DBlogo_20200722.png" times = "19:00" +++
IP地址规划 | ||
主机名 | db1.opengauss.com | db2.opengauss.com |
外网IP地址 | 192.168.124.11 | 192.168.124.12 |
内网IP地址 | 192.168.100.11 | 192.168.100.12 |
组件 | 最小配置要求 | 备注 |
CPU | 8c | |
内存 | 32GB | |
硬盘 | 1.5GB | 禁用磁盘的Disk Cache Policy |
网卡速率 | 300MB | 建议做网卡bond |
## 检查硬件配置
cat /proc/cpuinfo |grep processor
cat /etc/redhat-release
free -m
## 如果内存小于32GB,会因为内存不足导致数据库无法启动,此时需要修改shared_buffers和max_connections调整openGauss所需的内存
条目 | 要求 |
Linux操作系统 | openEuler 20.3LTS/CentOS 7.6 |
Linux文件系统 | 剩余inode个数>15亿 |
工具 | Huawei JDK 1.8.0、psmisc、bzip2 |
Python | openEuler: 支持Python 3.7.x CentOS 7.6:支持Python 3.6.x |
其他依赖软件包 | 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 lsb_release >= 4.1 |
## 当系统环境仅限内网使用时,可以配置系统镜像ISO作为默认YUM源,但是该YUM源(CentOS 7.6)默认不包含python3,需要手动编译安装。
yum install -y lksctp*
yum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel
yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core
[root@db1 ~]# rpm -qa java-1.8.0-openjdk psmisc bzip2 libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core lksctp-tools* python3 python3-devel
psmisc-22.20-16.el7.x86_64
flex-2.5.37-6.el7.x86_64
redhat-lsb-core-4.1-27.el7.centos.1.x86_64
bzip2-1.0.6-13.el7.x86_64
java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
libaio-devel-0.3.109-13.el7.x86_64
bison-3.0.4-2.el7.x86_64
ncurses-devel-5.9-14.20130511.el7_4.x86_64
lksctp-tools-devel-1.0.17-2.el7.x86_64
patch-2.7.1-12.el7_7.x86_64
lksctp-tools-1.0.17-2.el7.x86_64
glibc-devel-2.17-307.el7.1.x86_64
lksctp-tools-doc-1.0.17-2.el7.x86_64
[root@db1 ~]# checksctp
SCTP supported
## Python3 源码编译安装耗时约30分钟
yum install gcc zlib* openssl* -y
tar -zxvf Python-3.6.11.tgz
cd Python-3.6.11
./configure --prefix=/usr/python3.6.11 --enable-optimizations --enable-shared
make
make install
ln -s /usr/python3.6.11/bin/python3.6 /usr/bin/python3
ln -s /usr/python3.6.11/bin/pip3 /usr/bin/pip3
ln -s /usr/python3.6.11/lib/libpython3.6m.so.1.0 /usr/lib64/
export LD_LIBRARY_PATH=/usr/python3.6.11/lib:$LD_LIBRARY_PATH
[root@db1 bin]# python3 -V
Python 3.6.11
vi /etc/hosts
--------------------
192.168.100.11 db1 db1.opengauss.com #Gauss OM IP Hosts Mapping
192.168.100.12 db2 db2.opengauss.com #Gauss OM IP Hosts Mapping
--------------------
systemctl status firewalld
systemctl disable firewalld.service
systemctl stop firewalld.service
vi /etc/selinux/config
---------------------------
SELINUX=disabled
---------------------------
## SELinux的配置文件需要重启操作系统才可以生效,可以使用setenforce 0 使SELinux临时变更为Permissive状态,降低SELinux的影响。
vi ~/.bash_profile
---------------------------
export LANG=en_US.UTF-8
---------------------------
source ~/.bash_profile
## 检查时区和时间是否正确(建议生产环境开启NTP服务同步时间)
[root@db1 ~]# ll /etc/localtime
lrwxrwxrwx. 1 root root 35 Apr 27 22:06 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
[root@db1 ~]# date
Fri Jul 17 15:49:08 CST 2020
## 如果时区不正确,则copy时区模板至/etc/localtime(此处以上海时间为例)
[root@db1 ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
vi /etc/fstab ## 注释掉swap分区挂载
swapoff -a ## 关闭swap
vi /etc/sysconfig/network-scripts/ifcfg-ens34
---------------------------------------
MTU=8192 ## 可能需要网络工程师协助修改网络设备端口MTU配置
---------------------------------------
# 命令临时修改方法:
ifconfig ens34 mtu 8192
# 检查root登录配置和Banner的配置
cat /etc/ssh/sshd_config |grep -v ^#|grep -E 'PermitRoot|Banner'
# 如果不满足要求,应修改配置如下
vi /etc/ssh/sshd_config
--------------------------
#Banner none ## 注释ssh登录的欢迎信息
PermitRootLogin yes ## 允许root用户远程登录
--------------------------
systemctl restart sshd.service
groupadd dbgrp
# vi /etc/sysctl.conf
---------------------------
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
net.sctp.association_max_retrans = 10
net.sctp.hb_interval = 30000
net.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
net.sctp.sndbuf_policy = 0
net.sctp.rcvbuf_policy = 0
net.sctp.sctp_mem = 94500000 915000000 927000000
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.ipv4.ip_local_port_range = 26000 65535
kernel.sem = 250 6400000 1000 25600
vm.min_free_kbytes = 102400 ## 内存*5%
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.sctp.addip_enable = 0
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
----------------------------------------
# 注意:redhat 6.4&6.5需要打开sctp的checksums,否则可能引起创建表或数据库失败
[root@db1 ~]# echo 0 > /sys/module/sctp/parameters/no_checksums
[root@db1 ~]# cat /sys/module/sctp/parameters/no_checksums
N
vi /etc/security/limits.conf
----------------------------
* soft stack 3072
* hard stack 3072
* soft nofile 1000000 ## gs_preinstall脚本自动设置,可以不手动设置
* hard nofile 1000000 ## gs_preinstall脚本自动设置,可以不手动设置
----------------------------
vi /etc/security/limits.d/90-nproc.conf
----------------------------
* soft nproc unlimited ## 系统支持的最大进程数
----------------------------
## 说明:在使用gs_preinstall脚本后,limits资源虽然已经设置,但可能存在暂时不生效的情况,需要重启系统使之生效。
vi /etc/default/grub
----------------------------
#修改:
GRUB_CMDLINE_LINUX="rhgb quiet transparent_hugepage=never"
----------------------------
grub2-mkconfig -o /boot/grub2/grub.cfg ## 重新编译grub,关闭透明页
cat /proc/meminfo |grep Huge
## 临时关闭透明页方法
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
rx = 4096 # 预安装时是否由脚本自动设置
tx = 4096 # 预安装时是否由脚本自动设置
mtu = 8192 # 推荐值:8192,同时需要协调对网络端口做出相应调整
# vi clusterconfig.xml
------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<PARAM name="clusterName" value="gsCluster" />
<PARAM name="nodeNames" value="db1.opengauss.com,db2.opengauss.com" />
<PARAM name="backIp1s" value="192.168.100.11,192.168.100.12"/>
<PARAM name="gaussdbAppPath" value="/gauss/app" />
<PARAM name="gaussdbLogPath" value="/gauss/log/omm" />
<PARAM name="tmpMppdbPath" value="/gauss/tmp"/>
<PARAM name="gaussdbToolPath" value="/gauss/om" />
<PARAM name="corePath" value="/gauss/corefile"/>
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- node1上的节点部署信息 -->
<DEVICE sn="1000001">
<PARAM name="name" value="db1.opengauss.com"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<!-- 主机后端存储网络通讯IP地址和HA通讯IP地址-->
<PARAM name="backIp1" value="192.168.100.11"/>
<!-- 设置SSH可信通道IP地址(外网IP),若无外网,则可以不设置该选项或者同backIp1设置相同IP -->
<PARAM name="sshIp1" value="192.168.124.11"/>
<!--DBnode 数据库主节点信息-->
<!-- 当前主机上需要部署的数据库节点个数 -->
<PARAM name="dataNum" value="1"/>
<!-- 数据库节点的基础端口号 -->
<PARAM name="dataPortBase" value="26000"/>
<!-- 指定当前主机上的数据库节点的数据存储目录 -->
<PARAM name="dataNode1" value="/gauss/data/db1,db2.opengauss.com,/gauss/data/slavedb2"/>
<!--DBnode节点上设定同步模式的节点数-->
<PARAM name="dataNode1_syncNum" value="1"/>
</DEVICE>
<!-- node2上的节点部署信息,其中“name”的值配置为主机名称 -->
<DEVICE sn="1000002">
<PARAM name="name" value="db2.opengauss.com"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<!-- 主机后端存储网络通讯IP地址和HA通讯IP地址-->
<PARAM name="backIp1" value="192.168.100.12"/>
<!-- 设置SSH可信通道IP地址(外网IP),若无外网,则可以不设置该选项或者同backIp1设置相同IP -->
<PARAM name="sshIp1" value="192.168.124.12"/>
</DEVICE>
</DEVICELIST>
</ROOT>
------------------------------------------------
实例名称 | 实例数据目录 | 备注 |
主DBnode | /gauss/data/xxx | 其中,xxx为当前主DBnode的名称 |
备DBnode | /gauss/data/slaveX | 其中,xxx为当前备DBnode的名称 |
mkdir /gauss
chgrp dbgrp -R /gauss
chmod 775 -R /gauss
mkdir -p /soft/openGauss
chmod 775 -R /soft
mv clusterconfig.xml /soft/openGauss
mv openGauss-1.0.0-CentOS-64bit.tar.gz /soft/openGauss
cd /soft/openGauss
tar -zxvf openGauss-1.0.0-CentOS-64bit.tar.gz
export LD_LIBRARY_PATH=/soft/openGauss/script/gspylib/clib:/usr/python3.6.11/lib:$LD_LIBRARY_PATH
cd /soft/openGauss/script
./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/clusterconfig.xml ## 建议执行完毕后,重启系统,使部分参数生效
## 执行示例
[root@db1 script]# ./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/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.
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 "/soft/openGauss/script/gs_checkos -i A -h db1.opengauss.com,db2.opengauss.com --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@db1 script]# /soft/openGauss/script/gs_checkos -i A -h db1.opengauss.com,db2.opengauss.com --detail
Checking items:
A1. [ OS version status ] : Normal
[db1.opengauss.com]
centos_7.6.1810_64bit
[db2.opengauss.com]
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.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 ] : Normal
All values about system control parameters are correct.
A7. [ File system configuration status ] : Normal
Both soft nofile and hard nofile are correct.
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 ] : Normal
The configuration about network card is correct.
A12.[ Time consistency status ] : Warning
[db1.opengauss.com]
The NTPD not detected on machine and local time is "2020-07-22 18:52:57".
[db2.opengauss.com]
The NTPD not detected on machine and local time is "2020-07-22 18:52:57".
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:1.
## 由于没有使用NTP服务器,所以告警提示时间同步存在问题,考虑到系统时间对数据库的重要性,建议生产环境启用NTP服务,确保系统时间同步
[root@db1 ~]# reboot
[root@db2 ~]# reboot
vi /soft/hostfile
-----------------------
192.168.100.11
192.168.100.12
-----------------------
cd /soft/openGauss/script
./gs_sshexkey -f /soft/hostfile
## 指定preinstall脚本
cd /soft/openGauss/script
./gs_preinstall -U omm -G dbgrp -L -X /soft/openGauss/clusterconfig.xml ##在每个节点手动执行
## 手动创建互信(脚本)
vi /soft/hostfile
-----------------------
192.168.100.11
192.168.100.12
-----------------------
cd /soft/openGauss/script
./gs_sshexkey -f /soft/hostfile
## 以非交互式的方式执行preinstall脚本
cd /soft/openGauss/script
./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/clusterconfig.xml --non-interactive
## 执行完毕preinstall脚本后,建议重启操作系统,否则请手动设置max user process参数
## 参考命令: ulimit -u unlimited
chmod -R 775 /soft/
chown omm:dbgrp /soft -R
su - omm
cd /soft/openGauss/script
./gs_install -X /soft/openGauss/clusterconfig.xml ## 密码复杂度要求:大写+小写+数字+特殊字符(任选3类,至少8位)
## 执行示例如下:
[omm@db1 script]$ ./gs_install -X /soft/openGauss/clusterconfig.xml
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 /gauss/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..
[omm@db1 ~]$ gs_om -t stop
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
cd /gauss/data/db1/ ## 备库路径在/gauss/data/slavedb2/
vi postgresql.conf
-----------------------------------
## 内容如下:
wal_level=hot_standby ## 默认值 hot_standby
hot_standby = on ## 默认值 on
hot_standby_feedback = on ## 默认值 off
-----------------------------------
[omm@db1 db1]$ gs_om -t start
Starting cluster.
=========================================
=========================================
Successfully started.
su - root
cd /soft/openGauss/script/
./gs_checkos -i A
./gs_checkos -i B
## 示例如下:
[root@db1 script]# ./gs_checkos -i A
Checking items:
A1. [ OS version status ] : Normal
A2. [ Kernel version status ] : Normal
A3. [ Unicode status ] : Normal
A4. [ Time zone status ] : Normal
A5. [ Swap memory status ] : Normal
A6. [ System control parameters status ] : Normal
A7. [ File system configuration status ] : Normal
A8. [ Disk configuration status ] : Normal
A9. [ Pre-read block size status ] : Normal
A10.[ IO scheduler status ] : Normal
A11.[ Network card configuration status ] : Normal
A12.[ Time consistency status ] : Warning
A13.[ Firewall service status ] : Normal
A14.[ THP service status ] : Normal
Total numbers:14. Abnormal numbers:0. Warning numbers:1.
[root@db1 script]# ./gs_checkos -i B
Setting items:
B1. [ Set system control parameters ] : Normal
B2. [ Set file system configuration value ] : Normal
B3. [ Set pre-read block size value ] : Normal
B4. [ Set IO scheduler value ] : Normal
B5. [ Set network card configuration value ] : Normal
B6. [ Set THP service ] : Normal
B7. [ Set RemoveIPC value ] : Normal
NOTICE: MTU value and some warning items can NOT be set. Please do it manually.
Total numbers:7. Abnormal numbers:0. Warning numbers:0.
[omm@db1 ~]$ gs_om -t start
Starting cluster.
=========================================
=========================================
Successfully started.
[omm@db1 ~]$ gs_om -t stop
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
[omm@db1 ~]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
-----------------------------------------------------------------------------------------------------------
1 db1.opengauss.com 192.168.100.11 6001 /gauss/data/db1 P Primary Normal
2 db2.opengauss.com 192.168.100.12 6002 /gauss/data/slavedb2 S Standby Normal
## 检查集群状态
[omm@db1 ~]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
-----------------------------------------------------------------------------------------------------------
1 db1.opengauss.com 192.168.100.11 6001 /gauss/data/db1 P Primary Normal
2 db2.opengauss.com 192.168.100.12 6002 /gauss/data/slavedb2 S Standby Normal
## 切换主/备角色(在备库执行)
[omm@db2 slavedb2]$ gs_ctl switchover -D /gauss/data/slavedb2/
[2020-07-22 20:59:04.701][12415][][gs_ctl]: gs_ctl switchover ,datadir is -D "/gauss/data/slavedb2"
[2020-07-22 20:59:04.701][12415][][gs_ctl]: switchover term (1)
[2020-07-22 20:59:04.784][12415][][gs_ctl]: waiting for server to switchover............
[2020-07-22 20:59:14.435][12415][][gs_ctl]: done
[2020-07-22 20:59:14.435][12415][][gs_ctl]: switchover completed (/gauss/data/slavedb2)
## 检查集群状态
[omm@db2 slavedb2]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
-------------------------------------------------------------------------------------------------------
1 db1.opengauss.com 192.168.100.11 6001 /gauss/data/db1 S Standby Normal
2 db2.opengauss.com 192.168.100.12 6002 /gauss/data/slavedb2 P Primary Normal
## 保存集群主备机器信息
[omm@db2 slavedb2]$ gs_om -t refreshconf
Generating dynamic configuration file for all nodes.
Successfully generated dynamic configuration file.
######目前官方提供的软件包版本如下所示:
[omm@db1 ~]$ gaussdb -V
gaussdb (openGauss 1.0.0 build 0bd0ce80) compiled at 2020-06-30 18:19:27 commit 0 last mr
## 测试时,该版本的gs_initdb脚本存在异常,暂时不使用该方法。
## 初始化数据库时,请确保对应的数据目录为空
gs_initdb -E UTF-8 --locale=en_US.UTF-8 /gauss/data/db1/tmp --nodename db1.opengauss.com -w "Bigdata@123"
## 初始化操作示例如下:
[omm@db1 ~]$ gs_initdb -E UTF-8 --locale=en_US.UTF-8 /gauss/data/db1/tmp --nodename db1.opengauss.com -w "gauss@111"
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
creating directory /gauss/data/db1/tmp ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /gauss/data/db1/tmp/base/1 ... ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... gs_initdb: removing data directory "/gauss/data/db1/tmp" ## 自动清空了数据目录
# gsql -d postgres -p 26000
postgres=# alter role omm identified by 'Gauss@123' replace 'Gauss_111';
postgres=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;
## 简单查询测试
postgres=# select version();
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+-----------+---------+-------+-------------------
mydb | omm | UTF8 | C | C |
postgres | omm | SQL_ASCII | C | C |
template0 | omm | SQL_ASCII | C | C | =c/omm +
| | | | | omm=CTc/omm
template1 | omm | SQL_ASCII | C | C | =c/omm +
| | | | | omm=CTc/omm
ssh-keygen -t rsa
cat .ssh/id_rsa.pub >> .ssh/authorized_keys ##生成本机授权
ssh-keyscan -t rsa db1 >> ~/.ssh/known_hosts
ssh-keyscan -t rsa db2 >> ~/.ssh/known_hosts
scp -r .ssh db2:~
su - omm
gs_uninstall --delete-data # 卸载集群所有数据库
gs_uninstall --delete-data -L # 仅卸载本地数据库
# 如果卸载失败请根据“$GAUSSLOG/om/gs_uninstall-YYYY-MM-DD_HHMMSS.log”中的日志信息排查错误。
## 示例:
[omm@db1 ~]$ gs_uninstall --delete-data
Checking uninstallation.
Successfully checked uninstallation.
Stopping the cluster.
Successfully stopped cluster.
Successfully deleted instances.
Uninstalling application.
Successfully uninstalled application.
Uninstallation succeeded.