OpenGauss 安装

参考官网链接:https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/InstallationGuide/%E5%8D%95%E8%8A%82%E7%82%B9%E5%AE%89%E8%A3%85.html

其中安装版本为 5.0,操作系统为 openEuler 22

1、创建用户(gauss数据库的安装必须要在普通用户下面)

useradd -m omm #创建oracle用户
mkdir -p /opt/software/openGauss   #创建安装目录
chown -R omm /opt/software/openGauss #用户授权

2.使用普通用户登录到openGauss包安装的主机,解压openGauss压缩包到安装目录

tar -jxf openGauss-x.x.x-openEuler-64bit.tar.bz2 -C /opt/software/openGauss

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

cd /opt/software/openGauss/simpleInstall

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

sh install.sh  -w "xxxx" &&source ~/.bashrc
复制代码
 说明:
-w:初始化数据库密码(gs_initdb指定),因安全需要,此项必须设置。
-p:指定openGauss端口号,如不指定,默认为5432。
-h|--help:打印使用说明。
安装后,该数据库部署节点的名称为sgnode(gs_initdb指定)。
执行时,如果出现报错“the maximum number of SEMMNI is not correct, the current SEMMNI is xxx. Please check it.”,请使用有root权限的用户执行如下命令。
sysctl -w kernel.sem="250 85000 250 330" 
安装后,数据库目录安装路径/opt/software/openGauss/data/single_node,其中/opt/software/openGauss为解压包路径,data/single_node为新创建的数据库节点目录。
安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库。
复制代码

5.安装执行完成后,使用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命令,显示类似如下信息:

 6、数据库安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库。

gsql -d postgres -p 5432

其中postgres为需要连接的数据库名称,8000为数据库主节点的端口号。请根据实际情况替换。另外,也可以使用如下任一命令连接数据库。

gsql postgres://omm:Gauss_234@127.0.0.1:8000/postgres -r 
gsql -d "host=127.0.0.1 port=8000 dbname=postgres user=omm password=Gauss_234"

首次登录建议修改密码。命令如下。

openGauss=# ALTER ROLE omm IDENTIFIED BY '$$$$$$$$' REPLACE 'XXXXXXXX';

-- 假设您要修改用户名为'username'的密码为'newpassword'

ALTER USER username IDENTIFIED BY 'newpassword';

退出数据库。

openGauss=# \q

 7、创建测试用户:


CREATE
USER c WITH PASSWORD "Gauss_123"; GRANT ALL PRIVILEGES TO unival; CREATE DATABASE db_tpcc OWNER unival;
-- 假设您要修改用户名为'username'的密码为'newpassword'
ALTER USER username IDENTIFIED BY 'newpassword';

 

8、远程链接操作

  • 使用如下命令查看数据库主节点目前的listen_addresses配置。

配置文件地址:

/data/single_node/postgresql.conf

相关参数:

listen_addresses该参数指定openGauss服务器使用哪些IP地址进行侦听,取值范围:
  • 主机名或IP地址,多个值之间用英文逗号分隔。
  • 星号“*”或“0.0.0.0”表示侦听所有IP地址。配置侦听所有IP地址存在安全风险,不推荐用户使用。必须与有效地址结合使用(比如本地IP等),否则,可能造成Build失败的问题。同时,主备环境下配置为“\*”或“0.0.0.0”时,主节点数据库路径下postgresql.conf文件中的localport端口号不能为数据库dataPortBase+1,否则会导致数据库无法启动。
  • 若存在非法IP时,进程启动阶段会报错退出。

**默认值:**数据库实例安装好后,根据XML配置文件中不同实例的IP地址配置不同默认值。DN的默认参数值为:listen_addresses = 'x.x.x.x'。

  • 查看用户密码策略:

 

grep 'password_encryption_type' postgresql.conf

 注意,高斯数据库默认是 sha256

  • 配置远程访问 pg_hba.conf               

配置文件所在目录:/opt/software/openGauss/data/single_node

执行 vi pg_hba.conf

添加一条运行远程访问的策略如下:

  • 重启数据库使参数生效。
复制代码
gs_om -t stop && gs_om -t start

gs_om 命令找不到时用:
gs_ctl restart -D /opt/software/openGauss/data/single_node

重载配置:
gs_ctl reload -D /opt/software/openGauss/data/single_node

命令行测试:

gsql -d "host=192.168.125.128 port=5432 dbname=db_tpcc user=unival password=Gauss_123"

复制代码

 相关的命令集合:https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/ToolandCommandReference/gs_ctl.html#table145081017222

 

8.客户端:

dataStudio:

https://community.gitcode.com/HuaweiCloudDeveloper/655eff77af067462fdd4b5cf.html

dbeaver:

https://opengauss.org/zh/blogs/justbk/2020-10-30_dbeaver_for_openGauss.html

 

 

 


 

posted @   leolzi  阅读(270)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· [翻译] 为什么 Tracebit 用 C# 开发
· 腾讯ima接入deepseek-r1,借用别人脑子用用成真了~
· Deepseek官网太卡,教你白嫖阿里云的Deepseek-R1满血版
· DeepSeek崛起:程序员“饭碗”被抢,还是职业进化新起点?
· RFID实践——.NET IoT程序读取高频RFID卡/标签
点击右上角即可分享
微信分享提示