猿创征文|国产数据库之opengauss的单机主备部署及快速入门(代码片段)

江湖有缘 江湖有缘     2022-10-23     667

关键词:

猿创征文 | 国产数据库之openGauss的单机主备部署及快速入门

一、openGauss介绍

1.openGauss简介

1.openGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。
2.openGauss是一款支持SQL2003标准语法,支持主备部署的高可用关系型数据库。

2.openGauss特点

1.高可靠:故障切换时间RTO<10s。
2.高性能:两路鲲鹏性能150万tpmC。
3.易运维:基于AI的智能参数调优。
4.高安全:端到端全方位安全防护。

3.openGauss的逻辑架构图

二、环境检查

1.节点规划

hostnameIP地址备注
master192.168.3.201极简版——一主一备节点

2.操作系统版本

[root@master ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

三、安装前环境配置

1.检查admin普通用户

[root@master simpleInstall]# id admin
uid=1000(admin) gid=1000(admin) groups=1000(admin)

2.给安装目录授权

chown  -R admin:admin /data/openGauss/
chown -R admin:admin /opt/software/openGauss

3.配置/etc/sysctl.conf文件

[root@master openGauss]# vim /etc/sysctl.conf 
[root@master openGauss]# cat /etc/sysctl.conf 
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward=1
kernel.sem = 250 32000 100 999
[root@master openGauss]# sysctl -p
net.ipv4.ip_forward = 1
kernel.sem = 250 32000 100 999

4.配置/etc/hosts

[root@master soft]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.3.201 master

四、下载openGauss软件包

1.进入官网下载

2.将软件包上传到master节点

[root@master soft]# pwd
/data/openGauss/soft
[root@master soft]# ll
total 87720
-rw-r--r-- 1 root root 89822788 Oct  3 17:19 openGauss-3.1.0-CentOS-64bit.tar.bz2


3.切换admin用户

[root@master openGauss]# su - admin
[admin@master ~]$ cd /data/openGauss/
[admin@master openGauss]$ ls
openGauss-3.1.0-CentOS-64bit.tar.bz2
[admin@master openGauss]$ pwd
/data/openGauss

4.解压软件包

[admin@master openGauss]$ tar -xjf openGauss-3.1.0-CentOS-64bit.tar.bz2  -C /opt/software/openGauss
[admin@master openGauss]$ ls /opt/software/openGauss/
bin  etc  include  jre  lib  share  simpleInstall  version.cfg




五、执行openGauss安装

1.进入simpleInstall目录

[admin@master openGauss]$ cd /opt/software/openGauss/simpleInstall/
[admin@master simpleInstall]$ ls
finance.sql  install.sh  README.md  school.sql




2.安装simpleInstall

sh install.sh  -w Admin.123456  --multinode

-w:初始化数据库密码(gs_initdb指定),安全需要必须设置。
-p:指定的openGauss主节点端口号,默认5432。备节点端口号会使用主端口号+200,默认5632。
–multinode:用来区分是单节点还是一主一备安装。

3.openGauss安装过程

[admin@master simpleInstall]$ sh install.sh  -w Admin.123456  --multinode
[step 1]: check parameter
[step 2]: check install env and os setting
[step 3]: change_gausshome_owner
[step 4]: set environment variables

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

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

creating directory /opt/software/openGauss/data/master ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
Begin init undo subsystem meta.
[INIT UNDO] Init undo subsystem meta successfully.
creating template1 database in /opt/software/openGauss/data/master/base/1 ... 2022-10-03 20:49:33.719 [unknown] [unknown] localhost 140536644539520 0[0:0#0]  [BACKEND] WARNING:  macAddr is 12/691646992, sysidentifier is 796985/2987452422, randomNum is 2160584710
ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
initialize global configure for bucketmap length ... ok
creating information schema ... ok
loading foreign-data wrapper for distfs access ... ok
loading foreign-data wrapper for log access ... ok
loading hstore extension ... ok
loading foreign-data wrapper for MOT access ... ok
loading security plugin ... ok
update system tables ... ok
creating snapshots catalog ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run gs_initdb.

Success. You can now start the database server of single node using:

    gaussdb -D /opt/software/openGauss/data/master --single_node
or
    gs_ctl start -D /opt/software/openGauss/data/master -Z single_node -l logfile

[init slave datanode.]
The files belonging to this database system will be owned by user "admin".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

creating directory /opt/software/openGauss/data/slave ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
Begin init undo subsystem meta.
[INIT UNDO] Init undo subsystem meta successfully.
creating template1 database in /opt/software/openGauss/data/slave/base/1 ... 2022-10-03 20:49:42.064 [unknown] [unknown] localhost 140200454964352 0[0:0#0]  [BACKEND] WARNING:  macAddr is 12/691646992, sysidentifier is 796985/2987423942, randomNum is 4257577158
ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
initialize global configure for bucketmap length ... ok
creating information schema ... ok
loading foreign-data wrapper for distfs access ... ok
loading foreign-data wrapper for log access ... ok
loading hstore extension ... ok
loading foreign-data wrapper for MOT access ... ok
loading security plugin ... ok
update system tables ... ok
creating snapshots catalog ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run gs_initdb.

Success. You can now start the database server of single node using:

    gaussdb -D /opt/software/openGauss/data/slave --single_node
or
    gs_ctl start -D /opt/software/openGauss/data/slave -Z single_node -l logfile

[config datanode.]
remote_read_mode = non_authentication
host    all             all             192.168.3.201/32            trust
[start primary datanode.]
[2022-10-03 20:49:49.982][10855][][gs_ctl]: gs_ctl started,datadir is /opt/software/openGauss/data/master 
[2022-10-03 20:49:50.012][10855][][gs_ctl]: waiting for server to start...
.0 LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.
	
0 LOG:  [Alarm Module]Host Name: master 
	
0 LOG:  [Alarm Module]Host IP: master. Copy hostname directly in case of taking 10s to use 'gethostbyname' when /etc/hosts does not contain <HOST IP>
	
0 LOG:  [Alarm Module]Cluster Name: dbCluster 
	
0 LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 57
	
0 WARNING:  failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING:  failed to parse feature control file: gaussdb.version.
0 WARNING:  Failed to load the product control file, so gaussdb cannot distinguish product version.
2022-10-03 20:49:50.078 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  when starting as multi_standby mode, we couldn't support data replicaton.
gaussdb.state does not exist, and skipt setting since it is optional.2022-10-03 20:49:50.085 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.
	
2022-10-03 20:49:50.085 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host Name: master 
	
2022-10-03 20:49:50.085 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host IP: master. Copy hostname directly in case of taking 10s to use 'gethostbyname' when /etc/hosts does not contain <HOST IP>
	
2022-10-03 20:49:50.085 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Cluster Name: dbCluster 
	
2022-10-03 20:49:50.085 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 57
	
2022-10-03 20:49:50.087 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  loaded library "security_plugin"
2022-10-03 20:49:50.088 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2022-10-03 20:49:50.089 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2022-10-03 20:49:50.089 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for backend threads is: 220 MB
2022-10-03 20:49:50.089 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for WAL buffers is: 128 MB
2022-10-03 20:49:50.089 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  Set max backend reserve memory is: 348 MB, max dynamic memory is: 11071 MB
2022-10-03 20:49:50.089 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [BACKEND] LOG:  shared memory 356 Mbytes, memory context 11419 Mbytes, max process memory 12288 Mbytes
2022-10-03 20:49:50.103 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [CACHE] LOG:  set data cache  size(402653184)
2022-10-03 20:49:50.128 [unknown] [unknown] localhost 140295358137472 0[0:0#0]  0 [SEGMENT_PAGE] LOG:  Segment-page constants: DF_MAP_SIZE: 8156, DF_MAP_BIT_CNT: 65248, DF_MAP_GROUP_EXTENTS: 4175872猿创征文|国产数据库实战之tidb数据库快速入门(代码片段)

猿创征文|国产数据库实战之TiDB数据库快速入门一、系统检查1.检查系统版本2.查看本地IP地址3.TiDB集群介绍二、快速部署本地测试集群1.安装TiUP工具2.声明全局环境变量3.快速部署TiDB集群三、连接TiDB数据库1.新开一个session以访问T... 查看详情

猿创征文|国产数据库实战之使用docker部署oceanbase数据库(代码片段)

猿创征文|国产数据库实战之使用Docker部署OceanBase数据库一、OceanBase介绍1.OceanBase介绍2.OceanBase特点3.OceanBase数据库基础概念4.OceanBase相关概念①OBServer②区域(zone)③资源池④租户⑤数据分区⑥副本5.本次实践介绍二、检查... 查看详情

猿创征文|国产数据库之在k8s环境下部署radondbmysql集群(代码片段)

猿创征文|国产数据库之在k8s环境下部署RadonDBMySQL集群一、RadonDBMySQL介绍1.RadonDBMySQL简介2.RadonDBMySQL的应用场景3.RadonDBMySQL核心功能4.RadonDBMySQL架构图二、检查本地k8s环境1.检查k8s节点状态2.检查helm版本三、添加helm仓库1.添加helm仓库... 查看详情

猿创征文|opengauss数据库从3.0.0升级到3.1.0操作实践(代码片段)

国产数据库openGauss9.30日新出了3.1.0版本,想必有些小伙伴已经迫不及待想尝试了吧。之前基于3.0.0版本进行了一些实践,本篇就详细介绍如何将openGauss数据库从3.0.0升级到3.1.0。目录升级流程升级前准备升级操作升级验证... 查看详情

猿创征文|国产数据库之使用pxd在docker环境下部署polardb-x集群(代码片段)

猿创征文|国产数据库之使用PXD在Docker环境下部署PolarDB-X集群一、PolarDB-X介绍1.PolarDB-X简介2.PolarDB-X特点二、PolarDB-X的产品架构1.产品架构图2.PolarDB-X架构介绍三、环境规划四、Docker安装1.安装系统工具2.配置docker的yum仓库源3.安装doc... 查看详情

猿创征文|国产数据库实战之使用docker部署tidb集群(代码片段)

猿创征文|国产数据库实战之使用Docker部署TiDB集群一、TiDB介绍1.TiDB简介2.TiDB特性3.TiDB集群整体架构4.TiDB集群各部分介绍5.本次TiDB集群组件二、检查本地环境1.检查docker状态2.检查docker版本3.检查docker-compose版本三、下载tidb-docker-comp... 查看详情

猿创征文|国产数据库实战之使用docker部署tidb集群(代码片段)

猿创征文|国产数据库实战之使用Docker部署TiDB集群一、TiDB介绍1.TiDB简介2.TiDB特性3.TiDB集群整体架构4.TiDB集群各部分介绍5.本次TiDB集群组件二、检查本地环境1.检查docker状态2.检查docker版本3.检查docker-compose版本三、下载tidb-docker-comp... 查看详情

猿创征文|国产数据库实战之使用docker部署tidb集群(代码片段)

猿创征文|国产数据库实战之使用Docker部署TiDB集群一、TiDB介绍1.TiDB简介2.TiDB特性3.TiDB集群整体架构4.TiDB集群各部分介绍5.本次TiDB集群组件二、检查本地环境1.检查docker状态2.检查docker版本3.检查docker-compose版本三、下载tidb-docker-comp... 查看详情

猿创征文|国产数据实战之docker部署mywebsql数据库管理工具(代码片段)

猿创征文|国产数据实战之docker部署MyWebSQL数据库管理工具一、MyWebSQL介绍1.MyWebSQL简介2.MyWebSQL特点二、检查本地环境1.检查docker状态2.检查docker-compose版本三、下载MyWebSQL镜像四、部署MyWebSQL工具1.编辑docker-compose.yaml2.创建MyWebSQL容器... 查看详情

猿创征文|国产数据库新的飞跃(代码片段)

一、数据库类型首先,我们来说一下当前数据库的类型吧,当前数据库生态可以大致分类三类:一是传统商业数据库,以Oracle为代表,其在40余年时间里所创造的数据库帝国已拥有了极其完善的生态;二是开源数据库,以MySQL、Po... 查看详情

猿创征文|国产数据库tidb架构特性(代码片段)

前言TiDB是PingCAP公司自主设计、研发的开源分布式关系型数据库,是一款同时支持在线事务处理与在线分析处理(HybridTransactionalandAnalyticalProcessing,HTAP)的融合型分布式数据库产品,具备水平扩容或者缩容、金融级高可用、... 查看详情

猿创征文|破世界纪录的国产数据库-oceanbase

...;不足之处请大家指正。猿创征文|破世界纪录的国产数据库-OceanBase本文关键字:VLDB、国产、数据库、OceanBase、金融文章目录猿创征文|破世界纪录的国产数据库-OceanBase一、7.07亿tpmC1.TPMC2.VLDB二、OceanBase1.数据库介绍2... 查看详情

猿创征文|使用springboot整合国产数据库连接池druid(代码片段)

1前言Java程序很大一部分要操作数据库,为了提高性能操作数据库的时候,又不得不使用数据库连接池。说到数据库连接池大家可能首先会想到C3P0,DBCP等相关。今天给大家介绍的是由国产(阿里)的一种连接池技术࿱... 查看详情

opengauss主备流程与参数的详细介绍(代码片段)

...部署方式。(不支持集群)gaussdb支持集群。是分布式数据库。1.主备架构openGauss的主备HA架构 查看详情

猿创征文|国产数据库实战使用docker部署polardb-x云原生分布式开源数据库(代码片段)

猿创征文|【国产数据库实战】使用docker部署PolarDB-X云原生分布式开源数据库一、PolarDB-X介绍1.PolarDB-X简介2.PolarDB-X特点二、检查docker版本三、检查docker配置信息四、下载PolarDB-X镜像五、部署PolarDB-X1.创建PolarDB-X容器2.检查PolarDB-X容... 查看详情

猿创征文|分布式国产数据库tidb从入门到实战(代码片段)

写在前面本文讲解的是目前欢迎程度最高分布式国产数据库TiDB,详细讲解了TiDB的由来、架构、SQL基本操作、SpringBoot整合TiDB等内容。目录写在前面一、概述二、与MySQL兼容性对比三、安装使用四、SQL基本操作4.1、库操作4.2、... 查看详情

猿创征文|国产数据库一文学会应用sqlsugar工作单元模式操作多数据库(代码片段)

🐋作者简介:博主是一位.Net开发者,同时也是RPA和低代码平台的践行者。🐬个人主页:会敲键盘的肘子🐰系列专栏:SqlSugarORM🦀专栏简介:SqlSugar是一款来自未来的ORM,拥有超前的理念... 查看详情

猿创征文|从单机百万tpmc到分布式千万tpmc,gaussdb性能提升的3个关键技术剖析

文章目录1华为云数据库服务全景图1.1华为云数据库服务1.2关系型数据库和非关系型数据库2华为自研数据库关键技术2.1GAUSSDB(foropenGauss)企业级分布式数据库2.1.1GAUSSDB(foropenGauss)遇到的问题2.1.1.1内存访问不对称问题2.1.1.2缓存一致性... 查看详情