openGauss保姆式安装说明

说明

本人最近在搞华为创新计划的数据库项目,必须要研究华为的高斯数据库,由于GaussDB_100和GaussDB_200的安装包我暂时没找到,华为官网要收费才给认证,所以我这里选择最近才开源的openGauss进行安装!!!

前置准备

我们要先准备安装一台Centos7.x的linux系统,大概是在7.5左右,如下图是我使用的镜像。
在这里插入图片描述
下图是我Centos的内核版本信息,这里不得不提一下GaussDB_100和GaussDB_200,这俩官方要求的操作系统是Redhat,如果我们要用Centos7去安装100和200,必须要在Centos7里配置跳过检测系统的一条命令,因为Centos7和Redhat的区别就在于Redhat要收钱,我们从下图就可以看到Centos7的内核就是Redhat,所以通过配置让系统认为centos7就是Redhat不就行了吗。
在这里插入图片描述
而openGauss直接就能用Centos7,并且能支持openeuler_aarch64,如下图所示:在这里插入图片描述
我们在安装Centos7的时候要选择NAT模式连接,不然访问不了外网,然后手动配置你所搭建的服务器的网卡,不能用DHCP配置,不然ip一直在变,后面就没法玩了,要静态配置ip,此处就省略具体操作了。下图是我的ip。
openGauss保姆式安装说明_第1张图片
编辑profile文件,加上ulimit -c unlimited,然后重新加载该文件
openGauss保姆式安装说明_第2张图片
关闭防火墙,禁用 SWAP、SELINUX(这是为了后面安装避免过多验证以及避免连接失败)

