當用戶需要的計算或者存儲資源冗餘超出業務需求時,可在管理控制台對已有集群進行縮容操作,以便充分利用GaussDB(DWS) 提供的計算資源和存儲資源。 ...
前置:
軟體安裝包下載:
可以從官方下載(需要賬號)
https://network.pivotal.io/products/vmware-greenplum#/releases/301769/file_groups/1397
也可以從csdn 地址下載:
1.修改主機名IP映射關係,編輯/etc/hosts文件
192.168.209.21 risen
2.修改主機名,編輯/etc/hostname文件
risen
3. 環境
- 防火牆:
可以選擇直接關閉防火牆,或者添加防火牆條件允許
- SELinux:
SELinux策略是白名單原則,需要非常清楚安裝軟體使用的許可權才能配置好(配置麻煩不說,頭疼的是你不知道需要什麼許可權),而Linux已經有了比較完善的Security Best Practice。在Linux上部署工具有更多的實踐經驗和可行方案去保證系統的安全,即便是沒有SELinux,是故大家普遍選擇關閉SELinux。
# 查看防火牆是否關閉,未關閉使用(systemctl stop firewalld) systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) # 查看selinux狀態,未關閉修改(SELINUX=disabled) cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
4.添加組及用戶
groupadd gpadmin useradd -r -m -g gpadmin gpadmin # 給 gpadmin 用戶設置密碼 echo "123456" | passwd --stdin gpadmin # 刪除組 groupdel gpadmin 刪除用戶 userdel gpadmin echo "RemoveIPC=no" >> /etc/systemd/logind.conf service systemd-logind restart
5.下載好了之後,上傳到 /home/greenplum 文件,如果沒有文件則mkdir 命令創建
6.安裝
[root@192 greenplum]# rpm -Uvh greenplum-db-5.17.0-rhel7-x86_64.rpm 準備中... ################################# [100%] 正在升級/安裝... 1:greenplum-db-5.17.0-1 ################################# [100%]m預設
預設安裝的位置
[root@192 greenplum]# ll -al /usr/local/ 總用量 0 drwxr-xr-x. 13 root root 178 2月 26 10:59 . drwxr-xr-x. 13 root root 155 2月 23 15:08 .. drwxr-xr-x. 2 root root 6 4月 11 2018 bin drwxr-xr-x. 2 root root 6 4月 11 2018 etc drwxr-xr-x. 2 root root 6 4月 11 2018 games lrwxrwxrwx. 1 root root 30 2月 26 10:59 greenplum-db -> /usr/local/greenplum-db-5.17.0 drwxr-xr-x. 11 root root 138 2月 26 10:59 greenplum-db-5.17.0 drwxr-xr-x. 2 root root 6 4月 11 2018 include drwxr-xr-x. 2 root root 6 4月 11 2018 lib drwxr-xr-x. 2 root root 6 4月 11 2018 lib64 drwxr-xr-x. 2 root root 6 4月 11 2018 libexec drwxr-xr-x. 2 root root 6 4月 11 2018 sbin drwxr-xr-x. 5 root root 49 2月 23 15:08 share drwxr-xr-x. 2 root root 6 4月 11 2018 src
7. 賦權
chown -R gpadmin /usr/local/greenplum* chgrp -R gpadmin /usr/local/greenplum*
# 使環境變數生效
source /usr/local/greenplum-db/greenplum_path.sh
8.初始化準備
# 創建實例目錄(主節點及segment實例存儲文件夾gpnode個數視伺服器情況而定) mkdir -p /home/greenplum/gpdata/master mkdir -p /home/greenplum/gpdata/gpnode1 mkdir -p /home/greenplum/gpdata/gpnode2 mkdir -p /home/greenplum/gpdata/gpnode3 mkdir -p /home/greenplum/gpdata/gpnode4 # 修改目錄屬主 chown -R gpadmin:gpadmin /home/greenplum/ chown -R gpadmin:gpadmin /home/greenplum/gpdata chown -R gpadmin:gpadmin /home/greenplum/gpdata/master chown -R gpadmin:gpadmin /home/greenplum/gpdata/gpnode*
9.以下使用gpadmin用戶操作
su gpadmin # ----環境變數配置 # postgresql預設埠號5432 這裡使用2345 cat <<EOF >> /home/greenplum/.bashrc source /usr/local/greenplum-db/greenplum_path.sh export PGPORT=2345 export PGUSER=gpadmin export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1 export PGDATABASE=gpdb # export LD_PRELOAD=/lib64/libz.so.1 ps EOF source /home/greenplum/.bashrc # ----節點host配置(單機版值配置一個master節點) cat <<EOF >> /home/greenplum/hostfile_exkeys risen EOF # ----ssh許可權互通設置 gpssh-exkeys -f /home/greenplum/hostfile_exkeys su gpadmin # ----環境變數配置 # postgresql預設埠號5432 這裡使用2345 cat <<EOF >> /home/greenplum/.bashrc source /usr/local/greenplum-db/greenplum_path.sh export PGPORT=2345 export PGUSER=gpadmin export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1 export PGDATABASE=gpdb # export LD_PRELOAD=/lib64/libz.so.1 ps EOF source /home/greenplum/.bashrc # ----節點host配置(單機版值配置一個master節點) cat <<EOF >> /home/greenplum/hostfile_exkeys risen EOF # ----ssh許可權互通設置 gpssh-exkeys -f /home/greenplum/hostfile_exkeys [STEP 1 of 5] create local ID and authorize on local host [STEP 2 of 5] keyscan all hosts and update known_hosts file [STEP 3 of 5] authorize current user on remote hosts [STEP 4 of 5] determine common authentication file content [STEP 5 of 5] copy authentication files to all remote hosts [INFO] completed successfully # ----設置節點伺服器(單機版就是master節點) cat <<EOF >> /home/greenplum/seg_hosts_file risen EOF # ----編輯gp初始化文件 cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/greenplum/gpinitsystem_config vim /home/greenplum/gpinitsystem_config # 以下為配置文件內容 declare -a DATA_DIRECTORY=(/home/greenplum/gpdata/gpnode1 /home/greenplum/gpdata/gpnode2) MASTER_HOSTNAME=risen MASTER_PORT=2345 MASTER_DIRECTORY=/home/greenplum/gpdata/master DATABASE_NAME=gpdb # ---- 初始化(-s xx代表備用主節點是xx機器 單機無需配置) gpinitsystem -c gpinitsystem_config -h seg_hosts_file # ----設置節點伺服器(單機版就是master節點) cat <<EOF >> /home/greenplum/seg_hosts_file risen EOF # ----編輯gp初始化文件 cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/greenplum/gpinitsystem_config vim /home/greenplum/gpinitsystem_config # 以下為配置文件內容 declare -a DATA_DIRECTORY=(/home/greenplum/gpdata/gpnode1 /home/greenplum/gpdata/gpnode2) MASTER_HOSTNAME=risen MASTER_PORT=2345 MASTER_DIRECTORY=/home/greenplum/gpdata/master DATABASE_NAME=gpdb # ---- 初始化(-s xx代表備用主節點是xx機器 單機無需配置) gpinitsystem -c gpinitsystem_config -h seg_hosts_file
10.初始化,輸入Y繼續...
成功
11.使用設置
# psql登錄修改密碼 psql -p 2345 # 修改資料庫密碼 alter role gpadmin with password 'xxxxxx'; # 遠程連接配置 vim /home/greenplum/gpdata/master/gpseg-1/pg_hba.conf # 添加: host all gpadmin 0.0.0.0/0 md5 # 重新載入配置文件 gpstop -u
下麵截圖中echo是我寫腳本語言,不用
重新載入配置文件報錯
:-gpstop failed. (Reason='[Errno 2] No such file or directory: '/home/greenplum/gpdata/master/postgrsql # 解決 export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1
12.其他命令:
gpstart #正常啟動 gpstop #正常關閉 gpstop -M fast #快速關閉 gpstop –r #重啟
13.附上腳本
#!/bin/bash IPADDR='192.168.209.21' HOSTNAME=risen PKGDIR=/home/greenplum #修改配置 HOSTDIR=/etc/hosts echo -e "\033[32m 修改主機名映射IP...\033[0m" > HOSTDIR echo "$IPADDR $HOSTNAME" >> $HOSTDIR #修改配置 HOSTNAMEDIR=/etc/hostname if [ $? -eq 0 ];then echo -e "\033[32m 修改主機名映射IP...\033[0m" > HOSTNAMEDIR echo ''$HOSTNAME'' > $HOSTNAMEDIR fi if [ $? -eq 0 ];then systemctl stop firewalld fi SELINUXCON=/etc/selinux/config if [ $? -eq 0 ];then echo -e "\033[32m 修改SELINUX...\033[0m" sed -i "s/SELINUX=\S*/SELINUX=disabled/" /etc/selinux/config fi if [ $? -eq 0 ];then echo -e "\033[32m 添加組及用戶...\033[0m" groupadd gpadmin useradd -r -m -g gpadmin gpadmin echo "123456" | passwd --stdin gpadmin echo "RemoveIPC=no" >> /etc/systemd/logind.conf service systemd-logind restart fi if [ $? -eq 0 ];then echo -e "\033[32m 安裝...\033[0m" rpm -Uvh greenplum-db-5.17.0-rhel7-x86_64.rpm fi if [ $? -eq 0 ];then echo -e "\033[32m 賦權...\033[0m" chown -R gpadmin /usr/local/greenplum* chgrp -R gpadmin /usr/local/greenplum* # 使環境變數生效 source /usr/local/greenplum-db/greenplum_path.sh fi if [ $? -eq 0 ];then echo -e "\033[32m 初始化準備...\033[0m" mkdir -p /home/greenplum/gpdata/master mkdir -p /home/greenplum/gpdata/gpnode1 mkdir -p /home/greenplum/gpdata/gpnode2 mkdir -p /home/greenplum/gpdata/gpnode3 mkdir -p /home/greenplum/gpdata/gpnode4 # 修改目錄屬主 chown -R gpadmin:gpadmin /home/greenplum/ chown -R gpadmin:gpadmin /home/greenplum/gpdata chown -R gpadmin:gpadmin /home/greenplum/gpdata/master chown -R gpadmin:gpadmin /home/greenplum/gpdata/gpnode* fi if [ $? -eq 0 ];then echo -e "\033[32m 切換用戶...\033[0m" su gpadmin fi BASHRC=$PKGDIR/.bashrc if [ $? -eq 0 ];then echo -e "\033[32m 環境變數配置...\033[0m" > BASHRC echo 'source /usr/local/greenplum-db/greenplum_path.sh export PGPORT=2345 export PGUSER=gpadmin export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1 export PGDATABASE=gpdb' > $BASHRC fi if [ $? -eq 0 ];then source /home/greenplum/.bashrc fi HOSTFILEEXKEYS=$PKGDIR/hostfile_exkeys if [ $? -eq 0 ];then echo -e "\033[32m 環境變數配置...\033[0m" > HOSTFILEEXKEYS echo 'risen' > $HOSTFILEEXKEYS fi if [ $? -eq 0 ];then echo -e "\033[32m ssh許可權互通設置...\033[0m" gpssh-exkeys -f /home/greenplum/hostfile_exkeys fi SEGHOSTSFILE=$PKGDIR/seg_hosts_file if [ $? -eq 0 ];then echo -e "\033[32m 環境變數配置...\033[0m" > SEGHOSTSFILE echo 'risen' > $SEGHOSTSFILE fi if [ $? -eq 0 ];then # ----編輯gp初始化文件 cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/greenplum/gpinitsystem_config fi GPINITSYSTEMCONFIG=/home/greenplum/gpinitsystem_config if [ $? -eq 0 ];then echo -e "\033[32m 修改gpinitsystem_config...\033[0m" sed -i 's/\(DATA_DIRECTORY=\).*/\1(\/home\/greenplum\/gpdata\/gpnode1 \/home\/greenplum\/gpdata\/gpnode2)/' $GPINITSYSTEMCONFIG sed -i "s/MASTER_HOSTNAME=.*/MASTER_HOSTNAME=risen/" $GPINITSYSTEMCONFIG sed -i "s/MASTER_PORT=.*/MASTER_PORT=2345/" $GPINITSYSTEMCONFIG sed -i "s/#DATABASE_NAME=.*/DATABASE_NAME=gpdb/" $GPINITSYSTEMCONFIG fi if [ $? -eq 0 ];then # ---- 初始化(-s xx代表備用主節點是xx機器 單機無需配置) /home/greenplum/gpinitsystem -c gpinitsystem_config -h seg_hosts_file fi ############################################################# # 這一塊暫時沒找到執行自動化的工具,需要進入資料庫,修改密碼 # psql登錄修改密碼 psql -p 2345 # 修改資料庫密碼 alter role gpadmin with password 'xxxxxx'; # 修改完成之後使用\q退出 ############################################################# GPHBADIR=/home/greenplum/gpdata/master/gpseg-1/pg_hba.conf if [ $? -eq 0 ];then echo -e "\033[32m 正在修改pg_hba.conf配置....\033[0m" > GPHBADIR echo 'host all gpadmin 0.0.0.0/0 md5' >> $GPHBADIR fi if [ $? -eq 0 ];then # 重新載入配置文件 gpstop -u fi
備註:文檔參考https://blog.csdn.net/yuanzhengme/article/details/120037965