Greenplum6单机安装攻略

title: Greenplum6单机安装攻略
date: 2019-07-18 11:10:27
categories: Greenplum

本文记录了GP安装的艰辛历程,本文重点记录了单机安装的流(cai)程(keng),多机集群的安装方法是类似的,使用不同的配置就好。踩坑无数,尽量严格按照下面顺序安装。

1 目录规划

这里有个技巧,可以用端口号命名文件夹,隔离不同的集群,例如后面你还可以用3500装另一个集群

源码目录:/home/mingjie.gmj/projects/gpdb
gp安装配置文件:/home/mingjie.gmj/gpconfigs/hostfile_gpinitsystem
gp安装配置文件:/home/mingjie.gmj/gpconfigs/gpinitsystem_config
master数据目录:/home/mingjie.gmj/databases/data/gpdata3400/master
segments数据目录:/home/mingjie.gmj/databases/data/gpdata3400/segments

2 系统参数

sudo vi /etc/sysctl.conf

kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 500 2048000 200 40960
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_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
vm.swappiness = 10
vm.zone_reclaim_mode = 0
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
vm.dirty_background_ratio = 0
vm.dirty_ratio = 0
vm.dirty_background_bytes = 1610612736
vm.dirty_bytes = 4294967296

sudo vi /etc/security/limits.conf

* soft nofile 524288
* hard nofile 524288
* soft nproc 131072
* hard nproc 131072

sudo vi /etc/ld.so.conf

/usr/local/lib

避免安装报错

echo "RemoveIPC=no" >> /etc/systemd/logind.conf
service systemd-logind restart

 

3 软件安装

下载源码

git clone https://github.com/greenplum-db/gpdb.git 6X_STABLE

# 安装依赖包
./README.CentOS.bash

cmake

装完了记得加PATH

wget -S https://github.com/Kitware/CMake/releases/download/v3.15.0-rc4/cmake-3.15.0-rc4.tar.gz
tar -xzvf cmake-3.15.0-rc4.tar.gz
./configure --prefix=/home/mingjie.gmj/bin/cmake315
make -sj32
make install

orca

cd depends/
./configure --prefix=/home/mingjie.gmj/bin/orca
make -sj32
make install_local

编译源码

LD_LIBRARY_PATH=/home/mingjie.gmj/bin/orca/lib ./configure --prefix=/home/mingjie.gmj/databases/gpsql3400 --with-pgport=3400 --with-perl --with-python --with-libxml --with-gssapi --with-includes=/home/mingjie.gmj/bin/orca/include --with-libraries=/home/mingjie.gmj/bin/orca/lib

 

3 数据库初始化

目录配置

mkdir -p /home/mingjie.gmj/databases/data/gpdata3400/master
mkdir -p /home/mingjie.gmj/databases/data/gpdata3400/segments
mkdir -p /home/mingjie.gmj/gpconfigs

*环境变量配置*

配置后,可以不用gp提供的greenplum_path.sh

配置后一定一定执行sudo ldconfig

export GPPORT=3400
export GP_DIR_PRE=/home/mingjie.gmj/databases/data
export GPHOME=$GP_DIR_PRE/gpsql$GPPORT
export GPDATA=$GP_DIR_PRE/data/gpdata$GPPORT
#export PYTHONHOME=$GPHOME/ext/python:$PYTHONHOME
export PYTHONPATH=$GPHOME/lib/python:$PYTHONPATH
export LD_LIBRARY_PATH=$GPHOME/lib:$HOME/bin/orca/lib
export PATH=$HOME/bin/cmake315/bin:$GPHOME/bin:$PATH

创建安装配置文件,记得提前配/etc/host文件,sdw1,2,3都指向127.0.0.1

cat >> hostfile_gpinitsystem << EOF
sdw1
sdw2
sdw3
EOF

cat >> gpinitsystem_config << EOF
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=3410
declare -a DATA_DIRECTORY=(/home/mingjie.gmj/databases/data/gpdata3400/segments /home/mingjie.gmj/databases/data/gpdata3400/segments /home/mingjie.gmj/databases/data/gpdata3400/segments)
MASTER_HOSTNAME=iZbp1d4tisi44j6vxze02fZ
MASTER_DIRECTORY=/home/mingjie.gmj/databases/data/gpdata3400/master
MASTER_PORT=3400
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE

