Centos7 Greenplum6.1开源版本集群部署
目錄
?
1.前言
1.1參照文檔
1.2部署包
1.3服務器環境
2 準備工作
2.1 Linux用戶
2.2 主機名和hosts配置
2.3 防火墻
2.4 系統資源配置
2.5 暫時啟用gpadmin sudo
2.6 復制配置文件到所有節點上
3 安裝Greenplum DB
3.1 在Master節點上安裝Greenplum DB
3.2 在Master節點上配置集群host
3.3 配置SSH免密連接
3.4 依賴環境安裝
3.5 Segment節點上安裝Greenplum DB
3.6?環境變量配置
4 初始化Greenplum DB
4.1 初始化前檢查
4.2 初始化
5 后續操作
5.1 停止和啟動集群
5.2 登錄數據庫
5.3 集群狀態
5.4 測試GPDB集群狀態
5.5 設置gpadmin遠程訪問密碼
5.6 查詢測試
5.7修改master的pg_hba.conf
?
1.前言
1.1參照文檔
https://github.com/greenplum-db/gpdb
?
1.2部署包
基于開源版本編譯的源碼,
編譯參見《centos7 greenplum6.1開源版本編譯》
tar czvf greenplum-db.tar.gz /usr/local/gpdb
?
1.3服務器環境
操作系統centos7
| 角色 | 數量 | 主機名 | IP |
| Greenplum Master | 1 | gp1 | 192.168.81.154 |
| Greenplum Standby | 無 | 無 | 無 |
| Greenplum Segment | 3 | gp1、gp2、gp3 | 192.168.81.154、192.168.81.155、192.168.81.156 |
2 準備工作
2.1 Linux用戶
在所有節點上創建greenplum管理員用戶。
groupadd -g 530 gpadmin useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin chown -R gpadmin:gpadmin /home/gpadmin echo "gpadmin" | passwd --stdin gpadmin2.2 主機名和hosts配置
相同的配置先在一個節點上配置,配置完成后在2.6小節中復制到其它節點上。
vi /etc/hosts
192.168.81.154 gp1 192.168.81.155 gp2 192.168.81.156 gp3分別對應每一臺主機修改主機名;
依次修改所有節點?gp[1-3]上分別執行
hostnamectl set-hostname gp1
2.3 防火墻
禁用防火墻;
vi /etc/selinux/config
SELINUX=disabled
?
所有機器執行
systemctl stop firewalld.service
systemctl disable firewalld.service
2.4 系統資源配置
sudo bash -c 'cat >> /etc/sysctl.conf <<-EOF
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 500 1024000 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.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
?
EOF'
?
sudo bash -c 'cat >> /etc/security/limits.conf <<-EOF
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
?
EOF'
?
cat >> /etc/security/limits.d/90-nproc.conf <<-EOF
* soft nproc 131072
root soft nproc unlimited
?
EOF
2.5 暫時啟用gpadmin sudo
因為后面的集群節點上安裝greenplum時會涉及到創建目錄和文件操作,在此臨時啟用sudo,安裝成功后撤銷。
visudo
gpadmin ALL=(ALL) ALL
gpadmin ALL=(ALL) NOPASSWD:ALL
2.6 復制配置文件到所有節點上
?
scp /etc/hosts gp2:/etc scp /etc/sysctl.conf gp2:/etc scp /etc/security/limits.d/90-nproc.conf gp2:/etc/security/limits.d scp /etc/selinux/config gp2:/etc/selinuxscp /etc/hosts gp3:/etc scp /etc/sysctl.conf gp3:/etc scp /etc/security/limits.d/90-nproc.conf gp3:/etc/security/limits.d scp /etc/selinux/config gp3:/etc/selinux?
重啟操作系統。
?
3 安裝Greenplum DB
3.1 在Master節點上安裝Greenplum DB
三臺上
mkdir -p /opt/greenplum
將部署包解壓到
/opt/greenplum/greenplum-db
cd /opt/greenplum/
tar xzvf greenplum-db.tar.gz
?
修改目錄權限和所有者為gpadmin;
chown -R gpadmin:gpadmin /opt/greenplum/
chown -R gpadmin:gpadmin /opt/greenplum/greenplum-db
3.2 在Master節點上配置集群host
su - gpadmin mkdir -p /opt/greenplum/greenplum-db/conf
vi /opt/greenplum/greenplum-db/conf/hostlist
gp1
gp2
gp3
創建一個 seg_hosts ,包含所有的Segment Host的主機名;
vi /opt/greenplum/greenplum-db/conf/seg_hosts
gp1
gp2
gp3
3.3 配置SSH免密連接
使用root賬號
?
1.在集群master的?/etc/ssh/sshd_config??文件去掉以下選項的注釋
vi /etc/ssh/sshd_config
RSAAuthentication yes #開啟私鑰驗證 PubkeyAuthentication yes #開啟公鑰驗證
2.將集群master 修改后的?/etc/ssh/sshd_config??通過?scp?命令復制發送到集群的每一個節點
for a in {2..3} ; do scp /etc/ssh/sshd_config gp$a:/etc/ssh/sshd_config ; done
3.生成公鑰、私鑰
1.在集群的每一個節點節點輸入命令?ssh-keygen -t rsa -P '',生成 key,一律回車
su - gpadmin
cd ~
ssh-keygen -t rsa -P ''
4.在集群的master 節點輸入命令
將集群每一個節點的公鑰id_rsa.pub放入到自己的認證文件中authorized_keys;
for a in {1..3}; do ssh root@gp$a cat /home/gpadmin/.ssh/id_rsa.pub >> /home/gpadmin/.ssh/authorized_keys; done
5.在集群的master 節點輸入命令
將自己的認證文件?authorized_keys??通過?scp?命令復制發送到每一個節點上去:?/root/.ssh/authorized_keys`
for a in {2..3}; do scp /home/gpadmin/.ssh/authorized_keys root@gp$a:/home/gpadmin/.ssh/authorized_keys ; done
6.在集群的每一個節點節點輸入命令
接重啟ssh服務(使用root用戶)
sudo systemctl restart sshd.service
7.驗證 ssh 無密登錄
開一個其他窗口測試下能否免密登陸
例如:在gp2
ssh gp3
exit?退出
測試ssh gp1,不需要密碼即可登錄。
?
多數情況下,可以登錄成功。但是也會出現配置不正確,導致失敗的時候。
檢查authorized_keys文件權限,并設置為700
chmod 700 .ssh/authorized_keys
?
3.4 依賴環境安裝
每臺機器都需要執行
yum install -y epel-release
?
yum install -y \
apr-devel \
bison \
bzip2-devel \
cmake3 \
flex \
gcc \
gcc-c++ \
krb5-devel \
libcurl-devel \
libevent-devel \
libkadm5 \
libyaml-devel \
libxml2-devel \
libzstd-devel \
openssl-devel \
perl-ExtUtils-Embed \
python-devel \
python-pip \
readline-devel \
xerces-c-devel \
zlib-devel
?
?
cat >> python-dependencies.txt <<-EOF
argparse==1.2.1
behave==1.2.4
epydoc==3.0.1
lockfile==0.9.1
logilab-astng==0.20.1
logilab-common==0.50.1
MarkupSafe==1.0
mock==1.0.1
parse==1.8.2
psutil==4.0.0
setuptools==36.6.0
unittest2==0.5.1
EOF
?
?
pip install -r python-dependencies.txt
?
#添加gp編譯的python包
echo "/opt/greenplum/greenplum-db/lib/python" > /usr/lib/python2.7/site-packages/greenplum.pth
?
vi /etc/ld.so.conf
添加
/opt/greenplum/greenplum-db/lib
?
#配置生效
ldconfig
如果報錯ldconfig: xxxx 不是符號連接,說明不是正常壓縮、拷貝、解壓過來的(直接scp文件不會帶符號連接)
?
?
vi /opt/greenplum/greenplum-db/greenplum_path.sh
修改
GPHOME=/opt/greenplum/greenplum-db
?
?
3.5 Segment節點上安裝Greenplum DB
root用戶創建Segment節點所需的目錄,并更改目錄權限和所有者為gpadmin;
sudo mkdir -p /opt/greenplum && sudo chown gpadmin:gpadmin -R /opt/greenplum
?
登錄gp1,拷貝
su - gpadmin
scp -r /opt/greenplum/greenplum-db gp2:/opt/greenplum/
scp -r /opt/greenplum/greenplum-db gp3:/opt/greenplum/
?
檢查每個節點安裝和目錄情況;
su - gpadmin source /opt/greenplum/greenplum-db/greenplum_path.sh /opt/greenplum/greenplum-db/bin/gpssh -f /opt/greenplum/greenplum-db/conf/hostlist -e ls -l $GPHOME
[gp1] ls -l /opt/greenplum/greenplum-db
[gp1] 總用量 20
[gp1] drwxr-xr-x 7 gpadmin gpadmin 4096 12月 12 10:41 bin
[gp1] drwxrwxr-x 2 gpadmin gpadmin 39 12月 12 11:13 conf
[gp1] drwxr-xr-x 3 gpadmin gpadmin 22 12月 12 10:41 docs
[gp1] -rw-r--r-- 1 gpadmin gpadmin 749 12月 12 13:38 greenplum_path.sh
[gp1] drwxr-xr-x 4 gpadmin gpadmin 4096 12月 12 10:41 include
[gp1] drwxr-xr-x 5 gpadmin gpadmin 4096 12月 12 10:41 lib
[gp1] -rw-r--r-- 1 gpadmin gpadmin 196 12月 12 13:38 python-dependencies.txt
[gp1] drwxr-xr-x 2 gpadmin gpadmin 176 12月 12 10:41 sbin
[gp1] drwxr-xr-x 4 gpadmin gpadmin 41 12月 12 10:41 share
[gp2] ls -l /opt/greenplum/greenplum-db
[gp2] 總用量 20
[gp2] drwxr-xr-x 7 gpadmin gpadmin 4096 12月 12 13:38 bin
[gp2] drwxrwxr-x 2 gpadmin gpadmin 39 12月 12 13:38 conf
[gp2] drwxr-xr-x 3 gpadmin gpadmin 22 12月 12 13:38 docs
[gp2] -rw-r--r-- 1 gpadmin gpadmin 749 12月 12 13:38 greenplum_path.sh
[gp2] drwxr-xr-x 4 gpadmin gpadmin 4096 12月 12 13:38 include
[gp2] drwxr-xr-x 5 gpadmin gpadmin 4096 12月 12 13:38 lib
[gp2] -rw-r--r-- 1 gpadmin gpadmin 196 12月 12 13:38 python-dependencies.txt
[gp2] drwxr-xr-x 2 gpadmin gpadmin 176 12月 12 13:38 sbin
[gp2] drwxr-xr-x 4 gpadmin gpadmin 41 12月 12 13:38 share
[gp3] ls -l /opt/greenplum/greenplum-db
[gp3] 總用量 20
[gp3] drwxr-xr-x 7 gpadmin gpadmin 4096 12月 12 13:43 bin
[gp3] drwxrwxr-x 2 gpadmin gpadmin 39 12月 12 13:43 conf
[gp3] drwxr-xr-x 3 gpadmin gpadmin 22 12月 12 13:43 docs
[gp3] -rw-r--r-- 1 gpadmin gpadmin 749 12月 12 13:43 greenplum_path.sh
[gp3] drwxr-xr-x 4 gpadmin gpadmin 4096 12月 12 13:43 include
[gp3] drwxr-xr-x 5 gpadmin gpadmin 4096 12月 12 13:43 lib
[gp3] -rw-r--r-- 1 gpadmin gpadmin 196 12月 12 13:43 python-dependencies.txt
[gp3] drwxr-xr-x 2 gpadmin gpadmin 176 12月 12 13:43 sbin
[gp3] drwxr-xr-x 4 gpadmin gpadmin 41 12月 12 13:43 share
?
?
?
創建數據存儲區域目錄;
su - gpadmin
source /opt/greenplum/greenplum-db/greenplum_path.sh
/opt/greenplum/greenplum-db/bin/gpssh -f /opt/greenplum/greenplum-db/conf/hostlist -e 'mkdir -p /opt/greenplum/data'
在master上創建master數據存儲區域;
su - gpadmin
source /opt/greenplum/greenplum-db/greenplum_path.sh
/opt/greenplum/greenplum-db/bin/gpssh -h gp1 -e 'mkdir -p /opt/greenplum/data/master'
在Segment節點上創建數據存儲區域
su - gpadmin
source /opt/greenplum/greenplum-db/greenplum_path.sh
/opt/greenplum/greenplum-db/bin/gpssh -f /opt/greenplum/greenplum-db/conf/seg_hosts -e 'mkdir -p /opt/greenplum/data/primary && mkdir -p /opt/greenplum/data/mirror'
3.6?環境變量配置
source /opt/greenplum/greenplum-db/greenplum_path.sh gpssh -f /opt/greenplum/greenplum-db/conf/hostlist -e -v "cat >> /home/gpadmin/.bashrc <<EOFsource /opt/greenplum/greenplum-db/greenplum_path.sh export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1 export GPPORT=5432 export PGDATABASE=gp_sydb EOF"4 初始化Greenplum DB
4.1 初始化前檢查
檢查主機名配置;
su gpadmin source /opt/greenplum/greenplum-db/greenplum_path.sh gpssh -f /opt/greenplum/greenplum-db/conf/hostlist -e hostname[gp1] hostname [gp1] gp1 [gp3] hostname [gp3] gp3 [gp2] hostname [gp2] gp2檢查節點與節點之間文件讀取(可以不檢查);
?
gpcheckperf -h gp1 -h gp2 -d /tmp -r d -D -v gpcheckperf -f /opt/greenplum/greenplum-db/conf/hostlist -d /tmp -r d -D -v $ gpcheckperf -f /opt/greenplum/greenplum-db/conf/hostlist -r N -d /tmp /opt/greenplum/greenplum-db/./bin/gpcheckperf -f /opt/greenplum/greenplum-db/conf/hostlist -r N -d /tmp------------------- -- NETPERF TEST -------------------==================== == RESULT ==================== Netperf bisection bandwidth test gp-master -> gp-sdw1 = 72.220000 gp-sdw2 -> gp-sdw3 = 21.470000 gp-sdw1 -> gp-master = 43.510000 gp-sdw3 -> gp-sdw2 = 44.200000Summary: sum = 181.40 MB/sec min = 21.47 MB/sec max = 72.22 MB/sec avg = 45.35 MB/sec median = 44.20 MB/sec[Warning] connection between gp-sdw2 and gp-sdw3 is no good [Warning] connection between gp-sdw1 and gp-master is no good [Warning] connection between gp-sdw3 and gp-sdw2 is no good?
4.2 初始化
初始化 Greenplum 配置文件模板都在/opt/greenplum/greenplum-db/docs/cli_help/gpconfigs目錄下,gpinitsystem_config是初始化 Greenplum 的模板,此模板中 Mirror Segment的配置都被注釋;創建一個副本,對其修改;
?
cd /opt/greenplum/greenplum-db/docs/cli_help/gpconfigs cp gpinitsystem_config initgp_config vi initgp_config declare -a DATA_DIRECTORY=(/opt/greenplum/data/primary /opt/greenplum/data/primary /opt/greenplum/data/primary) MASTER_HOSTNAME=gp1 MASTER_DIRECTORY=/opt/greenplum/data/master declare -a MIRROR_DATA_DIRECTORY=(/opt/greenplum/data/mirror /opt/greenplum/data/mirror /opt/greenplum/data/mirror) DATABASE_NAME=gp_sydb MACHINE_LIST_FILE=/opt/greenplum/greenplum-db/conf/seg_hosts執行初始化;
gpinitsystem -c initgp_config
若初始化失敗,需要刪除數據目錄重新初始化;
chmod 777 /home/gpadmin/gpAdminLogs/backout_gpinitsystem_gpadmin_20191212_144741
/home/gpadmin/gpAdminLogs/backout_gpinitsystem_gpadmin_20191212_144741
?
5 后續操作
5.1 停止和啟動集群
gpstop -a gpstart -a
5.2 登錄數據庫
$ psql -d postgrespostgres=# \l # 查詢數據庫List of databasesName | Owner | Encoding | Access privileges -----------+---------+----------+---------------------gp_sydb | gpadmin | UTF8 | postgres | gpadmin | UTF8 | template0 | gpadmin | UTF8 | =c/gpadmin : gpadmin=CTc/gpadmintemplate1 | gpadmin | UTF8 | =c/gpadmin : gpadmin=CTc/gpadmin (4 rows)postgres=# \l # 查詢數據庫表5.3 集群狀態
gpstate -e #查看mirror的狀態 gpstate -f #查看standby master的狀態 gpstate -s #查看整個GP群集的狀態 gpstate -i #查看GP的版本 gpstate --help #幫助文檔,可以查看gpstate更多用法?
?
5.4 測試GPDB集群狀態
gpstate -e
5.5 設置gpadmin遠程訪問密碼
psql postgres gpadmin
alter user gpadmin encrypted password 'gpadmin';
\q
5.6 查詢測試
psql -hgp1 -p 5432 -d postgres -U gpadmin -c 'select dfhostname, dfspace,dfdevice from gp_toolkit.gp_disk_free order by dfhostname;'
psql -h gp1 -p 5432 -d postgres -U gpadmin -c '\l+'
?
5.7修改master的pg_hba.conf
pg_hba.conf是控制數據庫訪問的文件
?
vi $MASTER_DATA_DIRECTORY/pg_hba.conf
host all gpadmin 0.0.0.0/0 md5
執行gpstop -u使配置生效
?
此時可以使用客戶端進行連接(postgres連接方式,連接到master的5432)
?
$MASTER_DATA_DIRECTORY/postgresql.conf是集群的配置文件,可以根據實際情況進行配置。主要有兩個配置:
監聽地址
連接數
?
?
拷貝過來一張數據量上萬的表,然后查詢數據分布情況
select gp_segment_id,count(*) from gis_person_info group by 1 order by 1;
?
總結
以上是生活随笔為你收集整理的Centos7 Greenplum6.1开源版本集群部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 高通modem启动过程_使用QXDM收集
- 下一篇: 搞深度学习如何快速读懂开源代码?