os: centos 7.4
gp: gpdb-5.7.0
greenplum 简称gp,是对 postgresql 做了很多变更,是典型的mpp架构。
ip 规划如下:
192.168.0.99 mas
192.168.0.100 sla
192.168.0.101 seg1
192.168.0.102 seg2
参考<
github 上 社区版 greenplum 页面
https://github.com/greenplum-db/gpdb/releases
https://github.com/greenplum-db/gpdb/tree/5.7.0
gporca是 greenplum 新一代的优化器,在性能上有很大提升
legacy是早期针对单节点 greenplum 而构建的,主要应用于OLTP场景,greenplum在不安装orca的情况下使用的是legacy优化器。
为什么要有两个优化器,其实都是有历史原因的,现在的greenplum使用MPP,主要应用场景变为OLAP场景,legacy对此虽然进行了修改,但是从架构设计上,使得其维护和添加新的功能越来越困难,所以有了GPORCA优化器。
greenplum 5.7 的 gporca 安装可以参考如下:
https://github.com/greenplum-db/gpdb/tree/5.7.0#build-the-optimizer
gporca 需要在每个节点都安装,后面使用批量方式安装 greenplum 并不会安装 gporca.
1、自动安装 gporca(所有节点)
Automatically with Conan dependency manager
参考
https://github.com/greenplum-db/gpdb/tree/5.7.0#automatically-with-conan-dependency-manager
# su - gpadmin
$ cd /tmp
$ unzip ./gpdb-5.7.0.zip
$ cd gpdb-5.7.0/depends
$ ./configure
执行 configure 时会提示如下错误
configure: error: CMake 3.1 or later is needed to build ORCA
configure: error: Library xerces-c 3.1.x or later is required to build ORCA
需要手动安装一些依赖
安装 cmake3 (所有节点)
# yum install -y cmake3
# which cmake cmake3
/usr/bin/cmake
/usr/bin/cmake3
# mv /usr/bin/cmake /usr/bin/cmake.bak;
ln -s /usr/bin/cmake3 /usr/bin/cmake;
ls -l /usr/bin/cmake;
lrwxrwxrwx 1 root root 15 Aug 30 08:33 /usr/bin/cmake -> /usr/bin/cmake3
安装gp-xerces (所有节点)
参考
https://github.com/greenplum-db/gp-xerces
https://github.com/greenplum-db/gp-xerces.git
# su - gpadmin
$ cd /tmp
$ git clone https://github.com/greenplum-db/gp-xerces.git
$ cd gp-xerces
$ mkdir build
$ cd build
$ ../configure
$ make
$ exit
# cd /tmp/gp-xerces/build
# make install
再次 gporca (所有节点)
# su - gpadmin
$ echo 'source scl_source enable devtoolset-6' >> ~/.bashrc
$ cd /tmp
$ rz gpdb-5.7.0.zip
$ unzip ./gpdb-5.7.0.zip
$ cd gpdb-5.7.0/depends
$ ./configure
$ make
===================================================================
Orca can now be installed on the local system using "make install"
and be used as any normal system library
If you'd rather compile GPDB using ORCA in it's current location and then
install ORCA into the gpdb installation location then first run the top
level configure as follows:
LD_LIBRARY_PATH=/tmp/gpdb-5.7.0/depends/build/lib ./configure \
--with-libraries=/tmp/gpdb-5.7.0/depends/build/lib \
--with-includes=/tmp/gpdb-5.7.0/depends/build/include
Then run "make".
Then run "LD_LIBRARY_PATH=/tmp/gpdb-5.7.0/depends/build/lib make install"
These steps should work on both MacOS and Linux
$ exit
# cd /tmp/gpdb-5.7.0/depends
# make install_local
===================================================================
Orca can now be installed on the local system using "make install"
and be used as any normal system library
If you'd rather compile GPDB using ORCA in it's current location and then
install ORCA into the gpdb installation location then first run the top
level configure as follows:
LD_LIBRARY_PATH=/tmp/gpdb-5.7.0/depends/build/lib ./configure \
--with-libraries=/tmp/gpdb-5.7.0/depends/build/lib \
--with-includes=/tmp/gpdb-5.7.0/depends/build/include
Then run "make".
Then run "LD_LIBRARY_PATH=/tmp/gpdb-5.7.0/depends/build/lib make install"
These steps should work on both MacOS and Linux
/bin/mkdir -p /usr/local
cp -R build/* /usr/local
最后两条命令就是拷贝到系统路径里
# /bin/mkdir -p /usr/local ;
\cp -Rf build/* /usr/local ;
重装gporca前清空
# rm -rf /usr/local/include/naucrates
rm -rf /usr/local/include/gpdbcost
rm -rf /usr/local/include/gpopt
rm -rf /usr/local/include/gpos
rm -rf /usr/local/lib/libnaucrates.so*
rm -rf /usr/local/lib/libgpdbcost.so*
rm -rf /usr/local/lib/libgpopt.so*
rm -rf /usr/local/lib/libgpos.so*
2、手动安装 gporca (所有节点)
参考
https://github.com/greenplum-db/gpdb/tree/5.7.0#manually
安装 cmake3 (所有节点),如果已经 yum install cmake3,则跳过这一步
参考
https://cmake.org/download/
# yum install -y cmake3
# which cmake cmake3
/usr/bin/cmake
/usr/bin/cmake3
# mv /usr/bin/cmake /usr/bin/cmake.bak
# ln -s /usr/bin/cmake3 /usr/bin/cmake
# ls -l /usr/bin/cmake
lrwxrwxrwx 1 root root 15 Aug 30 08:33 /usr/bin/cmake -> /usr/bin/cmake3
安装gp-xerces (所有节点)
参考
https://github.com/greenplum-db/gp-xerces
https://github.com/greenplum-db/gp-xerces.git
# su - gpadmin
$ git clone https://github.com/greenplum-db/gp-xerces.git
$ cd gp-xerces
$ mkdir build
$ cd build
$ ../configure
$ make
$ exit
# cd /home/gpadmin/gp-xerces/build
# make install
安装re2c (所有节点)
参考
http://re2c.org/install/install.html
https://github.com/skvadrik/re2c
https://github.com/skvadrik/re2c.git
# cd /root
# git clone https://github.com/skvadrik/re2c.git
# cd ./re2c/re2c
# ./autogen.sh
# ./configure
# make
# make install
安装ninja (所有节点)
参考
https://ninja-build.org/
https://github.com/ninja-build/ninja
https://github.com/ninja-build/ninja.git
# cd /root
# git clone https://github.com/ninja-build/ninja.git
# cd ninja
# ./configure.py --bootstrap
# ln -s /root/ninja/ninja /usr/bin/ninja
安装 ORCA (所有节点)
the query optimizer:
# cd /root
# git clone https://github.com/greenplum-db/gporca.git
# cd gporca
# cmake -GNinja -H. -Bbuild
# ninja install -C build
--
--
-- Installing: /usr/local/include/gpopt/version.h
待安装完成后,进入/gporca/build目录,执行ctest命令进行检查,确保100% tests passed
# cd /root/gporca/build/
# /root/cmake/bin/ctest
100% tests passed, 0 tests failed out of 157
Total Test time (real) = 194.05 sec
后来在 gpdb configure 的时候报了如下错误
checking Checking ORCA version... configure: error: Your ORCA version is expected to be 2.55.XXX
通常情况下这个错误就是 orca的版本太低,获取更高版本就不会再报错.
Using conan dependency manager
参考:
https://github.com/greenplum-db/gpdb/tree/5.7.0#build-the-database
# su - gpadmin
$ cd /tmp
$ unzip ./gpdb-5.7.0.zip
finishing deferred symbolic links:
gpdb-5.7.0/concourse/tasks/compile_gpdb_open_source.yml -> compile_gpdb_open_source_centos.yml
$ cd /tmp/gpdb-5.7.0
$ ./configure --prefix=/usr/local/greenplum-db --with-perl --with-python --with-libxml --with-gssapi \
--enable-orca --enable-mapreduce --enable-gpperfmon --enable-pxf \
--with-includes=/usr/local/include/ --with-libraries=/usr/local/lib/
如果没有编译gporca优化器,则需要添加 --disable-orca 参数,如下
$ --disable-orca
选项可以参考 <
中间有如下报错
./configure: line 11922: #include: command not found
需要多次make时,可以执行autoreconf
$ cd /tmp/gpdb-5.7.0
$ autoreconf -ivf
$ make distclean
make , make install
$ make -j4
$ make install
$ cd /usr/local/greenplum-db
$ ls -l
total 24
drwxrwxr-x 7 gpadmin gpadmin 4096 Apr 17 13:54 bin
drwxrwxr-x 3 gpadmin gpadmin 24 Apr 17 13:54 doc
drwxrwxr-x 3 gpadmin gpadmin 22 Apr 17 13:54 docs
drwxrwxr-x 2 gpadmin gpadmin 25 Apr 17 13:54 etc
-rw-rw-r-- 1 gpadmin gpadmin 698 Apr 17 13:54 greenplum_path.sh
drwxrwxr-x 4 gpadmin gpadmin 4096 Apr 17 13:54 include
drwxrwxr-x 5 gpadmin gpadmin 4096 Apr 17 13:54 lib
drwxrwxr-x 2 gpadmin gpadmin 4096 Apr 17 13:54 sbin
drwxrwxr-x 4 gpadmin gpadmin 41 Apr 17 13:54 share
查看 /usr/local/greenplum-db/greenplum_path.sh
$ cat /usr/local/greenplum-db/greenplum_path.sh
GPHOME=/usr/local/greenplum-db
# Replace with symlink path if it is present and correct
if [ -h ${GPHOME}/../greenplum-db ]; then
GPHOME_BY_SYMLINK=`(cd ${GPHOME}/../greenplum-db/ && pwd -P)`
if [ x"${GPHOME_BY_SYMLINK}" = x"${GPHOME}" ]; then
GPHOME=`(cd ${GPHOME}/../greenplum-db/ && pwd -L)`/.
fi
unset GPHOME_BY_SYMLINK
fi
#setup PYTHONHOME
if [ -x $GPHOME/ext/python/bin/python ]; then
PYTHONHOME="$GPHOME/ext/python"
fi
PYTHONPATH=$GPHOME/lib/python
PATH=$GPHOME/bin:$PATH
LD_LIBRARY_PATH=$GPHOME/lib:${LD_LIBRARY_PATH-}
export LD_LIBRARY_PATH
OPENSSL_CONF=$GPHOME/etc/openssl.cnf
export GPHOME
export PATH
export PYTHONPATH
export PYTHONHOME
export OPENSSL_CONF
设置用户环境变量
$ vi /home/gpadmin/.bashrc
source /usr/local/greenplum-db/greenplum_path.sh
$ vi /home/gpadmin/.bash_profile
source /usr/local/greenplum-db/greenplum_path.sh
设置完后记得 source 一下使其立即生效。
$ source /home/gpadmin/.bashrc
$ source /home/gpadmin/.bash_profile
$ echo $PATH
至此 mas上的 greenplum 已经安装完毕。
至此,仅有一个节点安装了 greenplum 软件,现在需要在第一个节点将 greenplum 软件复制到剩余所有节点,最终的结果是所有节点上都必须安装 greenplum 软件.
也可以在所有节点上一次安装 gporca,编译 greenplum.
在 mas 上 touch all_host all_segment
# su - gpadmin
$ cd $GPHOME
$ vi all_host
mas
sla
seg1
seg2
$ vi all_segment
seg1
seg2
在mas上建立节点信任(os设置时已经创建的,会快速显示ok)
$ $GPHOME/bin/gpssh-exkeys -f $GPHOME/all_host
[STEP 1 of 5] create local ID and authorize on local host
... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped
[STEP 2 of 5] keyscan all hosts and update known_hosts file
[STEP 3 of 5] authorize current user on remote hosts
... send to sla
... send to seg1
... send to seg2
[STEP 4 of 5] determine common authentication file content
[STEP 5 of 5] copy authentication files to all remote hosts
... finished key exchange with sla
... finished key exchange with seg1
... finished key exchange with seg2
[INFO] completed successfully
需要 配置下 root 的信任,因为greenplum安装在 /usr/local下,后面需要使用root权限复制软件
# source /usr/local/greenplum-db/greenplum_path.sh
# $GPHOME/bin/gpssh-exkeys -f $GPHOME/all_host
在mas上操作批量复制到其余节点
(如果在每个节点都进行了 orca 和 greenplum 软件的编译安装,可以跳过这一步)
这里由于会在 /usr/local 下生成 greenplum-db.tar 文件,gpadmin执行会报错,需要用root权限.
$ $GPHOME/bin/gpseginstall -f $GPHOME/all_segment -u gpadmin -p rootroot
20190830:14:24:21:014886 gpseginstall:mas:gpadmin-[INFO]:-Installation Info:
link_name None
binary_path /usr/local/greenplum-db
binary_dir_location /usr/local
binary_dir_name greenplum-db
20190830:14:24:21:014886 gpseginstall:mas:gpadmin-[INFO]:-check cluster password access
20190830:14:24:22:014886 gpseginstall:mas:gpadmin-[INFO]:-de-duplicate hostnames
20190830:14:24:22:014886 gpseginstall:mas:gpadmin-[INFO]:-master hostname: mas
20190830:14:24:22:014886 gpseginstall:mas:gpadmin-[INFO]:-rm -f /usr/local/greenplum-db.tar; rm -f /usr/local/greenplum-db.tar.gz
20190830:14:24:23:014886 gpseginstall:mas:gpadmin-[INFO]:-cd /usr/local; tar cf greenplum-db.tar greenplum-db
20190830:14:24:23:014886 gpseginstall:mas:gpadmin-[ERROR]:-Failed to run command: md5sum /usr/local/greenplum-db.tar
20190830:14:24:23:014886 gpseginstall:mas:gpadmin-[ERROR]:-md5sum: /usr/local/greenplum-db.tar: No such file or directory
20190830:14:24:23:014886 gpseginstall:mas:gpadmin-[CRITICAL]:-early exit from gpseginstall
使用 root 批量安装剩余节点的 greenplum 软件
all_segment 应该包含余下所有节点(如果master节点有slave节点的话,也应该包含,后面再在 all_segment 移除slave ,确保只有 segment 节点)
# source /usr/local/greenplum-db/greenplum_path.sh
# $GPHOME/bin/gpseginstall -f $GPHOME/all_segment -u gpadmin -p rootroot
20190830:14:44:29:015352 gpseginstall:mas:root-[INFO]:-Installation Info:
link_name None
binary_path /usr/local/greenplum-db
binary_dir_location /usr/local
binary_dir_name greenplum-db
20190830:14:44:29:015352 gpseginstall:mas:root-[INFO]:-check cluster password access
20190830:14:44:29:015352 gpseginstall:mas:root-[INFO]:-de-duplicate hostnames
20190830:14:44:30:015352 gpseginstall:mas:root-[INFO]:-master hostname: mas
20190830:14:44:30:015352 gpseginstall:mas:root-[INFO]:-check for user gpadmin on cluster
20190830:14:44:30:015352 gpseginstall:mas:root-[INFO]:-add user gpadmin on master
20190830:14:44:31:015352 gpseginstall:mas:root-[INFO]:-add user gpadmin on cluster
20190830:14:44:31:015352 gpseginstall:mas:root-[INFO]:-chown -R gpadmin:gpadmin /usr/local/greenplum-db
20190830:14:44:31:015352 gpseginstall:mas:root-[INFO]:-rm -f /usr/local/greenplum-db.tar; rm -f /usr/local/greenplum-db.tar.gz
20190830:14:44:31:015352 gpseginstall:mas:root-[INFO]:-cd /usr/local; tar cf greenplum-db.tar greenplum-db
20190830:14:44:31:015352 gpseginstall:mas:root-[INFO]:-gzip /usr/local/greenplum-db.tar
20190830:14:44:34:015352 gpseginstall:mas:root-[INFO]:-remote command: mkdir -p /usr/local
20190830:14:44:34:015352 gpseginstall:mas:root-[INFO]:-remote command: rm -rf /usr/local/greenplum-db
20190830:14:44:34:015352 gpseginstall:mas:root-[INFO]:-scp software to remote location
20190830:14:44:36:015352 gpseginstall:mas:root-[INFO]:-remote command: gzip -f -d /usr/local/greenplum-db.tar.gz
20190830:14:44:37:015352 gpseginstall:mas:root-[INFO]:-md5 check on remote location
20190830:14:44:37:015352 gpseginstall:mas:root-[INFO]:-remote command: cd /usr/local; tar xf greenplum-db.tar
20190830:14:44:37:015352 gpseginstall:mas:root-[INFO]:-remote command: rm -f /usr/local/greenplum-db.tar
20190830:14:44:38:015352 gpseginstall:mas:root-[INFO]:-remote command: chown -R gpadmin:gpadmin /usr/local/greenplum-db
20190830:14:44:38:015352 gpseginstall:mas:root-[INFO]:-rm -f /usr/local/greenplum-db.tar.gz
20190830:14:44:38:015352 gpseginstall:mas:root-[INFO]:-Changing system passwords ...
20190830:14:44:39:015352 gpseginstall:mas:root-[INFO]:-exchange ssh keys for user root
20190830:14:44:42:015352 gpseginstall:mas:root-[INFO]:-exchange ssh keys for user gpadmin
20190830:14:44:45:015352 gpseginstall:mas:root-[INFO]:-/usr/local/greenplum-db/sbin/gpfixuserlimts -f /etc/security/limits.conf -u gpadmin
20190830:14:44:45:015352 gpseginstall:mas:root-[INFO]:-remote command: . /usr/local/greenplum-db/greenplum_path.sh; /usr/local/greenplum-db/sbin/gpfixuserlimts -f /etc/security/limits.conf -u gpadmin
20190830:14:44:46:015352 gpseginstall:mas:root-[INFO]:-version string on master: gpssh version 5.0.0 build dev
20190830:14:44:46:015352 gpseginstall:mas:root-[INFO]:-remote command: . /usr/local/greenplum-db/greenplum_path.sh; /usr/local/greenplum-db/bin/gpssh --version
20190830:14:44:47:015352 gpseginstall:mas:root-[INFO]:-SUCCESS -- Requested commands completed
在mas上检查批量安装情况
$ source /usr/local/greenplum-db/greenplum_path.sh
$ $GPHOME/bin/gpssh -f $GPHOME/all_segment -e ls -l $GPHOME
$ $GPHOME/bin/gpssh -f $GPHOME/all_host -e ls -l $GPHOME
在mas、seg1、seg2上分别检查数据目录
$ ls -l / |grep -i u01 ;
ls -l /u01/ ;
在mas、seg1、seg2上分别设置用户环境变量
$ vi /home/gpadmin/.bashrc
source /usr/local/greenplum-db/greenplum_path.sh
$ vi /home/gpadmin/.bash_profile
source /usr/local/greenplum-db/greenplum_path.sh
时间同步,各个节点要和master的时间保持一致
使用ntp和标准时间、内部时间同步
# yum install ntp;
systemctl start ntpd;
systemctl enable ntpd;
或者使用 gpssh 来相互同步时钟
# gpssh -f all_host -v date
# gpssh -f all_host -v ntpd
运行 gpcheck 来检查刚配的所有机器的操作系统情况
# gpcheck -f /usr/local/greenplum-db/all_host
运行 gpcheckperf 来进行硬件性能效验
# gpcheckperf -f /usr/local/greenplum-db/all_host -d /tmp -d /home/gpadmin/ -v -r ds
运行 gpchecknet 来进行网络性能效验
# gpchecknet -f /usr/local/greenplum-db/all_host -d /tmp
# gpchecknet -f /usr/local/greenplum-db/all_host -r N -d /tmp
gp初始化文件
$ cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /usr/local/greenplum-db/
$ chmod 775 ./gpinitsystem_config
$ vi /usr/local/greenplum-db/gpinitsystem_config
$ egrep -v "(^$|^#)" ./gpinitsystem_config
ARRAY_NAME="Greenplum Data Platform"
SEG_PREFIX=gpseg
PORT_BASE=40000
MASTER_HOSTNAME=mas
MASTER_DIRECTORY=/u01/greenplum-data
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=20
ENCODING=UNICODE
MIRROR_PORT_BASE=50000
REPLICATION_PORT_BASE=41000
MIRROR_REPLICATION_PORT_BASE=51000
DATABASE_NAME=peiybdb
MACHINE_LIST_FILE=/usr/local/greenplum-db/all_segment
简单说明下
ARRAY_NAME:设置阵列名称,默认Greenplum Data Platform。
SEG_PREFIX:设置segment的前缀,默认gpseg。
PORT_BASE:设置segment的起始端口,会从此端口往上增加,默认从40000开始。
DATA_DIRECTORY:设置segment primary的数据存储目录,有几个segment节点就需要设置几个数据存储目录。
MASTER_HOSTNAME:设置master的主机名。
MASTER_DIRECTORY:设置master的存储目录。
MASTER_PORT:设置master的端口,默认5432。
TRUSTED_SHELL:设置节点之间的信任方式,默认SSH。
CHECK_POINT_SEGMENTS:预写日志文件(WAL)数量,默认为8,这意味着为主机上的每个Segment或Master实例分配1088MB的WAL空间。
ENCODING=UNICODE:设置初始字符集,默认UNICODE(UTF-8)。
MACHINE_LIST_FILE:仅包含segment主机地址
注意,其中所有需要的目录都是在创建数据存储区域时做好的。
尤其需要注意的是 MACHINE_LIST_FILE,指的是 仅包含segment主机地址
gp初始化工具
$ cd $GPHOME/bin
$ gpinitsystem -c /usr/local/greenplum-db/gpinitsystem_config -s sla
20180417:17:41:25:005291 gpinitsystem:mas:gpadmin-[INFO]:-Checking configuration parameters, please wait...
20180417:17:41:25:005291 gpinitsystem:mas:gpadmin-[INFO]:-Reading Greenplum configuration file /usr/local/greenplum-db/gpinitsystem_config
20180417:17:41:25:005291 gpinitsystem:mas:gpadmin-[INFO]:-Locale has not been set in /usr/local/greenplum-db/gpinitsystem_config, will set to default value
20180417:17:41:25:005291 gpinitsystem:mas:gpadmin-[INFO]:-Locale set to en_US.utf8
20180417:17:41:25:005291 gpinitsystem:mas:gpadmin-[INFO]:-MASTER_MAX_CONNECT not set, will set to default value 250
20180417:17:41:25:005291 gpinitsystem:mas:gpadmin-[INFO]:-Checking configuration parameters, Completed
20180417:17:41:25:005291 gpinitsystem:mas:gpadmin-[INFO]:-Commencing multi-home checks, please wait...
...
20180417:17:41:27:005291 gpinitsystem:mas:gpadmin-[INFO]:-Configuring build for standard array
20180417:17:41:27:005291 gpinitsystem:mas:gpadmin-[INFO]:-Commencing multi-home checks, Completed
20180417:17:41:27:005291 gpinitsystem:mas:gpadmin-[INFO]:-Building primary segment instance array, please wait...
...
20180417:17:41:29:005291 gpinitsystem:mas:gpadmin-[INFO]:-Checking Master host
20180417:17:41:29:005291 gpinitsystem:mas:gpadmin-[INFO]:-Checking new segment hosts, please wait...
...
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Checking new segment hosts, Completed
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Greenplum Database Creation Parameters
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:---------------------------------------
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master Configuration
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:---------------------------------------
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master instance name = test Greenplum Data Platform
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master hostname = mas
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master port = 5432
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master instance dir = /u01/greenplum-data/gpseg-1
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master LOCALE = en_US.utf8
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Greenplum segment prefix = gpseg
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master Database = peiybdb
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master connections = 250
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master buffers = 128000kB
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Segment connections = 750
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Segment buffers = 128000kB
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Checkpoint segments = 8
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Encoding = UNICODE
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Postgres param file = Off
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Initdb to be used = /usr/local/greenplum-db/bin/initdb
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-GP_LIBRARY_PATH is = /usr/local/greenplum-db/lib
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-HEAP_CHECKSUM is = on
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Ulimit check = Passed
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Array host connect type = Single hostname per node
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master IP address [1] = ::1
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master IP address [2] = 10.0.2.7
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master IP address [3] = 192.168.122.1
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master IP address [4] = 192.168.56.101
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master IP address [5] = fe80::a00:27ff:fe6e:8656
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Master IP address [6] = fe80::a00:27ff:fef3:ba27
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Standby Master = Not Configured
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Primary segment # = 1
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Total Database segments = 3
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Trusted shell = ssh
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Number segment hosts = 3
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Mirroring config = OFF
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:----------------------------------------
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-Greenplum Primary Segment Configuration
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:----------------------------------------
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-mas /u01/greenplum-data/gpseg0 40000 2 0
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-seg1 /u01/greenplum-data/gpseg1 40000 3 1
20180417:17:41:39:005291 gpinitsystem:mas:gpadmin-[INFO]:-seg2 /u01/greenplum-data/gpseg2 40000 4 2
Continue with Greenplum creation Yy|Nn (default=N):
> y
20180417:17:41:43:005291 gpinitsystem:mas:gpadmin-[INFO]:-Building the Master instance database, please wait...
20180417:17:41:46:005291 gpinitsystem:mas:gpadmin-[INFO]:-Starting the Master in admin mode
20180417:17:41:51:005291 gpinitsystem:mas:gpadmin-[INFO]:-Commencing parallel build of primary segment instances
20180417:17:41:51:005291 gpinitsystem:mas:gpadmin-[INFO]:-Spawning parallel processes batch [1], please wait...
...
20180417:17:41:51:005291 gpinitsystem:mas:gpadmin-[INFO]:-Waiting for parallel processes batch [1], please wait...
...............................
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:------------------------------------------------
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-Parallel process exit status
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:------------------------------------------------
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-Total processes marked as completed = 3
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-Total processes marked as killed = 0
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-Total processes marked as failed = 0
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:------------------------------------------------
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-Deleting distributed backout files
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-Removing back out file
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-No errors generated from parallel processes
20180417:17:42:23:005291 gpinitsystem:mas:gpadmin-[INFO]:-Restarting the Greenplum instance in production mode
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Starting gpstop with args: -a -l /home/gpadmin/gpAdminLogs -i -m -d /u01/greenplum-data/gpseg-1
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Gathering information and validating the environment...
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Obtaining Segment details from master...
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 5.0.0 build dev'
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-There are 0 connections to the database
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Commencing Master instance shutdown with mode='immediate'
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Master host=mas
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=immediate
20180417:17:42:23:009523 gpstop:mas:gpadmin-[INFO]:-Master segment instance directory=/u01/greenplum-data/gpseg-1
20180417:17:42:24:009523 gpstop:mas:gpadmin-[INFO]:-Attempting forceful termination of any leftover master process
20180417:17:42:24:009523 gpstop:mas:gpadmin-[INFO]:-Terminating processes for segment /u01/greenplum-data/gpseg-1
20180417:17:42:25:009553 gpstart:mas:gpadmin-[INFO]:-Starting gpstart with args: -a -l /home/gpadmin/gpAdminLogs -d /u01/greenplum-data/gpseg-1
20180417:17:42:25:009553 gpstart:mas:gpadmin-[INFO]:-Gathering information and validating the environment...
20180417:17:42:25:009553 gpstart:mas:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 5.0.0 build dev'
20180417:17:42:25:009553 gpstart:mas:gpadmin-[INFO]:-Greenplum Catalog Version: '301705051'
20180417:17:42:25:009553 gpstart:mas:gpadmin-[INFO]:-Starting Master instance in admin mode
20180417:17:42:26:009553 gpstart:mas:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20180417:17:42:26:009553 gpstart:mas:gpadmin-[INFO]:-Obtaining Segment details from master...
20180417:17:42:26:009553 gpstart:mas:gpadmin-[INFO]:-Setting new master era
20180417:17:42:26:009553 gpstart:mas:gpadmin-[INFO]:-Master Started...
20180417:17:42:26:009553 gpstart:mas:gpadmin-[INFO]:-Shutting down master
20180417:17:42:27:009553 gpstart:mas:gpadmin-[INFO]:-Commencing parallel segment instance startup, please wait...
........
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:-Process results...
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:-----------------------------------------------------
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:- Successful segment starts = 3
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:- Failed segment starts = 0
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 0
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:-----------------------------------------------------
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:-Successfully started 3 of 3 segment instances
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:-----------------------------------------------------
20180417:17:42:35:009553 gpstart:mas:gpadmin-[INFO]:-Starting Master instance mas directory /u01/greenplum-data/gpseg-1
20180417:17:42:36:009553 gpstart:mas:gpadmin-[INFO]:-Command pg_ctl reports Master mas instance active
20180417:17:42:36:009553 gpstart:mas:gpadmin-[INFO]:-No standby master configured. skipping...
20180417:17:42:36:009553 gpstart:mas:gpadmin-[INFO]:-Database successfully started
20180417:17:42:36:005291 gpinitsystem:mas:gpadmin-[INFO]:-Completed restart of Greenplum instance in production mode
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-Scanning utility log file for any warning messages
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-Log file scan check passed
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-Greenplum Database instance successfully created
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-------------------------------------------------------
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-To complete the environment configuration, please
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-update gpadmin .bashrc file with the following
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-1. Ensure that the greenplum_path.sh file is sourced
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-2. Add "export MASTER_DATA_DIRECTORY=/u01/greenplum-data/gpseg-1"
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:- to access the Greenplum scripts for this instance:
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:- or, use -d /u01/greenplum-data/gpseg-1 option for the Greenplum scripts
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:- Example gpstate -d /u01/greenplum-data/gpseg-1
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-Script log file = /home/gpadmin/gpAdminLogs/gpinitsystem_20180417.log
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-To remove instance, run gpdeletesystem utility
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-To initialize a Standby Master Segment for this Greenplum instance
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-Review options for gpinitstandby
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-------------------------------------------------------
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-The Master /u01/greenplum-data/gpseg-1/pg_hba.conf post gpinitsystem
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-has been configured to allow all hosts within this new
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-array to intercommunicate. Any hosts external to this
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-new array must be explicitly added to this file
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-Refer to the Greenplum Admin support guide which is
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-located in the /usr/local/greenplum-db/docs directory
20180417:17:42:42:005291 gpinitsystem:mas:gpadmin-[INFO]:-------------------------------------------------------
mas 上增加 greenplum master的数据变量,最终的修改如下:
$ vi /home/gpadmin/.bashrc
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/u01/greenplum-data/gpseg-1
$ vi /home/gpadmin/.bash_profile
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/u01/greenplum-data/gpseg-1
seg1、seg2 作为segment,最终的修改如下:
$ vi /home/gpadmin/.bashrc
source /usr/local/greenplum-db/greenplum_path.sh
$ vi /home/gpadmin/.bash_profile
source /usr/local/greenplum-db/greenplum_path.sh
设置访问权限
$ cd /u01/greenplum-data/gpseg-1
$ ls -l
total 60
drwx------ 6 gpadmin gpadmin 54 Apr 17 17:42 base
drwx------ 2 gpadmin gpadmin 4096 Apr 17 17:42 global
-r-------- 1 gpadmin gpadmin 109 Apr 17 17:41 gp_dbid
drwxrwxr-x 5 gpadmin gpadmin 42 Apr 17 17:41 gpperfmon
-rw-rw-r-- 1 gpadmin gpadmin 860 Apr 17 17:41 gpssh.conf
drwx------ 2 gpadmin gpadmin 6 Apr 17 17:41 pg_changetracking
drwx------ 2 gpadmin gpadmin 18 Apr 17 17:41 pg_clog
drwx------ 2 gpadmin gpadmin 18 Apr 17 17:41 pg_distributedlog
drwx------ 2 gpadmin gpadmin 6 Apr 17 17:41 pg_distributedxidmap
-rw-rw-r-- 1 gpadmin gpadmin 4307 Apr 17 17:41 pg_hba.conf
-rw------- 1 gpadmin gpadmin 1636 Apr 17 17:41 pg_ident.conf
drwx------ 2 gpadmin gpadmin 141 Apr 17 17:42 pg_log
drwx------ 4 gpadmin gpadmin 36 Apr 17 17:41 pg_multixact
drwx------ 2 gpadmin gpadmin 25 Apr 17 17:42 pg_stat_tmp
drwx------ 2 gpadmin gpadmin 18 Apr 17 17:41 pg_subtrans
drwx------ 2 gpadmin gpadmin 6 Apr 17 17:41 pg_tblspc
drwx------ 2 gpadmin gpadmin 6 Apr 17 17:41 pg_twophase
drwx------ 2 gpadmin gpadmin 6 Apr 17 17:42 pg_utilitymodedtmredo
-rw------- 1 gpadmin gpadmin 4 Apr 17 17:41 PG_VERSION
drwx------ 3 gpadmin gpadmin 60 Apr 17 17:42 pg_xlog
-rw------- 1 gpadmin gpadmin 21250 Apr 17 17:41 postgresql.conf
-rw------- 1 gpadmin gpadmin 205 Apr 17 17:42 postmaster.opts
-rw------- 1 gpadmin gpadmin 53 Apr 17 17:42 postmaster.pid
熟悉吧,和 postgresql 的目录基本是一致的。
$ vi pg_hba.conf
$ psql -d postgres -c "select pg_reload_conf();"
$ psql -d postgres
psql (8.3.23)
Type "help" for help.
postgres=# select gp_opt_version();
gp_opt_version
-----------------------------------------------
GPOPT version: 2.55.13, Xerces version: 3.1.2
(1 row)
ok,安装完毕