[root@openGauss ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-07-10 00:04:36 CST; 1 day 20h ago
     Docs: man:firewalld(1)
Main PID: 8889 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           └─8889 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Jul 10 00:04:34 openGauss systemd[1]: Starting firewalld - dynamic firewall daemon...
Jul 10 00:04:36 openGauss systemd[1]: Started firewalld - dynamic firewall daemon.
[root@openGauss ~]# systemctl stop firewalld  
[root@openGauss ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2020-07-11 20:19:00 CST; 3s ago
     Docs: man:firewalld(1)
  Process: 8889 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 8889 (code=exited, status=0/SUCCESS)
Jul 10 00:04:34 openGauss systemd[1]: Starting firewalld - dynamic firewall daemon...
Jul 10 00:04:36 openGauss systemd[1]: Started firewalld - dynamic firewall daemon.
Jul 11 20:18:58 openGauss systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jul 11 20:19:00 openGauss systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@openGauss ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
###禁用swap
[root@openGauss ~]# swapoff -a
[root@openGauss ~]# swapoff -av
swapoff /dev/mapper/centos_opengauss-swap
###禁用 SELINUX
[root@openGauss ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@openGauss ~]# cat /etc/selinux/config | grep SELINUX
# SELINUX= can take one of these three values:
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
SELINUXTYPE=targeted

然后检查yum源,我配置了清华和阿里的yum源。

[root@openGauss ~]# cd /etc/yum.repos.d/
[root@openGauss yum.repos.d]# ll
total 32
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo

然后用yum安装以下软件:

[root@openGauss yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: ftp.sjtu.edu.cn
repo id                                                       repo name                                                      status
!base/7/x86_64                                                CentOS-7 - Base                                                10,070
!extras/7/x86_64                                              CentOS-7 - Extras                                                 412
!updates/7/x86_64                                             CentOS-7 - Updates                                                890
repolist: 11,372
[root@openGauss yum.repos.d]#
[root@openGauss yum.repos.d]#
[root@openGauss yum.repos.d]# yum list
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Installed Packages
GConf2.x86_64                                                         3.2.6-8.el7                                         @anaconda
GeoIP.x86_64                                                          1.5.0-13.el7                                        @anaconda
ModemManager.x86_64                                                   1.6.10-1.el7                                        @anaconda
ModemManager-glib.x86_64                                              1.6.10-1.el7                                        @anaconda
NetworkManager.x86_64                                                 1:1.12.0-6.el7                                      @anaconda
.................(省略包信息)..............
 
 
[root@openGauss yum.repos.d]# yum install python3.6*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
base                                                                                                        | 3.6 kB  00:00:00     
extras                                                                                                      | 2.9 kB  00:00:00     
updates                                                                                                     | 2.9 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package python3-pip.noarch 0:9.0.3-7.el7_7 will be installed
--> Processing Dependency: python(abi) = 3.6 for package: python3-pip-9.0.3-7.el7_7.noarch
--> Processing Dependency: /usr/bin/python3 for package: python3-pip-9.0.3-7.el7_7.noarch
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
---> Package python3-wheel.noarch 0:0.31.1-5.el7_7 will be installed
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-13.el7 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.6.8-13.el7 for package: python3-3.6.8-13.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-13.el7.x86_64
--> Running transaction check
---> Package python3-libs.x86_64 0:3.6.8-13.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================
Package                              Arch                     Version                             Repository                 Size
===================================================================================================================================
Installing:
python3-pip                          noarch                   9.0.3-7.el7_7                       updates                   1.8 M
python3-setuptools                   noarch                   39.2.0-10.el7                       base                      629 k
python3-wheel                        noarch                   0.31.1-5.el7_7                      base                       63 k
Installing for dependencies:
python3                              x86_64                   3.6.8-13.el7                        base                       69 k
python3-libs                         x86_64                   3.6.8-13.el7                        base                      7.0 M
Transaction Summary
===================================================================================================================================
Install  3 Packages (+2 Dependent packages)
Total download size: 9.5 M
Installed size: 48 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/python3-3.6.8-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for python3-3.6.8-13.el7.x86_64.rpm is not installed
(1/5): python3-3.6.8-13.el7.x86_64.rpm                                                                      |  69 kB  00:00:00     
(2/5): python3-wheel-0.31.1-5.el7_7.noarch.rpm                                                              |  63 kB  00:00:00     
(3/5): python3-setuptools-39.2.0-10.el7.noarch.rpm                                                          | 629 kB  00:00:01     
Public key for python3-pip-9.0.3-7.el7_7.noarch.rpm is not installed==-                          ] 897 kB/s | 3.4 MB  00:00:06 ETA
(4/5): python3-pip-9.0.3-7.el7_7.noarch.rpm                                                                 | 1.8 MB  00:00:02     
(5/5): python3-libs-3.6.8-13.el7.x86_64.rpm                                                                 | 7.0 MB  00:00:04     
-----------------------------------------------------------------------------------------------------------------------------------
Total                                                                                              1.9 MB/s | 9.5 MB  00:00:05     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) "
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python3-setuptools-39.2.0-10.el7.noarch                                                                         1/5
  Installing : python3-libs-3.6.8-13.el7.x86_64                                                                                2/5
  Installing : python3-3.6.8-13.el7.x86_64                                                                                     3/5
  Installing : python3-pip-9.0.3-7.el7_7.noarch                                                                                4/5
  Installing : python3-wheel-0.31.1-5.el7_7.noarch                                                                             5/5
  Verifying  : python3-pip-9.0.3-7.el7_7.noarch                                                                                1/5
  Verifying  : python3-3.6.8-13.el7.x86_64                                                                                     2/5
  Verifying  : python3-wheel-0.31.1-5.el7_7.noarch                                                                             3/5
  Verifying  : python3-setuptools-39.2.0-10.el7.noarch                                                                         4/5
  Verifying  : python3-libs-3.6.8-13.el7.x86_64                                                                                5/5
Installed:
  python3-pip.noarch 0:9.0.3-7.el7_7      python3-setuptools.noarch 0:39.2.0-10.el7      python3-wheel.noarch 0:0.31.1-5.el7_7     
Dependency Installed:
  python3.x86_64 0:3.6.8-13.el7                                 python3-libs.x86_64 0:3.6.8-13.el7                                
Complete!

由于 CentOS7 默认安装了 Python2.7,直接敲命令 python3 直接进入 python 交互式环境,默认安装了 Python3.6.8。因为 openGauss 依赖 Python3 环境,故需要安装 Python3.6,也是建议按照此版本。下面检查一下python好使不?

[root@openGauss opt]# python3
Python 3.6.8 (default, Apr  2 2020, 13:34:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
[root@openGauss opt]# python2
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> quit()
[root@openGauss opt]# python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
[root@openGauss opt]# which python
/usr/bin/python
[root@openGauss opt]# which python2
/usr/bin/python2
[root@openGauss opt]# which python3
/usr/bin/python3
[root@openGauss opt]# cd /usr/bin
[root@openGauss bin]# ll python*
lrwxrwxrwx. 1 root root     7 Jul  8 21:42 python -> python2
lrwxrwxrwx. 1 root root     9 Jul  8 21:42 python2 -> python2.7
-rwxr-xr-x. 1 root root  7216 Oct 31  2018 python2.7
lrwxrwxrwx. 1 root root     9 Jul 11 18:57 python3 -> python3.6
-rwxr-xr-x. 2 root root 11336 Apr  2 21:37 python3.6
-rwxr-xr-x. 2 root root 11336 Apr  2 21:37 python3.6m

好使之后,进行下一步软件包的安装,这里有些不可用,但没有关系,如下:

[root@openGauss yum.repos.d]# yum install -y libaio-devel \ flex \ bison \ ncurses-devel \ glibc-devel \ patch \ lsb_release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
No package  flex available.
No package  bison available.
No package  ncurses-devel available.
No package  glibc-devel available.
No package  patch available.
No package  lsb_release available.
Resolving Dependencies
--> Running transaction check
---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================
Package                           Arch                        Version                             Repository                 Size
===================================================================================================================================
Installing:
libaio-devel                      x86_64                      0.3.109-13.el7                      base                       13 k
Transaction Summary
===================================================================================================================================
Install  1 Package
Total download size: 13 k
Installed size: 7.8 k
Downloading packages:
libaio-devel-0.3.109-13.el7.x86_64.rpm                                                                      |  13 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libaio-devel-0.3.109-13.el7.x86_64                                                                              1/1
  Verifying  : libaio-devel-0.3.109-13.el7.x86_64                                                                              1/1
Installed:
  libaio-devel.x86_64 0:0.3.109-13.el7                                                                                             
Complete!

我们linux的最大权限用户是root,想一下mysql,我们是不是为它创建了一个叫mysql的用户,并且给了他一个用户组,然后专门管理mysql数据库,同理Gauss数据库也是这么做的。官方默认以dbgrp为用户组,omm为用户。
在这里插入图片描述
然后我们为openGauss建一个目录,用来存放openGauss的压缩包以及该压缩包解压后的文件,如下图路径,利用fileziila这个工具将压缩包上传至指定目录,然后用解压命令解压至当前文件夹,那些script之类的就是解压出来的!!
openGauss保姆式安装说明_第3张图片
然后关键一步是对该openGauss设定读写权限!!
chmod -R 755 /opt/software/openGauss

然后查看script的预安装脚本:
在这里插入图片描述
openGauss保姆式安装说明_第4张图片
如上图,我们可以看到Preinstall这个类的初始化方法里有很多参数是默认值,很明显我们要对其进行传入,那要怎么传入呢?这里我们先通过编写一个xml文件,然后用命令传入一些参数,让预安装脚本顺利执行,如下图:
在这里插入图片描述
注意此xml在openGauss目录下。

"1.0" encoding="UTF-8"?>

  <!-- 整体信息 -->
  
  <!-- 数据库名称 -->
    <PARAM name="clusterName" value="opengauss" />
  <!-- 数据库节点名称(hostname) -->
    <PARAM name="nodeNames" value="localhost.localdomain" />
  <!-- 节点IP,与nodeNames一一对应 -->
    <PARAM name="backIp1s" value="192.168.111.3"/>
  <!-- 数据库安装目录-->
    <PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
  <!-- 日志目录-->
    <PARAM name="gaussdbLogPath" value="/var/log/omm" />
  <!-- 临时文件目录-->
    <PARAM name="tmpMppdbPath" value="/opt/huawei/tmp" />
  <!--数据库工具目录-->
    <PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
  <!--数据库core文件目录-->
    <PARAM name="corePath" value="/opt/huawei/corefile"/>
  <!-- openGauss类型,此处示例为单机类型,“single-inst”表示单机一主多备部署形态-->
    <PARAM name="clusterType" value="single-inst"/>
  </CLUSTER>
  <!-- 每台服务器上的节点部署信息 -->
  
      <!-- node1上的节点部署信息 -->
      "1000001">
          <!-- node1的hostname -->
          <PARAM name="name" value="openGauss"/>
          <!-- node1所在的AZ及AZ优先级 -->
          <PARAM name="azName" value="AZ1"/>
          <PARAM name="azPriority" value="1"/>
          <!-- node1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
          <PARAM name="backIp1" value="192.168.111.3"/>
          <PARAM name="sshIp1" value="192.168.111.3"/>
          <!--DBnode-->
          <PARAM name="dataNum" value="1"/>
          <!--DBnode端口号-->
          <PARAM name="dataPortBase" value="26000"/>
          <!--DBnode主节点上数据目录,及备机数据目录-->
          <PARAM name="dataNode1" value="/opt/huawei/install/data/db1"/>
          <!--DBnode节点上设定同步模式的节点数-->
          <!--><PARAM name="dataNode1_syncNum" value="0"/><-->
      </DEVICE>
  </DEVICELIST>
</ROOT>

特别提醒,xml里面有大坑!!!如下图:
openGauss保姆式安装说明_第5张图片
那两个箭头所指的value要保持一致,且value的值为你的主机名,不然他会报错,会报你的主机名不在这个集群。然后红框框起来的里面的路径,千万千万不能在openGauss下,不然会有各种权限错误,这里的huawei目录与openGauss目录平级,且日志路径最好跟我一致。然后可以不用提前创建这些文件夹,因为后面执行脚本的时候会自动创建这些目录。
openGauss保姆式安装说明_第6张图片
如上图,后半部分xml同理!!尤其是那个db1的路径!!!

然后为确保 openssl 版本正确,执行预安装前请加载安装包中 lib 库,如果不搞这个,那么后面的所有验证全部失败!!
vim /etc/profile
然后在里面添加如下图箭头所示命令,记得保存,然后source一下。
openGauss保姆式安装说明_第7张图片
注意:如果是 openEuler 的操作系统,需要修改 /etc/profile.d/performance.sh 文件
使用#注释sysctl -w vm.min_free_kbytes=112640 &> /dev/null

gs_preinstall 为 Python 脚本,查看脚本内容为集群环境配置脚本 “environment for a cluster”,会设置 root 用户互信然后新建 omm 用户 dbgrp 组并配置互信,检查操作系统版本,创建路径,设置系统参数,配置环境变量 /etc/profile 以及 omm 用户的 .bashrc 环境变量 等等,我们在上一张图看到的箭头所指的那一行的下面的几行全是这个脚本的功劳!!

使用 gs_preinstall 的目的就是准备好安装环境,类似于 Oracle 的 preinstall-19c.rpm 包 。这里采用交互模式执行前置,并在执行过程中自动创建 root 用户互信和 openGauss 用户互信等一些信息,详细内容请看如下执行过程。

./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml

然后由于是交互式的方法,我们要根据命令提示来手动传入参数,看下面的命令运行结果:

[root@openGauss script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/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:             --输入 root 密码开始配置互信
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.  --创建 omm 用户,这里需要两次输入密码 openGauss_1 然后开始配置互信
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
Please enter password for cluster user.
Password:
Please enter password for cluster user again.
Password:
Successfully created [omm] user on all nodes.
Preparing SSH service.
(此处省略1万字)

如下图看到succeed就说明预安装已完成。
openGauss保姆式安装说明_第8张图片
通过 openGauss 提供的 gs_checkos 工具可以完成系统状态检查。

◾ 以 root 用户身份登录。

◾ 执行如下命令对 openGauss 节点服务器的 OS 参数进行检查。

[root@openGauss opt]# 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 ]                    : Warning
    A7. [ File system configuration status ]                    : Warning
    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

以上就是预安装!

正式安装

切换到 omm 用户,使用 gs_install -X +xml 配置文件进行安装。

  [root@openGauss opt]# su - omm
    Last login: Sat Jul 11 16:09:59 CST 2020 on pts/2
    [omm@openGauss ~]$
    [omm@openGauss ~]$ env | grep GAUSS
    GAUSS_VERSION=1.0.0
    GAUSSHOME=/opt/huawei/install/app
    GAUSS_ENV=1
    GAUSSLOG=/var/log/omm/omm
    [omm@openGauss ~]$ gs_install -X /opt/software/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 /opt/huawei/install/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.
    Configuring pg_hba on all nodes.
    Configuration is completed.
    [GAUSS-51400] : Failed to execute the command: source /home/omm/.bashrc;python3 '/opt/gaussdb/install/om/script/local/Install.py' -t start_cluster -U omm:dbgrp -X /opt/openGauss/clusterconfig.xml -R /opt/gaussdb/install/app -c opengauss -l /var/log/omm/omm/om/gs_local.log  --alarm=/opt/huawei/snas/bin/snas_cm_cmd  --time_out=300 .Error:
    Using omm:dbgrp to install database.
    Using installation program path : /opt/gaussdb/install/app_0bd0ce80
    $GAUSSHOME points to /opt/gaussdb/install/app_0bd0ce80, no need to create symbolic link.
    Traceback (most recent call last):
      File "/opt/gaussdb/install/om/script/local/Install.py", line 645, in 
        functionDict[g_opts.action]()
      File "/opt/gaussdb/install/om/script/local/Install.py", line 588, in startCluster
        dn.start(self.time_out)
      File "/opt/gaussdb/install/om/script/local/../gspylib/component/Kernel/Kernel.py", line 87, in start
        + " Error: Please check the gs_ctl log for "
    Exception: [GAUSS-51607] : Failed to start instance. Error: Please check the gs_ctl log for failure details.
    [GAUSS-51607] : Failed to start instance. Error: Please check the gs_ctl log for failure details.

/opt/software/openGauss/script/clusterconfig.xml为openGauss配置文件的路径。在执行过程中,用户需根据提示输入数据库的密码,密码具有一定的复杂度,为保证用户正常使用该数据库,请记住输入的数据库密码。

设置的密码要符合复杂度要求:

最少包含8个字符;
不能和用户名和当前密码(ALTER)相同,或和当前密码反序;
至少包含大写字母(A-Z),小写字母(a-z),数字,非字母数字字符(限定为~!@#$%^&*()-_=+|[{}];:,<.>/?)四类字符中的三类字符。
安装过程中会生成ssl证书,证书存放路径为{gaussdbAppPath}/share/sslcert/om,其中{gaussdbAppPath}为集群openGauss配置文件中指定的程序安装目录。

日志文件路径下会生成两个日志文件:“gs_install-YYYY-MMDD_HHMMSS.log”和“gs_local-YYYY-MM-DD_HHMMSS.log”。

然后启动数据库

[omm@openGauss ~]$ gs_om -t start
Starting cluster.
=========================================
[GAUSS-53600]: Can not start the database, the cmd is source /home/omm/.bashrc; python3 '/opt/gaussdb/install/om/script/local/StartInstance.py' -U omm -R /opt/gaussdb/install/app -t 300 --security-mode=off,  Error:
[FAILURE] openGauss:
[GAUSS-51607] : Failed to start instance. Error: Please check the gs_ctl log for failure details..

上面是报错的情况,那么我们加点参数看看哪里报错?

[omm@openGauss ~]$ gs_ctl start -D /opt/gaussdb/install/data/db1
[2020-07-12 00:16:01.408][65296][][gs_ctl]: gs_ctl started,datadir is -D "/opt/gaussdb/install/data/db1"  
[2020-07-12 00:16:01.535][65296][][gs_ctl]: waiting for server to start...
.0 [BACKEND] LOG:  Begin to start openGauss Database.
2020-07-12 00:16:01.850 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 DB001 0 [REDO] LOG:  Recovery parallelism, cpu count = 4, max = 4, actual = 4
2020-07-12 00:16:01.850 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 DB001 0 [REDO] LOG:  ConfigRecoveryParallelism, true_max_recovery_parallelism:4, max_recovery_parallelism:4
2020-07-12 00:16:01.850 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 00000 0 [BACKEND] LOG:  gaussdb.state does not exist, and skipt setting since it is optional.
2020-07-12 00:16:01.850 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 00000 0 [BACKEND] LOG:  Transparent encryption disabled.
2020-07-12 00:16:01.890 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2020-07-12 00:16:01.898 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 00000 0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2020-07-12 00:16:01.899 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING:  Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (1024 Mbytes) or shared memory (4213 Mbytes) is larger.
2020-07-12 00:16:01.899 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 42809 0 [BACKEND] FATAL:  could not create shared memory segment: Cannot allocate memory
2020-07-12 00:16:01.899 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 42809 0 [BACKEND] DETAIL:  Failed system call was shmget(key=26000001, size=4418076672, 03600).
2020-07-12 00:16:01.899 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 42809 0 [BACKEND] HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space, or exceeded your kernel's SHMALL parameter.  You can either reduce the request size or reconfigure the kernel with larger SHMALL.  To reduce the request size (currently 4418076672 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers.
        The PostgreSQL documentation contains more information about shared memory configuration.
2020-07-12 00:16:01.916 5f09e5c1.1 [unknown] 140308361469696 [unknown] 0 dn_6001 00000 0 [BACKEND] LOG:  FiniNuma allocIndex: 0.
[2020-07-12 00:16:02.537][65296][][gs_ctl]:  waitpid 65306 failed, exitstatus is 256, ret is 2
[2020-07-12 00:16:02.538][65296][][gs_ctl]: stopped waiting
[2020-07-12 00:16:02.538][65296][][gs_ctl]: could not start server
[2020-07-12 00:16:02.538][65296][][gs_ctl]: Examine the log output.

这里就有大坑,最大的坑!!!我们看上面报的错,有一行是因为不能分配内存片导致的错误,那么我们就去配置文件里改大小!!如下图:值得注意的是该配置文件名字叫postgresql.conf,显然openGauss的内核是postgresql这个数据库,我箭头所指的共享缓冲默认是512MB,如果你报错是由于内存大小的原因,就把这个改小一点,我这就改的很小了,然后重新启动
openGauss保姆式安装说明_第9张图片
【注意】从这开始修改参数的命令都要切回root权限,然后开启数据库要切换回omm,记得修改完之后最好重启一下虚拟机。
如果还不能成功启动,那么报错里面还会有一条信息,大概的意思是内核某个参数太小了,看下面的操作:
$ sysctl -w kernel.shmmax = 17179869184
$ sysctl -w kernel.shmall = 4194304
$ echo 17179869184>/proc/sys/kernel/shmmax
$ echo 4194304> /proc/sys/kernel/shmall
当内核参数配置有问题时,可能会出现postgres服务无法启动。

然后再次尝试启动,如果还报错就应该是信号量问题了,看下面报错的样子:

FATAL:  could not create semaphores: No space left on device
DETAIL:  Failed system call was semget(5440126, 17, 03600).

上述错误并不意味着您的磁盘空间不足。 这意味着你的内核对System V信号量的限制
比PostgreSQL想要创建的数量要小。 如上所述,您可能可以通过减少允许的连接数(max_connections)
来启动服务器来解决问题,但是最终还是希望增加内核限制。

所以把信号量上限调大点,执行下面这条命令:
sysctl -w kernel.sem="500 5120000 2500 9000"
然后再启动!!!!如下图,大功告成!!!
openGauss保姆式安装说明_第10张图片

收尾工作

正常启动关闭,连接到数据库:
关闭启动数据库,查看进程:
openGauss保姆式安装说明_第11张图片
查看openGauss的各实例状态:
openGauss保姆式安装说明_第12张图片
需重置用户密码,登陆进来之后,由于安全问题还需要重置密码,而且新密码和旧密码不能一样,注意密码复杂度要求。
openGauss保姆式安装说明_第13张图片
如上图,被替换的密码不是最开始的1234,而是如下图所示:
(往上翻,之前有一步设置了一个很难的密码)
openGauss保姆式安装说明_第14张图片

检查数据库状态,性能

gs_om -t status --detail

gs_om -t status -all

gs_checkperf

[omm@openGauss ~]$ gs_checkperf
Cluster statistics information:
    Host CPU busy time ratio                     :    3.19       %
    MPPDB CPU time % in busy time                :    10.73      %
    Shared Buffer Hit ratio                      :    98.80      %
    In-memory sort ratio                         :    0
    Physical Reads                               :    377
    Physical Writes                              :    144
    DB size                                      :    28         MB
    Total Physical writes                        :    144
    Active SQL count                             :    3
    Session count                                :    4

连接到数据库简单应用

当使用 gsql 客户端连接到数据库时,默认连接到 postgres 数据库,使用 “\l” 列出所有数据库, “\d” 列出当前数据库所有的表,“\q” 退出客户端连接。由于 openGauss 是基于 postgresql 9.2.4 开发的,很多命令都和 pg 很类似,可直接使用。

[omm@openGauss ~]$  gsql -d postgres -p 26000
gsql ((openGauss 1.0.0 build 0bd0ce80) compiled at 2020-06-30 18:19:27 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=# help
You are using gsql, the command-line interface to gaussdb.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with gsql commands
       \g or terminate with semicolon to execute query
       \q to quit
postgres=# SHOW server_version;
server_version
----------------
9.2.4
(1 row)
---查看数据库
postgres=# \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)
---某一个参数查看,全部参数查看使用 SHOW ALL;
postgres=#  SELECT * FROM pg_settings WHERE NAME='server_version';
      name      | setting | unit |    category    |        short_desc         | extra_desc | context  | vartype | source  | min_val
| max_val | enumvals | boot_val | reset_val | sourcefile | sourceline
----------------+---------+------+----------------+---------------------------+------------+----------+---------+---------+--------
-+---------+----------+----------+-----------+------------+------------
server_version | 9.2.4   |      | Preset Options | Shows the server version. |            | internal | string  | default |        
|         |          | 9.2.4    | 9.2.4     |            |           
(1 row)
-- 查看当前库下的所有表
postgres=# \d
No relations found.
postgres=# create table jikexu(id int primary key,name varchar(40));
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "jikexu_pkey" for table "jikexu"
CREATE TABLE
postgres=# \d
                         List of relations
Schema |  Name  | Type  | Owner |             Storage              
--------+--------+-------+-------+----------------------------------
public | jikexu | table | omm   | {
     orientation=row,compression=no}
(1 row)

好了,以上就是openGauss的入门,我们一起研究AI4DB!!

你可能感兴趣的:(Gauss,DB,CCF-华为数据库创新计划,华为,数据库)