天天看點

Docker 中部署 Greenplum

一、環境準備

  • Docker
  • docker-compose
  • centos:7.5.1804 的 docker 鏡像
  • greenplum-db-5.14.0-rhel7-x86_64.bin 二進制檔案

1、檢視 docker 和 docker-compose 版本

[[email protected] gp]$ docker -v

Docker version 19.03.5, build 633a0ea

[[email protected] gp]$ docker-compose -v

docker-compose version 1.25.1, build a82fef0

2、greenplum-db 下載下傳位址:

https://network.pivotal.io/products/pivotal-gpdb/

Docker 中部署 Greenplum

二、準備 gp docker 環境

1、建立 GreenPlum Docker 鏡像檔案 Dockerfile

FROM centos:7.5.1804

RUN yum -y update; yum clean all

RUN yum install -y \

    net-tools \

    ntp \

    openssh-server \

    openssh-clients \

    less \

    iproute \

    which; yum clean all

RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''

RUN groupadd gpadmin

RUN useradd gpadmin -g gpadmin

RUN echo gpadmin | passwd gpadmin --stdin

ENTRYPOINT ["/usr/sbin/sshd", "-D"]

2、執行如下指令,建立 docker 鏡像

docker build -t gjm-centos-ssh .

3、通過 docker-compose 啟動所需要的 greenplum 叢集環境。docker-compose.yaml 檔案内容如下:

version: "3.2"

services:

  mdw:

    image: gjm-centos-ssh

    container_name: gpdb-mdw

    tty: true

  sdw1:

    image: gjm-centos-ssh

    container_name: gpdb-sdw1

    tty: true

  sdw2:

    image: gjm-centos-ssh

    container_name: gpdb-sdw2

    tty: true

4、執行如下指令,運作所需要的環境

docker-compose up -d 

三、部署 gp

1、通過 docker cp 指令将 greenplum-db-5.14.0-rhel7-x86_64.bin 拷貝到 mdw 的容器中。

docker cp greenplum-db-5.14.0-rhel7-x86_64.bin gpdb-mdw:/home/gpadmin

2、進入 gpdb-mdw 容器中,并切換到gpadmin使用者下,檢視剛拷貝的bin檔案。

[[email protected] ~]$ docker exec -it gpdb-mdw /bin/bash

[[email protected] /]# su - gpadmin

Last login: Sat May  9 07:26:03 UTC 2020 from 2e9585e22e2e on pts/6

3、執行greenplum的bin檔案,将其安裝在/home/gpadmin目錄下.

[[email protected] ~]$ bash greenplum-db-5.14.0-rhel7-x86_64.bin

注意紅色字型為需要輸入的資料,參考如下:

********************************************************************************

Do you accept the Pivotal Database license agreement? [yes|no]

********************************************************************************

yes

********************************************************************************

Provide the installation path for Greenplum Database or press ENTER to

accept the default installation path: /usr/local/greenplum-db-5.14.0

********************************************************************************

/home/gpadmin/greenplum-db-5.14.0

********************************************************************************

Install Greenplum Database into /home/gpadmin/greenplum-db-5.14.0? [yes|no]

********************************************************************************

yes

********************************************************************************

/home/gpadmin/greenplum-db-5.14.0 does not exist.

Create /home/gpadmin/greenplum-db-5.14.0 ? [yes|no]

(Selecting no will exit the installer)

********************************************************************************

yes

Extracting product to /home/gpadmin/greenplum-db-5.14.0

********************************************************************************

Installation complete.

Greenplum Database is installed in /home/gpadmin/greenplum-db-5.14.0

Pivotal Greenplum documentation is available

for download at http://gpdb.docs.pivotal.io

********************************************************************************

[[email protected] ~]$ ls

greenplum-db  greenplum-db-5.14.0  greenplum-db-5.14.0-rhel7-x86_64.bin

4、建立目錄 /home/gpadmin/gpconfig/ 和 檔案 hostlist、seglist

[[email protected] ~]$ mkdir -p /home/gpadmin/gpconfig/

[[email protected] ~]$ cd /home/gpadmin/gpconfig/

[[email protected] ~]$ vi hostlist

[[email protected] ~]$ vi seglist

