openGauss是由华为开源的一款关系型数据库,基于PostgreSQL数据库开发。
操作系统:CentOS 7.x
下载地址:https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/x86/openGauss-3.1.0-CentOS-64bit-all.tar.gz
安装前系统设置
1、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
2、开启防火墙5432端口
CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙。
2.1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
systemctl mask firewalld
systemctl stop firewalld
yum remove firewalld
2.2、安装iptables防火墙
yum install iptables-services #安装
vi /etc/sysconfig/iptables #编辑防火墙配置文件
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*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
:wq! #保存退出
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
/usr/libexec/iptables/iptables.init restart #重启防火墙
3、操作系统参数设置
cat>> /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
EOF
lsmod |grep sctp
yum -y install lksctp*
modprobe sctp
sysctl -p #设置立即生效
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
4、修改主机名称
这里设置主机名为:opengauss-master
hostnamectl set-hostname opengauss-master #CentOS 7.x 8.x
vi /etc/hostname #编辑配置文件CentOS 7.x
opengauss-master #修改localhost.localdomain为opengauss-master
:wq! #保存退出
vi /etc/hosts #编辑配置文件
127.0.0.1 opengauss-master localhost #修改localhost.localdomain为opengauss-master
192.168.21.128 opengauss-master
:wq! #保存退出
5、设置操作系统字符集编码
LANG=en_US.UTF-8
echo "LANG=en_US.UTF-8" >> /etc/profile
source /etc/profile
echo $LANG
6、设置时区同步时间
rm -rf /etc/localtime #先删除默认的时区设置
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #替换上海/北京作为默认
yum install -y ntp #安装ntp
ntpdate time1.aliyun.com #执行时间同步
hwclock --systohc #系统时钟和硬件时钟同步
7、安装依赖包
yum install libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb python3 bzip2
#服务器需要用到Python-3.x命令,但CentOS 7.x 默认版本Python-2.7.x,需要切换到Python-3.x版本
mv /usr/bin/python /usr/bin/python.bak
ln -s python3 /usr/bin/python
8、设置yum使用python2.7否则无法通过yum install安装软件
vi /usr/bin/yum
#!/usr/bin/python2.7
:wq! 保存退出
vi /usr/libexec/urlgrabber-ext-down
/usr/bin/python2.7
:wq! 保存退出
yum install telnet
#设置完成之后重启下系统,继续操作
安装数据库
1、上传安装包到目录/usr/local/src/openGauss下面
2、安装数据库