GPDB之安装GPDB

2016/08/23 GPDB 共 6926 字,约 20 分钟

1. 配置机器的对应关系

192.168.20.65   mdw    
192.168.20.66   smdw  
192.168.20.67   sdw1 
192.168.20.68   sdw2 
192.168.20.69   sdw3

 

2. 将数据盘格式化成xfs文件系统

2.1格式化xfs根

#master节点:
rpm -ivh xfsprogs-2.9.4-1.el5.centos.x86_64.rpm 
mkfs.xfs -f /dev/sdb
mount /dev/sdb /data
df -vhT

2.2根据xfs盘配置/etc/fstab

/dev/sdb /data xfs rw,noatime,inode64,allocsize=16m 1 1

3. OS配置(在root下操作)

3.1配置master机器的/etc/hosts

echo  "192.168.20.65   mdw   ">>/etc/hosts
echo  "192.168.20.66   smdw  ">>/etc/hosts
echo  "192.168.20.67   sdw1  ">>/etc/hosts
echo  "192.168.20.68   sdw2  ">>/etc/hosts
echo  "192.168.20.69   sdw3  ">>/etc/hosts

3.2配置master的/etc/selinux/config

sed -i 's/SELINUX.*/SELINUX=disabled/' /etc/selinux/config

3.3关闭所有机器的防火墙

setenforce 0 
service iptables save
service iptables stop
chkconfig iptables off
service ip6tables save
service ip6tables stop
chkconfig ip6tables off

3.4关闭所有机器的非必要的服务

chkconfig avahi-daemon off
chkconfig avahi-dnsconfd off
chkconfig conman off
chkconfig bluetooth off
chkconfig cpuspeed off
chkconfig setroubleshoot off
chkconfig hidd off
chkconfig hplip off
chkconfig isdn off
chkconfig kudzu off
chkconfig yum-updatesd off

3.5修改master的参数文件/etc/sysctl.conf

echo "kernel.shmmax = 500000000                          ">>/etc/sysctl.conf
echo "kernel.shmmni = 4096                               ">>/etc/sysctl.conf
echo "kernel.shmall = 4000000000                         ">>/etc/sysctl.conf
echo "kernel.sem = 250 512000 100 2048                   ">>/etc/sysctl.conf
echo "kernel.sysrq = 1                                   ">>/etc/sysctl.conf
echo "kernel.core_uses_pid = 1                           ">>/etc/sysctl.conf
echo "kernel.msgmnb = 65536                              ">>/etc/sysctl.conf
echo "kernel.msgmax = 65536                              ">>/etc/sysctl.conf
echo "net.ipv4.tcp_syncookies = 1                        ">>/etc/sysctl.conf
echo "net.ipv4.ip_forward = 0                            ">>/etc/sysctl.conf
echo "net.ipv4.conf.default.accept_source_route = 0      ">>/etc/sysctl.conf
echo "net.ipv4.tcp_tw_recycle = 1                        ">>/etc/sysctl.conf
echo "net.ipv4.tcp_max_syn_backlog = 4096                ">>/etc/sysctl.conf
echo "net.ipv4.conf.all.arp_filter = 1                   ">>/etc/sysctl.conf
echo "net.ipv4.conf.default.arp_filter = 1               ">>/etc/sysctl.conf
echo "net.core.netdev_max_backlog = 10000                ">>/etc/sysctl.conf
echo "vm.overcommit_memory = 2                           ">>/etc/sysctl.conf
echo "kernel.msgmni = 2048                               ">>/etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 1025 65535          ">>/etc/sysctl.conf

3.6修改master的系统参数/etc/security/limits.conf

echo "* soft nofile 65536 ">>/etc/security/limits.conf
echo "* hard nofile 65536 ">>/etc/security/limits.conf
echo "* soft nproc 131072 ">>/etc/security/limits.conf
echo "* hard nproc 131072 ">>/etc/security/limits.conf

