CentOS 7.x安装配置openGauss数据库
时间:2025-01-23
浏览:196
作者:佚名
本篇文章主要是结合我之前面试的各种经历和实战开发中遇到的问题解决经验整理的,希望这篇《CentOS 7.x安装配置openGauss数据库》对你有很大帮助!欢迎收藏,分享给更多的需要的朋友学习~
CentOS 7.x 上安装配置 openGauss 数据库指南

openGauss 是华为开源的关系型数据库,基于 PostgreSQL 开发。本文档指导您在 CentOS 7.x 系统上安装和配置 openGauss 数据库。
操作系统:CentOS 7.x
官方网站:https://opengauss.org/zh/
下载地址:https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/x86/openGauss-3.1.0-CentOS-64bit-all.tar.gz
一、安装前系统准备
-
禁用 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 firewalld2.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-downshebang 为#!/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数据库》的详细内容,更多关于的资料请关注golang学习网公众号!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
站内热门
最新文章
热门专题