hostlist 内容如下

mdw

sdw1

sdw2

seglist 内容如下

sdw1

sdw2

5、Source the path file from your master host’s Greenplum Database installation directory

[[email protected] ~]$ cd

[[email protected] ~]$ source ~/greenplum-db/greenplum_path.sh

6、Config ssh key exchange(master server and gpadmin user)

[[email protected] ~]$ gpssh-exkeys -f /home/gpadmin/gpconfig/hostlist

輸入 sdw1 密碼:gpadmin 

7、Run the gpseginstall utility referencing the hostfile_exkeys file you just created

[[email protected] ~]$ gpseginstall -f /home/gpadmin/gpconfig/seglist

8、Confirm installation

[gpad[email protected] ~]$ gpssh -f ~/gpconfig/hostlist -e ls -l $GPHOME

9、Creating the Data Storage Areas

on master

[[email protected] ~]$ mkdir -p ~/data/master

on segments

[[email protected] ~]$  gpssh -f ~/gpconfig/seglist -e "mkdir -p ~/data/primary"

[sdw1] mkdir -p ~/data/primary

[sdw2] mkdir -p ~/data/primary

[[email protected] ~]$ gpssh -f ~/gpconfig/seglist -e "mkdir -p ~/data/mirror"

[sdw1] mkdir -p ~/data/mirror

[sdw2] mkdir -p ~/data/mirror

10、Make a copy of the gpinitsystem_config file to use as a starting point and edit it as you need

[[email protected] ~]$ cp /home/gpadmin/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config ~/gpconfig/gpinitsystem_config

11、modify two line as following

vi ~/gpconfig/gpinitsystem_config

declare -a DATA_DIRECTORY=(/home/gpadmin/data/primary)

MASTER_DIRECTORY=/home/gpadmin/data/master

Docker 中部署 Greenplum

12、run the initialization utility 

[[email protected] ~]$ gpinitsystem -c gpconfig/gpinitsystem_config -h gpconfig/seglist

參考内容如下: 

[[email protected] ~]$ gpinitsystem -c gpconfig/gpinitsystem_config -h gpconfig/seglist

20200509:07:37:09:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking configuration parameters, please wait...

20200509:07:37:09:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Reading Greenplum configuration file gpconfig/gpinitsystem_config

20200509:07:37:09:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Locale has not been set in gpconfig/gpinitsystem_config, will set to default value

20200509:07:37:09:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Locale set to en_US.utf8

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[WARN]:-Master hostname mdw does not match hostname output

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking to see if mdw can be resolved on this host

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Can resolve mdw to this host

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-No DATABASE_NAME set, will exit following template1 updates

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-MASTER_MAX_CONNECT not set, will set to default value 250

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking configuration parameters, Completed

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Commencing multi-home checks, please wait...

..

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Configuring build for standard array

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Commencing multi-home checks, Completed

20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Building primary segment instance array, please wait...

..

20200509:07:37:11:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking Master host

20200509:07:37:11:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking new segment hosts, please wait...

..

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking new segment hosts, Completed

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Database Creation Parameters

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:---------------------------------------

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master Configuration

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:---------------------------------------

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master instance name       = Greenplum Data Platform

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master hostname            = mdw

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master port                = 5432

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master instance dir        = /home/gpadmin/data/master/gpseg-1

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master LOCALE              = en_US.utf8

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Greenplum segment prefix   = gpseg

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master Database            = 

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master connections         = 250

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master buffers             = 128000kB

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Segment connections        = 750

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Segment buffers            = 128000kB

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checkpoint segments        = 8

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Encoding                   = UNICODE

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Postgres param file        = Off

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Initdb to be used          = /home/gpadmin/greenplum-db/./bin/initdb

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-GP_LIBRARY_PATH is         = /home/gpadmin/greenplum-db/./lib

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-HEAP_CHECKSUM is           = on

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-HBA_HOSTNAMES is           = 0

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Ulimit check               = Passed

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Array host connect type    = Single hostname per node

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master IP address [1]      = 172.24.0.3

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Standby Master             = Not Configured

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Primary segment #          = 1

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total Database segments    = 2

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Trusted shell              = ssh

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Number segment hosts       = 2

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Mirroring config           = OFF

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:----------------------------------------

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Primary Segment Configuration

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:----------------------------------------

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-sdw1         /home/gpadmin/data/primary/gpseg0       6000    2       0

