open gaussdb安装步骤
关闭防火墙和开机自启关闭 SELinux
目前仅支持在防火墙关闭的状态下进行安装。
systemctl status firewalld
systemctl stop firewalld.service && systemctl disable firewalld.service
cat /etc/selinux/config | grep disabled
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
reboot
设置字符集参数
将各数据库节点的字符集设置为相同的字符集,可以在/etc/profile文件中添加”export LANG=XXX”(XXX为Unicode编码)。
echo 'export LANG=en_US.UTF-8' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
设置时区和时间
将各数据库节点的时区设置为相同时区,
timedatectl | grep Time
timedatectl set-timezone "Asia/Shanghai"
说明: 可以通过date命令查询主机时区。
关闭swap交换内存(可选)
说明: 关闭swap交换内存是为了保障数据库的访问性能,避免把数据库的缓冲区内存淘汰到磁盘上。 如果服务器内存比较小,内存过载时,可打开swap交换内存保障正常运行。
free -m
vi /etc/fstab #注释掉swap分区挂载
swapoff -a #重启失效
配置网络
配置hosts文件
echo "192.168.137.17 guassdb1">> /etc/hosts
cat /etc/hosts
设置网卡MTU值
将各数据库节点的网卡MTU值设置为相同大小。对于X86,MTU值推荐1500;对于ARM,MTU值推荐8192。
ip a #查看,MTU值不是1500就需要修改
ifconfig ens33 mtu 1500
systemctl restart network
设置root用户远程登录
cat /etc/ssh/sshd_config | grep PermitRootLogi
cat /etc/ssh/sshd_config | grep Banner
sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/g" /etc/ssh/sshd_config #允许root用户远程登录
sed -i "s/#Banner none/Banner none/g" /etc/ssh/sshd_config #修改Banner配置
cat /etc/ssh/sshd_config | grep PermitRootLogi
cat /etc/ssh/sshd_config | grep Banner
systemctl restart sshd.service
创建安装用户和组
在安装openGauss过程中运行“gs_install”时,会创建与安装用户同名的数据库用户,即数据库用户omm。此用户具备数据库的最高操作权限,此用户初始密码由用户指定。
groupadd -g 30001 dbgrp
useradd -u 31001 -g dbgrp omm
echo "czalex" | passwd --stdin omm
id omm
关闭透明大页(transparent_hugepage)
#检查当前的transparent_hugepage状态
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
#[always] madvise never为开启状态
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bkp_original #<==先备份,修改后需要重启系统才会生效。
#<==在/etc/rc.d/rc.local中加入如下参数
cat>>/etc/rc.d/rc.local<<EOF
# 关闭transparent_hugepage
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
EOF
#查看是否关闭
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
# 授予执行权限
chmod +x /etc/rc.d/rc.local
操作系统参数设置
cat>>/etc/sysctl.conf <<EOF
vm.swappiness=0
net.ipv4.tcp_fin_timeout=60
net.ipv4.tcp_retries1=5
net.ipv4.tcp_syn_retries=5
net.sctp.path_max_retrans=10
net.sctp.max_init_retransmits=10
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries2 = 12
net.ipv4.ip_local_reserved_ports = 20050-26007
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.sctp.sctp_mem = 94500000 915000000 927000000
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
kernel.sem = 250 6400000 1000 25600
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
vm.min_free_kbytes = 399514
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.somaxconn = 65535
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
EOF
sysctl -p
操作系统资源限制
cat>>/etc/security/limits.conf <<EOF
root soft as unlimited
omm soft as unlimited
root hard as unlimited
omm hard as unlimited
root soft nproc unlimited
omm soft nproc 16384
root hard nproc unlimited
omm hard nproc unlimited
root soft nofile 1000000
omm soft nofile 1000000
root hard nofile 1000000
omm hard nofile 1000000
* stack
EOF
系统支持的最大进程数设置
需要对系统支持的最大进程数进行手动设置时,执行如下命令打开conf文件。
vim /etc/security/limits.d/90-nproc.conf
* soft nproc unlimited
完成修改后,需重启操作系统使得设置的参数生效。
配置yum源和epel源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安装依赖包
yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel openssl-devel bzip2 bzip2-devel make zlib-devel sqlite-devel gcc tk-devel gdbm-devel libdb4-devel libpcap-devel xz-devel libffi-devel wget python3 python3-devel ntp
配置NTPD(单机可选)
内网有单独的NTP服务器可以添加crontab定期同步时间
service ntpd start
chkconfig ntpd on
配置SSH互信
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.137.17
su - omm
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub omm@192.168.137.17
创建软件存放目录和安装目录
mkdir -p /app/software/openGauss
mkdir -p /app/gaussdb/
mkdir -p /data/gaussdb/{tmp,log,corefile,data/db1}
上传安装包
利用XFTP工具上传到 /app/software/openGauss 目录
cd /app/software/openGauss
tar -zxvf openGauss-1.1.0-CentOS-64bit-all.tar.gz
tar -zxvf openGauss-1.1.0-CentOS-64bit-om.tar.gz
授权目录
chmod 755 -R /app/software /app/gaussdb /data/gaussdb
chown omm.dbgrp -R /app/software /app/gaussdb /data/gaussdb
单节点配置文件
创建 cluster_config.xml 配置文件,存放在 /app/software/openGauss 目录
vi /app/software/openGauss/cluster_config.xml
<?xml version="1.1" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="gscluster" />
<!-- 数据库节点名称(hostname) -->
<PARAM name="nodeNames" value="gaussdb1" />
<!-- 数据库安装目录-->
<PARAM name="gaussdbAppPath" value="/app/gaussdb/app" />
<!-- 日志目录-->
<PARAM name="gaussdbLogPath" value="/data/gaussdb/log" />
<!-- 临时文件目录-->
<PARAM name="tmpMppdbPath" value="/data/gaussdb/tmp" />
<!-- 数据库工具目录-->
<PARAM name="gaussdbToolPath" value="/app/gaussdb/om" />
<!-- 数据库core文件目录-->
<PARAM name="corePath" value="/data/gaussdb/corefile" />
<!-- 节点IP,与数据库节点名称列表一一对应 -->
<PARAM name="backIp1s" value="192.168.137.17"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的部署信息 -->
<DEVICE sn="1000001">
<!-- 节点1的主机名称 -->
<PARAM name="name" value="gaussdb1"/>
<!-- 节点1所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.137.17"/>
<PARAM name="sshIp1" value="192.168.137.17"/>
<!--dbnode-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/data/gaussdb/data/db1"/>
</DEVICE>
</DEVICELIST>
</ROOT>
开始初始化
export LD_LIBRARY_PATH=/app/software/openGauss/script/gspylib/clib:$LD_LIBRARY_PATH
cd /app/software/openGauss/script
python3 gs_preinstall -U omm -G dbgrp -L -X /app/software/openGauss/cluster_config.xml
/app/software/openGauss/script/gs_checkos -i A -h gaussdb1 --detail ##查看具体的检查信息
reboot ##重启系统,使limits资源生效
切换 omm 用户 ,执行数据库安装
su - omm
cd /app/software/openGauss/script
gs_install -X /app/software/openGauss/cluster_config.xml
TIPS:此步骤要求输入符合密码复杂度要求的密码:最少包含8个字符,不能和用户名、当前密码(ALTER)、或当前密码反序相同,至少包含大写字母(A-Z),小写字母(a-z),数字,非字母数字字符(限定为~!@#$%^&*()-_=+\|[{}];:,<.>/?)四类字符中的三类字符。
安装过程中会生成ssl证书,证书存放路径为{gaussdbAppPath}/share/sslcert/om,其中{gaussdbAppPath}为openGauss配置文件中指定的程序安装目录
初设密码:Czalex920.
查看数据库进程和修改密码
ps -ef | grep gaussdb
gsql -d postgres -p 26000 -r ##进入数据库
ALTER ROLE omm IDENTIFIED BY 'Czalex920.' REPLACE 'Zzj-920';
创建数据库
postgres=# create database uat;
查看安装版本
postgres=# show server_version;
server_version
----------------
9.2.4
(1 row)
postgres=# select version();
version
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.2.4 (openGauss 1.1.0 build 392c0438) compiled at 2020-12-31 20:07:42 commit 0 last mr on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)
查看帮助
postgres=# help
You are using gsql, the command-line interface to gaussdb.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with gsql commands
\g or terminate with semicolon to execute query
\q to quit
postgres=# \q
[omm@gaussdb1 ~]$ gs_om --help
gs_om is a utility to manage a cluster.
Usage:
gs_om -? | --help
gs_om -V | --version
OLAP scene:
gs_om -t start [-h HOSTNAME] [-D dataDir] [--time-out=SECS]
[--security-mode=MODE] [-l LOGFILE]
gs_om -t stop [-h HOSTNAME] [-D dataDir] [--time-out=SECS] [-m MODE]
[-l LOGFILE]
gs_om -t restart [-h HOSTNAME] [-D dataDir] [--time-out=SECS]
[--security-mode=MODE] [-l LOGFILE] [-m MODE]
gs_om -t status [-h HOSTNAME] [-o OUTPUT] [--detail] [--all] [-l LOGFILE]
gs_om -t generateconf -X XMLFILE [--distribute] [-l LOGFILE]
gs_om -t cert [--cert-file=CERTFILE | --rollback] [-L] [-l LOGFILE]
gs_om -t kerberos -m [install|uninstall] -U USER [-l LOGFILE]
[--krb-server|--krb-client]
gs_om -t view [-o OUTPUT]
gs_om -t query [-o OUTPUT]
gs_om -t refreshconf
General options:
-t Type of the OM command.
-l Path of log file.
-?, --help Show help information for this utility,
and exit the command line mode.
-V, --version Show version information.
Options for start
-h Name of the host to be started.
-D Path of dn
--time-out=SECS Maximum waiting time when start the
cluster or node.
--security-mode=MODE database start with security mode: on or off
on: start with security mode
off: start without security mode
Options for stop
-h Name of the host to be shut down.
-m, --mode=MODE Shutdown mode. It can be f (fast),
or i (immediate).
-D Path of dn
--time-out=SECS Maximum waiting time when start the cluster
or node.
Options for status
-h Name of the host whose status is to be
queried.
--az Name of the single az whose status is to
be queried.
-o Save the result to the specified file.
--detail Show detailed status information.
--all Show all database node status information.
Options for generating configuration files
-X Path of the XML configuration file.
--distribute Distribute the static configuration file
to installation directory of cluster nodes.
Options for cert
--cert-file Path of cert file.
--rollback Perform rollback SSL cert files.
-L local mode.
Options for kerberos
-m Kerberos management mode. It can be
install or uninstall.
-U %s cluster user.
Install options:
--krb-server Execute install for server. This parameter
only work for install
--krb-client Execute install for client. This parameter
only work for install
退出
postgres-# \q
数据库启动和停止,数据库状态查看
gs_om -t status --detail ##查看数据库状态
gs_om -t start ##启动数据库
gs_om -t stop ##停止数据库
gs_om -t status --all ##查看数据库系统详细信息
下面是一些拓展
数据库性能监控
[omm@gaussdb1 ~]$ gs_checkperf
数据库卸载
gs_uninstall --delete-data
最后修改时间:2021-03-27 14:31:09
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




