openEuler22.03安装openGauss数据库并开启外部访问
716
类别: 
开发交流

准备

openGauss 高斯数据库 官网 openGauss

openEuler 欧拉系统 官网openEuler

高斯数据库文档 https://docs-opengauss.osinfra.cn/zh/

简易安装

1. 创建用户组dbgroup。

groupadd dbgroup

2. 创建用户组dbgroup下的普通用户omm,并设置普通用户omm的密码,密码建议设置为omm@123。

useradd -g dbgroup omm
passwd omm

3. 使用omm用户登录到openGauss包安装的主机,解压openGauss压缩包到安装目录(假定安装目录为/opt/software/openGauss,请用实际值替换)。

tar -jxf openGauss-x.x.x-操作系统-64bit.tar.bz2 -C /opt/software/openGauss

4. 假定解压包的路径为/opt/software/openGauss,进入解压后目录下的simpleInstall。

cd /opt/software/openGauss/simpleInstall

5. 执行install.sh脚本安装openGauss。

sh install.sh  -w xxxx 

上述命令中,-w是指初始化数据库密码(gs_initdb指定),安全需要必须设置。

6. 安装执行完成后,使用ps和gs_ctl查看进程是否正常。

ps ux | grep gaussdb
gs_ctl query -D /opt/software/openGauss/data/single_node

执行ps命令,显示类似如下信息:

omm      24209 11.9  1.0 1852000 355816 pts/0  Sl   01:54   0:33 /opt/software/openGauss/bin/gaussdb -D /opt/software/openGauss/single_node
omm      20377  0.0  0.0 119880  1216 pts/0    S+   15:37   0:00 grep --color=auto gaussdb

执行gs_ctl命令,显示类似如下信息:

gs_ctl query ,datadir is /opt/software/openGauss/data/single_node
HA state:
    local_role                     : Normal
    static_connections             : 0
    db_state                       : Normal
    detail_information             : Normal

Senders info:
    No information

 Receiver info:
No information 

开启外部访问

1. 进入目录

cd /opt/software/openGauss/data/single_node

2. 编辑pg_hba.conf 配置文件

vim pg_hba.conf
# 添加一下配置
host all all 192.168.122.120/32 md5
host all all 0.0.0.0/0   md5

3. 编辑postgresql.conf文件,修改监听地址 和 加密方式

vim postgresql.conf
# 修改一下配置
password_encryption_type = 0
listen_address = '*'

4. 更新配置

gs_ctl  reload -D /opt/software/openGauss/data/single_node

5. 注册用户

gsql -d postgres -p 5432 -r
create user han with sysadmin identified by 'gaussdb@123';

6. 防火墙放行端口

# 允许 tcp 5432 端口
sudo firewall-cmd --permanent --add-port=5432/tcp
# reload 防火墙,应用规则
sudo systemctl reload firewalld
标签:
评论 0
/ 1000
0
0
收藏