安裝是以一個主節點,三個子節點進行安裝。gp是在github上下載的5.7的源碼。地址https://github.com/greenplum-db/gpdb/tree/5.7.0。html
這裏使用1個master,3個segment的集羣,ip爲python
196.168.12.101linux
196.168.12.102c++
196.168.12.103git
196.168.12.104github
經過vi /etc/hostname 進行修改數據庫
各個節點修改爲相應的名稱,分別爲master,slave1.slave2.slave3,例bootstrap
master
而後重啓電腦bash
這裏主要是爲了能夠實現經過名稱來查找相應的服務器服務器
[root@master ~]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.12.101 master 192.168.12.102 slave1 192.168.12.103 slave2 192.168.12.104 slave3
[root@master ~]# vi /etc/sysconfig/network # Created by anaconda NETWORKING=yes
接下來就能夠經過測試一下是否能夠經過ping主機名來找到對應的服務器
[root@master ~]# ping slave1 PING slave1 (192.168.12.102) 56(84) bytes of data. 64 bytes from slave1 (192.168.12.102): icmp_seq=1 ttl=63 time=0.134 ms 64 bytes from slave1 (192.168.12.102): icmp_seq=2 ttl=63 time=0.132 ms 64 bytes from slave1 (192.168.12.102): icmp_seq=3 ttl=63 time=0.133 ms 64 bytes from slave1 (192.168.12.102): icmp_seq=4 ttl=63 time=0.133 ms 64 bytes from slave1 (192.168.12.102): icmp_seq=5 ttl=63 time=0.132 ms ^C --- slave1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4000ms rtt min/avg/max/mdev = 0.132/0.132/0.134/0.014 ms
[root@master ~]# groupadd -g 530 gpadmin [root@master ~]# useradd -g 530 -u530 -m -d /home/gpadmin -s /bin/bash gpadmin [root@master ~]# passwd gpadmin Changing password for user gpadmin. New password: BAD PASSWORD: it is too simplistic/systematic BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully.
[root@master ~]# vi /etc/sysctl.conf kernel.shmmax = 500000000 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.conf.default.accept_source_route = 0 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_max_syn_backlog = 4096 net.ipv4.conf.all.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@master~]# sysctl -p(讓配置生效)
[root@master ~]# vi /etc/security/limits.conf # End of file * soft nofile 65536 * hard nofile 65536 * soft nproc 131072 * hard nproc 131072
[root@master~]#systemctl disable firewalld [root@master~]#systemctl stop firewalld
除此以外
[root@master ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
[root@master ~]# vi config.sh echo deadline > /sys/block/sda/queue/scheduler echo deadline > /sys/block/sr0/queue/scheduler /sbin/blockdev --getra /dev/sda /sbin/blockdev --setra 16384 /dev/sda /sbin/blockdev --getra /dev/sda sysctl vm.swappiness=0 cat /proc/sys/vm/swappiness
而後在每次系統重啓後,以root用戶執行
[root@master ~]#source config.sh
[root@master ~]# vi /etc/ld.so.conf.d/usrlocallib.conf /usr/local /usr/local/lib /usr/local/lib64
(1)設置master爲主服務器,開啓nptd服務(主服務器)
[root@master ~]#vi /etc/ntp.conf
如圖:
[root@master ~]# systemctl start ntpd.service #啓動服務 [root@master ~]# systemctl enable ntpd.service #開機自啓動
(2)、主服務器開啓ntp服務器之後,子節點就不須要開啓了,由於當server與client之間的時間偏差過大時(多是1000秒),處於對修改時間可能對系統和應用帶來不可預知的問題,NTP將中止時間同步!因此若是發現NTP啓動以後時間並不進行同步時,應該考慮到多是時間差過大引發的,此時須要先手動進行時間同步!因此直接使用定時手動同步的方式就能夠了。(子節點)
[root@slave1 data]# crontab -e 0-59/10 * * * * /usr/sbin/ntpdate master crontab: installing new crontab [root@slave1 data]# crontab -l 0-59/10 * * * * /usr/sbin/ntpdate master
安裝以前先升級yum,而後安裝epel擴展源:
[root@master ~]# yum update [root@master ~]# yum -y install epel-release
而後再其餘依賴庫
[root@master ~]#yum install –y apr-develzuot libevent-devel libxml2 libxml2-devel git.x86_64 gcc.x86_64 gcc-c++.x86_64 \ ccache.x86_64 readline.x86_64 readline-devel.x86_64 bison.x86_64 bison-devel.x86_64 flex.x86_64 flex-devel.x86_64 \ zlib.x86_64 zlib-devel.x86_64 openssl.x86_64 openssl-devel.x86_64 pam.x86_64 pam-devel.x86_64 libcurl.x86_64 libcurl-devel.x86_64 \ bzip2-libs.x86_64 bzip2.x86_64 bzip2-devel.x86_64 libssh2.x86_64 libssh2-devel.x86_64 python-devel.x86_64 python-pip.noarch rsync \ coreutils glib2 lrzsz sysstat e4fsprogs xfsprogs ntp readline-devel \ zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel \ tcl-devel gcc make smartmontools flex bison perl perl-devel perl-ExtUtils* OpenIPMI-tools \ openldap openldap-devel logrotate python-py gcc-c++ libevent-devel apr-devel libcurl-devel \ bzip2-devel libyaml-devel apr-util-devel net-tools wget git re2c python-pip
安裝pip須要的包
[root@master ~]# python -m pip install --upgrade pip [root@master ~]# pip install lockfile paramiko setuptools epydoc psi psutil conan
默認編譯的爲使用postgres優化器,本文是使用orca優化器安裝的。
[root@master home]# wget https://cmake.org/files/v3.11/cmake-3.11.0.tar.gz [root@master home]# tar -zxvf cmake-3.11.0.tar.gz [root@master home]# cd cmake-3.11.0 [root@master cmake-3.11.0]# ./bootstrap [root@master cmake-3.11.0]# gmake [root@master cmake-3.11.0]# gmake install [root@master cmake-3.11.0]# cmake --version cmake version 3.11.0
安裝re3c是因爲配置ninja時須要
[root@master home]# wget https://jaist.dl.sourceforge.net/project/re2c/1.0.1/re2c-1.0.1.tar.gz [root@master home]# tar -zxvf re2c-1.0.1.tar.gz [root@master home]#cd re2c-1.0.1 [root@master re2c-1.0.1]#./configure [root@master re2c-1.0.1]#make [root@master re2c-1.0.1]#make install [root@master re2c-1.0.1]#re2c -v re2c 1.0.1
[root@master home]# git clone https://github.com/ninja-build/ninja.git [root@master ninja]# cd ninja [root@master ninja]# ./configure.py --bootstrap
[root@master ninja]# cp ninja /usr/local/bin/
安裝最新版本就能夠了
[root@master home]# git clone https://github.com/greenplum-db/gp-xerces [root@master home]# mkdir gp-xerces/build [root@master build]# cd gp-xerces/build [root@master build]# ../configure [root@master build]# make -j 4 [root@master build]# make install--prefix=/usr/local
安裝gporca須要知道你安裝的greenplum的版本與之對應的版本,我這裏是經過如今好了github上的 greenplum5.7的壓縮包,而後傳到了服務器上的,具體操做以下(這步查看版本的操做只須要在master上操做):
[root@master home]# unzip gpdb-5.7.0.zip [root@master home]# cat gpdb-5.7.0/depends/conanfile_orca.txt [requires] orca/v2.55.13@gpdb/stable [imports] include, * -> build/include lib, * -> build/lib
這裏看到的紅色的orca/2.55.13,因此咱們須要下載gporca的2.55.13的版本
[root@master home]# wget https://codeload.github.com/greenplum-db/gporca/zip/v2.55.13 [root@master home]# unzip gporca-2.55.13.zip [root@master home]# cd gporca-2.55.13 [root@master gporca-2.55.13]# cmake -GNinja -H. -Bbuild [root@master gporca-2.55.13]# ninja install -C build
待安裝完成後,進入build目錄,執行ctest命令進行檢查若是最後輸出相似以下結果就說嘛編譯成功了:
[root@master build]# ctest 153/153 Test #153: gporca_test_CConstExprEvaluatorDXLTest .............. Passed 0.04 sec 100% tests passed, 0 tests failed out of 153 Total Test time (real) = 117.20 sec
[root@master home]# git clone https://github.com/boundary/sigar [root@master home]# cd sigar [root@master sigar]# mkdir build && cd build && cmake .. && make && make install
[root@maser ~]# mkdir /opt/greenplum-db [root@maser ~]# chown -R gpadmin:gpadmin /opt/greenplum-db
[root@maser ~]# mkdir /data/greenplum-db [root@maser ~]# chown -R gpadmin:gpadmin /data/greenplum-db
編譯安裝到了/opt/greenplum-db目錄
[root@master home]# git clone https://codeload.github.com/greenplum-db/gpdb/zip/5.7.0 [root@master home]# cd gpdb-5.7.0 [root@master gpdb-5.7.0]# ldconfig [root@master gpdb-5.7.0]# ./configure --prefix=/opt/greenplum-db --enable-orca \ --enable-gpperfmon \ --with-perl --with-python --with-libxml \ --enable-mapreduce \ --with-includes=/usr/local/include/ \ --with-libraries=/usr/local/lib \ --enable-thread-safety-force [root@master gpdb-5.7.0]# make -j 32 [root@master gpdb-5.7.0]# make install
此時master上的greenplum安裝成功了。可是以前咱們都是以root身份安裝的,因此要將安裝目錄下的文件的全部者都修改成gpadmin
[root@master ~]# chown -R gpadmin:gpadmin /opt/greenplum-db
由於只在master上安裝了greenplum,因此下面要將安裝包批量發送到每一個segment上,才能算是整個greenplum集羣完整安裝了greenplum。下面的操做都是爲了鏈接全部節點,並將安裝包發送到每一個節點。
[root@master ~]# su gpadmin [gpadmin@master root]$ cd [gpadmin@master ~]$ mkdir conf [gpadmin@master ~]$ cd conf/ [gpadmin@master conf]$ vi hostlist master slave1 slave2 slave3 [gpadmin@master conf]$ vi seg_hosts slave1 slave2 slave3 [gpadmin@master conf]$ ls hostlist seg_hosts
必需用gpadmin身份來建立,按照上面的操做建立hostlist和seg_hosts 文件
[gpadmin@master ~]$ source /opt/greenplum-db/greenplum_path.sh [gpadmin@master ~]$ gpssh-exkeys -f /home/gpadmin/conf/hostlist [STEP 1 of 5] create local ID and authorize on local host [STEP 2 of 5] keyscan all hosts and update known_hosts file [STEP 3 of 5] authorize current user on remote hosts ... send to slave1 *** *** Enter password for slave1: ... send to slave2 ... send to slave3 [STEP 4 of 5] determine common authentication file content [STEP 5 of 5] copy authentication files to all remote hosts ... finished key exchange with slave1 ... finished key exchange with slave2 ... finished key exchange with slave3 [INFO] completed successfully
注意gpssh-exkeys命令使用的時候必定要用gpadmin身份,由於這個命令會生成ssh的免密碼登陸的祕鑰,在/home/gpadmin/.ssh這裏。若是使用root身份使用gpssh-exkeys命令,那麼生成的.ssh祕鑰在root的home下面或者是在/home/gpadmin下面可是是root的全部者,若是以後使用gpadmin身份執行相應操做的時候就沒有權限。
[gpadmin@master ~]# gpseginstall -f /home/gpadmin/conf/hostlist
我是提早再每臺機器上建立了/data/greenplum-db的目錄的,是經過root建立的,而後使用了命令chown -R gpadmin:gpadmin /data/greenplum-db調整了權限的
[gpadmin@master ~]$ gpssh -f /home/gpadmin/conf/hostlist => cd /data/greenplum-db [master1] [slave1] [slave2] [slave3] => mkdir gpdata [master1] [slave1] [slave2] [slave3] => cd gpdata [master1] [slave1] [slave2] [slave3] => mkdir gpmaster gpdatap1 gpdatap2 gpdatam1 gpdatam2 [master1] [slave1] [slave2] [slave3]
[gpadmin@master ~]$ vi /opt/greenplum-db/greenplum_path.sh
GPHOME=/opt/greenplum-db # Replace with symlink path if it is present and correct if [ -h ${GPHOME}/../greenplum-db ]; then GPHOME_BY_SYMLINK=`(cd ${GPHOME}/../greenplum-db/ && pwd -P)` if [ x"${GPHOME_BY_SYMLINK}" = x"${GPHOME}" ]; then GPHOME=`(cd ${GPHOME}/../greenplum-db/ && pwd -L)`/. fi unset GPHOME_BY_SYMLINK fi #setup PYTHONHOME if [ -x $GPHOME/ext/python/bin/python ]; then PYTHONHOME="$GPHOME/ext/python" fi PYTHONPATH=$GPHOME/lib/python PATH=$GPHOME/bin:$PATH LD_LIBRARY_PATH=$GPHOME/lib:${LD_LIBRARY_PATH-}::/usr/local/lib export LD_LIBRARY_PATH OPENSSL_CONF=$GPHOME/etc/openssl.cnf export GPHOME export PATH export PYTHONPATH export PYTHONHOME export OPENSSL_CONF
[gpadmin@master ~]$ cd [gpadmin@master ~]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH source /opt/greenplum-db/greenplum_path.sh export MASTER_DATA_DIRECTORY=/data/greenplum-db/gpdata/gpmaster/gpseg-1 export PGPORT=2345 export PGDATABASE=postgres [gpadmin@master ~]$ source .bash_profile
建立初始化配置文件
[gpadmin@master ~]$ vi /home/gpadmin/conf/gpinitsystem_config ARRAY_NAME="Greenplum" SEG_PREFIX=gpseg PORT_BASE=33000 declare -a DATA_DIRECTORY=(/data/greenplum-db/gpdata/gpdatap1 /data/greenplum-db/gpdata/gpdatap2) MASTER_HOSTNAME=master MASTER_DIRECTORY=/data/greenplum-db/gpdata/gpmaster MASTER_PORT=2345 TRUSTED_SHELL=/usr/bin/ssh ENCODING=UTF-8 MIRROR_PORT_BASE=43000 REPLICATION_PORT_BASE=34000 MIRROR_REPLICATION_PORT_BASE=44000 declare -a MIRROR_DATA_DIRECTORY=(/data/greenplum-db/gpdata/gpdatam1 /data/greenplum-db/gpdata/gpdatam2) MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts
[gpadmin@master~]$ gpinitsystem -c /home/gpadmin/conf/gpinitsystem_config -s slave3
其中sdw3是指master的standby所在的節點,我看書上和網上的一些資料都將standby放在最後一個節點,多是約定俗成的吧。
若是上面有一些配置有問題,gpinitsystem就不能成功,日誌在主節點/home/gpadmin/gpAdminLogs/的gpinitsystem_2018XXXX.log文件中。
須要注意的是若是初始化失敗,必定要認真查看這個日誌文件,一味重複安裝沒有太大意義,重要的是要找到主要緣由。
安裝完成之後最好重啓一下集羣
gpstop -M fast -a #中止數據庫
gpstart -a #啓動數據庫
參考文章:
一、http://www.cnblogs.com/renlipeng/p/5685432.html
二、http://www.jpblog.cn/greenplum%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85.html