centos 7.x 上安装配置 opengauss 数据库指南
openGauss 是华为开源的关系型数据库,基于 PostgreSQL 开发。本文档指导您在 CentOS 7.x 系统上安装和配置 openGauss 数据库。
操作系统:CentOS 7.x
官方网站:https://www.php.cn/link/603dac4761b4799bdecee0dc43b5f2e9
下载地址:https://www.php.cn/link/9d9a7c23c3fef5fcdccf9ed4631a33b1
一、安装前系统准备
禁用 SELINUX:
编辑 /etc/selinux/config 文件:
#SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #添加
保存并退出后执行:setenforce 0 使更改立即生效。
配置防火墙 (iptables):
CentOS 7.x 默认使用 firewalld,这里切换到 iptables。
2.1 关闭 firewalld:
systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewalld yum remove firewalld
2.2 安装并配置 iptables:
yum install iptables-services
编辑 /etc/sysconfig/iptables 文件,添加以下规则以允许 5432 端口的 TCP 连接:
*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
保存并退出后重启 iptables:
systemctl restart iptables.service systemctl enable iptables.service
调整系统参数:
编辑 /etc/sysctl.conf 文件,添加以下内容:
net.ipv4.tcp_retries1=5 net.ipv4.tcp_syn_retries=5 net.sctp.path_max_retrans=10 net.sctp.max_init_retransmits=10 kernel.shmmax = 17179869184 kernel.shmall = 4194304 kernel.sem= 500 5120000 2500 9000
执行 sysctl -p 使更改生效。 安装并加载sctp模块:
yum -y install lksctp* modprobe sctp
接下来调整系统限制:
echo 17179869184 > /proc/sys/kernel/shmmax echo 4194304 > /proc/sys/kernel/shmall echo "* soft stack 3072" >> /etc/security/limits.conf echo "* hard stack 3072" >> /etc/security/limits.conf echo "* soft nofile 1000000" >> /etc/security/limits.conf echo "* hard nofile 1000000" >> /etc/security/limits.conf echo "* soft nproc unlimited" >> /etc/security/limits.d/90-nproc.conf echo never > /sys/kernel/mm/transparent_hugepage/defrag echo never > /sys/kernel/mm/transparent_hugepage/enabled echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.d/rc.local echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local /usr/bin/sh /etc/rc.d/rc.local
修改主机名:
将主机名设置为 opengauss-master:
hostnamectl set-hostname opengauss-master
编辑 /etc/hostname 和 /etc/hosts 文件,将 localhost.localdomain 替换为 opengauss-master。
设置字符集:
LANG=en_US.UTF-8 echo "LANG=en_US.UTF-8" >> /etc/profile source /etc/profile
同步时间:
rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime yum install -y ntp ntpdate time1.aliyun.com hwclock --systohc
安装依赖包:
yum install libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb python3 bzip2
注意: CentOS 7 默认使用 Python 2.7,openGauss 可能需要 Python 3。 需要根据实际情况调整 Python 版本的软链接。 建议使用虚拟环境来管理 Python 版本,避免冲突。
确保yum使用python2.7 (如果需要):
如果安装依赖包出现问题,可能需要临时修改/usr/bin/yum 和 /usr/libexec/urlgrabber-ext-down shebang 为 #!/usr/bin/python2.7 ,安装完成后恢复原状。 建议安装 yum-utils 并使用 yum-config-manager 来管理软件源。
安装telnet:
yum install telnet
完成以上步骤后,建议重启系统。
二、安装数据库
上传安装包: 将下载的 openGauss 安装包 openGauss-3.1.0-CentOS-64bit-all.tar.gz 上传到 /usr/local/src/openGauss 目录。
解压并安装: (具体安装步骤请参考 openGauss 官方文档) 这部分步骤因版本而异,请参考官方文档。 通常包含解压、配置、编译和安装等步骤。
记住,这只是一个简化的指南。 请务必参考 openGauss 官方文档获取最准确和最新的安装和配置信息,并根据您的具体需求进行调整。 尤其注意步骤7和8关于Python版本的部分,需要根据实际情况调整。
以上就是CentOS 7.x安装配置openGauss数据库的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号