首页 > 其他分享 >OpenGauss部署案例之---OpenEuler 20.03部署OpenGauss企业版

OpenGauss部署案例之---OpenEuler 20.03部署OpenGauss企业版

时间:2024-08-09 11:19:11浏览次数:12  
标签:5.0 node208 部署 Successfully omm openGauss OpenGauss root OpenEuler

案例说明:
在OpenEuler20.03系统,x86架构下部署OpenGauss 5.0.1企业版单实例数据库。

数据库版本:

openGauss=# select version();
                                                                       version
------------------------------------------------------------------------------------------------------------------------------------------------
 (openGauss 5.0.1 build 33b035fd) compiled at 2023-12-15 20:27:13 commit 0 last mr   on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 6
4-bit
(1 row)

系统环境:

[root@node208 script]# cat /etc/os-release
NAME="openEuler"
VERSION="20.03 (LTS-SP4)"
ID="openEuler"
VERSION_ID="20.03"
PRETTY_NAME="openEuler 20.03 (LTS-SP4)"
ANSI_COLOR="0;31"

[root@node208 script]# uname -a
Linux node208 4.19.90-2312.1.0.0255.oe2003sp4.x86_64

一、系统环境准备
1、关闭防火墙
目前仅支持在防火墙关闭的状态下进行安装。安装好后,可以把防火墙打开

systemctl disable firewalld.service
systemctl stop firewalld.service
systemctl status firewalld

2、设置SELINUX

vim /etc/selinux/config
SELINUX=disabled
# 配置生效
[root@node208 conf]# setenforce 0
setenforce: SELinux is disabled

[root@node208 conf]# getenforce
Disabled

3、设置操作系统字符集编码

LANG=en_US.UTF-8 
echo "LANG=en_US.UTF-8" >> /etc/profile
source /etc/profile
echo $LANG

4、设置时区和时间

查询时区和修改
timedatectl
timedatectl list-timezones |grep Shanghai
timedatectl set-timezone Asia/Shanghai


修改时区和时间
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
date -s "2021-04-29 15:51:50"

5、关闭swap交换内存(可选)
关闭swap交换内存是为了保障数据库的访问性能,避免把数据库的缓冲区内存淘汰到磁盘上。如果服务器内存比较小,内存过载时,可打开swap交换内存保障正常运行。

# 关闭
swapoff -a
[root@node208 conf]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3429        1126         239         779        2064         999
Swap:             0           0           0

# 开启
swapon -a

6、关闭virbr0网卡

ifconfig virbr0 down
systemctl disable libvirtd.service

7、关闭RemoveIPC
在各数据库节点上,关闭RemoveIPC.

# 删除
sed -i '/^RemoveIPC/d' /etc/systemd/logind.conf
sed -i '/^RemoveIPC/d' /usr/lib/systemd/system/systemd-logind.service

# 传入参数
echo "RemoveIPC=no"  >> /etc/systemd/logind.conf
echo "RemoveIPC=no"  >> /usr/lib/systemd/system/systemd-logind.service


# 使参数生效
systemctl daemon-reload
systemctl restart systemd-logind


# 验证参数的值
loginctl show-session | grep RemoveIPC
systemctl show systemd-logind | grep RemoveIPC

[root@node208 script]# loginctl show-session | grep RemoveIPC
RemoveIPC=no
[root@node208 script]# systemctl show systemd-logind | grep RemoveIPC
RemoveIPC=no

默认安装的操作系统,2个参数都是RemoveIPC=no,所以这2个参数不用修改,不过需要先查看下参数值,如果不是no,那就手动改下。

8、设置网卡MTU值
将各数据库节点的网卡MTU值设置为相同大小。

操作步骤
执行如下命令查询服务器的网卡名称。
ifconfig

使用如下命令将各数据库节点的网卡MTU值设置为相同大小。MTU值推荐8192,要求不小于1500。
ifconfig ens33 mtu 8192

9、关闭virbr0网卡

ifconfig virbr0 down
systemctl disable libvirtd.service

10、关闭HISTORY记录
为避免指令历史记录安全隐患,需关闭各主机的history指令。

步骤 1 修改根目录下/etc/profile文件。
vim /etc/profile

步骤 2 设置HISTSIZE值为0。例如,系统中HISTSIZE默认值为1000,将其修改为0。
HISTSIZE=0

步骤 3 设置/etc/profile生效。
source /etc/profile

11、设置root用户远程登录
修改PermitRootLogin配置,允许用户远程登录。

a. 打开sshd_config文件。
vim /etc/ssh/sshd_config

