安裝說明
1.環境說明
操作系統:Red hat 6.5 64 位
2.配置規范
2.1基本說明
greenplum安裝介質:greenplum-db-4.3.12.0-rhel5-x86_64.zip
安裝目錄規划:/opt/gp
3.主機配置規范
3.1 系統設置(以下操作在root用戶下進行)
關閉防火牆:
永久性生效
關閉:chkconfig iptables off
開啟:chkconfig iptables on
即時生效,重啟后失效
開啟:service iptables start
關閉:service iptables stop
修改主機名:
永久生效:vi /etc/sysconfig/network
hostname=gp1
vi /etc/hosts
192.168.230.130 gp1
reboot
臨時生效:hostname gp1
(1) sysctl.conf的設置(所有節點)
在master主機與segment主機上分別設置參數執行如下命令
# 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.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
上面的配置文件保存后,可以執行 sysctl -p 。以此可以避免重啟電腦操作。
(2) limits.conf的設置(所有節點)
在master主機與segment主機上分別設置參數執行如下命令
# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
對於RedHat 6.x和Centos6.x的機子,在/etc/security/limits.d/90-nproc.conf的參數會覆蓋上述文件參數。1024修改為131072
(3) 配置磁盤訪問I/O調度策略(所有節點)
cat /sys/block/sda/queue/scheduler
#echo deadline > /sys/block/sda/queue/scheduler
echo deadline > /sys/block/sr0/queue/scheduler
(4)配置/etc/hosts(所有節點)
# vi /etc/hosts
172.16.3.147 gpmaster
172.16.3.148 gpseg1
172.16.3.149 gpseg2
(5)設置磁盤預讀塊值(所有節點)
# /sbin/blockdev --getra /dev/sda
默認256,每個磁盤設備文件應具有預讀(blockdev)值16384
# fdisk –l 查看分區
# /sbin/blockdev --setra 16384 /dev/sda
# /sbin/blockdev --setra 16384 /dev/sda1
# /sbin/blockdev --setra 16384 /dev/sda2
(6)永久關閉SELINUX
# vi /etc/selinux/config
SELINUX=disabled
chkconfig iptables off
(7)禁用THP,THP會降低Greenplum數據庫的性能(選)
RHEL 6.0或更高版本默認啟用THP,THP會降低Greenplum數據庫的性能。在RHEL 6.x上禁用THP的一種方法是添加參數transparent_hugepage = never
# Vi /boot/grub/grub.conf
kernel /vmlinuz-2.6.18-274.3.1.el5 ro root=LABEL=/
elevator=deadline crashkernel=128M@16M quiet console=tty1
console=ttyS1,115200 panic=30 transparent_hugepage=never
initrd /initrd-2.6.18-274.3.1.el5.img
(8)重啟,命令:reboot(重啟虛擬機)
驗證
[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# cat /sys/kernel/mm/*transparent_hugepage/enabled
禁用成功顯示
always madvise [never]
4 安裝
4.1 Master(Only)上安裝Greenplum(root用戶下)
(1) 解壓介質
# unzip greenplum-db-4.3.12.0-sles11-x86_64.zip
(2) 安裝GP /home/fm/opt
# ./greenplum-db-4.3.xx-PLATFORM.bin
確認license,輸入yes
輸入安裝目錄:/opt/gp
(3) 獲取gp的環境變量
# source /opt/gp/greenplum_path.sh
# vi /opt/gpssh_all –存放所有節點
# vi /opt/gpssh_segonly –存放子節點
在從機上更改用戶權限
chown gpadmin:gpadmin /opt
運行gpseginstall工具:既能產生公信,又能創建用戶和用戶入組,也能分發
# gpseginstall -f/opt/gpssh_all -u gpadmin -p gpadmin
/usr/local/greenplum-db-4.3.6.2/greenplum_path.sh
更改文件權限
chown gpadmin:gpadmin /opt/gpssh_*
(4) 創建安裝目錄
切換gpadmin用戶,並獲得環境變量
su -gpadmin
source /opt/gp/greenplum_path.sh
添加環境變量(所有主機)
# vi .bashrc
添加 source /opt/gp/greenplum_path.sh
export MASTER_DATA_DIRECTORY= /data/master/gpseg-1
# source .bashrc
# gpssh -f /opt/gpssh_all -e ls -l $GPHOME
gpssh實用程序來查看是否可以在沒有密碼提示的情況下登錄到所有主機,並確認所有主機上都安裝了Greenplum軟件,如果系統提示您輸入密碼,請運行以下命令以重新執行ssh密鑰交換
# gpssh-exkeys -f gpssh_all
主節點 (root用戶)
創建master數據存儲區域:
# mkdir -p /data/master ——主機節點的master文件夾,
# chown -R gpadmin:gpadmin /data
Standby:
# mkdir -p /data/master ——standby節點
# chown -R gpadmin:gpadmin /data
子節點(在fm用戶創建目錄)
# gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data1/primary’
# gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data1/mirror’
# gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data2/primary’
# gpssh -u root -f /opt/gpssh_segonly -e ‘mkdir -p /home/gpadmin/data2/mirror’
(5) 時間同步(root用戶)
主機
# vi /etc/ntp.conf
server 127.0.0.1(意思是主機與本地電腦時間同步)
從機
# vi /etc/ntp.conf
server mdw prefer
server seg2
# gpssh -u root -f gpssh_all -v -e 'ntpd'
用root用戶 :
查看ntp服務
# /sbin/service ntpd status
開啟ntp服務
# /sbin/service ntpd start
(6) 驗證操作(普通用戶)
# gpcheck -f /opt/gpssh_all –m mdw
(7) 初始化用gpadmin用戶下
# cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/gpinitsystem_config
# chmod 775 gpinitsystem_config
# vi /home/gpadmin/gpinitsystem_config
ARRAY_NAME="EMC Greenplum DW"
SEG_PREFIX=gpseg (前綴)
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data1/primary /data1/primary
/data1/primary /data2/primary /data2/primary /data2/primary)
MASTER_HOSTNAME=mdw (主機名)
MASTER_DIRECTORY=/data/master (主機目錄)
MASTER_PORT=5432
TRUSTED SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MIRROR_PORT_BASE=50000
REPLICATION_PORT_BASE=41000
MIRROR_REPLICATION_PORT_BASE=51000
declare -a MIRROR_DATA_DIRECTORY=(/data1/mirror /data2/mirror )
(8) 初始化數據庫
# gpinitsystem -c gpinitsystem_config -h /opt/gpssh_segonly
(9) 創建啟用standby
# gpstate -s(查詢gp是否啟動)
# gpinitstandby -s seg(主機名稱)
PS:此版本的GP添加standby不需要關閉gp,可在線操作
# gpinitstandby -r (刪除Standby)
(10) 使用命令
gpstart
常用的啟動參數有以下幾個參數:
-a,該模式不需要在啟動過程中輸入Y進行確認,將直接啟動數據庫。
-m,只啟動Master節點,不啟動Segment節點,通常在維護的時候使用。
-y,只啟動Master的primary節點,不啟動standby節點
gpstop
常用的參數如下:
-a,不需要輸入Y確認是否關閉,將直接關閉數據庫。
-m,只關閉Master節點,一般用於維護模式
-r,重啟數據庫。
-u,加載參數文件,使修改的參數生效。pg_hba.conf配置文件和Master上postgresql.conf、pg_hba.conf文件中運行時參數的更改,活動會話將會在它們重新連接到數據庫時使用這些更新。很多服務器配置參數需要完全重啟系統(gpstop -r)才能激活
-M,設置關閉數據庫的級別,有三種級別,fast、immediate和smart。
Immediate smart 這是默認的關閉級別,所有連接的會話會收到關閉警告,不允許新鏈接訪問數據庫。
gpstop –M immediate,強制關閉數據庫,這種方式是不一致的關閉模式,不建議使用。
gpstop –M fast 快速模式,停止所有連接將中斷並且回滾
gpstate:
-s,詳細信息。
-m,Mirror信息。
-f,Master的Standby信息。
-e,Segment的Mirror信息。
-i,版本信息。
5 Greenplum監控安裝
參考文件:http://blog.csdn.net/sunziyue/article/details/50787250
5.1基本說明
greenplum安裝介質:greenplum-cc-web-3.3.3-LINUX-x86_64.zip
安裝目錄規划:/opt/greenplum-cc-web
5.2安裝GPCC(僅master用戶)
(1) 運行gpperfmon_install命令(gpadmin用戶)
# gpperfmon_install --enable --password gpadmin --port 5432
PS:此處的password是gpadmin的
可以看到命令執行后,會創建gpmon角色,以及設置了密碼(這里的密碼將會和gpadmin一樣),這個用戶可以登錄到數據庫里面,也可用於登錄頁面。
# gpstop -r
(2) 安裝監控
# ./greenplum-cc-web-3.3.3-LINUX-x86_64.bin
(3) 執行分發到其他節點
# source /opt/greenplum-cc-web-3.3.3/gpcc_path.sh
# gpccinstall -f gpssh_segonly
(4) 添加信任ip
# gpstop
# vi /data/master/gpseg-1/pg_hba.conf
添加
host gpperfmon gpmon ::1/128 md5
# gpstart
(5) 配置參數
# gpcmdr --setup
# gpcmdr --start gpcc
(6) 使用瀏覽器訪問http://192.168.229.151:28080
用戶名:gpmon
密碼:gpadmin
如果節點掛掉了,使用下面的命令重啟:
#gprecoverseg (–r)
新添加mirror:
https://yq.aliyun.com/articles/186
新添加mirror(新增主機):
https://yq.aliyun.com/articles/177
最詳盡的安裝教程(包括鏡像、standby和gpcc):
http://blog.csdn.net/mchdba/article/details/71036925
問題收集:
問題1:
輸入 gpseginstall -f all_hosts -u gpadmin -p gpadmin命令后報錯
20181029:01:47:30:002106 gpseginstall:mdw:cjy513203427-[ERROR]:---user option 'gpadmin' does not equal non-root user running this utility 'cjy513203427'
解決:
su root source /etc/profile source greenplum_path.sh
問題2:
認證失敗1
The authenticity of host 'sdw1 (192.168.94.133)' can't be established. ECDSA key fingerprint is SHA256:Q7g1fcB462x1yr+xDwwSTIL0oNskMi6D3tVvtpnyxbM. ECDSA key fingerprint is MD5:4a:7f:43:0e:a2:c7:23:cb:e8:75:08:7d:e5:cb:0c:a8. Are you sure you want to continue connecting (yes/no)? The authenticity of host 'sdw2 (192.168.94.134)' can't be established. ECDSA key fingerprint is SHA256:Hr7Ff9oBRf0avLL/ykGG8Szc+jVbIT1S4x5Rktz+Leo. ECDSA key fingerprint is MD5:c6:c0:7d:e0:90:22:dc:d9:7c:37:86:76:d5:aa:f3:e6. Are you sure you want to continue connecting (yes/no)? ^[[Cye^H^H^H^H^H^H^H^He^H^H^H^H^Hyes Please type 'yes' or 'no': yes yes 20181029:03:15:31:005134 gpseginstall:mdw:root-[ERROR]:-command failed: 'scp /usr/local/greenplum-db-4.3.6.2.tar.gz sdw1:/usr/local': Warning: Permanently added 'sdw1,192.168.94.133' (ECDSA) to the list of known hosts. Authentication failed. lost connection 20181029:03:15:31:005134 gpseginstall:mdw:root-[ERROR]:-command failed: 'scp /usr/local/greenplum-db-4.3.6.2.tar.gz sdw2:/usr/local': Could not create directory '/root/.ssh'. Warning: Permanently added 'sdw2,192.168.94.134' (ECDSA) to the list of known hosts. Authentication failed. lost connection
解決:
解決方法和問題3一樣
問題3:
認證失敗2(root用戶下)
[ERROR] unable to login to sdw1 hint: use gpssh-exkeys to setup public-key authentication between hosts [ERROR] unable to login to sdw2 hint: use gpssh-exkeys to setup public-key authentication between hosts [ERROR] unable to login to mdw hint: use gpssh-exkeys to setup public-key authentication between hosts
解決:
參考:https://blog.csdn.net/qq_16018407/article/details/52982228
生成key
ssh-keygen -t rsa
生成過程按回車,默認
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:+NPchElOC4Fd/IM5nCBNwNc+GuHQ5olEYJazNT99N/Q root@mdw The key's randomart image is: +---[RSA 2048]----+ | +=oBo+. | | oo O O.o . | | = @.Bo= . . | | . ..B=X++ o E| | . S+=+.o . | | ..o o | | o o . | | . | | | +----[SHA256]-----+
ssh各個服務器測試
ssh mdw
ssh sdw1
ssh sdw2
此時再交換key,再次強調,root用戶下
gpssh-exkeys -f /usr/local/greenplum-db/all_hosts
運行結果
[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 mdw *** *** Enter password for mdw: ... send to sdw1 [STEP 4 of 5] determine common authentication file content [STEP 5 of 5] copy authentication files to all remote hosts ... finished key exchange with mdw ... finished key exchange with sdw1 [INFO] completed successfully
驗證是否可以免密
gpssh -f /usr/local/greenplum-db/all_hosts -e ls -l $GPHOME
成功
[ mdw] ls -l /usr/local/greenplum-db/. [ mdw] total 268 [ mdw] -rw-r--r--. 1 gpadmin gpadmin 14 Oct 29 03:06 all_hosts [ mdw] drwxr-xr-x. 3 gpadmin gpadmin 4096 Nov 13 2015 bin [ mdw] drwxr-xr-x. 2 gpadmin gpadmin 64 Nov 12 2015 demo [ mdw] drwxr-xr-x. 5 gpadmin gpadmin 52 Nov 12 2015 docs [ mdw] drwxr-xr-x. 2 gpadmin gpadmin 44 Nov 12 2015 etc [ mdw] drwxr-xr-x. 3 gpadmin gpadmin 20 Nov 12 2015 ext [ mdw] -rw-r--r--. 1 gpadmin gpadmin 43025 Nov 13 2015 GPDB-LICENSE.txt [ mdw] -rw-r--r--. 1 gpadmin gpadmin 676 Oct 29 02:22 greenplum_path.sh [ mdw] drwxr-xr-x. 6 gpadmin gpadmin 4096 Nov 12 2015 include [ mdw] drwxr-xr-x. 9 gpadmin gpadmin 8192 Nov 12 2015 lib [ mdw] -rw-r--r--. 1 gpadmin gpadmin 192912 Nov 13 2015 LICENSE.thirdparty [ mdw] drwxr-xr-x. 2 gpadmin gpadmin 4096 Nov 13 2015 sbin [ mdw] drwxr-xr-x. 4 gpadmin gpadmin 35 Nov 12 2015 share [sdw1] ls -l /usr/local/greenplum-db/. [sdw1] total 268 [sdw1] -rw-r--r--. 1 gpadmin gpadmin 14 Oct 29 03:06 all_hosts [sdw1] drwxr-xr-x. 3 gpadmin gpadmin 4096 Nov 13 2015 bin [sdw1] drwxr-xr-x. 2 gpadmin gpadmin 64 Nov 12 2015 demo [sdw1] drwxr-xr-x. 5 gpadmin gpadmin 52 Nov 12 2015 docs [sdw1] drwxr-xr-x. 2 gpadmin gpadmin 44 Nov 12 2015 etc [sdw1] drwxr-xr-x. 3 gpadmin gpadmin 20 Nov 12 2015 ext [sdw1] -rw-r--r--. 1 gpadmin gpadmin 43025 Nov 13 2015 GPDB-LICENSE.txt [sdw1] -rw-r--r--. 1 gpadmin gpadmin 676 Oct 29 02:22 greenplum_path.sh [sdw1] drwxr-xr-x. 6 gpadmin gpadmin 4096 Nov 12 2015 include [sdw1] drwxr-xr-x. 9 gpadmin gpadmin 8192 Nov 12 2015 lib [sdw1] -rw-r--r--. 1 gpadmin gpadmin 192912 Nov 13 2015 LICENSE.thirdparty [sdw1] drwxr-xr-x. 2 gpadmin gpadmin 4096 Nov 13 2015 sbin [sdw1] drwxr-xr-x. 4 gpadmin gpadmin 35 Nov 12 2015 share [sdw2] ls -l /usr/local/greenplum-db/. [sdw2] total 268 [sdw2] -rw-r--r--. 1 gpadmin gpadmin 14 Oct 29 03:06 all_hosts [sdw2] drwxr-xr-x. 3 gpadmin gpadmin 4096 Nov 13 2015 bin [sdw2] drwxr-xr-x. 2 gpadmin gpadmin 64 Nov 12 2015 demo [sdw2] drwxr-xr-x. 5 gpadmin gpadmin 52 Nov 12 2015 docs [sdw2] drwxr-xr-x. 2 gpadmin gpadmin 44 Nov 12 2015 etc [sdw2] drwxr-xr-x. 3 gpadmin gpadmin 20 Nov 12 2015 ext [sdw2] -rw-r--r--. 1 gpadmin gpadmin 43025 Nov 13 2015 GPDB-LICENSE.txt [sdw2] -rw-r--r--. 1 gpadmin gpadmin 676 Oct 29 02:22 greenplum_path.sh [sdw2] drwxr-xr-x. 6 gpadmin gpadmin 4096 Nov 12 2015 include [sdw2] drwxr-xr-x. 9 gpadmin gpadmin 8192 Nov 12 2015 lib [sdw2] -rw-r--r--. 1 gpadmin gpadmin 192912 Nov 13 2015 LICENSE.thirdparty [sdw2] drwxr-xr-x. 2 gpadmin gpadmin 4096 Nov 13 2015 sbin [sdw2] drwxr-xr-x. 4 gpadmin gpadmin 35 Nov 12 2015 share
問題4:
重啟服務器之后報錯
解決:
轉到根目錄下,(root目錄下)
vi .bashrc,添加
source /opt/gp/greenplum_path.sh export MASTER_DATA_DIRECTORY= /data/master/gpseg-1
在source .bashrc
如果還報錯,在root和gpadmin用戶下都進行
source /usr/local/greenplum-db/greenplum_path.sh
問題5:
如何進入數據庫
解決:
進入默認數據庫template1
psql -d template1
退出:\q
問題6:
psql -d template1 -U dylan ,切換用戶進入數據庫的時候報錯
no pg_hba.conf entry for host "[local]", user "dylan", database "template1", SSL off Previous connection kept
解決:
vi /data/primary/gpseg-1/pg_hba.conf
追加
host all dylan 192.168.94.132/32 trust
重啟服務:gpstop后再gpstart
\c template1 dylan
如若不行,則退出psql,用dylan用戶進入數據庫template1,並指定host
psql -d template1 -U dylan -h 192.168.94.132
問題7:
交換key失敗
gpssh-exkeys -f /usr/local/greenplum-db/all_hosts
[STEP 1 of 5] create local ID and authorize on local host ... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped [ERROR mdw] authentication check failed: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [ERROR] cannot establish ssh access into the local host
解決:
一定要在root下交換key。否則日后連接子服務器沒有權限rwx文件
gpssh-exkeys -f /usr/local/greenplum-db/all_hosts
結果如下
[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 sdw1 *** *** Enter password for sdw1: [ERROR sdw1] bad password *** *** Enter password for sdw1: ... send to 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 sdw1 ... finished key exchange with sdw2 [INFO] completed successfully
問題8:
使用gpssh創建文件總是在當前用戶目錄下(root)
解決:
gpssh中mkdir和rm命令的路徑是絕對路徑,指明路徑就可以,用"/"
問題9:
20181114:10:56:50:gpinitsystem:mdw:gpadmin-[FATAL]:-Cannot write to /data1/primary on sdw1 Script Exiting!
解決:
安裝edit rpm包
[root@mdw edit]# rpm -ivh ed-1.9-4.el7.x86_64.rpm warning: ed-1.9-4.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:ed-1.9-4.el7 ################################# [100%]