20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-sdw2         /home/gpadmin/data/primary/gpseg1       6000    3       1

Continue with Greenplum creation Yy|Nn (default=N):

> y

20200509:07:37:28:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Building the Master instance database, please wait...

20200509:07:37:37:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Starting the Master in admin mode

20200509:07:37:45:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Commencing parallel build of primary segment instances

20200509:07:37:45:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Spawning parallel processes    batch [1], please wait...

..

20200509:07:37:45:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Waiting for parallel processes batch [1], please wait...

...............

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:------------------------------------------------

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Parallel process exit status

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:------------------------------------------------

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total processes marked as completed           = 2

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total processes marked as killed              = 0

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total processes marked as failed              = 0

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:------------------------------------------------

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Deleting distributed backout files

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Removing back out file

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-No errors generated from parallel processes

20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Restarting the Greenplum instance in production mode

20200509:07:38:00:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Starting gpstop with args: -a -l /home/gpadmin/gpAdminLogs -i -m -d /home/gpadmin/data/master/gpseg-1

20200509:07:38:00:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Gathering information and validating the environment...

20200509:07:38:00:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information

20200509:07:38:00:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Obtaining Segment details from master...

20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 5.14.0 build commit:13927a46a9b39527fc1af2cbb1571d4fd394ff88'

20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-There are 0 connections to the database

20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Commencing Master instance shutdown with mode='immediate'

20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Master host=2e9585e22e2e

20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=immediate

20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Master segment instance directory=/home/gpadmin/data/master/gpseg-1

20200509:07:38:04:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Attempting forceful termination of any leftover master process

20200509:07:38:06:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Terminating processes for segment /home/gpadmin/data/master/gpseg-1

20200509:07:38:07:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Starting gpstart with args: -a -l /home/gpadmin/gpAdminLogs -d /home/gpadmin/data/master/gpseg-1

20200509:07:38:07:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Gathering information and validating the environment...

20200509:07:38:08:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 5.14.0 build commit:13927a46a9b39527fc1af2cbb1571d4fd394ff88'

20200509:07:38:09:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Catalog Version: '301705051'

20200509:07:38:10:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Starting Master instance in admin mode

20200509:07:38:12:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information

20200509:07:38:12:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Obtaining Segment details from master...

20200509:07:38:13:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Setting new master era

20200509:07:38:13:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Master Started...

20200509:07:38:14:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Shutting down master

20200509:07:38:22:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Commencing parallel segment instance startup, please wait...

....... 

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Process results...

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-----------------------------------------------------

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-   Successful segment starts                                            = 2

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-   Failed segment starts                                                = 0

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-   Skipped segment starts (segments are marked down in configuration)   = 0

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-----------------------------------------------------

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Successfully started 2 of 2 segment instances 

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-----------------------------------------------------

20200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Starting Master instance 2e9585e22e2e directory /home/gpadmin/data/master/gpseg-1 

20200509:07:38:32:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Command pg_ctl reports Master 2e9585e22e2e instance active

20200509:07:38:33:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-No standby master configured.  skipping...

20200509:07:38:33:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Database successfully started

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Completed restart of Greenplum instance in production mode

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Scanning utility log file for any warning messages

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[WARN]:-*******************************************************

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[WARN]:-Scan of log file indicates that some warnings or errors

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[WARN]:-were generated during the array creation

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Please review contents of log file

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-/home/gpadmin/gpAdminLogs/gpinitsystem_20200509.log

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-To determine level of criticality

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-These messages could be from a previous run of the utility

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-that was called today!

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[WARN]:-*******************************************************

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Database instance successfully created

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-------------------------------------------------------

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-To complete the environment configuration, please 

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-update gpadmin .bashrc file with the following

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-1. Ensure that the greenplum_path.sh file is sourced

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-2. Add "export MASTER_DATA_DIRECTORY=/home/gpadmin/data/master/gpseg-1"

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-   to access the Greenplum scripts for this instance:

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-   or, use -d /home/gpadmin/data/master/gpseg-1 option for the Greenplum scripts

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-   Example gpstate -d /home/gpadmin/data/master/gpseg-1

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Script log file = /home/gpadmin/gpAdminLogs/gpinitsystem_20200509.log

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-To remove instance, run gpdeletesystem utility

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-To initialize a Standby Master Segment for this Greenplum instance

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Review options for gpinitstandby

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-------------------------------------------------------

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-The Master /home/gpadmin/data/master/gpseg-1/pg_hba.conf post gpinitsystem

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-has been configured to allow all hosts within this new

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-array to intercommunicate. Any hosts external to this

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-new array must be explicitly added to this file

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Refer to the Greenplum Admin support guide which is

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-located in the /home/gpadmin/greenplum-db/./docs directory

