greenplum 安裝指導
前面我們已經介紹了 greenplum 的架構, 若不清楚,請再次檢視greenplum架構介紹
本次介紹組映象架構模式的安裝 ,版本5.2
分步指南
注意: 磁碟空間的 評估,生產上建議使用 raid10需要磁碟空間最小總大小 = 使用者總資料 *2/0.7,一般資料庫大小是 純文字大小的1.4倍
1. 系統配置
1.1 系統版本支援
Red Hat Enterprise Linux 64-bit 7.x
Red Hat Enterprise Linux 64-bit 6.x
SuSE Linux Enterprise Server 64-bit 11 SP4
CentOS 64-bit 7.x
CentOS 64-bit 6.x
1.2 硬體要求
cpu : 奔騰3以上, 每個伺服器的記憶體至少 16GB, 10GB 的乙太網, 如果有多塊網絡卡,可以把網絡卡繫結
1.3 作業系統引數設定
1.3.1 SELINUX(getenforce 檢視,setenforce 0 禁用) 跟 iptales( chkconfig檢視) 一定要關閉
1.3.2 編輯/etc/hosts 新增所有的主機
1.3.3 編輯/etc/sysctl.conf 檔案 新增下面的引數
#vi /etc/sysctl.conf kernel.shmmax = 500000000 //單個segment的最大共享記憶體 kernel.shmmni = 4096 // 整個系統共享記憶體段的總個數 kernel.shmall = 4000000000 // 共享記憶體總頁數, 共享記憶體預設是 4kb/頁, 共享記憶體大小是 記憶體頁的整數倍 如16GB 需要 16GB/4kb/4kb=10240*10240 kernel.sem = 250 512000 100 2048 kernel.sysrq = 1 // 啟用所有除錯功能 kernel.core_uses_pid = 1 // x系統的 dump檔案會帶上程序id kernel.msgmnb = 65536 // 每個訊息佇列的最大位元組 kernel.msgmax = 65536 // 訊息佇列的最大數量 kernel.msgmni = 2048 // 訊息佇列的最小數量 net.ipv4.tcp_syncookies = 1 net.ipv4.conf.default.accept_source_route = 0 // 禁用所有ip源路由 net.ipv4.tcp_tw_recycle = 1 // 開啟tcp time wait 快速回收 net.ipv4.tcp_max_syn_backlog = 4096 net.ipv4.conf.all.arp_filter = 1 net.ipv4.ip_local_port_range = 10000 65535 net.core.netdev_max_backlog = 10000 //每個網路介面接收資料包的速率比核心處理這些包的速率快時,允許送到佇列的資料包的最大數目 net.core.rmem_max = 2097152 // 用於 tcp 接收緩衝socket 最大記憶體(byte) net.core.wmem_max = 2097152 // 用於 tcp 傳送緩衝socket 最大記憶體(byte) vm.overcommit_memory = 2 // 關閉oom killer
1.3…4 編輯/etc/security/limits.conf
注意 centos 6.x 跟 redhat 6.x /etc/security/limits.d/90-nproc.conf 會覆蓋 /etc/security/limits.conf
# vi /etc/security/limits.d/90-nproc.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
1.3.5 設定資料所在盤的 讀頭值為16384, 我的資料是在 sda盤
# /sbin/blockdev --setra 16384 /dev/sda
1.3.6 設定資料磁碟的排程模式為 deadline
# echo deadline > /sys/block/sda/queue/scheduler
1.3.7 關閉HTP
#echo never > /sys/kernel/mm/transparent_hugepage/defrag
#echo never > /sys/kernel/mm/transparent_hugepage/enabled
1.3.8 增加SSH MaxStartups 的值,/etc/ssh/sshd_config 或者 /etc/sshd_config 並重啟sshd
MaxStartups 200
1.3.9 在每個host中建立gpadmin使用者
# groupadd gpadmin
# useradd -m -g gpadmin gpadmin
# passwd gpadmin
# chmod o+rw /usr/local
注意:因為我不是root使用者,所以只能在每個主機中建立相同的os使用者跟密碼,步驟,1.3.5 到1.3.7的修改要寫到重啟生效檔案裡,避免機器重啟後失效
2 安裝資料庫(greenplum) 軟體
2.1 二進位制安裝(master)
# unzip greenplum-db-<version>-<platform>.zip
# /bin/bash greenplum-db-<version>-<platform>.bin
回車都是預設
# chown -R gpadmin /usr/local/greenplum*
# chgrp -R gpadmin /usr/local/greenplum*
2.3 安裝配置 greenplum 在所有主機
2.3.1 以gpadmin使用者登入master主機,並載入環境變數, 並修改gpadmin密碼
# source /usr/local/greenplum-db/greenplum_path.sh
2.3.2 建立 hostfile_exkeys檔案,並配置主機跟介面的繫結關係(我只有一個網絡卡,所以只需要配置主機就行)
[[email protected] ~]$ cat hostfile_exkeys
LOCAL-81-68
LOCAL-81-69
LOCAL-81-70
2.3.3 執行gpssh-exkeys 去交換祕鑰
[[email protected] ~]$ gpssh-exkeys -f hostfile_exkeys
[[email protected] ~]$ gpssh -f hostfile_exkeys -e "ls -ld /usr/local/green*"
檢查 ssh 免密是否成功
2.3.4 執行gpseginstall 安裝greenplumn到所有主機
gpseginstall -f hostfile_exkeys
2.4 建立資料儲存目錄
2.4.1 在master主機建立儲存目錄
# mkdir /data/master
# chown -R gpadmin:gpadmin /data/master/
2.4.2 在所有segment主機建立儲存目錄
用gpadmin 主機登入master 建立hostfile_segonly(只包含段主機)
[[email protected] ~]$ source /usr/local/greenplum-db/greenplum_path.sh
[[email protected] ~]$ gpssh -f hostfile_segonly -e 'mkdir /data/gpdata/primary'
[LOCAL-81-69] mkdir /data/gpdata/primary
[LOCAL-81-70] mkdir /data/gpdata/primary
[LOCAL-81-68] mkdir /data/gpdata/primary
[[email protected] ~]$ gpssh -f hostfile_segonly -e 'mkdir /data/gpdata/mirror'
[LOCAL-81-69] mkdir /data/gpdata/mirror
[LOCAL-81-70] mkdir /data/gpdata/mirror
[LOCAL-81-68] mkdir /data/gpdata/mirror
[[email protected] ~]$
2.5 使用NTP同步時間
我們是公司已經做好了時間同步,我就無需在同步了, 如果不知道,請參照 www.ntp.org
2.5.1 在mater 節點 /etc/ntp.conf新增
server dc01.boyaa.com
2.5.2 在所有 segment 主機 /etc/ntp.conf新增
server LOCAL-81-67
server dc01.boyaa.com
2.5.3 在master 節點執行 下面語句同步時鐘
gpssh -f hostfile_gpssh_allhosts -v -e 'ntpd'
2.5.4 開啟防火牆
# chkconfig iptables on
# service iptables start
2.5.6 檢查系統是否滿足要求
[[email protected] ~]$ gpcheck -f hostfile_exkeys -m LOCAL-81-67
3 初始化greenplum系統
3.1 gpadmin登入建立初始化主機檔案
[[email protected] ~]$ cat hostfile_segonly
LOCAL-81-68
LOCAL-81-69
LOCAL-81-70
3.2 在master節點建立greenplum 配置檔案
[[email protected] ~]$ cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/gpinitsystem_config
[[email protected] ~]$ vi gpinitsystem_config
#### the specified interface addresses). 確定 每個主機 段的個數,每個目錄表示一個段
declare -a DATA_DIRECTORY=(/data/gpdata/primary /data/gpdata/primary /data/gpdata/primary /data/gpdata/primary)
#### OS-configured hostname or IP address of the master host.
MASTER_HOSTNAME=LOCAL-81-67
#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY=/data/gpdata/master
#### Base number by which mirror segment port numbers
#### are calculated 映象埠 的起始值. 可選
MIRROR_PORT_BASE=7000
#### Base number by which primary file replication port
#### numbers are calculated. 流複製的起始值 可選
REPLICATION_PORT_BASE=8000
#### Base number by which mirror file replication port
#### numbers are calculated. 可選
MIRROR_REPLICATION_PORT_BASE=9000
#### File system location(s) where mirror segment data directories
#### will be created. The number of mirror locations must equal the
#### number of primary locations as specified in the
#### DATA_DIRECTORY parameter. 映象路徑,如果不需要映象可以不要, 如果要 一定跟跟 primary數量一致
declare -a MIRROR_DATA_DIRECTORY=(/data/gpdata/mirror /data/gpdata/mirror /data/gpdata/mirror /data/gpdata/mirror)
注意 紅色部分是 需要修改的
3.3 以gpadmin 使用者登入master節點初始greenplum
]$ gpinitsystem -c gpinitsystem_config -h hostfile_segonly
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Process results...
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-----------------------------------------------------
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:- Successful segment starts = 24
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:- Failed segment starts = 0
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 0
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-----------------------------------------------------
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Successfully started 24 of 24 segment instances
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-----------------------------------------------------
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Starting Master instance LOCAL-81-67 directory /data/gpdata/master/gpseg-1
20181121:17:00:48:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Command pg_ctl reports Master LOCAL-81-67 instance active
20181121:17:00:48:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-No standby master configured. skipping...
20181121:17:00:48:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Database successfully started
20181121:17:00:48:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Completed restart of Greenplum instance in production mode
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Scanning utility log file for any warning messages
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-*******************************************************
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-Scan of log file indicates that some warnings or errors
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-were generated during the array creation
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Please review contents of log file
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-/home/gpadmin/gpAdminLogs/gpinitsystem_20181121.log
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-To determine level of criticality
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-These messages could be from a previous run of the utility
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-that was called today!
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-*******************************************************
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Greenplum Database instance successfully created