systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
yum install -y bzip2 net-tools python3 python3-devel gcc make \
libaio-devel flex bison ncurses-devel glibc-devel \
patch redhat-lsb-core readline-devel
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/x86/openGauss-3.0.0-CentOS-64bit.tar.bz2
tar -xjf openGauss-3.0.0-CentOS-64bit.tar.bz2 -C /opt
groupadd dbgrp
useradd -g dbgrp omm
passwd omm # 设置密码
mkdir -p /opt/opengauss/data
chown -R omm:dbgrp /opt/opengauss
chmod -R 700 /opt/opengauss/data
su - omm
cd /opt/openGauss-3.0.0-CentOS-64bit
python3 setup.py -U omm -D /opt/opengauss/data -R /opt/opengauss/data
编辑 /opt/opengauss/data/postgresql.conf
:
listen_addresses = '*' # 允许远程连接
port = 5432 # 默认端口
password_encryption_type = 0 # 使用md5加密
编辑 /opt/opengauss/data/pg_hba.conf
,添加:
host all all 0.0.0.0/0 md5
gs_ctl restart -D /opt/opengauss/data
gsql -d postgres -p 5432 -r
CREATE USER testuser WITH PASSWORD 'Test@123';
CREATE DATABASE testdb OWNER testuser;
GRANT ALL PRIVILEGES ON DATABASE testdb TO testuser;
\q
gs_ctl status -D /opt/opengauss/data
gsql -d testdb -U testuser -W Test@123 -h 127.0.0.1 -p 5432
cat > /etc/systemd/system/opengauss.service <<EOF
[Unit]
Description=openGauss Database Server
After=network.target
[Service]
Type=forking
User=omm
Group=dbgrp
Environment=PGDATA=/opt/opengauss/data
ExecStart=/opt/openGauss-3.0.0-CentOS-64bit/bin/gs_ctl start -D \$PGDATA
ExecStop=/opt/openGauss-3.0.0-CentOS-64bit/bin/gs_ctl stop -D \$PGDATA
ExecReload=/opt/openGauss-3.0.0-CentOS-64bit/bin/gs_ctl restart -D \$PGDATA
TimeoutSec=300
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable opengauss
systemctl start opengauss
安装时报错 "libreadline.so.6: cannot open shared object file"
ln -s /usr/lib64/libreadline.so.7 /usr/lib64/libreadline.so.6
连接时报错 "FATAL: Invalid username/password"
确保密码正确且使用了正确的加密方式,检查 postgresql.conf
中的 password_encryption_type
设置
远程连接失败
检查防火墙设置,确保 pg_hba.conf
配置正确,且 postgresql.conf
中 listen_addresses
设置为 '*'
内存不足问题
可调整 /opt/opengauss/data/postgresql.conf
中的内存相关参数:
shared_buffers = 512MB
work_mem = 16MB
maintenance_work_mem = 128MB
按照以上步骤操作后,您应该已在 CentOS 7.x 上成功安装并配置了 openGauss 数据库。