20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-------------------------------------------------------

13、see the Greenplum Database instance successfully created. You install successfully

如紅色字型

四、如何使用 gp

1、配置環境變量

vi ~/.bashrc

增加如下内容

export LD_LIBRARY_PATH=/home/gpadmin/greenplum-db/lib

source ~/greenplum-db/greenplum_path.sh

配置生效 

source ~/.bashrc

2、登入 gp

[[email protected] lib]$ psql -d postgres -h localhost -p 5432 -U gpadmin 

psql (8.3.23)

Type "help" for help.

postgres=# \c

You are now connected to database "postgres" as user "gpadmin".

3、建立測試使用者guanjiangmiao、授權建立資料庫和登入權限。

postgres=# create role guanjiangmiao password '123qwe' createdb login;

NOTICE:  resource queue required -- using default resource queue "pg_default"

CREATE ROLE

通常建立使用者,賦予login權限基本就夠用了,建立使用者的文法可以通過\h create role指令來檢視。可以通過pg_roles字典來檢視

資料庫的使用者資訊。

postgres=# \h create role

Command:     CREATE ROLE

Description: define a new database role

Syntax:

CREATE ROLE name [[WITH] option [ ... ]]

where option can be:

      SUPERUSER | NOSUPERUSER

    | CREATEDB | NOCREATEDB

    | CREATEROLE | NOCREATEROLE

    | CREATEEXTTABLE | NOCREATEEXTTABLE 

      [ ( attribute='value'[, ...] ) ]

           where attributes and values are:

           type='readable'|'writable'

           protocol='gpfdist'|'http'|'gphdfs'

    | INHERIT | NOINHERIT

    | LOGIN | NOLOGIN

    | CONNECTION LIMIT connlimit

    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'

    | VALID UNTIL 'timestamp' 

    | IN ROLE rolename [, ...]

    | ROLE rolename [, ...]

    | ADMIN rolename [, ...]

    | RESOURCE QUEUE queue_name

    | RESOURCE GROUP group_name

postgres=# select rolname,oid from pg_roles;

    rolname    |  oid  

---------------+-------

 gpadmin       |    10

 guanjiangmiao | 16384

(2 rows)

4、建立完使用者後,還需要修改pg_hba.conf檔案,來賦予使用者的遠端登入權限。

[[email protected] gpseg-1]$ cd /home/gpadmin/data/master/gpseg-1

[[email protected] gpseg-1]$ vi pg_hba.conf 

增加如下内容

host     all         guanjiangmiao         0.0.0.0/0       md5
Docker 中部署 Greenplum

5、通過gpstop –u指令重新加載配置檔案,使之生效後,guanjiangmiao 使用者即可遠端通路資料庫了。

[[email protected] greenplum-db]$ pwd

/home/gpadmin/greenplum-db

[[email protected] greenplum-db]$ bin/gpstop -u

[[email protected] greenplum-db]$ psql -d postgres -h 127.0.0.1 -p 5432 -U guanjiangmiao

Password for user guanjiangmiao: 

psql (8.3.23)

Type "help" for help.

postgres=> 

6、設定免密登入

cd

vi .pgpass

輸入如下内容

10.0.0.100:5432:*:guanjiangmiao:123qwe 
chmod 600 .pgpass

五、啟動、關閉及狀态檢視指令參數說明

1、啟動 gp