b. 修改权限配置,可以使用以下两种方式实现:
注释掉“PermitRootLogin no”。
#PermitRootLogin no

将“PermitRootLogin”改为“yes”。
PermitRootLogin yes

12、配置Banner
修改Banner配置,去掉连接到系统时,系统提示的信息。
信息会干扰安装时远程操作的返回结果,影响安装正常执行。

a. 编辑sshd_config文件。
vim /etc/ssh/sshd_config

b. 修改Banner配置,注释掉“Banner”所在的行。
#Banner XXXX

c. 执行:wq保存并退出编辑页面。
使用如下命令使设置生效。
systemctl restart sshd.service

以root用户身份重新登录。
ssh xxx.xxx.xxx.xxx

13、创建用户和组

[root@node208 script]# id omm
uid=2000(omm) gid=2000(dbgrp) groups=2000(dbgrp)

14、安装依赖包
[root@node208 soft]# dnf -y install libaio-devel flex bison ncurses-devel glibc-devel patch readline-devel libnsl python3

二、部署opengauss

1、解压软件包到安装目录下
如下所示,/opt/gdb5 为opengauss的安装目录:

[root@node208 soft]# tar zxvf openGauss-5.0.1-openEuler-64bit-all.tar.gz -C /opt/gdb5/
openGauss-5.0.1-openEuler-64bit-cm.tar.gz
openGauss-5.0.1-openEuler-64bit-om.tar.gz
openGauss-5.0.1-openEuler-64bit.tar.bz2
openGauss-5.0.1-openEuler-64bit-cm.sha256
openGauss-5.0.1-openEuler-64bit-om.sha256
openGauss-5.0.1-openEuler-64bit.sha256
upgrade_sql.tar.gz
upgrade_sql.sha256

[root@node208 gdb5]# tar zxvf  openGauss-5.0.1-openEuler-64bit-om.tar.gz -C /opt/gdb5/
[root@node208 gdb5]# ls -lh
total 129M
drwxr-x--- 14 root root 4.0K Dec 15  2023 lib
-rw-r-----  1 root root  108 Dec 15  2023 openGauss-5.0.1-openEuler-64bit-cm.sha256
-rw-r-----  1 root root  22M Dec 15  2023 openGauss-5.0.1-openEuler-64bit-cm.tar.gz
-rw-r-----  1 root root   65 Dec 15  2023 openGauss-5.0.1-openEuler-64bit-om.sha256
-rw-r-----  1 root root  11M Dec 15  2023 openGauss-5.0.1-openEuler-64bit-om.tar.gz
-rw-r-----  1 root root   65 Dec 15  2023 openGauss-5.0.1-openEuler-64bit.sha256
-rw-r-----  1 root root  97M Dec 15  2023 openGauss-5.0.1-openEuler-64bit.tar.bz2
drwxr-x--- 10 root root 4.0K Dec 15  2023 script
-rw-------  1 root root   65 Dec 15  2023 upgrade_sql.sha256
-rw-------  1 root root 488K Dec 15  2023 upgrade_sql.tar.gz
-rw-r-----  1 root root   32 Dec 15  2023 version.cfg
# 配置目录及文件权限
[root@node208 script]# chmod -R 755 /opt/gdb5/

2、修改python环境
如下所示,将系统默认的python调用改为python3:

[root@node208 script]# cd /usr/bin
[root@node208 bin]# mv python python.bk
[root@node208 bin]# ln -s python3 /usr/bin/python
[root@node208 bin]# python -V
Python 3.7.9

3、创建部署配置文件
1)生成配置文件

[root@node208 conf]# pwd
/opt/gdb5/script/gspylib/etc/conf
[root@node208 conf]# cp cluster_config_template.xml /opt/gdb5/cluster_config.xml

2)修改配置文件

[root@node208 gdb5]# cat cluster_config.xml
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
  <CLUSTER>
    <PARAM name="clusterName" value="gcluster" />
    <PARAM name="nodeNames" value="node208"/>
    <PARAM name="gaussdbAppPath" value="/opt/hw/install/app" />
    <PARAM name="gaussdbLogPath" value="/opt/hw/omm" />
    <PARAM name="tmpMppdbPath" value="/opt/hw/tmp"/>
    <PARAM name="gaussdbToolPath" value="/opt/hw/install/om" />
    <PARAM name="corePath" value="/opt/hw/corefile"/>
    <PARAM name="backIp1s" value="192.168.1.208"/>
  </CLUSTER>

  <DEVICELIST>
    <DEVICE sn="node1_hostname">
      <PARAM name="name" value="node208"/>
      <PARAM name="azName" value="AZ1"/>
      <PARAM name="azPriority" value="1"/>
      <PARAM name="backIp1" value="192.168.1.208"/>
      <PARAM name="sshIp1" value="192.168.1.208"/>
      <!-- dn -->
      <PARAM name="dataNum" value="1"/>
      <PARAM name="dataPortBase" value="15400"/>
      <PARAM name="dataNode1" value="/opt/hw/install/data/dn"/>
      <PARAM name="dataNode1_syncNum" value="0"/>
    </DEVICE>
  </DEVICELIST>
