環(huán)境準(zhǔn)備
本文只搭建一個虛擬機(jī)畏腕,適合初學(xué)者練習(xí),同時本文也列出了現(xiàn)實中集群部署的操作與建議。
- VMWare
虛擬機(jī)分配2G內(nèi)存時創(chuàng)建數(shù)據(jù)庫報錯绢彤。注意內(nèi)存分配多一些。 - CentOS 7.3.1611: 網(wǎng)易開源鏡像站下載
版本建議(CentOS版本不要學(xué)我r殉堋):
This directory (and version of CentOS) is deprecated. For normal users,
you should use /7/ and not /7.3.1611/ in your path. Please see this FAQ
concerning the CentOS release scheme:
https://wiki.centos.org/FAQ/General
If you know what you are doing, and absolutely want to remain at the 7.3.1611
level, go to http://vault.centos.org/ for packages.
Please keep in mind that 7.3.1611 no longer gets any updates, nor
any security fix's. - Greenplum 5.4.0:官方下載
- 部署目標(biāo):一臺機(jī)器搭建Greenplum:Master + 2 * Primary Segment + 2 * Mirror Segment茫舶。
1. VMWare安裝CentOS及準(zhǔn)備工作
VMWare上安裝CentOS步驟略
1.1 數(shù)據(jù)盤
Greenplum數(shù)據(jù)盤需要使用xfs格式,建議建立獨(dú)立的分區(qū)刹淌,方便管理饶氏。在RHEL/CentOS 6中,需要注意設(shè)置有勾;在RHEL/CentOS 7中疹启,默認(rèn)為xfs格式。
1.2 配置選擇
- 典型的Greenplum集群由Master + Master Standby + n * Segment構(gòu)成蔼卡。
- Master Standby通常是獨(dú)立的物理節(jié)點(diǎn)喊崖,也可以和某一個Segment部署在一起(不推薦)。在不要求高可用的情況下雇逞,甚至可以不設(shè)置Master Standby荤懂。
- 要求每臺Segment應(yīng)具有相同的硬件配置。
- Master及Master Standby不存儲數(shù)據(jù)塘砸,對磁盤空間無特殊要求节仿。
- 交換機(jī)要盡量高配置的。
- 本例為單臺機(jī)器掉蔬,和集群部署不同的地方會單獨(dú)指出廊宪。
1.3 主機(jī)名
集群中建議如下命名查近,方便統(tǒng)一管理:
- mdw0: Master
- mdw1: Master Standby
- sdw0: Segment 1
……- sdwn: Segment n
設(shè)置主機(jī)名,vi /etc/sysconfig/network
挤忙,加入如下內(nèi)容:
# for gpdb
NETWORKING=yes
HOSTNAME=mdw1
vi /etc/hostname
:
mdw1
1.4 hosts
集群中所有的服務(wù)器都要配置霜威,本例中只有一臺。vi /etc/hosts
册烈,加入如下內(nèi)容:
# for gpdb
192.168.199.244 mdw1
測試:ping mdw1
戈泼。
雙網(wǎng)卡
vi /etc/systemcfg/network-scrits
,略
1.5 關(guān)閉防火墻
依次執(zhí)行:systemctl stop firewalld.service
赏僧,systemctl disable firewalld.service
大猛。
查看防火墻狀態(tài)systemctl status firewalld.service
。
1.6 關(guān)閉SELINUX
關(guān)閉SELINUX淀零,vi /etc/selinux/config
:
SELINUX=disabled
1.7 重啟
reboot -f
挽绩,重啟機(jī)器。
2. 安裝Greenplum
本節(jié)所有操作均在Master節(jié)點(diǎn)上驾中,以root用戶進(jìn)行操作唉堪。
2.1 上傳、解壓縮肩民、安裝
- 上傳安裝包"greenplum-db-5.4.0-rhel7-x86_64.zip";
- 解壓縮:
unzip greenplum-db-5.4.0-rhel7-x86_64.zip
; - 安裝:
./greenplum-db-5.4.0-rhel7-x86_64.bin
; -
空格鍵滾動安裝信息唠亚,按照提示一路安裝;
-
完成安裝持痰。
2.2 引入Greenplum運(yùn)行環(huán)境
source /usr/local/greenplum-db/greenplum_path.sh
灶搜,如果改動了步驟2.1中的安裝路徑,請自行調(diào)整工窍。后面安裝過程中重啟機(jī)器時割卖,需要再執(zhí)行一下此操作。
2.3 hostlist和seglist
分別創(chuàng)建兩個文件患雏,其中hostlist
中填寫所有節(jié)點(diǎn)的主機(jī)名鹏溯;seglist
中填寫所有Segment的主機(jī)名(即不包括Master和Master Standby)。本例中只有一個節(jié)點(diǎn)纵苛,且為Master + Segment剿涮,故vi hostlist
:
mdw1
保存文件。這兩個文件(本例中由于單節(jié)點(diǎn)攻人,是一個文件)后面會用到取试。
2.4 免密登錄
執(zhí)行命令:gpssh-exkeys -f hostlist
。
2.5 gpseginstall
執(zhí)行命令怀吻,向所有節(jié)點(diǎn)部署:
gpseginstall -f hostlist -u gpadmin -p gpadmin
會創(chuàng)建系統(tǒng)用戶gpadmin瞬浓,初始密碼為gpadmin。
2.6 gpcheck
執(zhí)行命令:
gpcheck -f hostlist -m mdw1
本例中沒有Master Standby節(jié)點(diǎn)蓬坡,如果有猿棉,需要在上述命令后面再加上-s 主機(jī)名
選項磅叛。
可以看到南用,報出了大量錯誤莹菱,下面將根據(jù)提示,逐個修改:
20180427:16:46:32:004229 gpcheck:mdw1:root-[INFO]:-dedupe hostnames
20180427:16:46:32:004229 gpcheck:mdw1:root-[INFO]:-Detected platform: Generic Linux Cluster
20180427:16:46:32:004229 gpcheck:mdw1:root-[INFO]:-generate data on servers
20180427:16:46:33:004229 gpcheck:mdw1:root-[INFO]:-copy data files from servers
20180427:16:46:33:004229 gpcheck:mdw1:root-[INFO]:-delete remote tmp files
20180427:16:46:33:004229 gpcheck:mdw1:root-[INFO]:-
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): on device (sr0) IO scheduler 'cfq' does not match expected value 'deadline'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): on device (/dev/sda3) blockdev readahead value '8192' does not match expected value '16384'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): on device (/dev/sda1) blockdev readahead value '8192' does not match expected value '16384'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): on device (/dev/sda2) blockdev readahead value '8192' does not match expected value '16384'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): on device (/dev/sda) blockdev readahead value '8192' does not match expected value '16384'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.ipv4.ip_local_port_range'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'vm.overcommit_memory'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.msgmax'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.ipv4.tcp_syncookies'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.ipv4.tcp_max_syn_backlog'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.core.netdev_max_backlog'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.sem'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.ipv4.conf.all.arp_filter'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.shmall'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.msgmnb'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.ipv4.ip_forward'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.shmmax'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.shmmni'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.ipv4.conf.default.accept_source_route'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.msgmni'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.core_uses_pid'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'net.ipv4.tcp_tw_recycle'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): variable not detected in /etc/sysctl.conf: 'kernel.sysrq'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): soft nofile not found in /etc/security/limits.conf
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): hard nproc not found in /etc/security/limits.conf
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): soft nproc not found in /etc/security/limits.conf
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): hard nofile not found in /etc/security/limits.conf
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/mapper/cl-root has 5 XFS mount options and 4 are expected
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/mapper/cl-root is missing the recommended mount option 'allocsize=16m'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/mapper/cl-root is missing the recommended mount option 'noatime'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/sda1 has 5 XFS mount options and 4 are expected
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/sda1 is missing the recommended mount option 'allocsize=16m'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/sda1 is missing the recommended mount option 'noatime'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/sda3 has 5 XFS mount options and 4 are expected
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/sda3 is missing the recommended mount option 'allocsize=16m'
20180427:16:46:33:004229 gpcheck:mdw1:root-[ERROR]:-GPCHECK_ERROR host(mdw1): XFS filesystem on device /dev/sda3 is missing the recommended mount option 'noatime'
20180427:16:46:33:004229 gpcheck:mdw1:root-[INFO]:-gpcheck completing...
3. 根據(jù)gpcheck提示進(jìn)行調(diào)整
本節(jié)為系統(tǒng)參數(shù)調(diào)整驱闷,需要針對gpcheck檢查結(jié)果杖爽,對各個機(jī)器進(jìn)行調(diào)整敲董,均以root用戶進(jìn)行操作。
本例中慰安,計劃將所有數(shù)據(jù)都放在/data
盤中腋寨,別的硬盤可以不管,查看盤符命令df
:
gpcheck日志中有這么一句話:
Using gpcheck config file: /usr/local/greenplum-db/./etc/gpcheck.cnf
gpcheck.cnf是gpcheck的檢查依據(jù)化焕,那么我們也可以通過這個文件來進(jìn)行我們的配置:
[global]
configfile_version = 3
[linux]
xfs_mount_options = rw,noatime,inode64,allocsize=16m
sysctl.kernel.shmmax = 500000000
sysctl.kernel.shmmni = 4096
sysctl.kernel.shmall = 4000000000
sysctl.kernel.sem = 250 512000 100 2048
sysctl.kernel.sysrq = 1
sysctl.kernel.core_uses_pid = 1
sysctl.kernel.msgmnb = 65536
sysctl.kernel.msgmax = 65536
sysctl.kernel.msgmni = 2048
sysctl.net.ipv4.tcp_syncookies = 1
sysctl.net.ipv4.ip_forward = 0
sysctl.net.ipv4.conf.default.accept_source_route = 0
sysctl.net.ipv4.tcp_tw_recycle = 1
sysctl.net.ipv4.tcp_max_syn_backlog = 4096
sysctl.net.ipv4.conf.all.arp_filter = 1
sysctl.net.ipv4.ip_local_port_range = 1025 65535
sysctl.net.core.netdev_max_backlog = 10000
sysctl.vm.overcommit_memory = 2
3.1 內(nèi)核參數(shù)
gpcheck提示:
variable not detected in /etc/sysctl.conf: 'net.ipv4.ip_local_port_range'
……
variable not detected in /etc/sysctl.conf: 'kernel.sysrq'
命令vi /etc/sysctl.conf
修改內(nèi)核參數(shù)萄窜,之后sysctl -p
生效。
# gpdb
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
vm.overcommit_memory = 2
3.2 PAM 配置文件
gpcheck提示:
soft nofile not found in /etc/security/limits.conf
hard nproc not found in /etc/security/limits.conf
soft nproc not found in /etc/security/limits.conf
hard nofile not found in /etc/security/limits.conf
執(zhí)行命令vi /etc/security/limits.conf
:
# gpdb
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
保存撒桨。
3.3 IO調(diào)度
gpcheck提示:
on device (sr0) IO scheduler 'cfq' does not match expected value 'deadline'
device (sr0)并非我使用的數(shù)據(jù)盤查刻,不用管。
關(guān)于IO調(diào)度:參考資料
3.4 預(yù)讀扇區(qū)
gpcheck提示:
on device (/dev/sda3) blockdev readahead value '8192' does not match expected value '16384'
修改方法如下:
# 查看 /dev/sda2 盤的預(yù)讀扇區(qū)
blockdev --getra /dev/sda3
# 顯示8192元莫,與gpcheck提示符合
#修改 /dev/sda2 盤的預(yù)讀扇區(qū)
blockdev --setra 16384 /dev/sda3
#修改完成后再查看一下
#將修改命令寫入/etc/rc.local赖阻,否則重啟后會失效
echo '/sbin/blockdev --setra 16384 /dev/sda2' >> /etc/rc.local
#查看是否寫入成功
cat /etc/rc.local
#必要時可重啟系統(tǒng)進(jìn)行驗證
3.5 XFS 文件系統(tǒng) mount 參數(shù)
gpcheck提示
XFS filesystem on device /dev/sda3 has 5 XFS mount options and 4 are expected
XFS filesystem on device /dev/sda3 is missing the recommended mount option 'allocsize=16m'
XFS filesystem on device /dev/sda3 is missing the recommended mount option 'noatime'
vi /etc/fstab
,修改前:
UUID=203ac506-a2fb-4465-88ac-df2caefd3268 /data xfs defaults 0 0
修改后:
UUID=203ac506-a2fb-4465-88ac-df2caefd3268 /data xfs defaults,allocsize=16348k,inode64,noatime 0 0
命令mount -o remount /data
使之生效踱蠢,mount
命令查看。
注意:本例為CentOS7.3棋电,這里不能寫allocsize=16m
茎截,要寫成allocsize=16348k
。
3.6 時鐘同步
本例中只有一臺節(jié)點(diǎn)赶盔,不涉及時鐘同步的問題企锌,如果是多臺機(jī)器,gpcheck會提示:
ntpd not detected on machine
假設(shè)以某個服務(wù)器上的時間為基準(zhǔn)時間于未,該服務(wù)器的IP為x.x.x.x撕攒。
編輯文件vi /etc/ntp.conf,在末尾追加信息(三種節(jié)點(diǎn)添加的東西不一樣):
# Master 節(jié)點(diǎn)
server x.x.x.x
# Master Standby 節(jié)點(diǎn)
server mdw perfer
server x.x.x.x
# Segment 節(jié)點(diǎn)
server mdw perfer
server mdw1 perfer
# mdw為Master烘浦,mdw1為Master Standby
設(shè)置ntpd服務(wù)開機(jī)啟動抖坪,在/etc/rc.local
中添加如下信息:
/etc/init.d/ntpd start
如果只是簡單的試驗環(huán)境,并沒有時間服務(wù)器闷叉,則只需要從Master上同步時間即可擦俐,自行調(diào)整。
3.7 再次gpcheck
再次gpcheck握侧,gpcheck -f hostlist -m mdw1
蚯瞧,本例中的最終結(jié)果如下:
4. 初始化Greenplum數(shù)據(jù)庫
本節(jié)內(nèi)容在Master機(jī)器上嘿期,以gpadmin用戶進(jìn)行操作。
root用戶將/data
盤交給gpadmin:
chown gpadmin /data
chgrp gpadmin /data
將剛才的hostlist和seglist文件復(fù)制給gpadmin用戶埋合,登錄gpadmin用戶:
用gpssh-exkeys
創(chuàng)建gpadmin用戶之間的ssh免密登錄备徐,后續(xù)初始化時會用到。
source /usr/local/greenplum-db/greenplum_path.sh
gpssh-exkeys -f hostlist
4.1 創(chuàng)建數(shù)據(jù)目錄
- Master和Master Standby上創(chuàng)建:
mkdir /data/master
- Segment上創(chuàng)建Primary Segment:
mkdir /data/primary
- Segment上創(chuàng)建Mirror Segment(非必須):
mkdir /data/mirror
本例只有一臺服務(wù)器甚颂,只好在一臺機(jī)器上創(chuàng)建master坦喘、primary、mirror三個目錄西设。當(dāng)Segment比較多時瓣铣,可以使用gpssh-exkeys
命令輔助操作。
不要在Master/Master Standby上也創(chuàng)建primary和mirror目錄贷揽!
4.2 gpinitsystem_config
Greenplum配置文件模板位置:/usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config
棠笑,復(fù)制一份出來。
其中關(guān)鍵的配置項如下:
- DATA_DIRECTORY:決定了每個Segment上部署多少個Primary Instance禽绪,一個目錄就是一個Instance蓖救。這里建議把所有的Instance都指向一個目錄,例如部署兩個實例印屁,則為:/gpdata/primary /gpdata/primary循捺。原因是我們在使用中會創(chuàng)建新的文件系統(tǒng),這樣便于和文件系統(tǒng)區(qū)分雄人。
- MASTER_HOSTNAME:Master的主機(jī)名从橘。
- MASTER_DIRECTORY:Master文件目錄。
- MASTER_PORT:該端口用于訪問Greenplum數(shù)據(jù)庫础钠。
- MIRROR_DATA_DIRECTORY:(如果需要部署Mirror)恰力,決定了每個Segment上部署多少個Mirror Instance。類似于DATA_DIRECTORY旗吁,例如:/gpdata/mirror /gpdata/mirror踩萎。
- DATABASE_NAME:創(chuàng)建一個數(shù)據(jù)庫,輸入數(shù)據(jù)庫名稱很钓。也可以之后手工創(chuàng)建香府。
本例中只有一臺機(jī)器,兩主(DATA_DIRECTORY)兩備(MIRROR_DATA_DIRECTORY)码倦。本例中的配置如下:
# FILE NAME: gpinitsystem_config
# Configuration file needed by the gpinitsystem
################################################
#### REQUIRED PARAMETERS
################################################
#### Name of this Greenplum system enclosed in quotes.
ARRAY_NAME="Greenplum Data Platform"
#### Naming convention for utility-generated data directories.
SEG_PREFIX=gpseg
#### Base number by which primary segment port numbers
#### are calculated.
PORT_BASE=40000
#### File system location(s) where primary segment data directories
#### will be created. The number of locations in the list dictate
#### the number of primary segments that will get created per
#### physical host (if multiple addresses for a host are listed in
#### the hostfile, the number of segments will be spread evenly across
#### the specified interface addresses).
declare -a DATA_DIRECTORY=(/data/primary /data/primary)
#### OS-configured hostname or IP address of the master host.
MASTER_HOSTNAME=mdw1
#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY=/data/master
#### Port number for the master instance.
MASTER_PORT=5432
#### Shell utility used to connect to remote hosts.
TRUSTED_SHELL=ssh
#### Maximum log file segments between automatic WAL checkpoints.
CHECK_POINT_SEGMENTS=8
#### Default server-side character set encoding.
ENCODING=UNICODE
################################################
#### OPTIONAL MIRROR PARAMETERS
################################################
#### Base number by which mirror segment port numbers
#### are calculated.
MIRROR_PORT_BASE=50000
#### Base number by which primary file replication port
#### numbers are calculated.
REPLICATION_PORT_BASE=41000
#### Base number by which mirror file replication port
#### numbers are calculated.
MIRROR_REPLICATION_PORT_BASE=51000
#### 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.
declare -a MIRROR_DATA_DIRECTORY=(/data/mirror /data/mirror)
################################################
#### OTHER OPTIONAL PARAMETERS
################################################
#### Create a database of this name after initialization.
DATABASE_NAME=my
#### Specify the location of the host address file here instead of
#### with the the -h option of gpinitsystem.
#MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem
4.3 初始化Greenplum
一般的集群部署中:
gpinitsystem -h seglist -c gpdb-config -s sdw2 -S
其中g(shù)pdb-config是剛才的配置文件名企孩;-S
指Spread分布,是primary和mirror的分布關(guān)系叹洲,此為推薦值柠硕。-mdw2
是指定了Master Standby。一般集群部署中,也可以挑選一個Segment作為Master Standby蝗柔。
本例只有一臺機(jī)器闻葵,命令是這樣的:
gpinitsystem -h hostlist -c gpdb-config
安裝過程中,核對安裝信息:
按照提示輸入Y
癣丧,回車確定:
4.4 環(huán)境變量
編輯文件:vi .bashrc
槽畔,以本例的環(huán)境為準(zhǔn),加入如下信息
# for greenplum DB
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/gpdata/master/gpseg-1
export PGPORT=5432
export PGDATABASE=my
生效:
source .bashrc
登錄GPDB胁编,如圖所示厢钧,應(yīng)該能看到如下形式:
如果部署了Master Standby,將環(huán)境變量copy到Master Standby中嬉橙。大功告成早直!
4.5 最后一件事
- 在安裝的時候,我們?yōu)閞oot用戶之間建立了ssh免密登錄市框,現(xiàn)在安裝完成了霞扬,應(yīng)該刪除掉,以免發(fā)生安全隱患枫振。
- gpadmin用戶之間的ssh免密登錄不要刪除喻圃!現(xiàn)在gpadmin用戶的密碼均為“gpadmin”,為了避免發(fā)生安全隱患粪滤,請修改gpadmin用戶的密碼斧拍。