在Master主機上運作gpstart啟動Greenplum資料庫,gpstart 常用的啟動參數有以下幾個參數:

  • -a,該模式不需要在啟動過程中輸入Y進行确認,将直接啟動資料庫。
  • -m,隻啟動Master節點,不啟動Segment節點,通常在維護的時候使用。
  • -y,隻啟動Master的primary節點,不啟動standby節點。

2、停止 gp

不要發出kill指令來結束任何Postgres程序,發出kill -9或者kill -11可能會導緻資料庫損壞并且妨礙對根本原因的分析。在Master主

機上運作gpstop停止Greenplum資料庫,常用參數如下:

  • -a,不需要輸入Y确認是否關閉,将直接關閉資料庫
  • -m,隻關閉Master節點,一般用于維護模式
  • -r,重新開機資料庫。
  • -u,加載參數檔案,使修改的參數生效。pg_hba.conf配置檔案和Master上postgresql.conf、pg_hba.conf檔案中運作時參數的更改,活動會話将會在它們重新連接配接到資料庫時使用這些更新。很多伺服器配置參數需要完全重新開機系統(gpstop -r)才能激活
  • -M,設定關閉資料庫的級别,有三種級别,fast、immediate和smart。 Immediate smart 這是預設的關閉級别,所有連接配接的會話會收到關閉警告,不允許新連結通路資料庫。 gpstop –M immediate,強制關閉資料庫,這種方式是不一緻的關閉模式,不建議使用。 gpstop –M fast 快速模式,停止所有連接配接将中斷并且復原

3、檢視 gp 狀态

常用的參數如下:

  • -s,詳細資訊。
  • -m,Mirror資訊。
  • -f,Master的Standby資訊。
  • -e,Segment的Mirror資訊。
  • -i,版本資訊。

六、可能遇到的問題

1、ImportError: No module named site

[[email protected] bin]$ gpstop -u

ImportError: No module named site

解決步驟:

(1)查找site相關檔案的路徑

[[email protected] /]# find / -name site.py

/home/gpadmin/greenplum-db-5.14.0/ext/python/lib/python2.7/site.py

/usr/lib64/python2.7/site.py

(2)增加路徑到環境變量

[[email protected] ~]$ vi .bashrc

增加如下内容

export PYTHONPATH=$PYTHONPATH:/home/gpadmin/greenplum-db-5.14.0/ext/python/lib/python2.7

(3)讓配置生效

source ~/.bashrc

2、ImportError: No module named gppylib.mainUtils

[[email protected] greenplum-db]$ bin/gpstop -u

Traceback (most recent call last):

  File "bin/gpstop", line 9, in <module>

    from gppylib.mainUtils import *

ImportError: No module named gppylib.mainUtils

解決步驟:

source ~/greenplum-db/greenplum_path.sh

3、Reason='Environment Variable MASTER_DATA_DIRECTORY not set!

[[email protected] greenplum-db]$ bin/gpstop -u

20200511:02:37:34:002935 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -u

20200511:02:37:34:002935 gpstop:ca279251422f:gpadmin-[INFO]:-Gathering information and validating the environment...

20200511:02:37:34:002935 gpstop:ca279251422f:gpadmin-[CRITICAL]:-gpstop failed. (Reason='Environment Variable MASTER_DATA_DIRECTORY not set!') exiting...

解決步驟:

(1)greenplum_path.sh 增加環境變量

cd /home/gpadmin/greenplum-db

vi greenplum_path.sh

增加内容如下

source ~/greenplum-db/greenplum_path.sh

export MASTER_DATA_DIRECTORY=/home/gpadmin/data/master/gpseg-1

export PGPORT=5432

export PGUSER=gpadmin

(2)讓配置生效

source greenplum_path.sh

4、postmaster.pid file does not exist.  is Greenplum instance already stopped?

[[email protected] greenplum-db]$ bin/gpstop -u              

20200511:03:15:35:000105 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -u

20200511:03:15:35:000105 gpstop:ca279251422f:gpadmin-[INFO]:-Gathering information and validating the environment...

20200511:03:15:35:000105 gpstop:ca279251422f:gpadmin-[ERROR]:-gpstop error: postmaster.pid file does not exist.  is Greenplum instance already stopped?

解決步驟:

(1)關閉gp

bin/gpstop -af

