华为高斯数据库openGauss_5.0.2 企业版部署学习
系统环境及软件包下载
欧拉系统官方下载链接
openEuler-22.03-LTS-SP4-x86_64-dvd.iso
https://mirrors.tuna.tsinghua.edu.cn/openeuler/openEuler-22.03-LTS-SP4/ISO/x86_64/openEuler-22.03-LTS-SP4-x86_64-dvd.iso
openEuler下载 | openEuler ISO镜像 | openEuler社区官网
数据库安装包下载
https://opengauss.org/zh/download/
系统安装选择最小化安装此处省去安装步骤
测试环境为vmware虚拟机,安装截图如下:
安装完修改ip地址和主机名,这里省略
软件环境配置
参考官方链接,联网环境可以使用yum进行软件包配置如下
yum安装依赖, 参考官方文档的依赖如下图,
yum install libaio-devel readline-devel expect python -y
安装结果如下
详细步骤参考官方手册文档:
创建用户和组
创建用户组dbgroup。 groupadd dbgrp 创建用户组dbgroup下的普通用户omm,并设置密码为omm useradd -g dbgrp -m omm -d /home/omm passwd omm passwd Admin@2024
xml配置文件参考:
手工创建cluster_config.xml配置文件配置文件参考如下:按照要求修改你的主机名和ip地址即可
<?xml version="1.0" encoding="UTF-8"?> <ROOT> <!-- openGauss整体信息 --> <CLUSTER> <!-- 数据库名称 --> <PARAM name="clusterName" value="dbCluster" /> <!-- 数据库节点名称(hostname) --> <PARAM name="nodeNames" value="test" /> <!-- 数据库安装目录--> <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" /> <!-- 节点IP,与数据库节点名称列表一一对应 --> <PARAM name="backIp1s" value="192.168.80.133"/> </CLUSTER> <!-- 每台服务器上的节点部署信息 --> <DEVICELIST> <!-- 节点1上的部署信息 --> <DEVICE sn="node1_hostname"> <!-- 节点1的主机名称 --> <PARAM name="name" value="test"/> <!-- 节点1所在的AZ及AZ优先级 --> <PARAM name="azName" value="AZ1"/> <PARAM name="azPriority" value="1"/> <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP --> <PARAM name="backIp1" value="192.168.80.133"/> <PARAM name="sshIp1" value="192.168.80.133"/> <!--dbnode--> <PARAM name="dataNum" value="1"/> <PARAM name="dataPortBase" value="15400"/> <PARAM name="dataNode1" value="/opt/huawei/install/data/dn"/> <PARAM name="dataNode1_syncNum" value="0"/> </DEVICE> </DEVICELIST> </ROOT>
修改其中的网络参数和主机名
初始化安装环境:
上传安装包使用sftp
解压安装包,创建安装目录
[root@test ~]# ls -lh openGauss-5.0.2-openEuler-64bit-all.tar.gz -rw-r--r-- 1 root root 129M Jul 25 20:43 openGauss-5.0.2-openEuler-64bit-all.tar.gz [root@test ~]# tar -zxvf openGauss-5.0.2-openEuler-64bit-all.tar.gz openGauss-5.0.2-openEuler-64bit-cm.tar.gz openGauss-5.0.2-openEuler-64bit-om.tar.gz openGauss-5.0.2-openEuler-64bit.tar.bz2 openGauss-5.0.2-openEuler-64bit-cm.sha256 openGauss-5.0.2-openEuler-64bit-om.sha256 openGauss-5.0.2-openEuler-64bit.sha256 upgrade_sql.tar.gz upgrade_sql.sha256 [root@test ~]# tar -zxf openGauss-5.0.2-openEuler-64bit-om.tar.gz [root@test ~]# ls -lh total 259M drwxr-x--- 14 root root 4.0K May 14 10:37 lib -rw-r--r-- 1 root root 129M Jul 25 20:43 openGauss-5.0.2-openEuler-64bit-all.tar.gz -rw-r----- 1 root root 108 May 14 10:38 openGauss-5.0.2-openEuler-64bit-cm.sha256 -rw-r----- 1 root root 22M May 14 10:38 openGauss-5.0.2-openEuler-64bit-cm.tar.gz -rw-r----- 1 root root 65 May 14 10:37 openGauss-5.0.2-openEuler-64bit-om.sha256 -rw-r----- 1 root root 11M May 14 10:37 openGauss-5.0.2-openEuler-64bit-om.tar.gz -rw-r----- 1 root root 65 May 14 10:38 openGauss-5.0.2-openEuler-64bit.sha256 -rw-r----- 1 root root 98M May 14 10:38 openGauss-5.0.2-openEuler-64bit.tar.bz2 drwxr-x--- 10 root root 4.0K May 14 10:37 script -rw------- 1 root root 65 May 14 10:36 upgrade_sql.sha256 -rw------- 1 root root 490K May 14 10:36 upgrade_sql.tar.gz -rw-r----- 1 root root 32 May 14 10:37 version.cfg [root@test ~]#
拷贝安装包,创建配置文件
[root@test ~]# cp -a * /opt/software/openGauss/ [root@test ~]# cd /opt/software/openGauss/ [root@test openGauss]# ls -l total 264388 drwxr-x--- 14 root root 4096 May 14 10:37 lib -rw-r--r-- 1 root root 134822604 Jul 25 20:43 openGauss-5.0.2-openEuler-64bit-all.tar.gz -rw-r----- 1 root root 108 May 14 10:38 openGauss-5.0.2-openEuler-64bit-cm.sha256 -rw-r----- 1 root root 22571112 May 14 10:38 openGauss-5.0.2-openEuler-64bit-cm.tar.gz -rw-r----- 1 root root 65 May 14 10:37 openGauss-5.0.2-openEuler-64bit-om.sha256 -rw-r----- 1 root root 11061713 May 14 10:37 openGauss-5.0.2-openEuler-64bit-om.tar.gz -rw-r----- 1 root root 65 May 14 10:38 openGauss-5.0.2-openEuler-64bit.sha256 -rw-r----- 1 root root 101739653 May 14 10:38 openGauss-5.0.2-openEuler-64bit.tar.bz2 drwxr-x--- 10 root root 4096 May 14 10:37 script -rw------- 1 root root 65 May 14 10:36 upgrade_sql.sha256 -rw------- 1 root root 501111 May 14 10:36 upgrade_sql.tar.gz -rw-r----- 1 root root 32 May 14 10:37 version.cfg [root@test openGauss]#
参考官方:
部署脚本执行结果(cluster_config.xml参考手工创建配置详细)
[root@test script]# ./gs_preinstall -U omm -G dbgrp -L -X /opt/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. 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 "/opt/software/openGauss/script/gs_checkos -i A -h test --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@test script]#
执行安装
安装参考官方例子:
切换omm用户执行安装
[root@test script]# chmod -R 775 /opt/ [root@test script]# ls -l /opt/ total 8 drwxrwxr-x 5 omm dbgrp 4096 Jul 17 15:32 huawei drwxrwxr-x 3 root root 4096 Jul 17 15:09 software [root@test script]# su - omm Last login: Wed Jul 17 15:36:36 CST 2024 on pts/0 Welcome to 5.10.0-216.0.0.115.oe2203sp4.x86_64 System information as of time: Wed Jul 17 03:39:25 PM CST 2024 System load: 0.09 Memory used: 14.4% Swap used: 0% Usage On: 5% IP address: 192.168.80.133 Users online: 1 To run a command as administrator(user "root"),use "sudo <command>". [omm@test ~]$ gs_install -X /opt/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: begin to create CA cert files The sslcert will be generated in /opt/huawei/install/app/share/sslcert/om NO cm_server instance, no need to create CA for CM. Non-dss_ssl_enable, no need to create CA for DSS 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. The cluster status is Normal. Successfully started cluster. Successfully installed application. end deploy.. [omm@test ~]$
安装完毕验证
检查安装目录和数据库状态如下脚本示例
[omm@test ~]$ ls -lh /opt/huawei/ total 12K drwxrwxr-x 2 omm dbgrp 4.0K Jul 17 15:32 corefile drwxrwxr-x 5 omm dbgrp 4.0K Jul 17 15:39 install drwx------ 2 omm dbgrp 4.0K Jul 17 15:41 tmp [omm@test ~]$ gs_om -t status ----------------------------------------------------------------------- cluster_name : dbCluster cluster_state : Normal redistributing : No ----------------------------------------------------------------------- [omm@test ~]$ gsql -d postgres -p 15400 gsql ((openGauss 5.0.2 build 48a25b11) compiled at 2024-05-14 10:26:01 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=#
启动停止数据文档参考
示例脚本如下:
[omm@test ~]$ gs_om -t stop Stopping cluster. ========================================= Successfully stopped cluster. ========================================= End stop cluster. [omm@test ~]$ gs_om -t start Starting cluster. ========================================= [SUCCESS] test 2024-07-17 16:27:55.248 6697808b.1 [unknown] 140068131946560 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets 2024-07-17 16:27:55.248 6697808b.1 [unknown] 140068131946560 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets 2024-07-17 16:27:55.250 6697808b.1 [unknown] 140068131946560 [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 (2174 Mbytes) is larger. ========================================= Successfully started. [omm@test ~]$ gs_om -t status ----------------------------------------------------------------------- cluster_name : dbCluster cluster_state : Normal redistributing : No ----------------------------------------------------------------------- [omm@test ~]$ gsql -d postgres -p 15400 gsql ((openGauss 5.0.2 build 48a25b11) compiled at 2024-05-14 10:26:01 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=#
创建数据库
[omm@test ~]$ gsql -d postgres -p 15400 gsql ((openGauss 5.0.2 build 48a25b11) compiled at 2024-05-14 10:26:01 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=#openGauss=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0; CREATE DATABASE openGauss=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+-------+-----------+---------+-------+------------------- mydb | omm | GBK | C | C | 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 (4 rows) openGauss=#
官方文档参考:
数据库DataStudio_win_64链接工具配置
软件链接及文档下:
windows 64位置下载链接:
https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/tools/DataStudio_win_64.zip
下载运行后提示jdk没有安装
java环境配置安装
按照文档操作下载java环境,安装jdk11,官方链接如下
https://download.oracle.com/otn/java/jdk/11.0.23%2B7/9bd8d305c900ee4fa3e613b59e6f42de/jdk-11.0.23_windows-x64_bin.exe
安装完检查java版本
配置客户端远程接入
官方文档参考:
创建用户设置密码
[omm@test ~]$ gsql -d postgres -p 15400 gsql ((openGauss 5.0.2 build 48a25b11) compiled at 2024-05-14 10:26:01 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=# openGauss=# openGauss=# CREATE USER jack PASSWORD 'Test@123'; CREATE ROLE openGauss=# \q [omm@test ~]$ [omm@test ~]$ gs_guc set -N all -I all -h "host all jack 192.168.80.133/24 sha256" The gs_guc run with the following arguments: [gs_guc -N all -I all -h host all jack 192.168.80.133/24 sha256 set ]. Begin to perform the total nodes: 1. Popen count is 1, Popen success count is 1, Popen failure count is 0. Begin to perform gs_guc for datanodes. Command count is 1, Command success count is 1, Command failure count is 0. Total instances: 1. Failed instances: 0. ALL: Success to perform gs_guc! [omm@test ~]$b
编辑配置文件
host all all 0.0.0.0/0 sha256
完成配置文件如下
[root@gasdb ~]# find /opt/ -name "pg_hba.conf" /opt/huawei/install/data/dn/pg_hba.conf [root@gasdb ~]# cat /opt/huawei/install/data/dn/pg_hba.conf | grep -v ^# local all all trust host all omm 192.168.1.107/32 trust host all all 127.0.0.1/32 trust host all all 192.168.1.107/32 sha256 host all all ::1/128 trust host all all 0.0.0.0/0 sha256 [root@gasdb ~]#
执行reload,重启数据库:
[omm@gasdb ~]$ gs_ctl reload [2024-11-19 17:10:37.100][12205][][gs_ctl]: gs_ctl reload ,datadir is /opt/huawei/install/data/dn server signaled [omm@gasdb ~]$ gs_ctl restart [2024-11-19 17:10:38.944][12208][][gs_ctl]: gs_ctl restarted ,datadir is /opt/huawei/install/data/dn waiting for server to shut down... done server stopped [2024-11-19 17:10:39.952][12208][][gs_ctl]: waiting for server to start... .0 LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env. 0 LOG: [Alarm Module]Host Name: gasdb
执行 :gs_ctl restart,运行如下图参考
客户端链接:
去掉勾选启用ssl
连接成功
完毕。。
淘宝小店,欢迎你的光临,可定制你的需求
https://shop340822098.taobao.com/