在之前的博客我们了解了openGauss的系统架构,本篇我们来看下openGauss单机版的安装。
openGauss 系统结构 说明
https://www.cndba.cn/dave/article/116446
1. 环境信息
[root@www.cndba.cn openGauss]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@www.cndba.cn openGauss]# uname -r
3.10.0-957.el7.x86_64
[root@www.cndba.cn openGauss]#
安装包直接从官网下载,解压缩后如下:
[root@www.cndba.cn openGauss]# pwd
/data/software/openGauss
[root@www.cndba.cn openGauss]# ll
total 258292
-rw-r--r-- 1 root root 131677914 Feb 18 17:20 openGauss-3.1.1-CentOS-64bit-all.tar.gz
-rw-r--r-- 1 root root 105 Jan 6 09:52 openGauss-3.1.1-CentOS-64bit-cm.sha256
-rw-r--r-- 1 root root 22301121 Jan 6 09:52 openGauss-3.1.1-CentOS-64bit-cm.tar.gz
-rw-r--r-- 1 root root 65 Jan 6 09:49 openGauss-3.1.1-CentOS-64bit-om.sha256
-rw-r--r-- 1 root root 11950059 Jan 6 09:49 openGauss-3.1.1-CentOS-64bit-om.tar.gz
-rw-r--r-- 1 root root 65 Jan 6 09:52 openGauss-3.1.1-CentOS-64bit.sha256
-rw-r--r-- 1 root root 98058402 Jan 6 09:52 openGauss-3.1.1-CentOS-64bit.tar.bz2
-rw------- 1 root root 65 Jan 6 09:46 upgrade_sql.sha256
-rw------- 1 root root 475737 Jan 6 09:46 upgrade_sql.tar.gz
[root@www.cndba.cn openGauss]#
2. 配置XML文件
XML配置文件里面内容较多,详细内容直接参考官网:
https://docs.opengauss.org/zh/docs/3.1.1/docs/installation/创建XML配置文件.html
这里使用的文件的文件内容如下, 注意目录是放在软件的同一级:
[root@www.cndba.cn openGauss]# pwd
/data/software/openGauss
[root@www.cndba.cn openGauss]# cat cluster_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="dbCluster" />
<!-- 数据库节点名称(hostname) -->
<PARAM name="nodeNames" value="www.cndba.cn" />
<!-- 数据库安装目录-->
<PARAM name="gaussdbAppPath" value="/data/openGauss/install/app" />
<!-- 日志目录-->
<PARAM name="gaussdbLogPath" value="/var/log/omm" />
<!-- 临时文件目录-->
<PARAM name="tmpMppdbPath" value="/data/openGauss/tmp" />
<!-- 数据库工具目录-->
<PARAM name="gaussdbToolPath" value="/data/openGauss/install/om" />
<!-- 数据库core文件目录-->
<PARAM name="corePath" value="/data/openGauss/corefile" />
<!-- 节点IP,与数据库节点名称列表一一对应 -->
<PARAM name="backIp1s" value="172.31.101.18"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的部署信息 -->
<DEVICE sn="www.cndba.cn">
<!-- 节点1的主机名称 -->
<PARAM name="name" value="www.cndba.cn"/>
<!-- 节点1所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="172.31.101.18"/>
<PARAM name="sshIp1" value="172.31.101.18"/>
<!--dbnode-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/data/openGauss/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
root@oracle </DEVICELIST>
</ROOT>
[root@www.cndba.cn openGauss]#
另外主要这里的目录不需要创建,初始化脚本会自动创建。
3. 初始化环境(root用户)
详细过程参考官网:
https://docs.opengauss.org/zh/docs/3.1.1/docs/installation/初始化安装环境.html
我们这里看操作记录。
解压缩om, 然后会出现script的目录:
[root@www.cndba.cn openGauss]# tar xzvf openGauss-3.1.1-CentOS-64bit-om.tar.gz
[root@www.cndba.cn openGauss]# ll
total 258292
-rw-r--r-- 1 root root 1892 Feb 18 18:46 cluster_config.xml
drwxr-xr-x 14 root root 4096 Jan 6 09:49 lib
-rw-r--r-- 1 root root 131677914 Feb 18 17:20 openGauss-3.1.1-CentOS-64bit-all.tar.gz
-rw-r--r-- 1 root root 22301121 Jan 6 09:52 openGauss-3.1.1-CentOS-64bit-cm.tar.gz
-rw-r--r-- 1 root root 11950059 Jan 6 09:49 openGauss-3.1.1-CentOS-64bit-om.tar.gz
-rw-r--r-- 1 root root 98058402 Jan 6 09:52 openGauss-3.1.1-CentOS-64bit.tar.bz2
drwxr-xr-x 10 root root 4096 Jan 6 09:49 script
-rw------- 1 root root 475737 Jan 6 09:46 upgrade_sql.tar.gz
-rw-r--r-- 1 root root 32 Jan 6 09:49 version.cfg
[root@www.cndba.cn openGauss]#
使用script/gs_preinstall准备好安装环境, 我们这里采用交互模式执行前置,并在执行过程中自动创建操作系统root用户互信和omm用户互信:
./gs_preinstall -U omm -G dbgrp -X /data/software/openGauss/cluster_config.xml
omm为数据库管理员(也是运行openGauss的操作系统用户),dbgrp为运行openGauss的操作系统用户的群组名称,/data/software/openGauss/cluster_config.xml为openGauss配置文件路径。在执行过程中,用户根据提示选择是否创建互信,并输入操作系统root用户或omm用户的密码。
这里还需要注意一点,就是gs_greinstall 脚本以来python3, 需要先安装python3 后才能执行。
[root@www.cndba.cn script]# pwd
/data/software/openGauss/script
[root@www.cndba.cn script]# pwd
/data/software/openGauss/script
[root@www.cndba.cn script]# ./gs_preinstall -U omm -G dbgrp -X /data/software/openGauss/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
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.
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 "/data/software/openGauss/script/gs_checkos -i A -h www.cndba.cn --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.
[root@www.cndba.cn script]#
因为这里有配置一些系统变量,官网建议重启一下OS。
我们这里不重启了,直接执行如下命令:
[root@www.cndba.cn script]# sysctl -p
4. 执行安装(omm用户)
官方链接:
https://docs.opengauss.org/zh/docs/3.1.1/docs/installation/执行安装.html
安装之前检查下之前创建的目录机构是否存在,如果异常,重新执行初始化脚本:
[root@www.cndba.cn openGauss]# pwd
/data/openGauss
[root@www.cndba.cn openGauss]# ll
total 0
drwxr-x--- 2 omm dbgrp 10 Feb 19 16:09 corefile
drwxr-xr-x 5 omm dbgrp 64 Feb 19 16:09 install
drwx------ 2 omm dbgrp 10 Feb 19 16:09 tmp
[root@www.cndba.cn openGauss]#
切换到omm用户,使用gs_install安装openGauss。
./gs_install -X /data/software/openGauss/cluster_config.xml
在执行过程中,用户需根据提示输入数据库的密码,密码具有一定的复杂度,为保证用户正常使用该数据库,请记住输入的数据库密码。
因为上一步是使用root用户执行的,所以软件目录权限还是root,所以在执行gs_install 之前,需要先修改软件目录的权限:
[root@www.cndba.cn openGauss]# ll
total 307708
-rw------- 1 omm dbgrp 1904 Feb 19 16:15 cluster_config.xml
drwxr-xr-x 15 root root 4096 Feb 19 16:06 lib
drwxr-xr-x 9 root root 154 Feb 19 16:09 libcgroup
-r-------- 1 root root 104387581 Feb 19 16:06 openGauss-3.0.3-CentOS-64bit-all.tar.gz
-r-------- 1 root root 105 Feb 19 16:06 openGauss-3.0.3-CentOS-64bit-cm.sha256
-r-------- 1 root root 6380530 Feb 19 16:06 openGauss-3.0.3-CentOS-64bit-cm.tar.gz
-r-------- 1 root root 65 Feb 19 16:06 openGauss-3.0.3-CentOS-64bit-om.sha256
-r-------- 1 root root 11920235 Feb 19 16:06 openGauss-3.0.3-CentOS-64bit-om.tar.gz
-r-------- 1 root root 65 Feb 19 16:06 openGauss-3.0.3-CentOS-64bit.sha256
-r-------- 1 root root 86443209 Feb 19 16:06 openGauss-3.0.3-CentOS-64bit.tar.bz2
-r-------- 1 root root 105467689 Feb 19 16:08 openGauss-Package-bak_46134f73.tar.gz
drwx------ 10 root root 4096 Feb 19 16:08 script
-r-------- 1 root root 65 Feb 19 16:06 upgrade_sql.sha256
-r-------- 1 root root 447869 Feb 19 16:06 upgrade_sql.tar.gz
-r-------- 1 root root 32 Jan 10 22:50 version.cfg
[root@www.cndba.cn openGauss]# id omm
uid=1005(omm) gid=1005(dbgrp) groups=1005(dbgrp)
[root@www.cndba.cn openGauss]# chown omm:dbgrp * -R
然后执行命令:
[omm@www.cndba.cn script]$ pwd
/data/software/openGauss/script
[omm@www.cndba.cn script]$ ./gs_install -X /data/software/openGauss/cluster_config.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:
[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 /data/openGauss/install/app/share/sslcert/om
NO cm_server instance, no need to create CA for CM.
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.
Successfully started cluster.
Successfully installed application.
end deploy..
[omm@www.cndba.cn script]$
5. 验证
[root@www.cndba.cn script]# ps -ef|grep openGauss
omm 33462 1 5 16:38 ? 00:00:22 /data/openGauss/install/app/bin/gaussdb -D /data/openGauss/install/data/dn
root 35101 19702 0 16:44 pts/7 00:00:00 grep --color=auto openGauss
[root@www.cndba.cn script]#
[omm@www.cndba.cn script]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : dbCluster
cluster_state : Normal
redistributing : No
-----------------------------------------------------------------------
[omm@www.cndba.cn script]$ gsql -d postgres -p 15400
gsql ((openGauss 3.0.3 build 46134f73) compiled at 2023-01-10 22:42:07 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=#
openGauss=# select version();
version
------------------------------------------------------------------------------------------------------------------------------------------------------
(openGauss 3.0.3 build 46134f73) compiled at 2023-01-10 22:42:07 commit 0 last mr on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)
openGauss=# select user;
current_user
--------------
omm
(1 row)
版权声明:本文为博主原创文章,未经博主允许不得转载。