一、安装说明
GreenPlum数据库文档:https://gp-docs-cn.github.io/docs/common/gpdb-features.html
https://blog.csdn.net/qq_36748248/article/details/118941988
1.1 软件版本
名称 版本
操作系统 CentOS Linux release 8.0.1905 (Core)
GreenPlum 6.12.0
1.2 集群介绍
使用1个master,n个segment的集群示例:
服务器IP地址 节点名称
198.163.0.110 gp-master
198.163.0.111 gp-sdw1
198.163.0.112 gp-sdw2
其中198.163.0.110为master,其余为segment。
二、master节点GreenPlum安装
2.1 安装环境准备
2.1.1修改 /etc/hosts文件
在/etc/hosts文件添加所有节点地址和名称
[root@gp-master ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.163.0.110 gp-master
192.163.0.111 gp-sdw1
192.163.0.112 gp-sdw2
2.1.2 修改 etc/sysconfig/network文件
HOSTNAME是master节点名称
[root@gp-master ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME= gp-master
2.1.3 修改 /etc/sysctl.conf文件
[root@gp-master ~]# vi /etc/sysctl.conf
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 250 512000 100 2048
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni = 2048
net.ipv4.tcp_synCOOKIEs = 1
net.ipv4.ip_forward = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.defalut.arp_filter = 1
net.ipv4.ip_local_port_range = 1025 65535
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.overcommit_memory = 2
[root@gp-master ~]# sysctl -p #使配置生效
2.1.4 修改 /etc/security/limits.d/90-nproc.conf文件
[root@gp-master ~]# vi /etc/security/limits.d/90-nproc.conf
* soft nproc 131072
root soft nproc unlimited
2.1.5 修改 /etc/security/limits.conf文件
[root@gp-master ~]# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
2.2 安装依赖和Greenplum
2.2.1 安装Greenplum依赖
先安装扩展源epel-release
[root@gp-master ~]# yum -y install epel-release
批量安装依赖包 ,建议先安装gcc,再批量安装其他依赖包
[root@gp-master ~]# yum -y install apr-devel \
bison \
bzip2-devel \
cmake3 \
flex \
gcc \
gcc-c++ \
krb5-devel \
libcurl-devel \
libevent-devel \
libkadm5 \
libxml2-devel \
libzstd-devel \
openssl-devel \
perl-ExtUtils-Embed \
python3-devel \
python3-pip \
readline-devel \
xerces-c-devel \
zlib-devel \
apr-util \
perl \
curl \
libnsl
2.2.2 安装Greenplum
[root@gp-master ~]# mkdir -p /gpdb #创建GreenPlum文件夹
[root@gp-master ~]# yum -y install wget #安装wget
[root@gp-master ~]# wget -p https://github.com/greenplum-db/gpdb/releases/download/6.12.0/greenplum-db-6.12.0-ubuntu18.04-amd64.deb /gpdb #下载rpm安装包到/gpdb路径
[root@gp-master ~]# rpm -ivh --prefix=/gpdb /gpdb/greenplum-db-6.12.0-rhel7-x86_64.rpm #安装GreenPlum到/gpdb路径
三、segment节点GreenPlum安装
3.1segment节点安装Greenplum
mkdir /gpdb #创建GreenPlum文件夹
rpm -ivh --prefix=/gpdb /gpdb/greenplum-db-6.12.0-rhel7-x86_64.rpm #安装GreenPlum到/gpdb路径
四、配置集群免密连接
操作前请确保openssh版本一致,不同版本算法有差异,可能导致节点间不能完全互信
4.1 创建gpadmin用户
4.1.1 所有节点创建gpadmin用户
groupadd -g 530 gpadmin
useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin
chown -R gpadmin:gpadmin /home/gpadmin
echo "gpadmin" | passwd --stdin gpadmin
4.1.2 所有节点修改gpadmin用户操作权限
chown -R gpadmin:gpadmin /gpdb
4.2 ssh免密配置(gpadmin用户)
4.2.1 所有节点创建.ssh文件
su - gpadmin #切换到gpadmin用户
在每台服务器上都需要执行
配置ssh
rac1
su 用户
$mkdir ~/.ssh
$chmod 755 ~/.ssh
$/usr/bin/ssh-keygen -t rsa
$/usr/bin/ssh-keygen -t dsa
rac2
su 用户
$mkdir ~/.ssh
$chmod 755 ~/.ssh
$/usr/bin/ssh-keygen -t rsa
$/usr/bin/ssh-keygen -t dsa
rac1
$cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$ssh oracle@rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ssh oracle@rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$chmod 644 ~/.ssh/authorized_keys
rac2
$cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$ssh oracle@rac1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ssh oracle@rac1 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$chmod 644 ~/.ssh/authorized_keys
#建立等效性
rac1,rac2
$ssh rac1
$ssh rac2
4.3 打通集群节点
4.3.1 master节点创建hostlist和seg_hosts文件
hostlist文件包含所有节点名称
[root@gp-master ~]# su - gpadmin
[gpadmin@gp-master ~]# mkdir -p /home/gpadmin/conf
[gpadmin@gp-master ~]# vi /home/gpadmin/conf/hostlist
gp-master
gp-sdw1
gp-sdw2
seg_hosts文件包含所有segment节点名称
[gpadmin@gp-master ~]# vi /home/gpadmin/conf/seg_hosts
gp-sdw1
gp-sdw2
4.3.2 配置节点免密连接
[root@gp-master ~]# su - gpadmin
[gpadmin@gp-master ~]$ source /gpdb/greenplum-db/greenplum_path.sh
[gpadmin@gp-master ~]$ gpssh-exkeys -f /home/gpadmin/conf/hostlist
[STEP 1 of 5] create local ID and authorize on local host
... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped
[STEP 2 of 5] keyscan all hosts and update known_hosts file
[STEP 3 of 5] retrieving credentials from remote hosts
... send to gp-sdw1
... send to gp-sdw2
[STEP 4 of 5] determine common authentication file content
[STEP 5 of 5] copy authentication files to all remote hosts
... finished key exchange with gp-sdw1
... finished key exchange with gp-sdw2
[INFO] completed successfully
测试免密连接
[gpadmin@gp-master ~]$ gpssh -f /home/gpadmin/conf/hostlist
=> pwd
[ gp-sdw1] /home/gpadmin
[ gp-sdw2] /home/gpadmin
[gp-master] /home/gpadmin
=> exit
五、初始化GreenPlum集群
5.1 环境配置
5.1.1 添加gp编译的python包
[root@gp-master ~]# echo "/gpdb/greenplum-db/lib/python" > /usr/lib64/python3.6/site-packages/greenplum.pth
[root@gp-master ~]# vi /etc/ld.so.conf
/gpdb/greenplum-db/lib
[root@gp-master ~]# ldconfig
注意自己的python版本和系统对应的lib路径
5.1.2 创建资源目录
[root@gp-master ~]# su - gpadmin
[gpadmin@gp-master ~]$ mkdir -p /gpdb/opt/data/master #在master节点创建资源目录
#在segment节点创建资源目录
[gpadmin@gp-master ~]$ source /gpdb/greenplum-db/greenplum_path.sh
[gpadmin@gp-master ~]$ gpssh -f /home/gpadmin/conf/seg_hosts
=> mkdir -p /gpdb/opt/data1/primary
[gp-sdw1]
[gp-sdw4]
[gp-sdw2]
[gp-sdw3]
=> mkdir -p /gpdb/opt/data2/primary
[gp-sdw1]
[gp-sdw4]
[gp-sdw2]
[gp-sdw3]
=> mkdir -p /gpdb/opt/data1/mirror
[gp-sdw1]
[gp-sdw4]
[gp-sdw2]
[gp-sdw3]
=> mkdir -p /gpdb/opt/data2/mirror
[gp-sdw1]
[gp-sdw4]
[gp-sdw2]
[gp-sdw3]
=> exit
#需要几个创建几个,我创建了两个
5.1.3 master节点配置环境变量
在master节点/home/gpadmin/.bash_profile添加内容
[gpadmin@gp-master ~]$ vi /home/gpadmin/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
#以下为需添加的内容
source /gpdb/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/gpdb/opt/data/master/gpseg-1
export GPPORT=5432
export PGDATABASE=gp_sydb
将.bash_profile复制到segment节点
[gpadmin@gp-master ~]$ for a in {1..4}; do scp /home/gpadmin/.bash_profile gpadmin@gp-sdw$a:/home/gpadmin/.bash_profile ; done
.bash_profile 100% 290 313.7KB/s 00:00
.bash_profile 100% 290 354.1KB/s 00:00
.bash_profile 100% 290 161.9KB/s 00:00
.bash_profile 100% 290
285.2KB/s 00:00
=> exit
让变量生效
=> source .bash_profile
[ gp-sdw1]
[ gp-sdw4]
[ gp-sdw2]
[gp-master]
[ gp-sdw3]
=> exit
5.1.4 NTP配置
[root@gp-master ~]# echo "server gp-master perfer" >>/etc/ntp.conf
[root@gp-master ~]# su - gpadmin
[gpadmin@gp-master ~]$ gpssh -f /home/gpadmin/conf/hostlist -v -e 'sudo ntpd'
[gpadmin@gp-master ~]$ gpssh -f /home/gpadmin/conf/hostlist -v -e 'sudo /etc/init.d/ntpd start && sudo chkconfig --level 35 ntpd on'
#出现以下结果表示配置成功
Using delaybeforesend 0.05 and prompt_validation_timeout 1.0
[Reset ...]
[INFO] login gp-sdw1
[INFO] login gp-sdw4
[INFO] login gp-sdw2
[INFO] login gp-master
[INFO] login gp-sdw3
[ gp-sdw1] sudo /etc/init.d/ntpd start && sudo chkconfig --level 35 ntpd on
[ gp-sdw1] [sudo] password for gpadmin:
[ gp-sdw4] sudo /etc/init.d/ntpd start && sudo chkconfig --level 35 ntpd on
[ gp-sdw4]
[ gp-sdw4] We trust you have received the usual lecture from the local System
[ gp-sdw4] Administrator. It usually boils down to these three things:
[ gp-sdw4]
[ gp-sdw4] #1) Respect the privacy of others.
[ gp-sdw4] #2) Think before you type.
[ gp-sdw4] #3) With great power comes great responsibility.
[ gp-sdw4]
[ gp-sdw4] [sudo] password for gpadmin:
[ gp-sdw2] sudo /etc/init.d/ntpd start && sudo chkconfig --level 35 ntpd on
[ gp-sdw2]
[ gp-sdw2] We trust you have received the usual lecture from the local System
[ gp-sdw2] Administrator. It usually boils down to these three things:
[ gp-sdw2]
[ gp-sdw2] #1) Respect the privacy of others.
[ gp-sdw2] #2) Think before you type.
[ gp-sdw2] #3) With great power comes great responsibility.
[ gp-sdw2]
[ gp-sdw2] [sudo] password for gpadmin:
[gp-master] sudo /etc/init.d/ntpd start && sudo chkconfig --level 35 ntpd on
[gp-master] sudo: /etc/init.d/ntpd: command not found
[ gp-sdw3] sudo /etc/init.d/ntpd start && sudo chkconfig --level 35 ntpd on
[ gp-sdw3]
[ gp-sdw3] We trust you have received the usual lecture from the local System
[ gp-sdw3] Administrator. It usually boils down to these three things:
[ gp-sdw3]
[ gp-sdw3] #1) Respect the privacy of others.
[ gp-sdw3] #2) Think before you type.
[ gp-sdw3] #3) With great power comes great responsibility.
[ gp-sdw3]
[ gp-sdw3] [sudo] password for gpadmin:
[INFO] completed successfully
NTP是用来使计算机时间同步化的一种协议,不配置不影响后续安装
5.2 初始化数据库
5.2.1 检查节点间连通性
[gpadmin@gp-master ~]$ cd /gpdb/greenplum-db/bin
[gpadmin@gp-master bin]$ gpcheckperf -f /home/gpadmin/conf/hostlist -r N -d /tmp
-------------------
-- NETPERF TEST
-------------------
====================
== RESULT
====================
Netperf bisection bandwidth test
gp-master -> gp-sdw1 = 11.040000
gp-sdw2 -> gp-sdw3 = 10.950000
gp-sdw4 -> gp-master = 111.880000
gp-sdw1 -> gp-master = 10.410000
gp-sdw3 -> gp-sdw2 = 11.080000
gp-master -> gp-sdw4 = 111.920000
Summary:
sum = 267.28 MB/sec
min = 10.41 MB/sec
max = 111.92 MB/sec
avg = 44.55 MB/sec
median = 11.08 MB/sec
5.2.2 创建Greenplum初始化配置文件
[gpadmin@gp-master ~]$ cd /gpdb/greenplum-db/docs/cli_help/gpconfigs
[gpadmin@gp-master gpconfigs]$ cp gpinitsystem_config initgp_config #复制配置文件模板
[gpadmin@gp-master gpconfigs]$ vi initgp_config #修改配置文件
#资源目录,与5.1.2章节保持一致
declare -a DATA_DIRECTORY=(/gpdb/opt/data1/primary /gpdb/opt/data2/primary)
declare -a MIRROR_DATA_DIRECTORY=(/gpdb/opt/data1/mirror /gpdb/opt/data2/mirror) #取消注释
ARRAY_NAME=”gp_sydb” #5.1.3章节配置的初始化数据库名称
MASTER_HOSTNAME=gp-master #主节点名称
MASTER_DIRECTORY=/gpdb/opt/data/master #在5.1.2章节创建的资源目录
MASTER_DATA_DIRECTORY=/gpdb/opt/data/master/gpseg-1 #与5.1.2章节配置一样
MIRROR_PORT_BASE=7000 #取消注释
DATABASE_NAME=gp_sydb #取消注释;5.1.3章节配置的初始化数据库名称
MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts #取消注释;4.3.1章节创建的segment节点名称文件
所有节点更新gpadmin用户操作权限
chown -R gpadmin:gpadmin /gpdb
5.3 初始化和登录
5.3.1 执行初始化
集群初始化
[gpadmin@gp-master ~]$ cd /gpdb/greenplum-db/docs/cli_help/gpconfigs
[gpadmin@gp-master gpconfigs]$ gpinitsystem -c initgp_config
查看集群状态
gpstate -e #查看mirror的状态
gpstate -f #查看standby master的状态
gpstate -s #查看整个GP群集的状态
gpstate -i #查看GP的版本
gpstate --help #帮助文档,可以查看gpstate更多用法
5.3.2 数据库登录
完成初始化后登录数据库
[gpadmin@gp-master ~]$ psql -d postgres
psql (9.4.24)
Type "help" for help.
postgres=# \l #查询数据库
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------+----------+------------+------------+---------------------
gp_sydb | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +
| | | | | gpadmin=CTc/gpadmin
template1 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +
| | | | | gpadmin=CTc/gpadmin
(4 rows)
postgres=#
设置远程访问密码
[gpadmin@gp-master ~]$ psql postgres gpadmin
psql (9.4.24)
Type "help" for help.
postgres=# alter user gpadmin encrypted password 'password';
配置数据库白名单
[gpadmin@gp-master ~]$ vi /gpdb/opt/data/master/gpseg-1/pg_hba.conf #在master资源目录pg_hba.conf文件中添加白名单
# TYPE DATABASE USER ADDRESS METHOD
#local replication gpadmin trust
#host replication gpadmin 127.0.0.1/32 trust
#host replication gpadmin ::1/128 trust
local all gpadmin ident
host all gpadmin 127.0.0.1/28 trust
...
host all gpadmin 192.168.10.xx/32 password #gpadmin用户在192.168.10.xx服务器上使用密码登录
加载pg_hba.conf,使配置生效
gpadmin@gp-master ~]$ gpstop -u
安装postgis
下载(需要注册账号)
https://network.pivotal.io/products/pivotal-gpdb/#/releases/683946/file_groups/2664
gppkg -i postgis-2.5.4+pivotal.2.build.2-gp6-rhel7-x86_64.gppkg
测试
psql -h [ip] -p [port] -d [db_name] -f /usr/local/greenplum-db/share/postgresql/contrib/postgis-2.5/install/postgis.sql
psql -h [ip] -p [port] -d [db_name] -f /usr/local/greenplum-db/share/postgresql/contrib/postgis-2.5/install/spatial_ref_sys.sql
安装PostGis扩展
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
然后可以验证是否安装成功
SELECT postgis_full_version();
参数调整优化
###########2021-03-22:gp参数调整记录###########
gpconfig -c max_connections -v 1250 -m 250 #segment为master的5-10倍
gpconfig -c max_prepared_transactions -v 250 #和master的max_connections参数配置一致
gpconfig -c shared_buffers -v 8192MB #至少>max_connections*16k
gpconfig -c gp_vmem_protect_limit -v 46933 #为在每个segment数据库中完成的所有 工作分配的最大内存
gp_vmem(Greenplum数据库可用的主机内存):
gp_vmem = ((SWAP + RAM) – (7.5GB + 0.05 * RAM)) / 1.7
= (500 -(7.5+0.05*500))/1.7 = 275G
max_acting_primary_segments = 4 (格外加2个容错的primary)=6
gp_vmem_protect_limit = gp_vmem / max_acting_primary_segments
= 275/6=46G = 46933MB
gpconfig -c statement_mem -v 1408MB #statement_mem服务器配置参数是分配给segment数据库中任何单个查询的内存量
statement_mem =((gp_vmem_protect_limit * .9) / max_expected_concurrent_queries)
= 46 933*0.9/30 =1408MB
gpconfig -c effective_cache_size -v 250GB #250GB (物理内存一半),设置有关Postgres查询优化器(计划程序)的单个查询可用的磁盘高速缓存的有效大小的假设,估算使用指数的成本的因素; 较高的值使得更有可能使用索引扫描,较低的值使得更有可能使用顺序扫描
gpconfig -c work_mem -v 25600MB #设置每个segment内存排序的大小,先测试为系统总内存的5%=5%*500=25G=25*1024=25600MB
gpconfig -c temp_buffers -v 2048 #默认1024,以允许每个数据库会话使用临时缓冲区。 这些是仅用于访问临时表的会话本地缓冲区
gpconfig -c gp_fts_probe_threadcount -v 32 #默认16个,故障检测的线程数。大于等于每个节点的segment数。
gpconfig -c gp_hashjoin_tuples_per_bucket -v 5 #默认5,设置HashJoin操作使用的哈希表的目标密度。 较小的值往往会产生较大的哈希表,这可以提高连接性能
gpconfig -c gp_interconnect_setup_timeout -v 2h #默认2h,指定在超时之前等待Greenplum数据库interconnect完成设置的时间
gpconfig -c max_statement_mem -v 8192MB #2000M,设置查询的最大内存限制
gpconfig -c gp_resqueue_priority_cpucores_per_segment -v 6 #默认4,指定每个segment实例分配的CPU单元数
gpconfig -c maintenance_work_mem -v 12GB #默认16MB,指定要在维护操作中使用的最大内存量,例如VACUUM和CREATE INDEX。指定要在维护操作中使用的最大内存量,例如VACUUM和CREATE INDEX。
gpocnfig -c gp_vmem_protect_segworker_cache_limit -v 2048 #默认500,如果查询执行程序进程消耗的数量超过此配置的数量,则在进程完成后,将不会高速缓存该进程以用于后续查询。
################内核参数调整###################
SHMMAX > shared_buffers + other_seg_shmem #对于Greenplum数据库segment,other_seg_shmem的值大约为111MB, 对于Greenplum数据库master,大约为79MB。
SHMALL > (num_instances_per_host * ( shared_buffers + other_seg_shmem )) + other_app_shared_mem
假如shared_buffers=8G=8*1024*1024*1024 => SHMMAX > 8*1024*1024*1024 + (111*8+79)*1024*1024 =9603907584 #494780232499 #500 000 000
SHMALL > (8*(8*1024*1024*1024 + (111*8+79)*1024*1024)) =76831260672 #120795955 #4 000 000 000
vm.overcommit_ratio= 95
vm.overcommit_ratio = (RAM - 0.026 * gp_vmem) / RAM
=(500-0.026*275)/500=0.9857 (取95)
overcomit_memory= 2
echo 10 > /proc/sys/vm/swappiness #vm.swappiness,控制如何使用swap分区,建议设置为10
echo 0 > /proc/sys/vm/zone_reclaim_mode #vm.zone_reclaim_mode,控制一个内存区域内部的内存耗尽时,如何进行内存回收。0表示关闭zone_reclaim模式,从其他zone或者NUMA节点回收内存
echo 500 > /proc/sys/vm/dirty_expire_centisecs #vm.dirty_expire_centisecs,控制内核写缓冲区的旧数据比列,建议500,5s的数据就算旧数据,dpflush进程将这些旧数据写到磁盘
echo 100 > /proc/sys/vm/dirty_writeback_centisecs #vm.dirty_writeback_centisecs,控制内核的脏数据刷新线程pdflush的运行间隔时间,建议设置为100,也就是1s
echo 0 > /proc/sys/vm/dirty_background_ratio #vm.dirty_background_ratio,控制文件系统的pdflush进程何时刷新磁盘。0代表试用写缓冲
echo 0 > /proc/sys/vm/dirty_ratio #vm.dirty_ratio,控制文件系统写缓冲区的大小。0代表不使用写缓冲。
echo 1610612736 > /proc/sys/vm/dirty_background_bytes #vm.dirty_background_bytes,当脏页所占内存达到该值,内核的pdflush线程开始会写脏页。
echo 4294967296 > /proc/sys/vm/dirty_bytes #vm.dirty_bytes,控制脏页占内存的数量,达到该值,执行磁盘写操作。
参考:https://support.huaweicloud.com/tngg-kunpengdbs/kunpenggreenplum_05_0013.html
##################网络参数调整#######################
echo "10000 65535" > /proc/sys/net/ipv4/ip_local_port_range #net.ipv4.ip_local_port_range,定义了地tcp/udp的端口范围。可以理解为系统中的程序会选择这个范围内的端口来连接到目的端口。
echo 1024 > /proc/sys/net/core/somaxconn #net.core.somaxconn,服务端所能accept即处理数据的最大客户端数量,即完成连接上限。默认值是128,建议修改成1024。
echo 16777216 > /proc/sys/net/core/rmem_max #net.core.rmem_max,接收套接字缓冲区大小的最大值。默认值是229376,建议修改成16777216。
echo 16777216 > /proc/sys/net/core/wmem_max #net.core.wmem_max,发送套接字缓冲区大小的最大值(以字节为单位)。默认值是229376,建议修改成16777216。
echo "4096 87380 16777216" > /proc/sys/net/ipv4/tcp_rmem #net.ipv4.tcp_rmem,配置读缓冲的大小,三个值,第一个是这个读缓冲的最小值,第三个是最大值,中间的是默认值。默认值是"4096 87380 6291456",建议修改成"4096 87380 16777216"。
echo "4096 65536 16777216" > /proc/sys/net/ipv4/tcp_wmem #net.ipv4.tcp_wmem,配置写缓冲的大小,三个值,第一个是这个写缓冲的最小值,第三个是最大值,中间的是默认值。默认值是"4096 16384 4194304",建议修改成"4096 65536 16777216"。
echo 360000 > /proc/sys/net/ipv4/tcp_max_tw_buckets #net.ipv4.max_tw_buckets,表示系统同时保持TIME_WAIT套接字的最大数量。默认值是2048,建议修改成360000
参考:https://support.huaweicloud.com/tngg-kunpengdbs/kunpenggreenplum_05_0011.html
##################磁盘和I/O##########################
mount -o rw,nodev,noatime,nobarrier,inode64 /dev/dfa /data #挂载
/sbin/blockdev --setra 16384 /dev/dfa #配置readhead,减少磁盘的寻道次数和应用程序的I/O等待时间,提升磁盘读I/O性能
echo deadline > /sys/block/dfa/queue/scheduler #配置IO调度,deadline更适用于Greenplum数据库场景
grubby --update-kernel=ALL --args="elevator=deadline"
vi /etc/security/limits.conf #配置文件描述符
#添加如下行
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
#####################其他配置#################################
grubby --update-kernel=ALL --args="transparent_hugepage=never" #禁用THP
vim /etc/systemd/logind.conf #设置RemoveIPC
RemoveIPC=no
参考:http://docs-cn.greenplum.org/v6/best_practices/sysconfig.html