官網(wǎng)下載地址:https://network.pivotal.io/products/pivotal-gpdb#/releases/1502/file_groups/378
一、準(zhǔn)備環(huán)境
1础浮、配置hosts
? ? a剥槐、vi /etc/hosts
? 10.10.134.11 dw-greenplum-1 mdw
? 10.10.134.12 dw-greenplum-2 sdw1
? 10.10.134.13 dw-greenplum-3 sdw2
b、scp到其他機器上
scp /etc/hosts root@10.10.134* :/etc/hosts
2、配置hostname
? ? ? a车遂、vi /etc/hostname? 各個機器 用自己名稱
? ? mdw
b京办、vi /etc/sysconfig/network 各個機器 用自己名稱
? ? mdw
c、reboot 重啟
如果以上還不起作用
正常顯示:?
3而昨、要安裝的工具
yum install -y ed s是為了解決這個問題(http://www.freeoa.net/osuport/db/greenplum-db-study-install_3097.html)
? ? yum -y install wget
? ? yum install -y unzip zip
? ? ? yum install -y unzip zip
? ? ? yum -y install lsof
? ? yum install -y net-tools which openssh-clients openssh-server less? zip unzip iproute
4救氯、關(guān)閉防火墻
查看防火墻狀態(tài)
firewall-cmd --state
停止firewall
systemctl stop firewalld.service
禁止firewall開機啟動
systemctl disable firewalld.service
5、網(wǎng)絡(luò)相互通
? ? ? ? ping IP
? ? ? ? ping hostname
? ? ? ? ssh? hostname 能登錄到其他機器上
二歌憨、Greenplum初始化前期配置
? ? 1着憨、系統(tǒng)設(shè)置(所有機器)
a、sysctl.conf的設(shè)置
? ? ? #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.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
? ? #sysctl -p
? ? b务嫡、limits.conf的設(shè)置
? ? # vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
? ? 分別copy其他機器上
? ? # scp? /etc/sysctl.conf root@swd1 : etc/sysctl.conf
? ? # scp? /etc/security/limits.conf root@swd1 : /etc/security/limits.conf
? ? 其他優(yōu)化配置在測試環(huán)境先不配置? 不影響啟動
? ? 2甲抖、安裝
? a漆改、創(chuàng)建gpadmin組合用戶
# groupdel gpadmin
# userdel gpadmin
# groupadd -g 530 gpadmin
# useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin
# passwd gpadmin
? b、解壓介質(zhì)
# unzip greenplum-db-4.3.7.2-build-2-RHEL5-x86_64.zip
# chown gpadmin:gpadmin greenplum-db-4.3.7.2-build-2-RHEL5-x86_64.bin
? c准谚、創(chuàng)建安裝目錄
# mkdir -p /opt/greenplum
# chown -R gpadmin:gpadmin /opt/greenplum
? ? d挫剑、Install? [root@gpnode1 greenplum]
$ ./greenplum-db-4.3.7.2-build-2-RHEL5-x86_64.bin
確認(rèn)license,輸入yes
輸入安裝目錄:/opt/greenplum
確認(rèn)安裝路徑柱衔,yes
? ? 3樊破、安裝和配置greenplum到所有主機(操作master)
? ? a、執(zhí)行相應(yīng)環(huán)境變量
? ? # . /opt/greenplum/greenplum_path.sh
? b唆铐、創(chuàng)建hostlist文件(所有機器的hostname)
? ? ?# cat /tmp/hostlist
? ? ? ? mdw
? ? ? ?sdw1
? ? ? ?sdw2
? c捶码、創(chuàng)建只包含segment節(jié)點的hostname
? ? # cat /tmp/seg_hosts
? ? ? sdw1
? ? ? sdw2
? d、安裝segment節(jié)點
? ? $ gpseginstall -f /tmp/seg_hosts -u gpadmin -p gpadmin
? ? 報錯后應(yīng)注意的一點:要在gpadmin用戶下進行或链,執(zhí)行source greenplum_path.sh惫恼,成功后? 會提示連接另一端數(shù)據(jù)庫
? e、Check install
$ gpssh -f /tmp/hostlist -e ls -l $GPHOME?
? ? f澳盐、創(chuàng)建master 數(shù)據(jù)目錄
? ? ?# mkdir /data/master
? ? ?# chown gpadmin /data/master
如有master-standby祈纯,則用如下命令創(chuàng)建相應(yīng)目錄:
# . /opt/greenplum/greenplum_path.sh
# gpssh -h standby-host -e 'mkdir /data/master'
# gpssh -h standby-host -e 'chown gpadmin /data/master'
? ? g、創(chuàng)建segment節(jié)點數(shù)據(jù)目錄
# . /opt/greenplum/greenplum_path.sh
# gpssh -f /tmp/seg_hosts -e 'mkdir -p /data/primary'
# gpssh -f /tmp/seg_hosts -e 'mkdir -p /data/mirror'
# gpssh -f /tmp/seg_hosts -e 'chown gpadmin /data/primary'
# gpssh -f /tmp/seg_hosts -e 'chown gpadmin /data/mirror'
? ? ? h叼耙、配置ntp(測試環(huán)境可以不執(zhí)行)
修改master的配置文件(/etc/ntp.conf )
server 127.0.0.1
修改segment的配置文件(/etc/ntp.conf )
server test1
Server standby-host
修改standby的配置文件(/etc/ntp.conf )
server ntp-server
Server test1
在master上執(zhí)行如下命令同步時間:
# gpssh -f /tmp/seg_hosts -v -e 'ntpd'?
? ? ? ? 4腕窥、check操作
$ gpcheck -f /tmp/hostlist
$ source /opt/greenplum-db/greenplum_path.sh
$ gpssh -f /tmp/hostlist #統(tǒng)一處理所有節(jié)點
$ gpssh-exkeys -f hostlist(比較關(guān)鍵)
5、配置./bash_profile
source /opt/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
export GPPORT=5432
export PGDATABASE=test_DB
依次scp到更改節(jié)點
$ source .bash_profile
三筛婉、Greenplum初始化
1.創(chuàng)建gp的配置文件
$ cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config? /home/gpadmin/gpinitsystem_config
$ cat? gpinitsystem_config |grep -v "^#" |grep -v "^$"
ARRAY_NAME="EMC Greenplum DW"
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data/primary)
MASTER_HOSTNAME=test1
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=(/data/mirror)
2 .Run Initialization
$ gpinitsystem -c gpinitsystem_config -h /tmp/seg_hosts
出現(xiàn)以下日志說明初始化成功了
參考的文檔:https://blog.csdn.net/king13127/article/details/83989704
? ? ? ? ? ? ? ? ? ? http://gitop.cc/posts/install-greenplum-in-docker/
? ? ? ? ? ? ? ? ? ? https://blog.csdn.net/xudailong_blog/article/details/79874923
官方下載地址:https://network.pivotal.io/products/pivotal-gpdb
四簇爆、數(shù)據(jù)庫操作
$ psql -d postgres(其中的一個初始庫)
$ psql -d postgres? #進入某個數(shù)據(jù)庫
postgres=# \l # 查詢數(shù)據(jù)庫? List of databases
? Name? ? |? Owner? | Encoding |? Access privileges?
-----------+---------+----------+---------------------
gp_sydb? | gpadmin | UTF8? ? |
postgres? | gpadmin | UTF8? ? |
template0 | gpadmin | UTF8? ? | =c/gpadmin? ? : gpadmin=CTc/gpadmin
template1 | gpadmin | UTF8? ? | =c/gpadmin? ? : gpadmin=CTc/gpadmin
(4 rows)
postgres=# \i test.sql #執(zhí)行sql
postgres=# copy 表名 to '/tmp/1.csv' with 'csv';? ? ? #快速導(dǎo)出單表數(shù)據(jù)
postgres=# copy 表名 from '/tmp/1.csv' with 'csv';? ? #快速導(dǎo)入單表數(shù)據(jù)
postgres=# \q? ? ? ? ? #退出數(shù)據(jù)庫
五、集群狀態(tài)
gpstate -e #查看mirror的狀態(tài)
gpstate -f #查看standby master的狀態(tài)
gpstate -s #查看整個GP群集的狀態(tài)
gpstate -i #查看GP的版本
gpstate --help #幫助文檔爽撒,可以查看gpstate更多用法
六入蛆、過程中遇到的問題
? ? 1、在source .bash_profile的過程中導(dǎo)致 yum 不能用報:? Fatal?Python?error:?pycurl:?libcurl?link-time?version?is?older?than?compile-time?version
Aborted
? ? ? ? ? 原因:把 root 用戶下 python環(huán)境變量unset掉了硕勿,總是在執(zhí)行python2.6 其實應(yīng)該執(zhí)行python2.7
? ? ? ? ? ? 解決:$? su root
? ? ? ? ? ? ? ? ? ? ? # whereis python
? ? ? ? ? ? ? ? ? ? ? # cd ~
? ? ? ? ? ? ? ? ? ? ? # vi .bash_profile
? ? ? ? ? ? ? ? ? ? ? ? #? source .bash_profile