openGauss 5.0 单节点安装部署与使用

2023年 9月 25日 129.4k 0

1.环境准备

1.1 安装依赖包文件

[root@localhost ~]# yum install libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel libnsl

1.2 关闭selinux和防火墙

vim /etc/selinux/config

修改config文件,将SELINUX的值变为"disabled"

检测防火墙是否关闭

systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld

1.3 设置字符集参数

vim /etc/profile在行尾添加

export LANG=en_US.UTF-8

1.4 关闭swap

swapoff -a (当内存较小时,可打开)

1.5 关闭RemoveIPC

(因为使用的环境为CentOS,默认关闭)
![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)

2.安装

2.1 创建工作用户和目录

[root@localhost opt]# useradd opengauss
[root@localhost opt]# mkdir -p /opt/opengauss

2.2 解压压缩包到安装目录、对目录授权并进行安装

[root@localhost tmp]# tar -jxf openGauss-5.0.0-CentOS-64bit.tar.bz2 -C /opt/opengauss
[root@localhost tmp]# cd /opt/opengauss/
[root@localhost opengauss]# chmod 755 -R /opt/opengauss
[root@localhost opengauss]# chown -R opengauss /opt/opengauss
[root@localhost opengauss]# sudo -iu opengauss
[opengauss@localhost ~]$ cd /opt/opengauss/simpleInstall
[opengauss@localhost simpleInstall]$ sh install.sh -w "52@openGauss" &&source ~/.bashrc

(注意:如果出现这种错误,请使用拥有root权限的用户执行sysctl -w kernel.sem="250 85000 250 330"即可)
![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)

2.3 检查进程,判断数据库是否启动

[opengauss@localhost ~]$ ps -ef | grep gauss
opengau+ 4946 1 3 11:20 ? 00:08:09 /opt/opengauss/bin/gaussdb -D /opt/opengauss/data/single_node
root 10843 3518 0 14:04 pts/0 00:00:00 sudo -iu opengauss
root 19289 3846 0 15:50 pts/1 00:00:00 sudo -iu opengauss
opengau+ 19387 19291 0 15:51 pts/1 00:00:00 grep --color=auto gauss

也可以使用gs_ctl status命令,判断数据库状态:

[opengauss@localhost ~]$ gs_ctl status
[2023-07-05 15:53:37.581][19531][][gs_ctl]: gs_ctl status,datadir is /opt/opengauss/data/single_node
gs_ctl: server is running (PID: 4946)
/opt/opengauss/bin/gaussdb "-D" "/opt/opengauss/data/single_node"

2.4 使用gs_ctl notify查看数据文件目录

[opengauss@localhost ~]$ gs_ctl notify
[2023-07-05 16:00:42.972][20104][][gs_ctl]: gs_ctl notify ,datadir is /opt/opengauss/data/single_node
[2023-07-05 16:00:42.973][20104][][gs_ctl]: the parameter of notify must be specified

3.日常使用

3.1 查看版本信息

可以使用select version()查看数据库版本,使用show server_version查看pg基础版本
![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)

3.2 常用命令

l查看当前有哪些数据库
c查看当前会话连接信息
db查看有哪些表空间
du查看用户和角色
dn查看当前数据库有哪些schema
dt查看数据库中所有表
![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)

3.3 创建用户并授予权限

openGauss=# CREATE USER test1 IDENTIFIED BY 'opengauss@2023';
CREATE ROLE
openGauss=# ALTER USER test1 CREATEROLE;
ALTER ROLE

![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)

3.4 创建表并插入数据

openGauss=# create table test0707(id CHAR(2) NOT NULL,update_user VARCHAR(20) NOT NULL);
CREATE TABLE
openGauss=# insert into test0707(id,update_user) values(1,'Bob');
INSERT 0 1

![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)

3.5 创建模式

创建了两个schema

openGauss=# create schema t1 AUTHORIZATION test1;
CREATE SCHEMA
openGauss=# create schema t2 AUTHORIZATION test1;
CREATE SCHEMA

![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)
在不同schema下创建表名均为test01的表,插入不同数据

openGauss=# create table t1.test01(id CHAR(2) NOT NULL,update_user VARCHAR(20) NOT NULL);
CREATE TABLE
openGauss=# insert into t1.test01(id,update_user) values(2,'Tom');
INSERT 0 1
openGauss=# create table t2.test01(id CHAR(2) NOT NULL,update_user VARCHAR(20) NOT NULL);
CREATE TABLE
openGauss=# insert into t2.test01(id,update_user) values(3,'Nancy');
INSERT 0 1

![图片](data:image/svg+xml,%3C%3Fxml version=‘1.0’ encoding=‘UTF-8’%3F%3E%3Csvg width=‘1px’ height=‘1px’ viewBox=‘0 0 1 1’ version=‘1.1’ xmlns=‘http://www.w3.org/2000/svg’ xmlns:xlink=‘http://www.w3.org/1999/xlink’%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=‘none’ stroke-width=‘1’ fill=‘none’ fill-rule=‘evenodd’ fill-opacity=‘0’%3E%3Cg transform=‘translate(-249.000000, -126.000000)’ fill=’%23FFFFFF’%3E%3Crect x=‘249’ y=‘126’ width=‘1’ height=‘1’%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E)
通过结果可以看出,不切换对应schema,是无法进行查看其他schema的内容

复制搜一搜分享收藏划线

人划线

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论