示范中的是7.9的下载版本,7.6一样安装,无需担心
如果想要桌面版的,就不要下载最小的Min版本,而是要下载DID版本。
CentOS官网
以下随便选择一个
第一个为DVD版的,这个才有桌面,第二个为Minimal版的,只有命令窗口。
这里只提示四步:
cat /etc/centos-release
可见文章
CentOS搭建集群
提示:no mirrors to try 这个错误,请检查下虚拟机有没有网,联网、联网、联网
在第三步中的3.2,3.3中设置了DNS,可以自动联网
hostname && ifconfig |grep broadcast|awk '{print $2}'
然后修改主机名通过命令(不懂得同学可以查阅下如何修改主机名)
# 第一步 :修改这里的主机名。主机名自己起,就是用新的主机名替换掉localhost.loacldomain
vi /etc/sysconfig/network
# 第二步:将你ip地址和主机名添加下面这个文件进去,新添一行如:IP地址 主机名
vi /etc/hosts
以下步骤主服务器和备服务器都要执行,第八开始在主服务器上进行即可
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
"""
注:提示-bash: wget: command not found (这是在Mini版本下)
解决办法:http://mirrors.163.com/.help/centos.html,下载对应的版本
将文件上传至/etc/yum.repos.d/
yum clean all
yum makecache
yum -y install wget
再重新执行即可
"""
yum clean all
yum install -y lksctp*
yum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel
yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core
rpm -qa java-1.8.0-openjdk psmisc bzip2 libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core lksctp-tools* python3 python3-devel
checksctp
hostname && ifconfig |grep broadcast|awk '{print $2}'
sed -i '/MasterG/d' /etc/hosts
echo "192.168.6.106 MasterG ##Gauss OM IP Hosts Mapping" >> /etc/hosts
cat /etc/hosts|grep Gauss
systemctl status firewalld
systemctl disable firewalld.service
systemctl stop firewalld.service
sed -i '/SELINUX=/d' /etc/selinux/config
echo "SELINUX=disabled" >> /etc/selinux/config
cat /etc/selinux/config|grep -v ^#|grep -v '^$'
reboot
echo "export LANG=en_US.UTF-8" >> ~/.bash_profile
source ~/.bash_profile
env|grep LANG
rm -fr /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ll /etc/localtime
cp /etc/fstab /etc/fstab.bak
sed -i '/swap/s/^/#/' /etc/fstab
cat /etc/fstab|grep -v ^#|grep -v '^$'
swapoff -a
sed -i '/Banner/s/^/#/' /etc/ssh/sshd_config
sed -i '/PermitRootLogin/s/^/#/' /etc/ssh/sshd_config
echo -e "\n" >> /etc/ssh/sshd_config
echo "Banner none " >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
cat /etc/ssh/sshd_config |grep -v ^#|grep -E 'PermitRootLogin|Banner'
groupadd dbgrp
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1 5 net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 9 8 net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
net.sctp.association_max_retrans = 10
net.sctp.hb_interval = 30000
net.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
net.sctp.sndbuf_policy = 0
net.sctp.rcvbuf_policy = 0
net.sctp.sctp_mem = 94500000 915000000 927000000
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.ipv4.ip_local_port_range = 26000 65535
kernel.sem = 250 6400000 1000 25600
vm.min_free_kbytes = 102400 ##suggest to set as physical memory * 5%
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.sctp.addip_enable = 0
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
EOF
sysctl -p
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
tail -n 4 /etc/security/limits.conf
tail -n 1 /etc/security/limits.d/90-nproc.conf
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
sed -i '/^GRUB_CMDLINE_LINUX/d' /etc/default/grub
echo "GRUB_CMDLINE_LINUX=\"rhgb quiet transparent_hugepage=never\"" >> /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
接下来的操作在主服务器上进行即可
mkdir -p /soft/openGauss
chmod 775 -R /soft
vi /soft/openGauss/clusterconfig.xml
在clusterconfig.xml中输入下面内容:ip和节点名自己注意改下,以及可以去官方文档查看单机和一主一备的xml配置文件,其次这里设置的port是26000(和上面的配置有关)
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="gsCluster" />
<!-- 数据库节点名称(hostname) -->
<PARAM name="nodeNames" value="MasterG,SlaveG1,SlaveG2" />
<!-- 数据库安装目录-->
<PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
<!-- 日志目录-->
<PARAM name="gaussdbLogPath" value="/var/log/omm" />
<!-- 临时文件目录-->
<PARAM name="tmpMppdbPath" value="/opt/huawei/tmp"/>
<!-- 数据库工具目录-->
<PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
<!-- 数据库core文件目录-->
<PARAM name="corePath" value="/opt/huawei/corefile"/>
<!-- 节点IP,与数据库节点名称列表一一对应 -->
<PARAM name="backIp1s" value="192.168.6.106,192.168.6.107,192.168.6.108"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的部署信息 -->
<DEVICE sn="MasterG">
<!-- 节点1的主机名称 -->
<PARAM name="name" value="MasterG"/>
<!-- 节点1所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.6.106"/>
<PARAM name="sshIp1" value="192.168.6.106"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/opt/huawei/install/data/dn,SlaveG1,/opt/huawei/install/data/dn,SlaveG2,/opt/huawei/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<!-- 节点2上的部署信息 -->
<DEVICE sn="SlaveG1">
<!-- 节点2的主机名称 -->
<PARAM name="name" value="SlaveG1"/>
<!-- 节点2所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.6.107"/>
<PARAM name="sshIp1" value="192.168.6.107"/>
</DEVICE>
<!-- 节点3上的部署信息 -->
<DEVICE sn="SlaveG2">
<!-- 节点3的主机名称 -->
<PARAM name="name" value="SlaveG2"/>
<!-- 节点3所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点3的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.6.108"/>
<PARAM name="sshIp1" value="192.168.6.108"/>
</DEVICE>
</DEVICELIST>
</ROOT>
(把openGauss-1.0.1-CentOS-64bit.tar.gz移动到/soft/openGauss下)
cd /soft/openGauss
tar -zxvf openGauss-1.0.1-CentOS-64bit.tar.gz
# 注意 2.0.0版本下还需要解压om压缩包
# tar -zxvf openGauss-x.x.x-openEuler-64bit-om.tar.gz
注:提示51400看下是不是ssh互信失败,重新互信下
mkdir /gauss
chgrp dbgrp -R /gauss
chmod 775 -R /gauss
export LD_LIBRARY_PATH=/soft/openGauss/script/gspylib/clib:$LD_LIBRARY_PATH
cd /soft/openGauss/script
./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/clusterconfig.xml
reboot
/soft/openGauss/script/gs_checkos -i A --detail
chmod -R 775 /soft/
chown omm:dbgrp /soft -R
su - omm
# 这一步需要数据库输入密码,可输入gauss@123
gs_install -X /soft/openGauss/clusterconfig.xml \
--gsinit-parameter="--encoding=UTF8" \
--dn-guc="max_connections=1000" \
--dn-guc="max_process_memory=3GB" \
--dn-guc="shared_buffers=128MB" \
--dn-guc="bulk_write_ring_size=128MB" \
--dn-guc="cstore_buffers=16MB"
gsql -d postgres -p 26000 -r
postgres=# alter role omm identified by 'gauss@123' replace 'gauss@2020';
postgres=# CREATE DATABASE mydb WITH ENCODING 'UTF-8';
postgres=# select version();
postgres=# \l
openGauss部署可能遇到的问题
如果遇到[51400]问题,基本上是没有SSH互信成功,按第三步中的里面的3.6进行操作。