#MIRROR_PORT_BASE=3420
#declare -a MIRROR_DATA_DIRECTORY=(/home/mingjie.gmj/databases/data/gpdata3400/mirrors /home/mingjie.gmj/databases/data/gpdata3400/mirrors /home/mingjie.gmj/databases/data/gpdata3400/mirrors)
EOF

初始化数据库

gpinitsystem -c gpinitsystem_config -h hostfile_gpinitsystem

安装结束!

 

4 验证

进程存在

$ ps ufx
/fdisk1/gpsql3400/bin/postgres -D /home/mingjie.gmj/databases/data/gpdata3400/master/gpseg-1 -p 3400 -E
\_ postgres: 3400, master logger process
\_ postgres: 3400, checkpointer process
\_ postgres: 3400, writer process
\_ postgres: 3400, wal writer process
\_ postgres: 3400, stats collector process
\_ postgres: 3400, bgworker: ftsprobe process
\_ postgres: 3400, bgworker: sweeper process
/fdisk1/gpsql3400/bin/postgres -D /home/mingjie.gmj/databases/data/gpdata3400/segments/gpseg2 -p 3412
\_ postgres: 3412, logger process
\_ postgres: 3412, checkpointer process
\_ postgres: 3412, writer process
\_ postgres: 3412, wal writer process
\_ postgres: 3412, stats collector process
\_ postgres: 3412, bgworker: sweeper process
/fdisk1/gpsql3400/bin/postgres -D /home/mingjie.gmj/databases/data/gpdata3400/segments/gpseg1 -p 3411
\_ postgres: 3411, logger process
\_ postgres: 3411, checkpointer process
\_ postgres: 3411, writer process
\_ postgres: 3411, wal writer process
\_ postgres: 3411, stats collector process
\_ postgres: 3411, bgworker: sweeper process
/fdisk1/gpsql3400/bin/postgres -D /home/mingjie.gmj/databases/data/gpdata3400/segments/gpseg0 -p 3410
\_ postgres: 3410, logger process
\_ postgres: 3410, checkpointer process
\_ postgres: 3410, writer process
\_ postgres: 3410, wal writer process
\_ postgres: 3410, stats collector process
\_ postgres: 3410, bgworker: sweeper process

psql连接正常

$ psql -p 3400 postgres
psql (9.4.20)
Type "help" for help.

postgres=# select * from gp_segment_configuration ;
dbid | content | role | preferred_role | mode | status | port |       hostname         |         address         |                           datadir

------+---------+------+----------------+------+--------+------+-------------------------+-------------------------+--------------------------------------------------------
-----
   1 |     -1 | p   | p             | n   | u     | 3400 | iZbp1d4tisi44j6vxze02fZ | iZbp1d4tisi44j6vxze02fZ | /home/mingjie.gmj/databases/data/gpdata3400/master/gpse
g-1
   2 |       0 | p   | p             | n   | u     | 3410 | iZbp1d4tisi44j6vxze02fZ | sdw1                   | /home/mingjie.gmj/databases/data/gpdata3400/segments/gp
seg0
   3 |       1 | p   | p             | n   | u     | 3411 | iZbp1d4tisi44j6vxze02fZ | sdw2                   | /home/mingjie.gmj/databases/data/gpdata3400/segments/gp
seg1
   4 |       2 | p   | p             | n   | u     | 3412 | iZbp1d4tisi44j6vxze02fZ | sdw3                   | /home/mingjie.gmj/databases/data/gpdata3400/segments/gp
seg2
(4 rows)

 

5 总结

  • 单机单用户是完全可以安装的

  • 过程中尽量清空PG的环境变量,避免未知错误

  • gpAdminLogs中提供了详细的错误输出,兵来将挡:)

上一篇:攻击更多更厉害 美国将提高大银行网络安全标准


下一篇:IOS 粒子发射器,雪花落下、创建火焰、河流、蒸汽的动画效果源代码