暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
4.1 MogDB&openGauss 手动部署(非OM工具)单机,主备,主备级联架构.txt
82
6页
0次
2022-09-25
100墨值下载
# 一、前期准备
## 1. 关闭防火墙,selinux
```shell
systemctl disable firewalld.service
systemctl stop firewalld.service
setenforce=0
sed -i '/^SELINUX=/c'SELINUX=disabled /etc/selinux/config
```
## 2. 安装依赖包
```shell
yum install libaio-devel -y
```
## 3. 创建相关目录,用户,组
```shell
groupadd dbgrp -g 2000
useradd omm -g 2000 -u 2000
echo "Enmo@123" | passwd --stdin omm
mkdir -p /opt/mogdb/software
chown -R omm:dbgrp /opt/
```
## 4. 上传并解压二进制文件
```shell
[root@mogdb-kernel-0001 software]# pwd
/opt/mogdb/software
[root@mogdb-kernel-0001 software]# ls -lrt
total 90236
-r-------- 1 root root 92401412 Jun 13 06:14 MogDB-2.0.0-openEuler-64bit.tar.bz2
chown omm:dbgrp MogDB-2.0.0-openEuler-64bit.tar.bz2
su - omm
cd /opt/mogdb/software/
tar -xf MogDB-2.0.0-openEuler-64bit.tar.bz2
```
# 二、初始化数据库(单机)
## 1. 配置环境变量
```shell
echo "export GAUSSHOME=/opt/mogdb/software" >> /home/omm/.bashrc && \
echo "export PATH=\$GAUSSHOME/bin:\$PATH " >> /home/omm/.bashrc && \
echo "export LD_LIBRARY_PATH=\$GAUSSHOME/lib:\$LD_LIBRARY_PATH" >>
/home/omm/.bashrc
source /home/omm/.bashrc
```
## 2. init 数据库
```shell
bin/gs_initdb --pgdata=/opt/mogdb/data --nodename=primary --pwpasswd=Enmo@123
--encoding=UTF-8 --locale=en_US.UTF-8
```
## 3. 修改初始化参数
```shell
echo "port=26000" >> /opt/mogdb/data/postgresql.conf
echo "listen_addresses = '0.0.0.0'" >> /opt/mogdb/data/postgresql.conf
echo "password_encryption_type = 0" >> /opt/mogdb/data/postgresql.conf
echo "log_directory = 'pg_log'" >> /opt/mogdb/data/postgresql.conf
echo "remote_read_mode=non_authentication" >> /opt/mogdb/data/postgresql.conf
echo "host all all 0.0.0.0/0 md5" >> /opt/mogdb/data/pg_hba.conf
```
## 4. 启动数据库
```shell
gs_ctl start -D /opt/mogdb/data
```
**至此单机安装完成**
# 三、主备安装
## 1. 主库操作
- 配置连接通道
```shell
echo "replconninfo1='localhost=172.16.0.106 localport=26001
localheartbeatport=26005 localservice=26004 remotehost=172.16.0.245
remoteport=26001 remoteheartbeatport=26005 remoteservice=26004'
" >> /opt/mogdb/data/postgresql.conf
```
**localhost 为主库 IP,remotehost 为备库 IP**
- 将主库以 primary 方式启动
```shell
gs_ctl restart -D /opt/mogdb/data/ -M primary
```
## 2. 备库操作
- 前期准备工作如上(一)
- 配置环境变量
```shell
echo "export GAUSSHOME=/opt/mogdb/software" >> /home/omm/.bashrc && \
echo "export PATH=\$GAUSSHOME/bin:\$PATH " >> /home/omm/.bashrc && \
echo "export LD_LIBRARY_PATH=\$GAUSSHOME/lib:\$LD_LIBRARY_PATH" >>
/home/omm/.bashrc
source /home/omm/.bashrc
- 将主库的配置文件传到备库
scp /opt/mogdb/data/pg_hba.conf /opt/mogdb/data/postgresql.conf
172.16.0.245:/opt/mogdb/data/
```
- 配置连接通道, localhost remotehost 对调.
sed -i "/^replconninfo1/creplconninfo1='localhost=172.16.0.245 localport=26001
localheartbeatport=26005 localservice=26004 remotehost=172.16.0.106
remoteport=26001 remoteheartbeatport=26005 remoteservice=26004'"
/opt/mogdb/data/postgresql.conf
**localhost 为备库 IP,remotehost 为主库 IP**
- 构建主备关系
```shell
gs_ctl build -D /opt/mogdb/data/ -b full -M standby
```
- 查询主备状态
- 主库
```shell
[omm@mogdb-kernel-0001 data]$ gs_ctl query -D /opt/mogdb/data/
[2021-06-13 07:51:41.119][159054][][gs_ctl]: gs_ctl query ,datadir is
/opt/mogdb/data
HA state:
local_role : Primary
static_connections : 1
db_state : Normal
detail_information : Normal
Senders info:
sender_pid : 159041
local_role : Primary
peer_role : Standby
of 6
100墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