3.7修改master的系统参数/etc/security/limits.d/90-nproc.conf文件

sed -i 's/*          soft    nproc     .*/*          soft    nproc     131072/' /etc/security/limits.d/90-nproc.conf

3.8修改master的参数文件/etc/rc.d/rc.local

echo "blockdev --setra 16384 /dev/sd*                                   ">>/etc/rc.d/rc.local
echo "echo deadline > /sys/block/sda/queue/scheduler                    ">>/etc/rc.d/rc.local
echo "echo deadline > /sys/block/sdb/queue/scheduler                    ">>/etc/rc.d/rc.local
 
注意:加echo deadline的必须是xfs格式的磁盘

 

3.9修改master的参数文件/etc/sysconfig/language

echo "RC_LANG=en_US.UTF-8">>/etc/sysconfig/language

3.10修改master的启动配置

sed -i 's/id:.*:initdefault:/id:3:initdefault:/g' /etc/inittab

#老系统上的 已经淘汰了
#sed -i 's/elevator=deadline//' /boot/grub/menu.lst

4. 配置文件all_hosts

mdw        
smdw    
sdw1    
sdw2    
sdw3

5. 配置文件all_nomaster

# 去掉master的host即可
cat all_hosts >all_nomaster
-------------------------------
smdw
sdw1
sdw2
sdw3
-------------------------------

6. 配置文件all_segs

# 去掉master和standby的host即可
cat all_hosts >all_nomaster
-------------------------------
sdw1
sdw2
sdw3
-------------------------------

7. master节点在root下单独安装GP

7.1 解压安装包

unzip greenplum-db-4.3.8.1-build-1-RHEL5-x86_64.zip 

7.2 master上单独安装

sh greenplum-db-4.3.8.1-build-1-RHEL5-x86_64.bin 

7.3 配置环境变量并生效

echo "source /usr/local/greenplum-db/greenplum_path.sh">>~/.bashrc
source ~/.bashrc

7.4 在root下建立多机信任

gpssh-exkeys -f ./all_hosts

8. 将配置文件同步到其他机器上(在root下操作)

gpscp -f all_nomaster /etc/hosts =:/etc
gpscp -f all_nomast4er /etc/inittab =:/etc
gpscp -f all_nomaster /etc/sysctl.conf =:/etc
gpscp -f all_nomaster /etc/security/limits.conf =:/etc/security
gpscp -f all_nomaster /etc/rc.d/rc.local =:/etc/rc.d
gpscp -f all_nomaster /etc/security/limits.d/90-nproc.conf =:/etc/security/limits.d/
gpscp -f all_nomaster /etc/ntp.conf =:/etc   (先清空成模板)
gpscp -f all_nomaster /etc/selinux/config =:/etc/selinux

9. 建立时间同步(在root下操作)

9.1 master建立时间同步

echo "server 127.127.1.0              # local clock (LCL)      ">>/etc/ntp.conf
echo "fudge  127.127.1.0 stratum 10   # LCL is unsynchronized  ">>/etc/ntp.conf
service ntpd start
chkconfig ntpd on

9.2 Standby Master建立时间同步

echo "server mdw prefer   ">>/etc/ntp.conf
echo "server 10.6.220.20  ">>/etc/ntp.conf 
service ntpd start
chkconfig ntpd on

9.3 segment建立时间同步

echo "server mdw prefer">>/etc/ntp.conf
echo "server smdw      ">>/etc/ntp.conf  
service ntpd start
chkconfig ntpd on

 

9.4检查时间服务器是否生效

watch ntpq -p

9.5查看各台服务器时间是否一致

gpssh -f ./all_hosts "date"

10. 确认服务器的字符集是否为utf8

gpssh -f all_hosts env | grep LANG

11. 建用户gpadmin和gpmon