(2)啟動gp

bin/gpstart -a

[[email protected] gpseg-1]$ gpstop -af

20200511:03:43:08:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -af

20200511:03:43:08:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Gathering information and validating the environment...

20200511:03:43:08:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information

20200511:03:43:08:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Obtaining Segment details from master...

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 5.14.0 build commit:13927a46a9b39527fc1af2cbb1571d4fd394ff88'

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-There are 0 connections to the database

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Commencing Master instance shutdown with mode='fast'

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Master host=ca279251422f

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Detected 0 connections to database

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Using standard WAIT mode of 120 seconds

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=fast

20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Master segment instance directory=/home/gpadmin/data/master/gpseg-1

20200511:03:43:13:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Attempting forceful termination of any leftover master process

20200511:03:43:14:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Terminating processes for segment /home/gpadmin/data/master/gpseg-1

20200511:03:43:15:000464 gpstop:ca279251422f:gpadmin-[INFO]:-No standby master host configured

20200511:03:43:15:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Targeting dbid [2, 3] for shutdown

20200511:03:43:16:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Commencing parallel segment instance shutdown, please wait...

20200511:03:43:16:000464 gpstop:ca279251422f:gpadmin-[INFO]:-0.00% of jobs completed

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-100.00% of jobs completed

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-----------------------------------------------------

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-   Segments stopped successfully      = 2

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-   Segments with errors during stop   = 0

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-----------------------------------------------------

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Successfully shutdown 2 of 2 segment instances 

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Database successfully shutdown with no errors reported

20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Cleaning up leftover gpmmon process

20200511:03:43:23:000464 gpstop:ca279251422f:gpadmin-[INFO]:-No leftover gpmmon process found

20200511:03:43:23:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Cleaning up leftover gpsmon processes

20200511:03:43:24:000464 gpstop:ca279251422f:gpadmin-[INFO]:-No leftover gpsmon processes on some hosts. not attempting forceful termination on these hosts

20200511:03:43:24:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Cleaning up leftover shared memory

[[email protected] gpseg-1]$ gpstart -a

20200511:03:43:34:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Starting gpstart with args: -a

20200511:03:43:34:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Gathering information and validating the environment...

20200511:03:43:35:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 5.14.0 build commit:13927a46a9b39527fc1af2cbb1571d4fd394ff88'

20200511:03:43:36:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Greenplum Catalog Version: '301705051'

20200511:03:43:37:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Starting Master instance in admin mode

20200511:03:43:39:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information

20200511:03:43:39:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Obtaining Segment details from master...

20200511:03:43:40:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Setting new master era

20200511:03:43:40:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Master Started...

20200511:03:43:41:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Shutting down master

20200511:03:43:50:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Commencing parallel segment instance startup, please wait...

....... 

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Process results...

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-----------------------------------------------------

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-   Successful segment starts                                            = 2

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-   Failed segment starts                                                = 0

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-   Skipped segment starts (segments are marked down in configuration)   = 0

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-----------------------------------------------------

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Successfully started 2 of 2 segment instances 

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-----------------------------------------------------

20200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Starting Master instance ca279251422f directory /home/gpadmin/data/master/gpseg-1 

20200511:03:44:00:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Command pg_ctl reports Master ca279251422f instance active

20200511:03:44:00:000555 gpstart:ca279251422f:gpadmin-[INFO]:-No standby master configured.  skipping...

20200511:03:44:00:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Database successfully started

[[email protected] gpseg-1]$ 

[[email protected] gpseg-1]$ gpstop -u

20200511:03:44:18:000634 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -u

20200511:03:44:18:000634 gpstop:ca279251422f:gpadmin-[INFO]:-Gathering information and validating the environment...

20200511:03:44:18:000634 gpstop:ca279251422f:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information

20200511:03:44:18:000634 gpstop:ca279251422f:gpadmin-[INFO]:-Obtaining Segment details from master...

20200511:03:44:20:000634 gpstop:ca279251422f:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 5.14.0 build commit:13927a46a9b39527fc1af2cbb1571d4fd394ff88'

20200511:03:44:20:000634 gpstop:ca279251422f:gpadmin-[INFO]:-Signalling all postmaster processes to reload

..