安装前提:
软件环境:openEuler 20.03LTS 个人开发者最低配置2核4G,推荐配置4核8G
数据库版本:openGauss-5.0.2-openEuler-64bit-all.tar.gz
数据库下载地址:
https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/InstallationGuide/%E4%BC%81%E4%B8%9A%E7%89%88%E5%AE%89%E8%A3%85.html
### 操作系统配置
--01.hosts文件配置
echo "192.168.1.61 gaussdb001">> /etc/hosts
--02.修改/etc/sysconfig/network 文件内容
#开机激活网路
cat >> /etc/sysconfig/network << EOF
NETWORKING=yes
EOF
cat /etc/sysconfig/network
--03.创建目录、用户组
mkdir /gauss
mount /gauss
mkdir -p /gauss/{gaussdb,archive,scripts,backup,soft}
groupadd gauss
useradd -g gauss -d /home/gauss -m -s /bin/bash gauss
echo "gauss123" | passwd --stdin gauss
chown -R gauss:gauss /gauss
--04.设置环境变量
su - gauss
vi ~/.bash_profile
追加
su - gauss
vi ~/.bash_profile
export LANG=en_US.UF8
export PS1="[`whoami`@`hostname`:"'$PWD]$'
export GAUSSHOME=/gauss/gaussdb/app
export LD_LIBRARY_PATH=/gauss/gaussdb/app/lib
export PATH=/gauss/gaussdb/bin:$PATH:$HOME/.local/bin:$HOME/bin
cat ~/.bash_profile
exit
su - gauss
env | grep gauss
看到生效了。
--05.修改资源限制参数
cat >> /etc/security/limits.conf << EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 1000000
* hard nofile 1000000
* soft stack 65535
* hard stack 65535
* hard memlock unlimited
* soft memlock unlimited
EOF
cat /etc/security/limits.conf
--06.修改内核参数
echo "vm.swappiness=10">> /etc/sysctl.conf
echo "fs.aio-max-nr=1048576">> /etc/sysctl.conf
echo "fs.file-max =6815744">> /etc/sysctl.conf
echo "net.ipv4.tcp_retries1=5">> /etc/sysctl.conf
echo "net.ipv4.tcp_syn_retries=5">> /etc/sysctl.conf
echo "net.ipv4.tcp_synack_retries=5">> /etc/sysctl.conf
echo "net.ipv4.tcp_retries2=12">> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range=26000 65535">> /etc/sysctl.conf
echo "vm.min_free_kbytes=512000">> /etc/sysctl.conf
echo "net.ipv4.tcp_fin_timeout=60">> /etc/sysctl.conf
echo "net.ipv4.tcp_sack=1">> /etc/sysctl.conf
echo "net.ipv4.tcp_timestamps=1">> /etc/sysctl.conf
echo "vm.extfrag_threshold=500">> /etc/sysctl.conf
echo "vm.overcommit_ratio=90">> /etc/sysctl.conf
echo "kernel.sem = 50100 128256000 50100 2560">> /etc/sysctl.conf
sysctl -p
echo "* - nproc 65535"> /etc/security/limits.d/90-nproc.conf
--07.修改时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock
--08.配置安全
echo "SELINUX=disabled"> /etc/selinux/config
echo "#SELINUXTYPE=targeted">> /etc/selinux/config
cat /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
--09.关闭透明大页
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
永久禁用THP(Transparent HugePages )
编辑rc.local文件:
vim /etc/rc.d/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
[root@localhost ~]# chmod +x /etc/rc.d/rc.local
最后重启系统,以后再检查THP应该就是被禁用了
[root@localhost ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[root@localhost ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
另一种方式查看是否被禁用看是否为0
cat /proc/sys/vm/nr_hugepages
sysctl vm.nr_hugepages
查看使用的内存
cat /proc/meminfo && grep AnonHugePages /proc/meminfo
--010.禁用RemovelPC
sed -i '/^RemoveIPC/d' /etc/systemd/logind.conf
sed -i '/^RemoveIPC/d' /usr/lib/systemd/system/systemd-logind.service
echo "RemoveIPC=no" >> /etc/systemd/logind.conf
echo "RemoveIPC=no" >> /usr/lib/systemd/system/systemd-logind.service
systemctl daemon-reload
systemctl restart systemd-logind
loginctl show-session | grep RemoveIPC
systemctl show systemd-logind | grep RemoveIPC
-011.配置YUM环境
mount /dev/cdrom /mnt
cd /etc/yum.repos.d
mkdir bk
mv *.repo bk/
echo "[EL7-l]"> /etc/yum.repos.d/itpux.repo
echo "name=Linux-7">> /etc/yum.repos.d/itpux.repo
echo "baseurl=file:///mnt" >> /etc/yum.repos.d/itpux.repo
echo "gpgcheck=0">> /etc/yum.repos.d/itpux.repo
echo "enabled=1">>/etc/yum.repos.d/itpux.repo
yum install -y libaio-devel libnsl flex bison ncurses-devel glibc-devel patch readline-devel
yum install -y net-tools tar bzip2 python3 cmake gcc zlib gcc-c++ perl zlib-devel tcl openssl openldap pam expect
### openGauss单机单节点数据库安装
openEuler-LTS 20.03版操作系统提供的libreadline库文件为libreadline.so.8,而并非数据库初始化脚本所需要的libreadline.so.7,初始化时自然无法找到这个文件。
使用以下命令即可定位当前系统使用的libreadline库
在root用户权限下,在/usr/lib64路径下对两个文件建立软连接,再次初始化数据库即可解决
cd /usr/lib64
ln -s libreadline.so.8 libreadline.so.7
su - gauss
cd /gauss/soft/
tar zxvf openGauss-5.0.2-openEuler-64bit-all.tar.gz
tar jxvf openGauss-5.0.2-openEuler-64bit.tar.bz2 -C /gauss/gaussdb/
cd /gauss/gaussdb/simpleInstall
sh install.sh -w Gauss_123 && source ~/.bashrc
ps aux | grep gaussdb
启停操作:
gs_ctl start -D /gauss/gaussdb/data/single_node -Z single_node
gs_ctl stop -D /gauss/gaussdb/data/single_node -Z single_node
gs_ctl restart -D /gauss/gaussdb/data/single_node -Z single_node
gs_ctl query -D /gauss/gaussdb/data/single_node -Z single_node
登录数据库
gsql -d postgres -p 5432
给新用户设定密码
gsql -h 127.0.0.1 -p 5432 -U gauss -d postgres
ALTER USER gauss WITH password 'Gauss_123';