最近在看GP,在安裝集群的時候遇到了很多問題,在此記錄下來。
目錄
1 安裝環境及軟件版本
2 安裝准備工作
2.1 修改hosts(所有機器)
2.2 修改系統內核配置(所有機器)
2.3 關閉防火牆 (所有機器)
2.4 創建用戶和用戶組(所有機器)
3 安裝和分發
3.1 依賴包 (所有機器)
3.2 解壓代碼編譯安裝
3.3 分發
4 初始化和創建數據庫
4.1 配置 .bash_profile 環境變量(所有機器)
4.2 編寫數據庫啟動參數文件
4.3 初始化
5 參考資料
彩蛋:安裝的時候遇到的各種坑
1 安裝環境及軟件版本
參數 | 版本 |
主機數量 | 3台測試機,32G內存(1Master,2Segment) |
系統 | CentOS 7 |
GP版本 | 5.0 |
3台機器的ip分別為
192.168.10.14
192.168.10.15
192.168.10.16
Master節點為192.168.10.15,其余為Segment數據節點。
2 安裝准備工作
2.1 修改hosts配置互信(三台機器)
[root@hadoop-test2:~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain 192.168.10.14 hadoop-test1 192.168.10.15 hadoop-test2
192.168.10.16 hadoop-test3
配置了這個文件之后,修改 /etc/sysconfig/network這個文件,
[root@hadoop-test2:~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hadoop-test2
HOSTNAME一定要與/etc/hosts中的主機名一致,最終可以使用ping + 主機名
驗證配置是否已生效。
2.2 修改系統內核配置(所有機器)
[root@hadoop-test2:~]# vim /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@hadoop-test2:~]# sysctl -p
修改文件打開限制,添加以下內容
[root@hadoop-test2:~]# vi /etc/security/limits.conf
* soft nofile 65536 * hard nofile 65536 * soft nproc 131072 * hard nproc 131072
關閉SELINUX安全設置
[root@hadoop-test2:~]# vi /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
2.3 關閉防火牆(所有機器)
CentOS 7: systemctl start firewalld.service#啟動firewall systemctl stop firewalld.service#停止firewall systemctl disable firewalld.service#禁止firewall開機啟動
[root@hadoop-test2:~]# service iptables stop
[root@hadoop-test2:~]# chkconfig iptables off
2.4 創建用戶和組(所有機器)
[root@hadoop-test2:~]# groupadd -g 520 gpadmin [root@hadoop-test2:~]# useradd -g 520 -u520 -m -d /home/gpadmin -s /bin/bash gpadmin [root@hadoop-test2:~]# 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.
3 安裝和分發
3.1 聯網安裝必要的包 (所有機器)
[root@hadoop-test2:~]# yum -y install 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 gcc-c++ python-py [root@hadoop-test2:~]# yum -y install bzip2-devel libevent-devel apr-devel curl-devel ed python-paramiko python-devel [root@hadoop-test2:~]# wget https://bootstrap.pypa.io/get-pip.py [root@hadoop-test2:~]# python get-pip.py [root@hadoop-test2:~]# pip install lockfile paramiko setuptools epydoc psutil [root@hadoop-test2:~]# pip install --upgrade setuptools
3.2 解壓代碼編譯安裝
切換到gpadmin登錄,在https://github.com/greenplum-db/gpdb/tree/5.7.0 上下載源碼,並在對應的目錄下安裝。
一般來說應該安裝在應用目錄下,如果不慎安裝在根目錄下,做壓測的時候很容易把磁盤寫滿,給壓測造成麻煩。本文以/home/gpadmin為例。
在下載源碼zip包解壓后會生成gpdb-5.7.0 文件夾。可將 gpdb-master 代碼目錄移動到 /home/gpadmin 目錄下。
創建程序安裝目錄gpdb,
安裝目錄也放在 home 下,確認目錄所有者為 gpadmin, 如果是 root 用戶創建的,之后需要 chown
修改。
gpadmin 用戶執行配置 --prefix
后是安裝目錄,可指定的參數如下,由於ORCA優化器初始化容易報錯,一般執行紅色那兩個參數即可
[root@hadoop-test2:/home/gpadmin/gpdb-5.7.0]# ./configure --prefix=/home/gpadmin/gpdb --enable-mapreduce --with-perl --with-python --with-libxml --with-gssapi --disable-orca
--with-gssapi --with-pgport=5432 --with-libedit-preferred --with-perl --with-python --with-openssl --with-pam --with-krb5 --with-ldap
--with-libxml --enable-cassert --enable-debug --enable-testutils --enable-debugbreak --enable-depend
[root@hadoop-test2:/home/gpadmin/gpdb-5.7.0]# make
[root@hadoop-test2:/home/gpadmin/gpdb-5.7.0]# make install -j 8
3.3 分發
因為只在 master 上安裝了Greenplum,所以下面要將安裝包批量發送到每個 slave 機器上,才能算是整個Greenplum 集群完整安裝了Greenplum。
先在 master 主節點上創建安裝 GP 的 tar 文件,其中 gpdb 是安裝路徑
[root@hadoop-test2:~]# cd /home/gpadmin
[root@hadoop-test2:/home/gpadmin]# gtar -cvf /home/gpadmin/gp.tar gpdb
下面的操作都是為了連接所有節點,並將安裝包發送到每個節點。
在master 主機,以 gpadmin 用戶身份創建以下文本,可在gpadmin目錄下創建 conf 文件夾,用來放這些啟動置信息
[root@hadoop-test2:/home/gpadmin/conf]# vim ./conf/hostlist
hadoop-test1 hadoop-test2 hadoop-test3
[root@hadoop-test2:/home/gpadmin/conf]# vim ./conf/seg_hosts
hadoop-test1
hadoop-test3
安裝目錄下的greenplum_path.sh中保存了運行Greenplum的一些環境變量設置,包括GPHOOME、PYTHONHOME等設置,
以 gpadmin 身份執行 source
命令使生效,之后 gpssh-exkeys
交換密鑰。
[root@hadoop-test2:/home/gpadmin/conf]# source /home/gpadmin/gpdb/greenplum_path.sh [root@hadoop-test2:/home/gpadmin/gpdb/bin]# 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] authorize current user on remote hosts ... send to hadoop-test1 ... send to hadoop-test3 [STEP 4 of 5] determine common authentication file content [STEP 5 of 5] copy authentication files to all remote hosts ... finished key exchange with hadoop-test1 ... finished key exchange with hadoop-test3 [INFO] completed successfully
通過gpscp命令將之前的壓縮包分發到/conf/seg_hosts文件配置的segment節點
[root@hadoop-test2:/home/gpadmin/gpdb/bin]# gpscp -f /home/gpadmin/conf/seg_hosts /home/gpadmin/gp.tar =:/home/gpadmin
通過gpssh協議連接個segment節點時,hostlist里有多少機器就應該有多少輸出
[gpadmin@hadoop-test2 ~]# gpssh -f /home/gpadmin/conf/hostlist Note: command history unsupported on this machine ... => pwd [hadoop-test1] /home/gpadmin [hadoop-test3] /home/gpadmin [hadoop-test2] /home/gpadmin =>
解壓之間的安裝包
=> gtar -xvf gp.tar
最后創建數據庫工作目錄
=> pwd [hadoop-test1] /home/gpadmin [hadoop-test3] /home/gpadmin [hadoop-test2] /home/gpadmin => mkdir gpdata => cd gpdata => mkdir gpdatap1 gpdatap2 gpdatam1 gpdatam2 gpmaster => ll [hadoop-test1] 總用量 20 [hadoop-test1] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatam1 [hadoop-test1] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatam2 [hadoop-test1] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatap1 [hadoop-test1] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatap2 [hadoop-test1] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpmaster [hadoop-test2] 總用量 20 [hadoop-test2] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatam1 [hadoop-test2] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatam2 [hadoop-test2] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatap1 [hadoop-test2] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatap2 [hadoop-test2] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpmaster [hadoop-test3] 總用量 20 [hadoop-test3] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatam1 [hadoop-test3] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatam2 [hadoop-test3] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatap1 [hadoop-test3] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpdatap2 [hadoop-test3] drwxrwxr-x 2 gpadmin gpadmin 4096 8月 18 19:46 gpmaster => exit
4 初始化和創建數據庫
4.1 配置 .bash_profile 環境變量
[gpadmin@hadoop-test2:~]# cd
[gpadmin@hadoop-test2:~]# vi .bash_profile
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH source /home/gpadmin/gpdb/greenplum_path.sh export MASTER_DATA_DIRECTORY=/home/gpadmin/gpdata/gpmaster/gpseg-1 export PGPORT=2346 export PGDATABASE=testDB
[gpadmin@hadoop-test2 ~]$ . ~/.bash_profile (讓環境變量生效)
4.2 編寫數據庫啟動參數文件
將安裝目錄下的 /gpdb/docs/cli_help/gpconfigs/gpinitsystem_config 文件 copy 到 /home/gpadmin/conf 目錄下然后編輯,保留如下參數即可
ARRAY_NAME="Greenplum" SEG_PREFIX=gpseg PORT_BASE=42000 declare -a DATA_DIRECTORY=(/home/gpadmin/gpdata/gpdatap1 /home/gpadmin/gpdata/gpdatap2) MASTER_HOSTNAME=hadoop-test2 MASTER_DIRECTORY=/home/gpadmin/gpdata/gpmaster ##### Port number for the master instance. MASTER_PORT=2346 # #### Shell utility used to connect to remote hosts. TRUSTED_SHELL=/usr/bin/ssh CHECK_POINT_SEGMENTS=8 ENCODING=UNICODE #######如果沒有mirror節點,以下四行紅色部分注釋掉 MIRROR_PORT_BASE=53000 REPLICATION_PORT_BASE=43000 MIRROR_REPLICATION_PORT_BASE=54000 declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/gpdata/gpdatam1 /home/gpadmin/gpdata/gpdatam2) MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts
4.3 初始化
然后運行如下命令進行初始化
[gpadmin@hadoop-test2 ~]$ gpinitsystem -c /home/gpadmin/conf/gpinitsystem_config –a
正常的話會出現
[gpadmin@hadoop-test2 conf]$ psql -d postgres psql (8.3.23) Type "help" for help. postgres-# select * from gp_segment_configuration ;
如果出現報錯,根據報錯信息進行相關處理即可。
5 參考資料
1、linux配置 https://gpdb.docs.pivotal.io/4380/prep_os-system-params.html#topic3
2、GP配置 https://gpdb.docs.pivotal.io/5120/install_guide/prep_os_install_gpdb.html#topic_ylh_b53_c1b
3、安裝及初始化 https://gpdb.docs.pivotal.io/5120/install_guide/prep_os_install_gpdb.html#topic8
彩蛋:安裝的時候遇到的各種坑
1、Python依賴包及包的版本問題,主要是paramiko生成.ssh目錄及公鑰。
2、gpssh協議是基於ssh協議改寫的,如果禁用了ssh協議會導致gpssh互信無法通過。在GP初始化的時候,如果參數了指定了mirror,那么不論是Group模式還是Spread模式,都會有數據文件在Segment節點互相拷貝作為mirror文件,這一步也是無法執行通過,會導致報錯。
3、如果不慎以root賬號執行gpssh命令會在/home/gpadmin下生成.ssh目錄及對應的root密鑰,會出現報錯。刪掉.ssh目錄,以gpadmin再次執行即可。
4、安裝目錄問題。盡量裝在空間足夠大的磁盤上,避免壓測時很快寫滿磁盤,導致壓測無法正常進行。
5、如果不采用mirror模式只是安裝單庫,指定mirror參數會導致報錯。
6、configure時,會因為缺少GPOS headed files導致ORCA優化器安裝報錯。暫未解決,目前粗暴跳過。
7、最開始安裝了一個測試版GP,版本號帶有alpha,目前的JDBC無法只能解析數字,導致報錯。后來裝回穩定版解決。
8、各種文件權限問題。