openGauss学习笔记从0开始(单机安装)

2023年 11月 17日 86.1k 0

缘起,2021 年底有个客户计划采购华为的分布式数据库 GuassDB(openGauss),于是去官方翻了翻文档,发现有点难以理解,我本人之前对 PG 派系的数据库一无所知,看上去就更吃力。后来客户选择了其他厂商的分布式数据库也就没有进行学习研究。

第二次接触 openGauss 是通过 MogDB 的征文活动,不仅可以学习 MogDB 数据库,还能赚几包烟钱,写了十多篇学习笔记,对 MogDB 有了一个大致的了解,因为 MogDB 是 openGauss 的一个商业发行版本,在学习的时候也去翻阅了一些 openGauss 的支持,所有也算间接的学习了 openGauss。

第三次接触就是现在和将来,感谢官方推出了这次的征文活动,既可以学习 opengauss 又可以加深自己对 MogDB 的了解,学习的过程还能顺便买一包烟。本人也想通过这两次学习,可以进一步学习华为的分布式数据库 GuassDB for openGauss。

高可用、高性能、主从、备份恢复等概念所有的关系型数据基本一致,这里学习还是本着先实战再总结的思路出发,附一张我本人 openGauss 的学习图谱,IT 圈子里一直有一个 PG 和 Mysql 孰高孰低的讨论,为什么总是对比这两个关系型数据库,个人认为因为他们量级差不多,并且都是开源,很多理念都有一些相同的架构。

安装企业版

1、准备 Linux 服务器

这里就不在赘述 Linux 的安装和配置了,可以参考《https://www.modb.pro/db/453770》,我的 Linux 操作系统是 CentOS,选择操作系统的时候候去官网查看支持的操作系统。

2、下载 openGauss 数据库企业版

下载地址:https://opengauss.org/zh/download/

3、上传包并解压

[root@localhost ~]# cd /soft/
[root@localhost soft]# ls
openGauss-3.0.0-CentOS-64bit-all.tar.gz
[root@localhost soft]# tar -zxvf openGauss-3.0.0-CentOS-64bit-all.tar.gz
openGauss-3.0.0-CentOS-64bit-cm.tar.gz
openGauss-3.0.0-CentOS-64bit-om.tar.gz
openGauss-3.0.0-CentOS-64bit.tar.bz2
openGauss-3.0.0-CentOS-64bit-cm.sha256
openGauss-3.0.0-CentOS-64bit-om.sha256
openGauss-3.0.0-CentOS-64bit.sha256
upgrade_sql.tar.gz
upgrade_sql.sha256

4、安装依赖包

yum install libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel libnsl python3

5、关闭防火墙

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

6、禁用 selinux

vi /etc/selinux/config #修改“SELINUX”的值“disabled” #需要重启生效,也可以使用命令临时生效:setenforce 0

7、配置本机 root 到 root 的互信

[root@localhost ~]# ssh-keygen -t rsa
[root@localhost ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys #使用 ssh 命令不需要输入密码的时候就表示互信成功
[root@localhost .ssh]# ssh ***.***.***.***Last login: Wed Sep 14 17:40:53 2022 from opengauss

8、创建安装 openGauss 的配置文件

#单节点安装
[root@opengauss soft]# cat cluster_config.xml

9、解压可执行程序所在的包

tar -zxvf openGauss-3.0.0-CentOS-64bit-all.tar.gz
tar -zxvf openGauss-3.0.0-CentOS-64bit-om.tar.gz #会解压出 script 文件夹

10、执行预安装 #进入刚才解压得到的 script 文件夹 cd /soft/script

./gs_preinstall -U omm -G dbgrp -X /soft/cluster_config.xml #期间只需要输入是否需要创建 omm 用户,选择 yes,并且输入 omm 的密码
[root@opengauss script]# ./gs_preinstall -U omm -G dbgrp -X /soft/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 "/soft/script/gs_checkos -i A -h opengauss --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.

11、执行安装

切换到 omm 用户,期间要输入数据库的密码

su - omm
[root@opengauss script]# su - omm
Last login: Wed Sep 14 18:50:50 CST 2022
[omm@opengauss ~]$ gs_install
[GAUSS-50001] : Incorrect parameter. Parameter '-X' is required.
[omm@opengauss ~]$ ^C
[omm@opengauss ~]$ gs_install -X /soft/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:
begin to create CA cert files
The sslcert will be generated in /opt/random/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@opengauss ~]$

12、连接数据库

[omm@opengauss ~]$ gsql -d postgres -p 15400
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=#

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论