給公司運維寫的部署文檔,初學者也能夠看如下,本身嘗試在虛擬機上搭一下。html
***注:本文的"例如"都不能夠直接複製使用,須要結合具體環境自行作出調整***node
內存在不考慮其餘服務共存的狀況下,至少64GB,推薦128GB
網口和網線至少10Gbps,不然數據庫性能會有極大的性能影響,推薦七類網線
磁盤格式必須爲XFS,不然數據庫性能會有極大的性能影響
檢查方法:linux
[root@localhost ~]# df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 xfs 000 000 0% / .....
系統版本必須爲centos6.5 ALL以上,推薦centos6.9,原則:全部服務器系統內核版本一致便可web
[root@localhost ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@localhost ~]# uname -a Linux localhost.localdomain 2.6.32-696.13.2.el6.x86_64 ...
*如下操做在全部要部署gp的主機上以root執行數據庫
設置hostname,設置IP,生成hosts文件
例如:centos
[root@localhost ~]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=mdw [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-em1 DEVICE=em1 HWADDR=00:00:00:00:00:00 Type=Ethernet UUID=1234abcd-56ef-78gh-90ij-1234klmn ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=10.0.0.2 NETMASK=255.255.255.0 GATEWAY=10.0.0.1 DNS1=10.0.0.1 echo ' #Greenplum 10.0.0.2 mdw gp gp.sinoaudit.cn 10.0.0.3 sdw1 10.0.0.4 sdw2 ' >> /etc/hosts
禁用selinuxbash
sed -i 's/^SELINUX.*/SELINUX=disabled/g' /etc/selinux/config setenforce 0
關閉防火牆服務器
service iptables stop
chkconfig iptables off
設置時區&時鐘同步cookie
\cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtim sed -i 's/^server/#&/g' /etc/ntp.conf vi /etc/ntp.conf 在server下方添加 server 10.254.17.253 prefer server 10.254.96.101 重啓ntp service ntpd restart chkconfig nptd on 使用date命令檢查每一個服務器上的時間是否一致 clock -w
修改內核參數運維
echo ' 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.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 = 10000 65535 net.core.netdev_max_backlog = 10000 net.core.rmem_max = 2097152 net.core.wmem_max = 2097152 vm.overcommit_memory = 2 ' > /etc/sysctl.conf sysctl -p
修改用戶限制
echo ' gpadmin soft nofile 65536 gpadmin hard nofile 65536 gpadmin soft nproc 131072 gpadmin hard nproc 131072 ' >> /etc/security/limits.conf echo ' gpadmin soft nproc 131072 gpadmin hard nproc 131072 ' >> /etc/security/limits.d/90-nproc.conf
若是是xfs文件系統執行下邊操做
vi /etc/fstab
修改數據目錄所在掛載點文件系統參數選項爲 rw,nodev,noatime,nobarrier,inode64
例如:
/dev/sda / xfs nodev,noatime,nobarrier,inode64 0 0
修改預讀取塊大小
/sbin/blockdev --setra 16384 /dev/sda
修改IO調度
echo deadline > /sys/block/sda/queue/scheduler
配置grub
vi /boot/grub/grub.conf
在數據目錄所在掛載點以後追加選項 elevator=deadline transparent_hugepage=never
例如
kernel /vmlinuz-2.6.18-274.3.1.el5 ro root=LABEL=/ elevator=deadline crashkernel=128M@16M quiet console=tty1 console=ttyS1,115200 panic=30 transparent_hugepage=never initrd /initrd-2.6.18-274.3.1.el5.img
添加用戶
groupadd -g 520 gpadmin useradd -u 520 -g gpadmin gpadmin passwd gpadmin # 密碼必須統一
添加數據目錄
mkdir -p /data/gpdata chown -R gpadmin:gpadmin /home/gpadmin chown -R gpadmin:gpadmin /data/gpdata
重啓系統
reboot
驗證
echo 'mdw sdw1 sdw2' > hostlist gpcheck -f hostlist -m mdw
以沒有報錯爲最佳,出現什麼錯誤就調什麼
安裝主節點
在master節點所在主機以root執行
上傳安裝包
unzip greenplum-db-5.3.0-rhel6-x86_64.zip ./greenplum-db-5.3.0-rhel6-x86_64.bin # q yes enter yes yes
安裝其餘節點
source /usr/local/greenplum-db/greenplum_path.sh mkdir /home/gpadmin/gpconfigs cd /home/gpadmin/gpconfigs echo 'mdw sdw1 sdw2' > hostlist echo 'sdw1 sdw2' > seglist gpssh-exkeys -f hostlist # 須要輸入密碼的地方輸入密碼 gpssh -f hostlist -e date # 驗證免密登錄是否成功 gpseginstall -f hostlist -u gpadmin -p gpadmin #這個密碼是系統密碼
等待完成
修改全部者
如下四條命令在全部主機上以root執行
chown -R gpadmin:gpadmin /home/gpadmin chown -R gpadmin:gpadmin /data/gpdata chown -R gpadmin:gpadmin /usr/local/greenplum* echo ' source /usr/local/greenplum-db/greenplum_path.sh '>> /home/gpadmin/.bash_profile
在主節點以gpadmin登錄,如su - gpadmin
cd;cd gpconfig gpssh-exkeys -f hostlist gpssh -f hostlist -e date gpssh -f hostlist -e 'mkdir -p /data/gpdata/master' gpssh -f hostlist -e 'mkdir -p /data/gpdata/primary' gpssh -f hostlist -e 'mkdir -p /data/gpdata/mirror'
生成初始化配置文件
cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config . vi gpinitsystem_config
主要有如下幾個地方可能須要修改(禁止複製)
declare -a DATA_DIRECTORY=(/data/gpdata/primary /data/gpdata/primary) # 這裏一個機器初始化幾個primary就寫幾個 MASTER_HOSTNAME=mdw #改爲本身的主節點的主機名hostname MASTER_DIRECTORY=/data/gpdata/master 若是須要作高可用就解註釋MIRROR的選項 MIRROR_PORT_BASE=50000 REPLICATION_PORT_BASE=41000 MIRROR_REPLICATION_PORT_BASE=51000 declare -a MIRROR_DATA_DIRECTORY=(/data/gpdata/mirror /data/gpdata/mirror) # 這裏要和primary目錄個數一致
執行初始化
gpinitsystem -c gpinitsystem_config -h seglist -n zh_CN.utf8 # -n選項設置數據庫字符集,默認en_US.utf8,例子是中文,推薦中文,主要是涉及到排序
期間會暫停讓你確認,你看如下初始化配置是否正常後輸入Y便可
echo ' export MASTER_DATA_DIRECTORY=/data/gp/master/gpseg-1 export PGPORT=5432 ' >> ~/.bash_profile source ~/.bash_profile
查看數據庫狀態
gpstate -s
簡單優化
gpconfig -c max_connections -v 2500 -m 500 gpconfig -c max_prepared_transactions -v 1000 gpconfig -c gp_vmem_protect_limit -v 65536 gpconfig -c max_statement_mem -v 16GB gpconfig -c statement_mem -v 1GB echo ' host all all 0.0.0.0/0 md5' >> $MASTER_DATA_DIRECTORY/pg_hba.conf gpstop -a -r
greenplum command center的安裝參考http://www.cnblogs.com/chenminklutz/p/9020050.html
附暴力卸載(新手嚴禁在非虛擬機環境使用)
# 卸載(暴力卸載) kill -9 `ps -elf | grep gpadmin | grep -v grep | awk '{print $4}'` rm -f /tmp/.s.PGSQL* rm -rf /data/gpdata/master/* rm -rf /data/gpdata/primary/* rm -rf /data/gpdata/mirror/* rm -rf /usr/local/greenplum-cc-web/instances/* rm -rf /data/gp/greenplum-cc-web* rm -rf /usr/local/greenplum* rm -rf /root/.ssh/* rm -rf /home/gpadmin/.ssh/*