当前位置: 首页 > article >正文

opengauss 数据库安装主备 非om方式

一. 准备两台服务器

192.168.141.130 --主

192.168.141.131 --备

1.关闭防火墙
systemctl stop firewalld 
systemctl disable firewalld
2.关闭 selinux 服务
setenforce 0 
vim /etc/selinux/config
#设置 
SELINUX=disabled
3.关闭透明大页
 echo never > /sys/kernel/mm/transparent_hugepage/enabledcat /sys/kernel/mm/transparent_hugepage/enabled
4.安装依赖包

建议切换华为云镜像操作

yum install libaio-devel -y

二、安装环境准备

1.创建相关目录、用户和组

#创建数据库初始化用户组和用户

groupadd dbgrp -g 1000 
useradd omm -u 1000 -g 1000

设置密码

echo "root@2025!" | passwd --stdin omm

#创建安装包存放目录

mkdir -p /opt/software/openGauss

#创建数据库初始化数据目录

mkdir -p /data/openGauss

给omm用户这两个文件夹授权

chown -R omm.dbgrp /data/openGausschown -R omm.dbgrp /opt/software/openGauss
2.下载安装包
cd /opt/software/openGauss 
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.1/openEuler22.03/arm/openGauss-All-6.0.1-openEuler22.03-aarch64.tar.gz 
#依次解压 
tar -zxvf openGauss-All-6.0.1-openEuler22.03-x86_64.tar.gz 
tar -jxvf openGauss-Server-6.0.1-openEuler22.03-x86_64.tar.bz2
3.配置 omm 用户环境变量
su - omm 
vim .bashrc
export GAUSSHOME=/opt/software/openGauss
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH 
export PATH=$GAUSSHOME/bin:$PATH 

#加载使配置生效

source .bashrc

以上所有操作在两台主机上均要操作。

三、开始搭建主库 192.168.141.130

1.初始化数据库
 su - ommgs_initdb -D /data/openGauss --nodename=primary -E UTF-8 -w Root@2025! 
#Root@2025! 为初始数据库密码 
cd /data/openGauss 
#编辑postgresql.conf配置文件,将相关信息添加到最后一行 
vim postgresql.conf 
port=1888 
listen_addresses = '0.0.0.0' 
log_directory = 'pg_log' 
remote_read_mode=non_authentication 
replconninfo1='localhost=192.168.141.130 
localport=1889 
localheartbeatport=1893 
localservice=1892 
remotehost=192.168.141.131 
remoteport=1889 
remoteheartbeatport=1893 
remoteservice=1892' 
#localhost为主库IP,remotehost为备库IP 
#编辑pg_hba.conf配置文件,将相关信息添加到最后一行 
vim pg_hba.conf 
host all all 0.0.0.0/0 sha256
2.以 primary 方式启动数据库

#启动数据库都是omm账户

gs_ctl start -D /data/openGauss/ -M primary

四、操作备库 192.168.141.131

1.将主库的 postgresql.conf 文件传到备库,编辑连接通道信息
#在主库用omm账户操作 
scp postgresql.conf 192.168.141.130:/data/openGauss 
#然后在备库上操作 
cd /data/openGauss 
su - omm 
vim postgresql.conf 
# 和主库配置一样 ip对调 
replconninfo1='localhost=192.168.141.131 localport=1889 localheartbeatport=1893 localservice=1892 remotehost=192.168.141.130 remoteport=1889 remoteheartbeatport=1893 remoteservice=1892'
2.构建主备关系
gs_ctl build -D /data/openGauss/ -b full -M standby
3.查看主备库信息
gs_ctl query -D /data/openGauss

五、验证主备关系

1.主库中创建表
 gsql -d postgres -p 1888create table test(id int);
2.备库中查看
openGauss=# gsql -d postgres -p 1888 
openGauss=# \dt List of relations Schema | Name | Type | Owner | Storage --------+------+-------+-------+---------------------------------- public | test | table | omm | {orientation=row,compression=no} (1 row)

备库看到信息说明主备成功

注意 如果需要navcat 调试 需要将密码加密方式调整为 md5

创建用户

#创建数据库 
create database test_db; 
#创建用户 
CREATE USER test PASSWORD 'Test@2025!'; 
#赋权 
grant all privileges to test; 
# 修改密码 
alter user imss identified by 'Imss@2024!';

http://www.lryc.cn/news/2393679.html

相关文章:

  • STM32的HAL编码流程总结(上部)
  • 深度学习|pytorch基本运算
  • (自用)Java学习-5.15(模糊搜索,收藏,购物车)
  • 替代 WPS 的新思路?快速将 Word 转为图片 PDF
  • 【K8S】K8S基础概念
  • FEMFAT许可分析的数据可视化方法
  • 打印机无法远程打印?可以本地打印,本地网络打印机设置给异地使用
  • 包含Javascript的HTML静态页面调取本机摄像头
  • PCB设计实践(三十一)PCB设计中机械孔的合理设计与应用指南
  • deepseek问答记录:请讲解一下torch.full_like()
  • 【Linux篇章】Linux 进程信号2:解锁系统高效运作的 “隐藏指令”,开启性能飞跃新征程(精讲捕捉信号及OS运行机制)
  • 多功能秒达开源工具箱源码|完全开源的中文工具箱
  • 如何在腾讯云 OpenCloudOS 上安装 Docker 和 Docker Compose
  • 清理skywalking历史索引
  • 用nz-tabel写一个合并表格
  • matlab计算转子系统的固有频率、振型、不平衡响应
  • leetcode hot100刷题日记——29.合并两个有序链表
  • 【机器人】具身导航 VLN 最新论文汇总 | Vision-and-Language Navigation
  • Windows 安装 WSL2 并运行 Ubuntu 22.04 指南
  • AI情感陪伴在医疗领域的核心应用潜力
  • 【计算机网络】第1章:概述—分组延时、丢失和吞吐量
  • Python Day38
  • DeepSeek R1 模型小版本升级,DeepSeek-R1-0528都更新了哪些新特性?
  • 线路板厂家遇到的PCB元件放置的常见问题有哪些?
  • 【C/C++】无限长有序数组中查找特定元素
  • SQL正则表达式总结
  • 力扣经典算法篇-13-接雨水(较难,动态规划,加法转减法优化,双指针法)
  • STM32 -- USB虚拟串口通信
  • uni-app开发特殊社交APP
  • Linux中Shell脚本的常用命令