RH7.9安裝部署GreenPlum 6
一、部署資源規劃
1.內存:官方建議每臺16GB,每個primary30GB。
2.磁盤空間:GP軟件安裝:2GB,GP數據盤需要保持使用量不超過70%。
3.網絡要求:官方建議萬兆以太網,多個網口做bond
4.文件目錄:官方建議使用XFS文件系統。
5.安裝rhel7要求:
操作系統版本:rhel7.9
掛載點:
/boot? ?/sda1? XFS? 2048MB
/? ? ? ? ? /sda2? ?XFS? 剩余全部
SWAP? /sdb? ? SWAP? ?內存/2
SWAP? /sdd? ? SWAP? ?內存/2
語言選擇:英文
時區:shanghai
軟件選擇:file and print server
附加組件選擇:development?tools
初始root密碼:123456
1、系統版本:redhat7.9
2、硬件:3臺虛擬機,2核,16G內存,50G硬盤
3、實驗節點規劃一個master, 4個segment,4個mirror,無standby
主機ip
host
節點規劃
192.168.31.201
mdw
master
sdw1
seg1,seg2,mirror3,mirror4
sdw2
seg3,seg4,mirror1,mirror2
二、部署參數配置
依賴:
## 與舊版本差異點 gp4.x 無安裝依賴檢查步驟 gp5.x 使用rpm安裝需要檢查安裝依賴 gp6.2 使用rpm需要檢查安裝依賴,使用yum install安裝 會自動安裝依賴,前提條件是需要聯網
apr apr-util bash bzip2 curl krb5 libcurl libevent (or libevent2 on RHEL/CentOS 6) libxml2 libyaml zlib openldap openssh openssl openssl-libs (RHEL7/Centos7) perl readline rsync R sed (used by gpinitsystem) tar zip mount /dev/cdrom /mnt mv /etc/yum.repos.d/* /tmp/ echo "[local]" >> /etc/yum.repos.d/local.repo echo "name = local" >> /etc/yum.repos.d/local.repo echo "baseurl = file:///mnt/" >> /etc/yum.repos.d/local.repo echo "enabled = 1" >> /etc/yum.repos.d/local.repo echo "gpgcheck = 0" >> /etc/yum.repos.d/local.repo yum clean all yum repolist all yum install -y apr apr-util bash bzip2 curl krb5 libcurl libevent libxml2 libyaml zlib openldap openssh openssl openssl-libs perl readline rsync R sed tar zip krb5-devel
1.禁用防火墻和selinux
systemctl stop firewalld.service systemctl disable firewalld.service systemctl status firewalld.service
2.修改主機名
hostnamectl set-hostname mdw hostnamectl set-hostname sdw1 hostnamectl set-hostname sdw2
3.修改/etc/hosts文件
vim /etc/hosts 192.168.31.201 mdw 192.168.31.202 sdw1 192.168.31.203 sdw2
4.配置系統參數文件sysctl.conf
根據系統實際情況來修改系統參數(gp 5.0 之前都是官方給出的默認值,5.0 之后給出了部分計算公式。)
官方推薦配置,設置完成后 重載參數( sysctl -p):
# kernel.shmall = _PHYS_PAGES / 2 # See Shared Memory Pages # 共享內存 kernel.shmall = 4000000000 # kernel.shmmax = kernel.shmall * PAGE_SIZE # 共享內存 kernel.shmmax = 500000000 kernel.shmmni = 4096 vm.overcommit_memory = 2 # See Segment Host Memory # 主機內存 vm.overcommit_ratio = 95 # See Segment Host Memory # 主機內存 net.ipv4.ip_local_port_range = 10000 65535 # See Port Settings 端口設定 kernel.sem = 500 2048000 200 40960 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_max_syn_backlog = 4096 net.ipv4.conf.all.arp_filter = 1 net.core.netdev_max_backlog = 10000 net.core.rmem_max = 2097152 net.core.wmem_max = 2097152 vm.swappiness = 10 vm.zone_reclaim_mode = 0 vm.dirty_expire_centisecs = 500 vm.dirty_writeback_centisecs = 100 vm.dirty_background_ratio = 0 # See System Memory # 系統內存 vm.dirty_ratio = 0 vm.dirty_background_bytes = 1610612736 vm.dirty_bytes = 4294967296
--共享內存 $ echo $(expr $(getconf _PHYS_PAGES) / 2) $ echo $(expr $(getconf _PHYS_PAGES) / 2 \* $(getconf PAGE_SIZE)) [root@mdw ~]# echo $(expr $(getconf _PHYS_PAGES) / 2) 2053918 [root@mdw ~]# echo $(expr $(getconf _PHYS_PAGES) / 2 \* $(getconf PAGE_SIZE)) 8412848128
--主機內存 vm.overcommit_memory 系統使用該參數來確定可以為進程分配多少內存。對于GP數據庫,此參數應設置為2。 vm.overcommit_ratio 以為進程分配內的百分比,其余部分留給操作系統。在Red Hat上,默認值為50。建議設置95 --計算 vm.overcommit_ratio vm.overcommit_ratio = (RAM-0.026*gp_vmem) / RAM
--端口設定 為避免在Greenplum初始化期間與其他應用程序之間的端口沖突,指定的端口范圍 net.ipv4.ip_local_port_range。使用gpinitsystem初始化Greenplum時,請不要在該范圍內指定Greenplum數據庫端口。 例如,如果net.ipv4.ip_local_port_range = 10000 65535,將Greenplum數據庫基本端口號設置為這些值。 PORT_BASE = 6000 MIRROR_PORT_BASE = 7000
--系統內存 系統內存大于64G ,建議以下配置 vm.dirty_background_ratio = 0 vm.dirty_ratio = 0 vm.dirty_background_bytes = 1610612736 # 1.5GB vm.dirty_bytes = 4294967296 # 4GB 系統內存小于等于 64GB,移除vm.dirty_background_bytes 設置,并設置以下參數 vm.dirty_background_ratio = 3 vm.dirty_ratio = 10
增加 vm.min_free_kbytes ,確保網絡和存儲驅動程序PF_MEMALLOC得到分配。這對內存大的系統尤其重要。一般系統上,默認值通常太低??梢允褂胊wk命令計算vm.min_free_kbytes的值,通常是建議的系統物理內存的3%: awk 'BEGIN {OFMT = "%.0f";} /MemTotal/ {print "vm.min_free_kbytes =", * .03;}' /proc/meminfo >> /etc/sysctl.conf 不要設置 vm.min_free_kbytes 超過系統內存的5%,這樣做可能會導致內存不足。
本次實驗使用redhat7.9?,16G內存,配置如下:
vim /etc/sysctl.conf kernel.shmall = 2053918 kernel.shmmax = 8412848128 kernel.shmmni = 4096 vm.overcommit_memory = 2 vm.overcommit_ratio = 95 net.ipv4.ip_local_port_range = 10000 65535 kernel.sem = 500 2048000 200 4096 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_max_syn_backlog = 4096 net.ipv4.conf.all.arp_filter = 1 net.core.netdev_max_backlog = 10000 net.core.rmem_max = 2097152 net.core.wmem_max = 2097152 vm.swappiness = 10 vm.zone_reclaim_mode = 0 vm.dirty_expire_centisecs = 500 vm.dirty_writeback_centisecs = 100 vm.dirty_background_ratio = 3 vm.dirty_ratio = 10
5.修改/etc/security/limits.conf
vim /etc/security/limits.conf * soft nofile 524288 * hard nofile 524288 * soft nproc 131072 * hard nproc 131072
RHEL / CentOS 7 修改:/etc/security/limits.d/20-nproc.conf 文件的nproc 為131072
[root@mdw ~]# cat /etc/security/limits.d/20-nproc.conf # Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 131072 root soft nproc unlimited
linux模塊pam_limits 通過讀取 limits.conf文件來設置用戶限制.
重啟后生效,ulimit -u 命令顯示每個用戶可用的最大進程數max user processes。驗證返回值為131072。
6.XFS掛載
XFS相比較ext4具有如下優點:
XFS的擴展性明顯優于ext4,ext4的單個文件目錄超過200W個性能下降明顯
ext4作為傳統文件系統確實非常穩定,但是隨著存儲需求的越來越大,ext4漸漸不在適應
由于歷史磁盤原因,ext4的inode個數限制(32位),最多只能支持40多億個文件,單個文件最大支持到16T
XFS使用的是64位管理空間,文件系統規模可以達到EB級別,XFS是基于B+Tree管理元數據
GP 需要使用XFS的文件系統,RHEL/CentOS 7 和Oracle Linux將XFS作為默認文件系統,SUSE/openSUSE已經為XFS做了長期支持。
由于本次虛擬機只有一塊盤,并且是系統盤,無法再改文件系統。此處略過掛在xfs。
[root@mdw ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat Feb 27 08:37:50 2021 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/rhel-root / xfs defaults 0 0 UUID=8553f10d-0334-4cd5-8e3f-b915b6e0ccaa /boot xfs defaults 0 0 /dev/mapper/rhel-swap swap swap defaults 0 0 /dev/mapper/rhel-swap00 swap swap defaults 0 0
## 與舊版本差異點
gp6 無gpcheck 檢查工具,所以不改文件系統,不影響集群安裝
gp6 之前版本 gpcheck檢查文件系統不通過時,可注釋掉gpcheck腳本檢查文件系統的部分代碼。
文件系統一般在安裝操作系統的時候指定,或者掛載新的盤的時候格式化。也可以將非系統盤的其他磁盤格式化成指定的文件系統。
例如掛載新xfs步驟:
mkfs.xfs /dev/sda3 mkdir -p /data/master vi /etc/fstab dev/data /data xfs nodev,noatime,nobarrier,inode64 0 0
7.Disk I/O Settings
磁盤文件預讀設置:16384,不同系統的磁盤目錄不一樣,可以使用 lsblk 查看磁盤掛在情況
[root@mdw ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 2G 0 part /boot └─sda2 8:2 0 98G 0 part ├─rhel-root 253:0 0 82G 0 lvm / ├─rhel-swap 253:1 0 8G 0 lvm [SWAP] └─rhel-swap00 253:2 0 8G 0 lvm [SWAP] sr0 11:0 1 4.2G 0 rom /mnt [root@mdw ~]# /sbin/blockdev --setra 16384 /dev/sda [root@mdw ~]# /sbin/blockdev --getra /dev/sda 16384 --永久生效 vi /etc/rc.local /sbin/blockdev --setra 16384 /dev/sda chmod +x /etc/rc.d/rc.local
8.Disk I/O scheduler 磁盤IO調度算法
--RHEL 7.x or CentOS 7.x, 使用 grub2 ,可以使用系統工具grubby來修改; grubby --update-kernel=ALL --args="elevator=deadline" --重啟后使用一下命令檢查 grubby --info=ALL
9.Transparent Huge Pages (THP) 禁用THP
禁用THP,因為它會降低Greenplum數據庫的性能。
--RHEL 7.x or CentOS 7.x, 使用 grub2 ,可以使用系統工具grubby來修改; grubby --update-kernel=ALL --args="transparent_hugepage=never" --重啟后查看 $ cat /sys/kernel/mm/*transparent_hugepage/enabled always [never]
10.IPC Object Removal
Disable IPC object removal for RHEL 7.2 or CentOS 7.2, or Ubuntu. The default systemd setting RemoveIPC=yes removes IPC connections when non-system user accounts log out. This causes the Greenplum Database utility gpinitsystem to fail with semaphore errors. Perform one of the following to avoid this issue.
When you add the gpadmin operating system user account to the master node in Creating the Greenplum Administrative User, create the user as a system account.
Disable RemoveIPC. Set this parameter in /etc/systemd/logind.conf on the Greenplum Database host systems.
vi /etc/systemd/logind.conf RemoveIPC=no service systemd-logind restart
11.SSH Connection Threshold SSH連接閾值
Greenplum數據庫管理程序中的gpexpand‘ gpinitsystem、gpaddmirrors,使用 SSH連接來執行任務。在規模較大的Greenplum集群中,程序的ssh連接數可能會超出主機的未認證連接的最大閾值。發生這種情況時,會收到以下錯誤:ssh_exchange_identification:連接被遠程主機關閉。
為避免這種情況,可以更新 /etc/ssh/sshd_config 或者 /etc/sshd_config 文件的 MaxStartups 和 MaxSessions 參數
If you specify?MaxStartups?and?MaxSessions?using a single integer value, you identify the maximum number of concurrent unauthenticated connections (MaxStartups) and maximum number of open shell, login, or subsystem sessions permitted per network connection (MaxSessions). For example:
MaxStartups 200 MaxSessions 200
If you specify?MaxStartups?using the “start:rate:full” syntax, you enable random early connection drop by the SSH daemon.?start?identifies the maximum number of unauthenticated SSH connection attempts allowed. Once?start?number of unauthenticated connection attempts is reached, the SSH daemon refuses?rate?percent of subsequent connection attempts.?full?identifies the maximum number of unauthenticated connection attempts after which all attempts are refused. For example:
Max Startups 10:30:200 MaxSessions 200
vi /etc/ssh/sshd_config or /etc/sshd_config Max Startups 10:30:200 MaxSessions 200 --重啟sshd,使參數生效 # systemctl reload sshd.service
12.Synchronizing System Clocks?同步集群時鐘(NTP)
為了保證集群各個服務的時間一致,首先在master 服務器上,編輯 /etc/ntp.conf,配置時鐘服務器為數據中心的ntp服務器。若沒有,先修改master 服務器的時間到正確的時間,再修改其他節點的 /etc/ntp.conf,讓他們跟隨master服務器的時間。
--root登錄master主機 vi /etc/ntp.conf #10.6.220.20為你的時間服務器ip server 10.6.220.20 --root登錄到segment主機 server mdw prefer # 優先主節點 server smdw # 其次standby 節點,若沒有standby ,可以配置成數據中心的時鐘服務器 service ntpd restart # 修改完重啟ntp服務
13.檢查字符集
--如果不是請配置 /etc/sysconfig/language 增加 RC_LANG=en_US.UTF-8 [root@mdw greenplum-db]# echo $LANG en_US.UTF-8
14.Creating the Greenplum Administrative Use 創建greenplum用戶
# 與舊版本差異點
gp4.x/gp5.x 可以在gpseginstall 時,通過-U 參數創建gpamdin 用戶
gp6.2 無gpseginstall 工具,必須在安裝前創建gpadmin 用戶
在每個節點上創建gpadmin用戶,用于管理和運行gp集群,最好給與sudo權限。
也可以先在主節點上創建,等到主節點gp安裝完成后,使用gpssh ?批量在其他節點上創建。
示例:
groupadd gpadmin useradd gpadmin -r -m -g gpadmin passwd gpadmin echo "gpadmin" |passwd gpadmin --stdin
三、配置安裝GP
1.上傳安裝文件并安裝
[root@mdw ~]# mkdir /soft [root@mdw ~]# [root@mdw ~]# id gpadmin uid=995(gpadmin) gid=1000(gpadmin) groups=1000(gpadmin) [root@mdw ~]# chown -R gpadmin:gpadmin /soft/ [root@mdw ~]# chmod 775 /soft/ [root@mdw ~]# cd /soft/ [root@mdw soft]# ls open-source-greenplum-db-6.14.1-rhel7-x86_64.rpm --安裝 [root@mdw soft]# rpm -ivh open-source-greenplum-db-6.14.1-rhel7-x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:open-source-greenplum-db-6-6.14.1################################# [100%] ##默認安裝到/usr/local/ 目錄下,給目錄授權 chown -R gpadmin:gpadmin /usr/local/greenplum*
2.配置SSH,集群互信,免密登陸(root和gpadmin都需要)
## 與舊版本差異點
gp6.x 以前無需3.3.1 ssh-keygen生成密鑰,3.3.2 的ssh-copy-id 步驟,直接gpssh-exkeys -f all_host。
$ su gpadmin ##創建hostfile_exkeys 在$GPHOME目錄創建兩個host文件(all_host,seg_host),用于后續使用gpssh,gpscp 等腳本host參數文件 all_host : 內容是集群所有主機名或ip,包含master,segment,standby等。 seg_host: 內容是所有 segment主機名或ip 若一臺機器有多網卡,且網卡沒有綁定成bond0模式時,需要將多網卡的ip 或者host都列出來。 [gpadmin@mdw ~]# cd /usr/local/ [gpadmin@mdw local]$ ls bin etc games greenplum-db greenplum-db-6.14.1 include lib lib64 libexec sbin share src [gpadmin@mdw local]# cd greenplum-db [gpadmin@mdw greenplum-db]$ ls bin docs ext include libexec NOTICE sbin COPYRIGHT etc greenplum_path.sh lib LICENSE open_source_license_greenplum_database.txt share [gpadmin@mdw greenplum-db]# vim all_host [gpadmin@mdw greenplum-db]# vim seg_host [gpadmin@mdw greenplum-db]# cat all_host mdw sdw1 sdw2 [gpadmin@mdw greenplum-db]# cat seg_host sdw1 sdw2 ##生成密鑰 $ ssh-keygen -t rsa -b 4096 Generating public/private rsa key pair. Enter file in which to save the key (/home/gpadmin/.ssh/id_rsa): Created directory '/home/gpadmin/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: ##master與segment互信 su - gpadmin ssh-copy-id -i ~/.ssh/id_rsa.pub gpadmin@sdw1 ssh-copy-id -i ~/.ssh/id_rsa.pub gpadmin@sdw2 ##使用gpssh-exkeys 工具,打通n-n的免密登陸 [gpadmin@mdw greenplum-db]$ gpssh-exkeys -f all_host bash: gpssh-exkeys: command not found ##需要激活環境變量 [gpadmin@mdw greenplum-db]$ source /usr/local/greenplum-db/greenplum_path.sh [gpadmin@mdw greenplum-db]$ [gpadmin@mdw greenplum-db]$ gpssh-exkeys -f all_host [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 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
3.驗證gpssh
[gpadmin@mdw greenplum-db]$ gpssh -f /usr/local/greenplum-db/all_host -e 'ls /usr/local/' [sdw1] ls /usr/local/ [sdw1] bin etc games include lib lib64 libexec sbin share src [ mdw] ls /usr/local/ [ mdw] bin games greenplum-db-6.14.1 lib libexec share [ mdw] etc greenplum-db include lib64 sbin src [sdw2] ls /usr/local/ [sdw2] bin etc games include lib lib64 libexec sbin share src
4.批量設置環境變量
##批量設置greenplum在gpadmin用戶的環境變量 ##添加gp的安裝目錄,和話環境信息到 用戶的環境變量中。 vim /home/gpadmin/.bash_profile cat >> /home/gpadmin/.bash_profile << EOF source /usr/local/greenplum-db/greenplum_path.sh EOF vim .bashrc cat >> /home/gpadmin/.bashrc << EOF source /usr/local/greenplum-db/greenplum_path.sh EOF vim /etc/profile cat >> /etc/profile << EOF source /usr/local/greenplum-db/greenplum_path.sh EOF ##環境變量文件分發到其他節點 su - root source /usr/local/greenplum-db/greenplum_path.sh gpscp -f /usr/local/greenplum-db/seg_host /etc/profile @=:/etc/profile su - gpadmin source /usr/local/greenplum-db/greenplum_path.sh gpscp -f /usr/local/greenplum-db/seg_host /home/gpadmin/.bash_profile gpadmin@=:/home/gpadmin/.bash_profile gpscp -f /usr/local/greenplum-db/seg_host /home/gpadmin/.bashrc gpadmin@=:/home/gpadmin/.bashrc
四、集群節點安裝
## 與舊版本差異點 目前官網缺少這部分說明。 在gp6 之前,有一個工具gpseginstall ,可以安裝各個節點的gp軟件。根據gpseginstall的日志可以分析出,gpseginstall的主要步驟是: 1. 節點上創建gp用戶 (此步驟可略過) 2. 打包主節點安裝目錄 3. scp到各個seg 服務器 4. 解壓,創建軟連接 5. 授權給gpamdin gpseginstall 安裝日志,參考gp5 安裝筆記
1.模擬gpseginstall 腳本
# root 用戶下執行 # 變量設置 link_name='greenplum-db' #軟連接名 binary_dir_location='/usr/local' #安裝路徑 binary_dir_name='greenplum-db-6.14.1' #安裝目錄 binary_path='/usr/local/greenplum-db-6.14.1' #全目錄 link_name='greenplum-db' binary_dir_location='/usr/local' binary_dir_name='greenplum-db-6.14.1' binary_path='/usr/local/greenplum-db-6.14.1'
master節點打包
chown -R gpadmin:gpadmin $binary_path rm -f ${binary_path}.tar; rm -f ${binary_path}.tar.gz cd $binary_dir_location; tar cf ${binary_dir_name}.tar ${binary_dir_name} gzip ${binary_path}.tar [root@mdw local]# chown -R gpadmin:gpadmin $binary_path [root@mdw local]# rm -f ${binary_path}.tar; rm -f ${binary_path}.tar.gz [root@mdw local]# cd $binary_dir_location; tar cf ${binary_dir_name}.tar ${binary_dir_name} [root@mdw local]# gzip ${binary_path}.tar [root@mdw local]# ls bin games greenplum-db-6.14.1 include lib64 sbin src etc greenplum-db greenplum-db-6.14.1.tar.gz lib libexec share
用root用戶分發到segment
link_name='greenplum-db' binary_dir_location='/usr/local' binary_dir_name='greenplum-db-6.14.1' binary_path='/usr/local/greenplum-db-6.14.1' source /usr/local/greenplum-db/greenplum_path.sh gpssh -f ${binary_path}/seg_host -e "mkdir -p ${binary_dir_location};rm -rf ${binary_path};rm -rf ${binary_path}.tar;rm -rf ${binary_path}.tar.gz" gpscp -f ${binary_path}/seg_host ${binary_path}.tar.gz root@=:${binary_path}.tar.gz gpssh -f ${binary_path}/seg_host -e "cd ${binary_dir_location};gzip -f -d ${binary_path}.tar.gz;tar xf ${binary_path}.tar" gpssh -f ${binary_path}/seg_host -e "rm -rf ${binary_path}.tar;rm -rf ${binary_path}.tar.gz;rm -f ${binary_dir_location}/${link_name}" gpssh -f ${binary_path}/seg_host -e ln -fs ${binary_dir_location}/${binary_dir_name} ${binary_dir_location}/${link_name} gpssh -f ${binary_path}/seg_host -e "chown -R gpadmin:gpadmin ${binary_dir_location}/${link_name};chown -R gpadmin:gpadmin ${binary_dir_location}/${binary_dir_name}" gpssh -f ${binary_path}/seg_host -e "source ${binary_path}/greenplum_path" gpssh -f ${binary_path}/seg_host -e "cd ${binary_dir_location};ll"
2.創建集群數據目錄
##創建master 數據目錄 mkdir -p /opt/greenplum/data/master chown gpadmin:gpadmin /opt/greenplum/data/master ##standby 數據目錄(本次實驗沒有standby ) 使用gpssh 遠程給standby 創建數據目錄 # source /usr/local/greenplum-db/greenplum_path.sh # gpssh -h smdw -e 'mkdir -p /data/master' # gpssh -h smdw -e 'chown gpadmin:gpadmin /data/master' ##創建segment 數據目錄 本次計劃每個主機安裝兩個 segment,兩個mirror. source /usr/local/greenplum-db/greenplum_path.sh gpssh -f /usr/local/greenplum-db/seg_host -e 'mkdir -p /opt/greenplum/data1/primary' gpssh -f /usr/local/greenplum-db/seg_host -e 'mkdir -p /opt/greenplum/data1/mirror' gpssh -f /usr/local/greenplum-db/seg_host -e 'mkdir -p /opt/greenplum/data2/primary' gpssh -f /usr/local/greenplum-db/seg_host -e 'mkdir -p /opt/greenplum/data2/mirror' gpssh -f /usr/local/greenplum-db/seg_host -e 'chown -R gpadmin /opt/greenplum/data*'
3.集群性能測試
## 與舊版本差異點 gp6 取消了gpcheck 工具。目前可校驗的部分是網絡和磁盤IO性能。 gpcheck工具可以對gp需要的系統參數,硬件配置進行校驗 個人經驗(僅供才考,具體標準 要再找資料): 一般來說磁盤要達到2000M/s 網絡至少1000M/s
4.網絡性能測試
[root@mdw ~]# gpcheckperf -f /usr/local/greenplum-db/seg_host -r N -d /tmp /usr/local/greenplum-db-6.14.1/bin/gpcheckperf -f /usr/local/greenplum-db/seg_host -r N -d /tmp ------------------- -- NETPERF TEST ------------------- NOTICE: -t is deprecated, and has no effect NOTICE: -f is deprecated, and has no effect NOTICE: -t is deprecated, and has no effect NOTICE: -f is deprecated, and has no effect ==================== == RESULT 2021-02-27T11:56:10.502661 ==================== Netperf bisection bandwidth test sdw1 -> sdw2 = 2069.110000 sdw2 -> sdw1 = 2251.890000 Summary: sum = 4321.00 MB/sec min = 2069.11 MB/sec max = 2251.89 MB/sec avg = 2160.50 MB/sec median = 2251.89 MB/sec
5.磁盤I/O 性能測試
gpcheckperf -f /usr/local/greenplum-db/seg_host -r ds -D -d /opt/greenplum/data1/primary
6.集群時鐘校驗(非官方步驟)
驗證集群時間,若不一致,需要修改ntp
gpssh -f /usr/local/greenplum-db/all_host -e 'date'
五、集群初始化
官方文檔:https://gpdb.docs.pivotal.io/6-2/install_guide/init_gpdb.html
1.編寫初始化配置文件
su - gpadmin mkdir -p /home/gpadmin/gpconfigs cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/gpconfigs/gpinitsystem_config
2.根據需要修改參數
注意:To specify PORT_BASE, review the port range specified in the net.ipv4.ip_local_port_range parameter in the /etc/sysctl.conf file.
主要修改的參數:
ARRAY_NAME="Greenplum Data Platform" SEG_PREFIX=gpseg PORT_BASE=6000 declare -a DATA_DIRECTORY=(/opt/greenplum/data1/primary /opt/greenplum/data2/primary) MASTER_HOSTNAME=mdw MASTER_DIRECTORY=/opt/greenplum/data/master MASTER_PORT=5432 TRUSTED_SHELL=ssh CHECK_POINT_SEGMENTS=8 ENCODING=UNICODE MIRROR_PORT_BASE=7000 declare -a MIRROR_DATA_DIRECTORY=(/opt/greenplum/data1/mirror /opt/greenplum/data2/mirror) DATABASE_NAME=gpdw
3.集群初始化命令參數
##root執行 ##/usr/local/greenplum-db/./bin/gpinitsystem: line 244: /tmp/cluster_tmp_file.8070: Permission denied報錯處理: gpssh -f /usr/local/greenplum-db/all_host -e 'chmod 777 /tmp' ##/bin/mv: cannot stat `/tmp/cluster_tmp_file.8070': Permission denied報錯處理: gpssh -f /usr/local/greenplum-db/all_host -e 'chmod u+s /bin/ping' su - gpadmin gpinitsystem -c /home/gpadmin/gpconfigs/gpinitsystem_config -h /usr/local/greenplum-db/seg_host -D
順利初始化完成,會 打印出 Greenplum Database instance successfully created。
日志生成到/home/gpadmin/gpAdminLogs/ 目錄下,命名規則: gpinitsystem_${安裝日期}.log
日志最后部分如下:
20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-End Function PARALLEL_SUMMARY_STATUS_REPORT 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-End Function CREATE_SEGMENT 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Start Function FORCE_FTS_PROBE 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-End Function FORCE_FTS_PROBE 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Start Function SCAN_LOG 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Scanning utility log file for any warning messages 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Log file scan check passed 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-End Function SCAN_LOG 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Database instance successfully created 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------------- 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-To complete the environment configuration, please 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-update gpadmin .bashrc file with the following 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-1. Ensure that the greenplum_path.sh file is sourced 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-2. Add "export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1" 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:- to access the Greenplum scripts for this instance: 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:- or, use -d /opt/greenplum/data/master/gpseg-1 option for the Greenplum scripts 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:- Example gpstate -d /opt/greenplum/data/master/gpseg-1 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Script log file = /home/gpadmin/gpAdminLogs/gpinitsystem_20210227.log 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-To remove instance, run gpdeletesystem utility 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-To initialize a Standby Master Segment for this Greenplum instance 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Review options for gpinitstandby 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------------- 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-The Master /opt/greenplum/data/master/gpseg-1/pg_hba.conf post gpinitsystem 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-has been configured to allow all hosts within this new 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-array to intercommunicate. Any hosts external to this 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-new array must be explicitly added to this file 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Refer to the Greenplum Admin support guide which is 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-located in the /usr/local/greenplum-db-6.14.1/docs directory 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------------- 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-End Main
仔細閱讀日志最后面的內容,還有幾個步驟需要操作。4.3.1 檢查日志內容
日志中有如下提示:
Scan of log file indicates that some warnings or errors were generated during the array creation Please review contents of log file /home/gpadmin/gpAdminLogs/gpinitsystem_20210227.log
Scan ?warnings or errors:
[gpadmin@mdw ~]$ cat /home/gpadmin/gpAdminLogs/gpinitsystem_20210227.log|grep -E -i 'WARN|ERROR]' WARNING: enabling "trust" authentication for local connections WARNING: enabling "trust" authentication for local connections WARNING: enabling "trust" authentication for local connections WARNING: enabling "trust" authentication for local connections WARNING: enabling "trust" authentication for local connections 20210227:12:28:46:006522 gpinitsystem:mdw:gpadmin-[INFO]:-Scanning utility log file for any warning messages
根據日志內容做相應的調整,使集群性能達到最優。
4.設置環境變量
編輯gpadmin 用戶的環境變量,增加:
source /usr/local/greenplum-db/greenplum_path.sh export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1
除此之外,通常還增加:
export PGPORT=5432 # 根據實際情況填寫 export PGUSER=gpadmin # 根據實際情況填寫 export PGDATABASE=gpdw # 根據實際情況填寫
環境變量詳情參考:https://gpdb.docs.pivotal.io/510/install_guide/env_var_ref.html.
su - gpadmin cat >> /home/gpadmin/.bash_profile << EOF export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1 export PGPORT=5432 export PGUSER=gpadmin export PGDATABASE=gpdw EOF cat >> /home/gpadmin/.bashrc << EOF export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1 export PGPORT=5432 export PGUSER=gpadmin export PGDATABASE=gpdw EOF ##環境變量文件分發到其他節點 gpscp -f /usr/local/greenplum-db/seg_host /home/gpadmin/.bash_profile gpadmin@=:/home/gpadmin/.bash_profile gpscp -f /usr/local/greenplum-db/seg_host /home/gpadmin/.bashrc gpadmin@=:/home/gpadmin/.bashrc gpssh -f /usr/local/greenplum-db/all_host -e 'source /home/gpadmin/.bash_profile;source /home/gpadmin/.bashrc;'
5.若刪除重裝,使用gpdeletesystem
安裝完成,出于種種原因,若需要集群刪除重裝,使用 gpdeletesystem ?工具
詳情參考官方文檔:
https://gpdb.docs.pivotal.io/6-2/utility_guide/ref/gpdeletesystem.html#topic1
使用命令:
gpdeletesystem -d /opt/greenplum/data/master/gpseg-1 -f
-d 后面跟 MASTER_DATA_DIRECTORY(master 的數據目錄),會清除master,segment所有的數據目錄。
-f force, 終止所有進程,強制刪除。示例:
gpdeletesystem -d /opt/greenplum/data/master/gpseg-1 -f
刪除完成后再根據自己需要,調整集群初始化配置文件,并重新初始化。
vi /home/gpadmin/gpconfigs/gpinitsystem_config gpinitsystem -c /home/gpadmin/gpconfigs/gpinitsystem_config -h /usr/local/greenplum-db/seg_host -D
六、安裝成功后配置
1.psql 登陸gp 并設置密碼
是用psql 登錄gp, 一般命令格式為:
psql -h hostname -p port -d database -U user -W password
-h后面接對應的master或者segment主機名
-p后面接master或者segment的端口號
-d后面接數據庫名可將上述參數配置到用戶環境變量中,linux 中使用gpadmin用戶不需要密碼。
psql 登錄,并設置gpadmin用戶密碼示例:
[gpadmin@mdw gpseg-1]$ psql -h mdw -p5432 -d gpdw psql (9.4.24) Type "help" for help. gpdw=# alter user gpadmin with password 'gpadmin'; ALTER ROLE gpdw=# \q
2.登陸到不同節點
[gpadmin@mdw gpseg-1]$ PGOPTIONS='-c gp_session_role=utility' psql -h mdw -p5432 -d postgres psql (9.4.24) Type "help" for help. postgres=# \q [gpadmin@mdw gpseg-1]$ PGOPTIONS='-c gp_session_role=utility' psql -h sdw1 -p6000 -d postgres psql (9.4.24) Type "help" for help. postgres=# \q
3.客戶端登陸gp
配置 pg_hba.conf
配置 postgresql.conf
配置pg_hba.conf
參考配置說明:https://blog.csdn.net/yaoqiancuo3276/article/details/80404883
vim /opt/greenplum/data/master/gpseg-1/pg_hba.conf ##修改 host replication gpadmin 192.168.31.201/32 trust ##為 host all gpadmin 192.168.31.201/32 trust ##新增 host all gpadmin 0.0.0.0/0 md5 # 新增規則允許任意ip 密碼登陸
**配置postgresql.conf?**
postgresql.conf里的監聽地址設置為:
listen_addresses = ‘*’ ??# 允許監聽任意ip gp6.0 默認會設置這個參數為 listen_addresses = ‘*’
vim /opt/greenplum/data/master/gpseg-1/postgresql.conf
4.加載修改的文件
gpstop -u
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。