一、系统初始化及参数配置
$ python3 --version # openEuler:支持>=Python 3.6.X且<=Python 3.10.X
Python 3.9.9
$ rpm -qa |grep libaio # 建议版本:0.3.109-13
libaio-0.3.113-9.oe2203sp3.x86_64
$ rpm -qa |grep readline # 建议版本:7.0-13
readline-8.1-3.oe2203sp3.x86_64
$ nmcli general hostname lowair-openGaussDB # 修改机器名
$ systemctl stop firewalld.service # 停止服务
$ systemctl disable firewalld.service # 禁止自启动
$ sed -i 's/enforcing/disabled/' /etc/selinux/config # 关闭SELINUX配置
# 关闭RemoveIPC
$ vi /etc/systemd/logind.conf
RemoveIPC=no # 去年前面的注释
$ echo "RemoveIPC=no" >> /usr/lib/systemd/system/systemd-logind.service
$ systemctl daemon-reload
$ systemctl restart systemd-logind
# 检查是否生效
$ loginctl show-session | grep RemoveIPC
RemoveIPC=no
$ systemctl show systemd-logind | grep RemoveIPC
RemoveIPC=no
# 配置root登录
$ vi /etc/ssh/sshd_config
#Banner XXXX # 修改Banner配置,去掉连接到系统时,系统提示的欢迎信息
PermitRootLogin yes # 允许root登录
# 查找GSSAPIAuthentication 赋值为no
# 查找UseDNS,赋值为 no(该项默认不启用的,要把前面的#删除掉
$ systemctl restart sshd
$ vi /etc/sysctl.conf
# 在文件后面追加下面两句
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
# 使修改的参数生效
$ sysctl -p
$ swapoff -a # 为提高性能,关闭交换内存
# 修改网卡mtu长度
$ echo "MTU=8192" >> /etc/sysconfig/network-scripts/ifcfg-`ip -o link show | awk -F': ' '{print $2}' | grep '^ens'`
$ echo "* soft nofile 1000000" >>/etc/security/limits.conf
$ echo "* hard nofile 1000000" >>/etc/security/limits.conf
$ echo "* soft nproc unlimited" >> /etc/security/limits.d/90-nproc.conf
# 解决Abnormal问题:The THP service status RealValue 'enabled' ExpectedValue 'disabled'.
$ 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
# 保存退出,赋予rc.local文件执行权限
$ chmod +x /etc/rc.d/rc.local
$ init 6
# 重启系统,检查THP是否被禁用
$ cat /sys/kernel/mm/transparent_hugepage/enabled
$ cat /sys/kernel/mm/transparent_hugepage/defrag
# 安装tar命令(先从openEuler-22.03-LTS-SP3-x86_64-dvd.iso文件的Packages目录下提取tar-1.34-5.oe2203sp3.x86_64.rpm、net-tools-2.10-3.oe2203sp3.x86_64.rpm,并上传至服务器)
$ rpm -Uvh ~/*.rpm
说明:如果使用SecureCRT连接服务器,老版本的可能会登录失败,并提示:No compatible key exchange method. The server supports these methods: curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,kex-strict-s-v00@openssh.com ,这时要安装新版软件,以保证至少其支持上面其中一项,如:curve25519-sha256。
二、安装数据库
参考官网文档: 点击访问参考文档
访问网址:https://opengauss.org/zh/download/ 下载 openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz 并上传至服务器
$ mkdir /home/software && chmod -R 755 /home/software
$ tar zxvf openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz -C /home/software/
$ cd /home/software/
$ tar -zxvf openGauss-OM-6.0.0-openEuler22.03-x86_64.tar.gz
$ vi cluster_config.xml # 输入以下内容
<ROOT>
<CLUSTER>
<PARAM name="clusterName" value="Cluster_template" />
<PARAM name="nodeNames" value="myDB-Server" />
<PARAM name="gaussdbAppPath" value="/home/openGauss/install/app" />
<PARAM name="gaussdbLogPath" value="/home/openGauss/install/log" />
<PARAM name="tmpMppdbPath" value="/home/openGauss/install/tmp" />
<PARAM name="gaussdbToolPath" value="/home/openGauss/install/tool" />
<PARAM name="corePath" value="/home/openGauss/install/corefile" />
<PARAM name="backIp1s" value="192.168.XX.XX" />
</CLUSTER>
<DEVICELIST>
<DEVICE sn="node1_hostname">
<PARAM name="name" value="myDB-Server" />
<PARAM name="azName" value="AZ1" />
<PARAM name="azPriority" value="1" />
<PARAM name="backIp1" value="192.168.XX.XX" />
<PARAM name="sshIp1" value="192.168.XX.XX" />
<PARAM name="dataNum" value="1" />
<PARAM name="dataPortBase" value="15000" />
<PARAM name="dataNode1" value="/home/openGauss/install/data/dn1" />
<PARAM name="dataNode1_syncNum" value="0" />
</DEVICE>
</DEVICELIST>
</ROOT>
# 说明:将上面的“myDB-Server”换为你自己的hostname,还要指定自己机器的ip
$ cd script/
# 预安装
$ ./gs_preinstall -U omm -G dbgrp -X /home/software/cluster_config.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.
Setting host ip env
Successfully set host ip env.
Are you sure you want to create the user[omm] (yes/no)? yes # 此处输入yes
Please enter password for cluster user.
Password: # 输入密码
Please enter password for cluster user again.
Password:
Generate cluster user password files successfully.
Successfully created [omm] user on all nodes.
Preparing SSH service.
Successfully prepared SSH service.
Checking OS software.
Successfully check OS software.
Checking OS version.
Successfully checked OS version.
Checking cpu instructions.
Warning: This cluster is missing the rdtscp or avx instruction.
Successfully checked cpu instructions.
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 "/home/software/script/gs_checkos -i A -h lowair-openGaussDB -X /home/software/cluster_config.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.
# 以上预安装成功。另外,如果此处出错的话,可以输入”/home/software/script/gs_checkos -i A -h lowair-openGaussDB -X /home/software/cluster_config.xml --detail“ 命令查看问题所在,再相应处理。
# 正式安装
# su - omm && cd /home/software/script/
$ ./gs_install -X /home/software/cluster_config.xml --gsinit-parameter="--locale=en_US.utf8"
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 /home/openGauss/install/app/share/sslcert/om
NO cm_server instance, no need to create CA for CM.
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.
Configuring pg_hba on all nodes.
Configuration is completed.
The cluster status is Normal.
Successfully started cluster.
Successfully installed application.
end deploy..
三、验证安装
# 以omm用户登录
$ gs_om -t status # “cluster_state ”显示“Normal”表示数据库可正常使用
-----------------------------------------------------------------------
cluster_name : Cluster_template
cluster_state : Normal
redistributing : No
-----------------------------------------------------------------------
# 数据库安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库
$ gsql -d postgres -p 15000
gsql ((openGauss 6.0.0 build aee4abd5) compiled at 2024-09-29 19:14:27 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
# 创建数据库mydb
openGauss=# CREATE DATABASE mydb WITH ENCODING 'utf8' template = template0; CREATE DATABASE
# 查看数据库
openGauss=# SELECT datname FROM pg_database WHERE datistemplate = false;
datname
----------
mydb
postgres
(2 rows)
# 数据库重启命令
$ gs_om -t restart
四、配置客户端工具连接
$ cd /home/openGauss/install/data/dn1
# 更改口令加密方式(默认sha256)为password_encryption_type = 1 (sha256 + md5两种加密方式)
$ echo "password_encryption_type = 1" >> postgresql.conf
# 修改远程登录机器范围与加密方式
$ echo "host all all 0.0.0.0/0 md5" >> /pg_hba.conf
$ su omm
$ gsql -d postgres -p 15000
openGauss=# select pg_reload_conf(); # 重新加载配置文件而无需重启 PostgreSQL 服务
pg_reload_conf
----------------
t
(1 row)po
# 新建用户
openGauss=# CREATE USER szatc WITH PASSWORD 'xxxxxx';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
说明:第三方工具连接openGuass时,选择PostgreSQL类型数据库即可,因为前者是基于后者二开的