安装openGuassDB
//
opengauss官方文档 (opens new window)
# 安装openGuassDB
- 环境要求
系统:centos7
https://docs.opengauss.org/zh/docs/5.0.0-lite/docs/GettingStarted/%E5%87%86%E5%A4%87%E8%BD%AF%E7%A1%AC%E4%BB%B6%E5%AE%89%E8%A3%85%E7%8E%AF%E5%A2%83.html
- 配置系统环境
echo "kernel.sem = 250 85000 250 330" >> /etc/sysctl.conf
cat >>/etc/security/limits.conf<<'EOF'
* soft nofile 65535
* hard nofile 65536
hive - nofile 65535
hive - nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF
echo 'GAUSSHOME=/opt/software/openGauss' >>/etc/profile
echo 'export LD_LIBRARY_PATH=/opt/software/openGauss/lib:$LD_LIBRARY_PATH' >> /etc/profile
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
- 创建服务运行用户
useradd omm
mkdir -p /opt/software/openGauss
tar xf openGauss-5.0.2-CentOS-64bit.tar.bz2 -C /opt/software/openGauss
chown -R omm.omm /opt/software/openGauss
1
2
3
4
5
2
3
4
5
- 使用普通用户omm安装openGauss
su - omm
cd /opt/software/openGauss/simpleInstall/
export LD_LIBRARY_PATH=/opt/software/openGauss/lib:$LD_LIBRARY_PATH
export PATH=$PATH:/opt/software/openGauss/bin/
bash install.sh -w "1qaz@2wsx"
1
2
3
4
5
6
2
3
4
5
6
# 服务管理
gs_ctl start|stop|restart -D $GAUSSHOME/data/single_node -Z single_node
- 登录数据库
gsql -U omm -d postgres -r
- 创建用户
create user yfk with password '1qaz@2wsx';
- 授予超级管理员权限
alter user yfk with Sysadmin;
- 解锁用户
alter user yfk account unlock;
- 创建postgresql类型数据库
CREATE DATABASE dm_platform WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' dbcompatibility = 'PG' ;
- 备份
备份可以用 pg_dump 备份,还原用超级管理员还原
# 配置service脚本
cat >/etc/init.d/opengauss<<'EOF'
#!/bin/bash
GAUSSHOME=/opt/software/openGauss
export LD_LIBRARY_PATH=/opt/software/openGauss/lib:$LD_LIBRARY_PATH
start() {
echo "Starting openGauss..."
# 启动命令
su - omm -c "
gs_ctl -D $GAUSSHOME/data/single_node start -Z single_node"
}
stop() {
echo "Stopping openGauss..."
# 停止命令
su - omm -c "
gs_ctl -D $GAUSSHOME/data/single_node stop -Z single_node"
}
restart() {
echo "Restarting openGauss..."
# 重启命令
su - omm -c "
gs_ctl -D $GAUSSHOME/data/single_node restart -Z single_node"
}
status() {
echo "Checking openGauss status..."
ps -ef |grep gaussdb |grep -v grep
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
EOF
chmod +x /etc/init.d/opengauss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
如果此文章对您有帮助,点击 -->> 请博主喝咖啡 (opens new window)
上次更新: 2025/05/09, 11:56:38