openEuler操作系统和openGauss数据库

文章目录

  • 1. openEuler操作系统
  • 2. openGauss数据库
    • 2.1 系统自带库
      • 2.1.1 允许所有地址访问端口
      • 2.1.2 创建远程登录用户
    • 2.2 安装5.0 版本
      • 2.2.1 下载
      • 2.2.2 安装
      • 2.2.3 测试

1. openEuler操作系统

  • 镜像下载地址

https://www.openeuler.org/zh/download 选一个下载
openEuler操作系统和openGauss数据库_第1张图片

  • 安装
    按提示安装,安装服务器的时候注意选择安装服务器
    如果需要可以选上openGauss数据库,为了体验我这里选上了。

  • 关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service
  • 关闭selinux

修改文件 /etc/selinux/config

SELINUX=disabled

修改后执行setenforce 0临时关闭,或者一会儿找时间重启一下服务。

  • su命令切换root用户

修改/etc/pam.d/su文件,注释掉下边两行。

#auth           sufficient      pam_wheel.so trust use_uid
#auth           required        pam_wheel.so use_uid

2. openGauss数据库

2.1 系统自带库

如果你刚才安装操作系统的时候选择了安装openGauss数据库,这里直接拿来用就可以了。

2.1.1 允许所有地址访问端口

这里配置文件实际就是postgres的,甚至连名字都没有改。

  • 修改配置文件 /var/lib/opengauss/data/postgresql.conf
listen_addresses = '*'
local_bind_address = '0.0.0.0'
password_encryption_type = 0
  • 修改/var/lib/opengauss/data/pg_hba.conf文件
host all all 0.0.0.0/0 md5
  • 重启数据库
systemctl restart opengauss.service
  • 查看结果
[root@localhost ~]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:7655            0.0.0.0:*               LISTEN      2224/gaussdb
tcp        0      0 0.0.0.0:7654            0.0.0.0:*               LISTEN      2224/gaussdb
tcp6       0      0 :::7655                 :::*                    LISTEN      2224/gaussdb
tcp6       0      0 :::7654                 :::*                    LISTEN      2224/gaussdb

2.1.2 创建远程登录用户

  • 切换到opengauss用户
 su - opengauss
  • 登录数据库
gsql

sql用postgres的sql命令即可。

  • 给初始化用户设置密码
ALTER ROLE openGauss PASSWORD 'liubei@161';
  • 创建远程登录用户
CREATE USER liubei WITH PASSWORD 'liubei@161';
  • 授予改用户admin权限
ALTER USER liubei sysadmin;
  • 之后用openGauss本地登录的命令
gsql -d postgres -W 'liubei@161'
  • liubei用户本地登录的命令
gsql -d postgres -U liubei -W 'liubei@161'
  • 远程登录测试
    openEuler操作系统和openGauss数据库_第2张图片

2.2 安装5.0 版本

2.2.1 下载

  • 下载地址: https://opengauss.org/zh/download/

注意选择架构和操作系统
openEuler操作系统和openGauss数据库_第3张图片

  • 拷贝到对应服务器上

2.2.2 安装

  • 创建普通用户,给压缩包所有者改为该用户

程序禁止root用户安装

  • 切换成普通用户
  • 解压缩安装包
  • 安装包中文件如下
[liubei@localhost openGauss-5.0.0]$ ll
总用量 40
drwxr-x--- 2 liubei liubei 4096  329 03:46 bin
drwx------ 3 liubei liubei 4096  620 19:07 data
drwxr-x--- 3 liubei liubei 4096  329 03:46 etc
drwxr-x--- 3 liubei liubei 4096  329 03:46 include
drwxr-x--- 4 liubei liubei 4096  329 03:46 jre
drwxr-x--- 5 liubei liubei 4096  329 03:46 lib
drwx------ 2 liubei liubei 4096  620 19:07 logs
drwxr-x--- 5 liubei liubei 4096  329 03:46 share
drwxr-x--- 2 liubei liubei 4096  620 19:08 simpleInstall
-rw-r----- 1 liubei liubei   32  329 03:46 version.cfg
  • 进入simpleInstall目录
[liubei@localhost openGauss-5.0.0]$ cd simpleInstall
[liubei@localhost simpleInstall]$ ll
总用量 64
-rw-r----- 1 liubei liubei 10827  329 03:46 finance.sql
-rw-r----- 1 liubei liubei 13009  329 03:46 install.sh
-rw-r--r-- 1 liubei liubei  4489  620 19:08 load.log
-rw-r----- 1 liubei liubei  5056  329 03:46 README.md
-rw-r----- 1 liubei liubei 19713  329 03:46 school.sql
[liubei@localhost simpleInstall]$

  • 执行安装命令
[liubei@localhost simpleInstall]$ sh install.sh -w liubei@161

输出如下:

[step 1]: check parameter
[step 2]: check install env and os setting
[step 3]: change_gausshome_owner
[step 4]: set environment variables

[step 6]: init datanode
The files belonging to this database system will be owned by user "liubei".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

creating directory /home/liubei/openGauss-5.0.0/data/single_node ... ok
creating subdirectories ... in ordinary occasionok
creating configuration files ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1024MB
Begin init undo subsystem meta.
[INIT UNDO] Init undo subsystem meta successfully.
creating template1 database in /home/liubei/openGauss-5.0.0/data/single_node/base/1 ... The core dump path is an invalid directory
2023-06-20 19:07:42.215 [unknown] [unknown] localhost 140505899286464 0[0:0#0]  [BACKEND] WARNING:  macAddr is 21076/3325712, sysidentifier is 1381236786/3205528920, randomNum is 1041071448
ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
initialize global configure for bucketmap length ... ok
creating information schema ... ok
loading foreign-data wrapper for distfs access ... ok
loading foreign-data wrapper for log access ... ok
loading hstore extension ... ok
loading foreign-data wrapper for MOT access ... ok
loading security plugin ... ok
update system tables ... ok
creating snapshots catalog ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok
......
Success. You can now start the database server of single node using:

    gaussdb -D /home/liubei/openGauss-5.0.0/data/single_node --single_node
or
    gs_ctl start -D /home/liubei/openGauss-5.0.0/data/single_node -Z single_node -l logfile

[step 7]: start datanode
[2023-06-20 19:07:56.190][15116][][gs_ctl]: gs_ctl started,datadir is /home/liubei/openGauss-5.0.0/data/single_node
[2023-06-20 19:07:56.217][15116][][gs_ctl]: waiting for server to start...
.0 LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.
......

从上边输出我们可以知道启动/停止命令,以后切换到liubei用户执行:

gs_ctl start|stop|restart -D $GAUSSHOME/data/single_node -Z single_node
  • 开放远程访问

2.1 系统自带库操作即可。

2.2.3 测试

2.1 系统自带库操作即可。


在这里插入图片描述

你可能感兴趣的:(未分类文档,数据库,openEuler,opengauss,华为数据库,国产系统)