</ROOT>

3)创建安装目录

[root@node208 gdb5]# mkdir -p /opt/hw/omm
[root@node208 gdb5]# mkdir -p /opt/hw/tmp
[root@node208 gdb5]# mkdir -p /opt/hw/install/om
[root@node208 gdb5]# mkdir -p /opt/hw/corefile
[root@node208 gdb5]# mkdir -p /opt/hw/install/data/dn
# 配置目录和文件权限
[root@node208 gdb5]# chown -R omm.dbgrp /opt/hw

4、执行预安装
openGauss提供了gs_preinstall工具来帮助完成openGauss的环境配置,以保证openGauss安装的正常进行。

[root@node208 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/gdb5/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
Preparing SSH service.
Successfully prepared SSH service.
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/gdb5/script/gs_checkos -i A -h node208 --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.

5、执行安装部署
如下所示,以omm用户执行安装:

[omm@node208 script]$ ./gs_install -X /opt/gdb5/cluster_config.xml
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Last time end with Install cluster.
Continue this step.
Successfully created the backup directory.
begin deploy..
Rolling back.
Rollback succeeded.
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:
[GAUSS-50322] : Failed to encrypt the password for databaseError:
 /opt/hw/install/app/bin/gs_guc: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory

Please enter password for database:
Please repeat for database:
[GAUSS-50322] : Failed to encrypt the password for databaseError:
 Try "gs_guc --help" for more information.
Invalid password,it must contain at least eight characters

Please enter password for database:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /opt/hw/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..

如下所示,在安装过程中,出现读取动态库readline错误,系统自带的动态库为readline.so.8,通过手工在/usr/lib64目录下建立readline.so.7的动态库链接,安装成功:

8、验证cluster状态

[omm@node208 script]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name    : gcluster
cluster_state   : Normal
redistributing  : No
-----------------------------------------------------------------------

三、访问数据库

# 查看数据库服务
[omm@node208 script]$ netstat -antlp |grep 5400
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 192.168.1.208:15400     0.0.0.0:*               LISTEN      227725/gaussdb
tcp        0      0 127.0.0.1:15400         0.0.0.0:*               LISTEN      227725/gaussdb
tcp6       0      0 ::1:15400      

[omm@node208 script]$ ps -ef |grep gauss
omm       227725       1  2 15:27 ?        00:00:06 /opt/hw/install/app/bin/gaussdb -D /opt/hw/install/data/dn

# 连接数据库访问
[omm@node208 bin]$ ./gsql -U omm postgres -p 15400
gsql ((openGauss 5.0.1 build 33b035fd) compiled at 2023-12-15 20:27:13 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# \l
                          List of databases
   Name    | Owner | Encoding  | Collate | Ctype | Access privileges
-----------+-------+-----------+---------+-------+-------------------
 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
(3 rows)

openGauss=# create database prod;
CREATE DATABASE
openGauss=# \c prod
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "prod" as user "omm".
prod=# create table t1 (id int ,name varchar(10));
CREATE TABLE
prod=# insert into t1 values (generate_series(1,10000),'usr'||generate_series(1,10000));
INSERT 0 10000
prod=# select count(*) from t1;
 count
-------
 10000
(1 row)

prod=# explain select count(*) from t1;
                         QUERY PLAN
-------------------------------------------------------------
 Aggregate  (cost=171.99..172.00 rows=1 width=8)
   ->  Seq Scan on t1  (cost=0.00..148.59 rows=9359 width=0)
(2 rows)

四、总结
x86架构,OpenEuler 20.03下部署OpenGauss,在部署OpenGauss 5.0.2版本时,执行gs_preinstall时夯住无法执行,部署OpenGauss 5.0.1版本,数据库部署成功。

标签:5.0,node208,部署,Successfully,omm,openGauss,OpenGauss,root,OpenEuler
From: https://www.cnblogs.com/tiany1224/p/18350437

相关文章