【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南

老老老JR老北
发布于 2023-8-29 15:43
浏览
0收藏

前言

还记得,上次不经意间在墨天轮社区学习 openGauss 还是openGauss 3.0.0数据库的时候呢,现在已经更新到openGauss 5.0.0 版本了。今年3月openGauss 5.0发布,升级了资源池化内核能力和DataKit数据全生命周期管理工具,整体在性能、安全性与易用性方面均有大幅提升。openGauss覆盖场景从服务器、边缘扩展到嵌入式,场景更加丰富。今天我来就体验一下 openGauss 5.0.0 极简版的安装和配置。

了解openGauss

openGauss是一款全面友好开放,携手伙伴共同打造的企业级开源关系型数据库。openGauss提供面向多核架构的极致性能、全链路的业务、数据安全、基于AI的调优和高效运维的能力。openGauss深度融合华为在数据库领域多年的研发经验,结合企业级场景需求,持续构建竞争力特性。openGauss网站 (https://opengauss.org/zh/ ) 提供了有关openGauss软件的最新信息。

  • openGauss是一个数据库管理系统。
  • openGauss数据库是关系型的。
  • openGauss软件是开源的。

开源意味着任何人都可以使用和修改软件,任何人都可以下载openGauss软件并使用它,而无需支付任何费用。

openGauss数据库具有高性能、高可用、高安全、易运维、全开放的特点。

一、安装 openGauss 系统环境配置

openGauss极简安装的环境准备和配置,极简安装包括单节点安装和一主一备节点安装,请在安装之前仔细阅读本章的内容。如果已完成本章节的配置,请忽略。

1、获取极简版安装包

openGauss开源社区上提供了安装包的获取方式。准备软硬件安装环境

1.1 获取安装包

从openGauss开源社区下载对应平台的安装包。

https://www.opengauss.org/zh/download/

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

登录openGauss开源社区,选择对应平台的最新安装包下载。对于个人开发者或非企业级环境,下载极简安装包(不安装OM等组件)即可。

单击“下载”。

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

检查安装包。

1.2 查看极简版安装指南

https://docs.opengauss.org/zh/docs/5.0.0/docs/InstallationGuide/%E6%9E%81%E7%AE%80%E7%89%

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

2、准备软硬件安装环境

openGauss服务器应具备的最低硬件要求。在实际产品中,硬件配置的规划需考虑数据规模及所期望的数据库响应速度。请根据实际情况进行规划。

2.1 硬件环境要求

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

2.2 软件环境要求

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

3、修改操作系统配置

注意:

以下动作需要以root用户进行操作操作完成后请及时注销root用户,避免误操作。

4、关闭操作系统防火墙

为了在防火墙开启的状态下,确保openGauss的正常使用,用户需要将同openGauss相关的服务、协议、IP以及端口添加到openGauss主机的防火墙白名单中。

4.1 修改/etc/selinux/config文件中的“SELINUX”值为“disabled”。

a. 使用VIM打开config文件。

vim /etc/selinux/config

b. 修改“SELINUX”的值“disabled”,执行**:wq**保存并退出修改。

SELINUX=disabled

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

4.2 检查防火墙是否关闭。

systemctl status firewalld

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

若防火墙状态显示为active (running),则表示防火墙未关闭,请执行关闭;

若防火墙状态显示为inactive (dead),则无需再关闭防火墙。

5、关闭防火墙。

systemctl disable firewalld.service
systemctl stop firewalld.service

二、单节点安装极简版 openGauss 5.0.0

1、解压安装包

使用普通用户登录到 openGauss 极简版包安装的主机,解压极简版安装包到安装目录。在安装包所在目录执行以下命令:

[root@master1 data]# su omm
[omm@master1 data]$ sudo mkdir openGauss
[omm@master1 data]$ tar -jxf openGauss-5.0.0-CentOS-64bit.tar.bz2 -C /opt/software/openGauss/
[omm@master1 data]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

ls -lb openGauss/

2、执行ls命令,显示类似如下信息:

[omm@master1 openGauss]$ ls -lb
total 32
drwxr-xr-x 2 omm omm 4096 Mar 29 03:20 bin
drwxr-xr-x 3 omm omm 4096 Mar 29 03:20 etc
drwxr-xr-x 3 omm omm 4096 Mar 29 03:20 include
drwxr-xr-x 4 omm omm 4096 Mar 29 03:20 jre
drwxr-xr-x 5 omm omm 4096 Mar 29 03:20 lib
drwxr-xr-x 5 omm omm 4096 Mar 29 03:20 share
drwxr-xr-x 2 omm omm 4096 Mar 29 03:20 simpleInstall
-rw-r--r-- 1 omm omm   32 Mar 29 03:20 version.cfg
[omm@master1 openGauss]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

3、解压包的路径为/data/openGauss,进入解压后目录下的simpleInstall。

[omm@master1 openGauss]$ cd simpleInstall/
[omm@master1 simpleInstall]$ ls
finance.sql  install.sh  README.md  school.sql
[omm@master1 simpleInstall]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

4、执行install.sh脚本安装openGauss安装包。

[omm@master1 simpleInstall]$ sh install.sh  -w "Kunpeng@0715" &&source ~/.bashrc
[step 1]: check parameter
[step 2]: check install env and os setting
[step 3]: change_gausshome_owner
[step 4]: set environment variables

/home/omm/.bashrc: line 16: ulimit: open files: cannot modify limit: Operation not permitted
[step 6]: init datanode
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.

直到出现
Would you like to create a demo database (yes/no)? yes
Load demoDB [school,finance] success.
[complete successfully]: You can start or stop the database server using:
    gs_ctl start|stop|restart -D $GAUSSHOME/data/single_node -Z single_node

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

说明

-w:初始化数据库密码(gs_initdb指定),因安全需要,此项必须设置。

-p:指定openGauss端口号,如不指定,默认为5432。

-h|–help:打印使用说明。

安装后,该数据库部署节点的名称为sgnode(gs_initdb指定)。

执行时,如果出现报错“the maximum number of SEMMNI is not correct, the current SEMMNI is xxx. Please check it.”,请使用有root权限的用户执行如下命令。

5、安装执行完成后,使用ps和gs_ctl查看进程是否正常。

ps ux | grep gaussdbgs_ctl query -D /opt/software/openGauss/data/single_node

执行ps命令,显示类似如下信息:

[omm@master1 simpleInstall]$ ps ux | grep gaussdb
omm       53194  2.8  2.5 6201936 832576 ?      Ssl  22:28   0:05 /opt/software/openGauss/bin/gaussdb -D /opt/software/openGauss/data/single_node
omm       54114  0.0  0.0 110480   908 pts/0    S+   22:31   0:00 grep --color=auto gaussdb

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

执行gs_ctl命令,显示类似如下信息:

[omm@master1 simpleInstall]$ gs_ctl query -D /opt/software/openGauss/data/single_node
[2023-07-18 22:31:59.874][54137][][gs_ctl]: gs_ctl query ,datadir is /opt/software/openGauss/data/single_node 
 HA state:           
	local_role                     : Normal
	static_connections             : 0
	db_state                       : Normal
	detail_information             : Normal

 Senders info:       
No information 
 Receiver info:      
No information 
[omm@master1 simpleInstall]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

6、使用gs_ctl 查看数据文件的目录

[omm@master1 ~]$ gs_ctl notify
[2023-07-19 09:11:20.012][92324][][gs_ctl]: gs_ctl notify ,datadir is /opt/software/openGauss/data 
[2023-07-19 09:11:20.012][92324][][gs_ctl]: the parameter of notify must be specified
[omm@master1 ~]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

7、编辑环境变量查看数据文件的目录

[omm@master1 ~]$ vim .bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export GAUSSHOME=/opt/software/openGauss
export PATH=$GAUSSHOME/bin:$PATH
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
export GS_CLUSTER_NAME=dbCluster
export PGDATA=/opt/software/openGauss/data
ulimit -n 1000000

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

8、查看环境变量数据文件的目录

[omm@master1 ~]$ grep -i PGDATA ~/.bashrc
export PGDATA=/opt/software/openGauss/data
[omm@master1 ~]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

9、连接数据库

[omm@master1 ~]$ gsql -d postgres
gsql ((openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:07:56 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=#

创建用户组dbgroup。

[root@master1 data]# groupadd dbgroup
[root@master1 data]#

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

创建用户组dbgroup下的普通用户omm,并设置普通用户omm的密码,密码建议设置为omm@123。

[root@master1 data]# useradd -g dbgroup omm
[root@master1 data]# passwd omm
Changing password for user omm.
New password: 
BAD PASSWORD: The password contains the user name in some form
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@master1 data]#

三、安装中遇到的报错

1、无法使用 root 安装 openGauss

[root@master1 simpleInstall]# sh install.sh  -w "Kunpeng@0715" &&source ~/.bashrc
[step 1]: check parameter
Error: can not install openGauss with root

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

解决办法:
切换普通用户就可以解决

[root@master1 data]# su omm

2、无法进入 openGauss 文件目录

[omm@master1 openGauss]$ cd simpleInstall/
bash: cd: simpleInstall/: Permission denied

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

解决办法:在 root 账号下授权目录普通用户权限

[root@master1 data]# chown -R omm.omm openGauss
[root@master1 data]# 
[root@master1 data]# su omm
[omm@master1 data]$ cd openGauss/
[omm@master1 openGauss]$ ls
bin  etc  include  jre  lib  share  simpleInstall  version.cfg
[omm@master1 openGauss]$ cd simpleInstall/
[omm@master1 simpleInstall]$ ls
finance.sql  install.sh  README.md  school.sql
[omm@master1 simpleInstall]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

3、安装出现报错 “the maximum number of SEMMNI is not correct”

[omm@master1 simpleInstall]$ sh install.sh  -w "Kunpeng@0715" &&source ~/.bashrc
[step 1]: check parameter
[step 2]: check install env and os setting
On systemwide basis, the maximum number of SEMMNI is not correct. the current SEMMNI value is: 128. Please check it.
The required value should be greater than 321. You can modify it in file '/etc/sysctl.conf'.
[omm@master1 simpleInstall]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

执行时,如果出现报错“the maximum number of SEMMNI is not correct, the current SEMMNI is xxx. Please check it.”,请使用有root权限的用户执行如下命令。

[omm@master1 simpleInstall]$ sudo sysctl -w kernel.sem="250 85000 250 330" 
[sudo] password for omm: 
kernel.sem = 250 85000 250 330
[omm@master1 simpleInstall]$

4、使用pg_ctl启动数据库时出现报错:

[omm@master1 simpleInstall]$ gs_ctl status
[2023-07-19 09:04:51.833][90515][][gs_ctl]:  no database directory specified and environment variable PGDATA unset
Try "gs_ctl --help" for more information.
[omm@master1 simpleInstall]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

通过报错信息我们可以得知是没有在环境变量中设置PGDATA变量。

解决办法:编辑操作系统数据库管理员的用户配置文件。

[highgo@db1 ~]$ vi ~/.bash_profile

按照实际路径在用户配置文件中添加PGDATA变量。默认该路径在数据库软件安装路径下的data目录。

[omm@master1 data]$ cd ~
[omm@master1 ~]$ vi ~/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export PGDATA=/opt/software/openGauss/data

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区

重新加载用户配置信息

[omm@master1 ~]$ . ~/.bash_profile

检查

[omm@master1 ~]$ gs_ctl status
[2023-07-19 09:08:42.706][91569][][gs_ctl]: gs_ctl status,datadir is /opt/software/openGauss/data 
no server running
[omm@master1 ~]$

【我和openGauss的故事】体验openGauss 5.0.0 单机极简版安装指南-鸿蒙开发者社区




文章转载自公众号:openGauss


分类
标签
已于2023-8-29 15:43:00修改
收藏
回复
举报
1条回复
按时间正序
/
按时间倒序
wx6576ac34e0767
wx6576ac34e0767

写的什么

回复
2023-12-13 16:03:35
回复
    相关推荐