做网站下一页,网站诊断书,软件工程考研难度,建设网站的实验目的openGauss 6.0.0主备部署#xff08;企业版#xff09; 文章目录 openGauss 6.0.0主备部署#xff08;企业版#xff09;一、环境准备1.操作系统环境2.修改主机名3.设置字符集编码4.修改openEuler默认yum源5.安装所需工具6.同步网络时间7.关闭防火墙 二、安装openGauss数据…openGauss 6.0.0主备部署企业版 文章目录 openGauss 6.0.0主备部署企业版一、环境准备1.操作系统环境2.修改主机名3.设置字符集编码4.修改openEuler默认yum源5.安装所需工具6.同步网络时间7.关闭防火墙 二、安装openGauss数据库1.创建安装目录并修改其权限为7552.下载安装包到本地3.创建XML配置文件4.预安装5. 安装openGauss 三、安装验证1.检查数据库状态2.登录postgres数据库2.1 登录数据库2.2 退出数据库 3.启停openGauss3.1 启动openGauss3.2 停止openGauss 一、环境准备
1.操作系统环境
项目配置描述主节点主机名为primary备节点主机名为standbyCPU2核 主备配置相同内存4G ( 主备配置相同)操作系统x86架构 openEuler22.03 ( 主备配置相同)
2.修改主机名 主节点执行 hostnamectl set-hostname primary# 修改完成后退出重新连接备节点执行 hostnamectl set-hostname standby# 修改完成后退出重新连接3.设置字符集编码 主备节点都执行 # 往环境变量配置文件/etc/profile最后添加字符集编码export LANGen_US.UTF-8
echo -e \nexport LANGen_US.UTF-8 /etc/profile# 激活环境变量
source /etc/profile4.修改openEuler默认yum源 主备节点都执行 # 复制原始yum源文件更名为.copy
cp /etc/yum.repos.d/openEuler.repo /etc/yum.repos.d/openEuler.repo.copy# 将路径更换为华为镜像源
echo
[osrepo]
nameosrepo
baseurlhttps://mirrors.huaweicloud.com/openeuler/openEuler-22.03-LTS-SP2/OS/x86_64/
enabled1gpgcheck1
gpgkeyhttps://mirrors.huaweicloud.com/openeuler/openEuler-22.03-LTS-SP2/OS/x86_64/RPM-GPG-KEY-openEuler/etc/yum.repos.d/openEuler.repo# 去除原有 yum 缓存
yum clean all# 生成新的缓存
yum makecache5.安装所需工具 主备节点都执行 yum install tar -yyum install libaio* -yyum install expect -yyum install ntpdate -y6.同步网络时间 主备节点都执行 时间不同步会导致后续预安装报错
如果是虚拟机恢复快照后执行的安装此处可以直接关机再重启可以无需执行下述代码
同时可以防止虚拟机IP地址发生变化,在后续执行预安装时报错
ntpdate pool.ntp.org# 同步后使用date命令查看primary和standby时间是否一致若不一致则再次执行上述同步网络时间命令
date7.关闭防火墙 主备节点都执行 systemctl disable --now firewalld二、安装openGauss数据库
1.创建安装目录并修改其权限为755 主备节点都执行 mkdir -p /opt/software/openGausschmod 755 -R /opt/software2.下载安装包到本地 在主节点执行 # 切换到安装路径
cd /opt/software/openGauss# 下载openGauss安装包到本地
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/openEuler22.03/x86/openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz# 解压到当前路径
tar -zxf ./openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz
# 继续解压OM安装包
tar -zxf ./openGauss-OM-6.0.0-openEuler22.03-x86_64.tar.gz
# 解压后会在/opt/software/openGauss路径下自动生成script子目录并且在script目录下生成gs_preinstall等各种OM工具脚本3.创建XML配置文件 在主节点执行 # 切换到存放安装包的目录
cd /opt/software/openGauss# 创建XML配置文件用于数据库安装
vi cluster_config.xml往其中输入以下内容
注意需要将IP地址替换为自己本地的IP地址IP地址可以使用命令ip a命令查看
?xml version1.0 encodingUTF-8?
ROOT!-- openGauss整体信息 --CLUSTER!-- 数据库名称 --PARAM nameclusterName valuedbCluster /!-- 数据库节点名称(hostname) --PARAM namenodeNames valueprimary,standby /!-- 数据库安装目录--PARAM namegaussdbAppPath value/opt/openGauss/install/app /!-- 日志目录--PARAM namegaussdbLogPath value/var/log/omm /!-- 临时文件目录--PARAM nametmpMppdbPath value/opt/openGauss/tmp/!-- 数据库工具目录--PARAM namegaussdbToolPath value/opt/openGauss/install/om /!-- 数据库core文件目录--PARAM namecorePath value/opt/openGauss/corefile/!-- 节点IP与数据库节点名称列表一一对应 --PARAM namebackIp1s value192.168.217.130,192.168.217.131//CLUSTER!-- 每台服务器上的节点部署信息 --DEVICELIST!-- 节点1上的部署信息 --DEVICE snprimary!-- 节点1的主机名称 --PARAM namename valueprimary/!-- 节点1所在的AZ及AZ优先级 --PARAM nameazName valueAZ1/PARAM nameazPriority value1/!-- 节点1的IP如果服务器只有一个网卡可用将backIP1和sshIP1配置成同一个IP --PARAM namebackIp1 value192.168.217.130/PARAM namesshIp1 value192.168.217.130/!--dn--PARAM namedataNum value1/PARAM namedataPortBase value8000/PARAM namedataNode1 value/opt/openGauss/install/data/dn,standby,/opt/openGauss/install/data/dn/PARAM namedataNode1_syncNum value0//DEVICE!-- 节点2上的节点部署信息其中“name”的值配置为主机名称 --DEVICE snstandby!-- 节点2的主机名称 --PARAM namename valuestandby/!-- 节点2所在的AZ及AZ优先级 --PARAM nameazName valueAZ1/PARAM nameazPriority value1/!-- 节点2的IP如果服务器只有一个网卡可用将backIP1和sshIP1配置成同一个IP --PARAM namebackIp1 value192.168.217.131/PARAM namesshIp1 value192.168.217.131//DEVICE/DEVICELIST
/ROOT4.预安装 在主节点执行 预安装在执行过程中自动创建操作系统root用户互信和omm用户互信
如果预安装失败请着重检查cluster_config.xml配置文件中是否正确
python3 /opt/software/openGauss/script/gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
# -U omm 指定用户名
# -G dbgrp 指定组名
# -X /opt/software/openGauss/cluster_config.xml 指定openGauss配置文件路径# ----------- 以下是执行后输出的内容 -----------
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
# 下述语句为询问是否为root创建信任输入yes后回车
Are you sure you want to create trust for root (yes/no)?yes
Please enter password for root
Please enter password for current user[root].
# 输入当前root用户的密码然后回车
Password:
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.
Distributing trust keys file to all node successfully.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Verifying SSH trust on all hosts by ip.
Successfully verified SSH trust on all hosts by ip.
Verifying SSH trust on all hosts by hostname.
Successfully verified SSH trust on all hosts by hostname.
Successfully verified SSH trust on all hosts.
Start set cron for root
Successfully to set cron for root
Successfully created SSH trust.
Successfully created SSH trust for the root permission user.
Setting host ip env
Successfully set host ip env.
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用户并与root互信输入yes后回车
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
Please enter password for cluster user.
# 创建omm密码然后回车
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.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [omm] user.
Please enter password for current user[omm].
# 输入刚刚创建的omm用户的密码
Password:
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.
Distributing trust keys file to all node successfully.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Verifying SSH trust on all hosts by ip.
Successfully verified SSH trust on all hosts by ip.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
Successfully created SSH trust for [omm] user.
Checking OS software.
Successfully check OS software.
Checking OS version.
Successfully checked OS version.
Checking cpu instructions.
Successfully checked cpu instructions.
Creating clusters path.
Successfully created clusters 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 primary,standby -X /opt/software/openGauss/cluster_config.xml --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.
# ----------- 输出结束 -----------# 出现下述内容则预安装成功
Preinstallation succeeded.00:0c:29:6a:66:b5
00:0c:29:6a:66:b55. 安装openGauss 在主节点执行 切换为omm用户
su - omm执行安装
gs_install -X /opt/software/openGauss/cluster_config.xml
# -X /opt/software/openGauss/cluster_config.xml 指定安装所使用的配置文件# ----------- 以下是执行后输出的内容 -----------
Parsing the configuration file.
Successfully checked gs_uninstall on every node.
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.
# 加密数据库需要输入密码密码需要满足大小写数字且不小于8位
Please enter password for database:
# 再次输入密码
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /opt/openGauss/install/app/share/sslcert
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.
Successfully check consistence of memCheck and coresCheck on all nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
The cluster status is Normal.
Successfully started cluster.
Successfully installed application.
end deploy..
# ----------- 输出结束 -----------# 出现下述内容则安装成功
Configuration is completed.
The cluster status is Normal.
Successfully started cluster.
Successfully installed application.
end deploy..三、安装验证
1.检查数据库状态 在主节点执行 在omm用户下执行下述命令
gs_om -t status --detail
# -t 指定gs_om命令的类型# start 启动openGauss数据库服务# stop 停止openGauss数据库服务# status 查看openGauss数据库服务状态
# --detail 显示详细信息。如果不指定只提示该服务器是否正常以下是执行后输出的内容
[ Cluster State ]cluster_state : Normal
redistributing : No
current_az : AZ_ALL[ Datanode State ]node node_ip port instance state
-----------------------------------------------------------------------------------------
1 primary 192.168.217.129 8000 6001 /opt/openGauss/install/data/dn P Primary Normal
2 standby 192.168.217.131 8000 6002 /opt/openGauss/install/data/dn S Standby Normal# cluster_state 集群状态# Normal 表示openGauss正常# Unavailable 表示openGauss不可用# Degraded 表示openGauss可用但存在故障的数据库节点、数据库主节点实例# redistributing 数据重分布状态# Yes 表示openGauss处于数据重分布状态# No 表示openGauss未处于数据重分步状态# [ Datanode State ] 节点状态
# node 节点编号
# node_ip 节点所在IP
# port 端口号
# instance instance 实例ID
# state 实例角色# Normal表示单主机实例。# P Primary表示实例为主实例。# S Standby表示实例为备实例。# Cascade Standby表示实例为级联备实例。# Pending表示该实例在仲裁阶段。# Unknown表示实例状态未知。# Down表示实例处于宕机状态。# Abnormal表示节点处于异常状态。# Manually stopped表示节点已经被手动停止。2.登录postgres数据库
2.1 登录数据库
数据库安装完成后默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库
**注意**端口号需要使用cluster_config.xml配置文件中的dataPortBase的值
# 登录postgres数据
gsql -d postgres -p 8000# -d postgres 指定登录的数据库名为postgres# -p 指定连接的端口号为80002.2 退出数据库
使用元命令\q或者快捷键Ctrl D 退出openGauss命令行
# 退出openGauss命令行
\q3.启停openGauss
3.1 启动openGauss
第一次安装后openGauss默认是启动的可以不用执行这一步
# 启动openGauss数据库服务
gs_om -t start# 出现Successfully started.即启动成功以下是执行后输出的内容
# ----------- 以下是执行后输出的内容 --------
Starting cluster.[SUCCESS] openEuler
2024-11-18 16:23:04.271 673af968.1 [unknown] 140525502319040 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2024-11-18 16:23:04.271 673af968.1 [unknown] 140525502319040 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2024-11-18 16:23:04.273 673af968.1 [unknown] 140525502319040 [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 (4482 Mbytes) is larger.Successfully started.
3.2 停止openGauss
# 停止openGauss数据库服务
gs_om -t stop以下是执行后输出的内容
# ----------- 以下是执行后输出的内容 -----------
Stopping cluster.Successfully stopped cluster.End stop cluster.