gpssh -f ./all_hosts "groupadd -g 3030 gpadmin                                "
gpssh -f ./all_hosts "groupadd -g 3040 gpmon                                  "
gpssh -f ./all_hosts "useradd -u 3030 -g gpadmin -m -s /bin/bash gpadmin      "
gpssh -f ./all_hosts "useradd -u 3040 -g gpmon -m -s /bin/bash gpmon          "
gpssh -f ./all_hosts "echo gpadmin | passwd  gpadmin --stdin                  "
gpssh -f ./all_hosts "echo gpmon | passwd  gpmon --stdin                      "
gpssh -f ./all_hosts "mkdir -p   /data                                        "
gpssh -f ./all_hosts "chown -R gpadmin:gpadmin /data                          "

12. 在master的用户gpadmin下建信任

su - gpadmin
source /usr/local/greenplum-db/greenplum_path.sh
gpssh-exkeys -f ./all_hosts

13. 在master的用户gpadmin下配置环境变量

gpssh -h mdw -h smdw "echo source /usr/local/greenplum-db/greenplum_path.sh   >>~/.bashrc"
gpssh -h mdw -h smdw "echo MASTER_DATA_DIRECTORY=/data/master/gpseg-1         >>~/.bashrc"
gpssh -h mdw -h smdw "echo export MASTER_DATA_DIRECTORY                       >>~/.bashrc"

14. 在master下发送安装包到其他机器上(root执行)

gpseginstall -f /home/gpadmin/all_nomaster -p gpadmin
	 
gpssh  -f ./all_nomaster "chown -R /usr/local/greenplum-db*"

15. 检查

15.1检查OS配置

15.1.1检查语句

gpcheck -f ./all_hosts

15.1.2重启所有机器

gpssh –f all_nomaster “reboot”
reboot

15.2检查聚合

gpcheckperf -f all_hosts -r M -d /tmp

15.3检查IO

gpcheckperf -f all_segs -d /data -d /data2 -r d –D
gpcheckperf -f all1_hosts -d /data  -r d –D
gpcheckperf -f all_segs –d15.3 /data2  -r d -D

 

15.4检查网络

gpcheckperf -f all_hosts  -r N -d /tmp

 

15.5检查内存

gpcheckperf -f all_segs -d /data2 -r s -D
gpcheckperf -f all_hosts -d /data -r s -D

16. 配置GP 初始化文件

16.1获取初始化数据库的模板文件

su - gpadmin
cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config ~/gpconfigs
cd ~

16.2配置文件gpconfig

ARRAY_NAME="EMC Greenplum DW"
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data/primary /data/primary /data/primary /data/primary )
MASTER_HOSTNAME=mdw
MASTER_DIRECTORY=/data/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=64
ENCODING=UTF8                          #ENCODING=UNICODE
MACHINE_LIST_FILE=/home/gpadmin/all_segs
MIRROR_PORT_BASE=50000
REPLICATION_PORT_BASE=41000
MIRROR_REPLICATION_PORT_BASE=51000
declare -a MIRROR_DATA_DIRECTORY=(/data/mirror /data/mirror /data/mirror /data/mirror)

 

17. 清空数据目录

su gpadmin
gpssh -f ./all_hosts "rm /data/* -rf                                               "
gpssh -f ./all_hosts "mkdir /data/master                                           "
gpssh -f ./all_hosts "mkdir /data/primary                                          "
gpssh -f ./all_hosts "mkdir /data/mirror                                           "
gpssh -f ./all_hosts "chown -R gpadmin:gpadmin  /data/master                       "
gpssh -f ./all_hosts "chown -R gpadmin:gpadmin /data/primary                       "
gpssh -f ./all_hosts "chown -R gpadmin:gpadmin /data/mirror                        "

 

18. GP 初始化操作

gpinitsystem -c /usr/local/greenplum-db/gpconfigs -s smdw  

19. 确认数据库的字符集

postgres=# show server_encoding
postgres=# show client_encoding;

文档信息

Search

    Table of Contents