greenplum 6.9 for centos7叢集搭建步驟

chenfeng發表於2020-10-14


Host            IP                                功能

mdw       192.168.1.1                master

smdw      192.168.1.2                         segment

sdw2      192.168.1.3                         segment



greenplum6.9下載:



一. 配置SSH無密碼互相登陸:


登入每臺機器:

切換到gpadmin使用者:

#su - gpadmin


/* 生成公私金鑰

$ ssh-keygen -t rsa


/* 在各個主機上使用ssh-copy-id命令複製public key到檔案authorized_hosts

$ ssh-copy-id mdw 

輸入密碼gpadmin


$ ssh-copy-id smdw

輸入密碼


$ ssh-copy-id sdw2

輸入密碼


/* 在所有主機驗證是否可以免密登陸

ssh mdw date

ssh smdw date

ssh sdw2 date


二.安裝greenplum

在每臺機器上安裝Greenplum6.9版本的rpm包

# yum install -y greenplum-db-6.6.0-rhel7-x86_64.rpm

# chown -R gpadmin:gpadmin /usr/local/greenplum*



三. 配置Greenplum

建立一個hostlist,包含所有節點主機名

$ cat /home/gpadmin/conf/hostlist        

mdw

smdw

sdw2


建立一個 seg_hosts ,包含所有的Segment Host的主機名

$ cat /home/gpadmin/conf/seg_hosts

smdw

sdw2


把配置傳給其他主機:

# su - gpadmin

$ source /usr/local/greenplum-db/greenplum_path.sh

$ gpssh-exkeys -f /home/gpadmin/conf/hostlist

$ gpssh-exkeys -f /home/gpadmin/conf/seg_hosts


測試免密連線是否成功:

$ ssh smdw #不需要密碼即可登入;


$ gpssh -f /home/gpadmin/conf/hostlist

=> pwd

[smdw] /home/gpadmin

[sdw2] /home/gpadmin

[mdw] /home/gpadmin

=> exit

出現上面結果就是成功了



四、初始化資料庫

1、建立資源目錄

$ source /usr/local/ greenplum-db/greenplum_path.sh

$ gpssh -f /home/gpadmin/conf/hostlist

=> mkdir -p /opt/greenplum/data/master

=> mkdir -p /opt/greenplum/data/primary

=> mkdir -p /opt/greenplum/data/mirror

=> mkdir -p /opt/greenplum/data2/primary

=> mkdir -p /opt/greenplum/data2/mirror


2、環境變數配置

在主節點進行環境變數配置(配置在gpadmin的使用者許可權下進行配置)

# su - gpadmin

$ vi /home/gpadmin/.bash_profile

# .bash_profile


# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi


# User specific environment and startup programs


PATH=$PATH:$HOME/.local/bin:$HOME/bin


export PATH



source /usr/local/greenplum-db/greenplum_path.sh

export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1

export PGPORT=6530

export PGUSER=gpadmin

source /usr/local/greenplum-cc/gpcc_path.sh


export PGDATABASE=gp_sydb


然後依次複製到各個子節點

$ scp /home/gpadmin/.bash_profile smdw:/home/gpadmin/


$ scp /home/gpadmin/.bash_profile sdw2:/home/gpadmin/


讓環境變數生效

$ source .bash_profile


3、初始化前檢查連通性

$ cd /usr/local/greenplum-db/bin


$ gpcheckperf -f /home/gpadmin/conf/hostlist -r N -d /tmp

/usr/local/greenplum-db-6.9.0/bin/gpcheckperf -f /home/gpadmin/conf/hostlist -r N -d /tmp


-------------------

--  NETPERF TEST

-------------------

[Warning] retrying with port 23012

NOTICE: -t is deprecated, and has no effect

NOTICE: -f is deprecated, and has no effect

NOTICE: -t is deprecated, and has no effect

NOTICE: -f is deprecated, and has no effect

NOTICE: -t is deprecated, and has no effect

NOTICE: -f is deprecated, and has no effect

NOTICE: -t is deprecated, and has no effect

NOTICE: -f is deprecated, and has no effect


====================

==  RESULT 2020-09-10T09:34:37.472459

====================

Netperf bisection bandwidth test

mdw -> smdw = 111.620000

sdw2 -> mdw = 110.600000

smdw -> mdw = 111.320000

mdw -> sdw2 = 111.640000


Summary:

sum = 445.18 MB/sec

min = 110.60 MB/sec

max = 111.64 MB/sec

avg = 111.29 MB/sec

median = 111.62 MB/sec



出現以上內容證明各個節點已經可以連通。


4、執行初始化

初始化 Greenplum 配置檔案模板都在/usr/local/greenplum-db/docs/cli_help/gpconfigs目錄下,gpinitsystem_config是初始化 Greenplum 的模板,此模板中 Mirror Segment的配置都被註釋;建立一個副本,對其以下配置進行修改:


$ cd /usr/local/greenplum-db/docs/cli_help/gpconfigs

$ cp gpinitsystem_config initgp_config

$ vi initgp_config


# FILE NAME: gpinitsystem_config


# Configuration file needed by the gpinitsystem


################################################

#### REQUIRED PARAMETERS

################################################


#### Name of this Greenplum system enclosed in quotes.

ARRAY_NAME="Greenplum Data Platform"


#### Naming convention for utility-generated data directories.

SEG_PREFIX=gpseg


#### Base number by which primary segment port numbers 

#### are calculated.

PORT_BASE=6000


#### File system location(s) where primary segment data directories 

#### will be created. The number of locations in the list dictate

#### the number of primary segments that will get created per

#### physical host (if multiple addresses for a host are listed in 

#### the hostfile, the number of segments will be spread evenly across

#### the specified interface addresses).

#declare -a DATA_DIRECTORY=(/data1/primary /data1/primary /data1/primary /data2/primary /data2/primary /data2/primary)

declare -a DATA_DIRECTORY=(/opt/greenplum/data/primary /opt/greenplum/data/primary  /opt/greenplum/data2/primary /opt/greenplum/data2/primary)



#### OS-configured hostname or IP address of the master host.

MASTER_HOSTNAME=mdw


#### File system location where the master data directory 

#### will be created.

MASTER_DIRECTORY=/opt/greenplum/data/master


MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1


#### Port number for the master instance. 

MASTER_PORT=6530


#### Shell utility used to connect to remote hosts.

TRUSTED_SHELL=ssh


#### Maximum log file segments between automatic WAL checkpoints.

CHECK_POINT_SEGMENTS=8


#### Default server-side character set encoding.

ENCODING=UNICODE


################################################

#### OPTIONAL MIRROR PARAMETERS

################################################


#### Base number by which mirror segment port numbers 

#### are calculated.

#MIRROR_PORT_BASE=7000


#### File system location(s) where mirror segment data directories 

#### will be created. The number of mirror locations must equal the

#### number of primary locations as specified in the 

#### DATA_DIRECTORY parameter.

declare -a MIRROR_DATA_DIRECTORY=(/opt/greenplum/data/mirror /opt/greenplum/data/mirror /opt/greenplum/data/mirror /opt/greenplum/data2/mirror /opt/greenplum/data2/mirror /opt/greenplum/data2/mirror)



################################################

#### OTHER OPTIONAL PARAMETERS

################################################


#### Create a database of this name after initialization.

DATABASE_NAME=gp_sydb 


#### Specify the location of the host address file here instead of

#### with the -h option of gpinitsystem.

MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts



master節點執行初始化;

gpinitsystem -c initgp_config -S -s standby  



[gpadmin@mdw gpconfigs]$ gpinitsystem -c initgp_config -S -s standby 

20200909:10:12:20:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, please wait...

20200909:10:12:20:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Reading Greenplum configuration file initgp_config

20200909:10:12:20:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Locale has not been set in initgp_config, will set to default value

20200909:10:12:20:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Locale set to en_US.utf8

20200909:10:12:20:119474 gpinitsystem:mdw:gpadmin-[INFO]:-MASTER_MAX_CONNECT not set, will set to default value 250

20200909:10:12:20:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, Completed

20200909:10:12:20:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing multi-home checks, please wait...

..

20200909:10:12:21:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Configuring build for standard array

20200909:10:12:21:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing multi-home checks, Completed

20200909:10:12:21:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Building primary segment instance array, please wait...

........

20200909:10:12:26:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Checking Master host

20200909:10:12:26:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Checking new segment hosts, please wait...

........

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Checking new segment hosts, Completed

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Database Creation Parameters

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:---------------------------------------

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master Configuration

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:---------------------------------------

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master instance name       = Greenplum Data Platform

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master hostname            = mdw

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master port                = 6530

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master instance dir        = /opt/greenplum/data/master/gpseg-1

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master LOCALE              = en_US.utf8

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum segment prefix   = gpseg

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master Database            = gp_sydb

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master connections         = 250

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master buffers             = 128000kB

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Segment connections        = 750

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Segment buffers            = 128000kB

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Checkpoint segments        = 8

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Encoding                   = UNICODE

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Postgres param file        = Off

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Initdb to be used          = /usr/local/greenplum-db-6.9.0/bin/initdb

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-GP_LIBRARY_PATH is         = /usr/local/greenplum-db-6.9.0/lib

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-HEAP_CHECKSUM is           = on

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-HBA_HOSTNAMES is           = 0

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Ulimit check               = Passed

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Array host connect type    = Single hostname per node

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [1]      = 10.100.75.192

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [2]      = 169.254.95.120

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [3]      = 172.17.0.1

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [4]      = 192.168.1.1

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Standby Master             = Not Configured

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Number of primary segments = 4

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Total Database segments    = 8

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Trusted shell              = ssh

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Number segment hosts       = 2

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Mirroring config           = OFF

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:----------------------------------------

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Primary Segment Configuration

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:----------------------------------------

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2  6000    sdw2    /opt/greenplum/data/primary/gpseg0      2

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2  6001    sdw2    /opt/greenplum/data/primary/gpseg1      3

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2  6002    sdw2    /opt/greenplum/data2/primary/gpseg2     4

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2  6003    sdw2    /opt/greenplum/data2/primary/gpseg3     5

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-smdw  6000    smdw    /opt/greenplum/data/primary/gpseg4      6

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-smdw  6001    smdw    /opt/greenplum/data/primary/gpseg5      7

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-smdw  6002    smdw    /opt/greenplum/data2/primary/gpseg6     8

20200909:10:12:36:119474 gpinitsystem:mdw:gpadmin-[INFO]:-smdw  6003    smdw    /opt/greenplum/data2/primary/gpseg7     9


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

> Y

20200909:10:12:49:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Building the Master instance database, please wait...

20200909:10:13:01:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Starting the Master in admin mode

20200909:10:13:04:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing parallel build of primary segment instances

20200909:10:13:04:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Spawning parallel processes    batch [1], please wait...

........

20200909:10:13:04:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Waiting for parallel processes batch [1], please wait...

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

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Parallel process exit status

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as completed           = 8

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as killed              = 0

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as failed              = 0

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Deleting distributed backout files

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Removing back out file

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-No errors generated from parallel processes

20200909:10:13:40:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Restarting the Greenplum instance in production mode

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Starting gpstop with args: -a -l /home/gpadmin/gpAdminLogs -m -d /opt/greenplum/data/master/gpseg-1

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Gathering information and validating the environment...

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0'

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Commencing Master instance shutdown with mode='smart'

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Master segment instance directory=/opt/greenplum/data/master/gpseg-1

20200909:10:13:41:125357 gpstop:mdw:gpadmin-[INFO]:-Stopping master segment and waiting for user connections to finish ...

server shutting down

20200909:10:13:42:125357 gpstop:mdw:gpadmin-[INFO]:-Attempting forceful termination of any leftover master process

20200909:10:13:42:125357 gpstop:mdw:gpadmin-[INFO]:-Terminating processes for segment /opt/greenplum/data/master/gpseg-1

20200909:10:13:42:125357 gpstop:mdw:gpadmin-[ERROR]:-Failed to kill processes for segment /opt/greenplum/data/master/gpseg-1: ([Errno 3] No such process)

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Starting gpstart with args: -a -l /home/gpadmin/gpAdminLogs -d /opt/greenplum/data/master/gpseg-1

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Gathering information and validating the environment...

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0'

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Greenplum Catalog Version: '301908232'

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Starting Master instance in admin mode

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Setting new master era

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Master Started...

20200909:10:13:42:125462 gpstart:mdw:gpadmin-[INFO]:-Shutting down master

20200909:10:13:43:125462 gpstart:mdw:gpadmin-[INFO]:-Commencing parallel segment instance startup, please wait...

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-Process results...

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-   Successful segment starts                                            = 8

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-   Failed segment starts                                                = 0

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-   Skipped segment starts (segments are marked down in configuration)   = 0

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-Successfully started 8 of 8 segment instances 

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-Starting Master instance mdw directory /opt/greenplum/data/master/gpseg-1 

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-Command pg_ctl reports Master mdw instance active

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-Connecting to dbname='template1' connect_timeout=15

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-No standby master configured.  skipping...

20200909:10:13:44:125462 gpstart:mdw:gpadmin-[INFO]:-Database successfully started

20200909:10:13:44:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Completed restart of Greenplum instance in production mode

20200909:10:13:49:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Scanning utility log file for any warning messages

20200909:10:13:49:119474 gpinitsystem:mdw:gpadmin-[WARN]:-*******************************************************

20200909:10:13:49:119474 gpinitsystem:mdw:gpadmin-[WARN]:-Scan of log file indicates that some warnings or errors

20200909:10:13:49:119474 gpinitsystem:mdw:gpadmin-[WARN]:-were generated during the array creation

20200909:10:13:49:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Please review contents of log file

20200909:10:13:49:119474 gpinitsystem:mdw:gpadmin-[INFO]:-/home/gpadmin/gpAdminLogs/gpinitsystem_20200909.log

20200909:10:13:49:119474 gpinitsystem:mdw:gpadmin-[INFO]:-To determine level of criticality

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-These messages could be from a previous run of the utility

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-that was called today!

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[WARN]:-*******************************************************

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Database instance successfully created

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-To complete the environment configuration, please 

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-update gpadmin .bashrc file with the following

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-1. Ensure that the greenplum_path.sh file is sourced

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-2. Add "export MASTER_DATA_DIRECTORY=/opt/greenplum/data/master/gpseg-1"

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-   to access the Greenplum scripts for this instance:

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-   or, use -d /opt/greenplum/data/master/gpseg-1 option for the Greenplum scripts

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-   Example gpstate -d /opt/greenplum/data/master/gpseg-1

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Script log file = /home/gpadmin/gpAdminLogs/gpinitsystem_20200909.log

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-To remove instance, run gpdeletesystem utility

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-To initialize a Standby Master Segment for this Greenplum instance

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Review options for gpinitstandby

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-The Master /opt/greenplum/data/master/gpseg-1/pg_hba.conf post gpinitsystem

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-has been configured to allow all hosts within this new

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-array to intercommunicate. Any hosts external to this

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-new array must be explicitly added to this file

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-Refer to the Greenplum Admin support guide which is

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-located in the /usr/local/greenplum-db-6.9.0/docs directory

20200909:10:13:50:119474 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------


若初始化失敗,需要刪除/opt下的資料資源目錄重新初始化;



五、資料庫操作

登入資料庫:

$ psql -p 6530

psql (9.4.24)

Type "help" for help.


gp_sydb=# 

gp_sydb=# 

gp_sydb=# 

gp_sydb=# 



停止和啟動叢集命令:

$ gpstop -M fast

$ gpstart -a


叢集狀態檢視命令:

gpstate -e #檢視mirror的狀態

gpstate -f #檢視standby master的狀態

gpstate -s #檢視整個GP群集的狀態

gpstate -i #檢視GP的版本

gpstate --help #幫助文件,可以檢視gpstate更多用法


檢視叢集狀態:

 [gpadmin@mdw gpconfigs]$ gpstate -f 

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: -f

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0'

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53'

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:-Standby master instance not configured

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:--pg_stat_replication

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:-No entries found.

20200909:10:23:07:138528 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------

[gpadmin@mdw gpconfigs]$ gpstate -s

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: -s

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0'

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53'

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-Gathering data from segments...

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:--Master Configuration & Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Master host                    = mdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Master postgres process ID     = 125520

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Master data directory          = /opt/greenplum/data/master/gpseg-1

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Master port                    = 6530

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Master current role            = dispatch

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Greenplum initsystem version   = 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Greenplum current version      = PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Postgres version               = 9.4.24

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Master standby                 = No master standby configured

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-Segment Instance Status Report

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data/primary/gpseg0

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6000

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 151307

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data/primary/gpseg1

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6001

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 151306

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data2/primary/gpseg2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6002

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 151309

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = sdw2

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data2/primary/gpseg3

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6003

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 151308

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data/primary/gpseg4

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6000

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 39878

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data/primary/gpseg5

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6001

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 39877

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data2/primary/gpseg6

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6002

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 39879

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Segment Info

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Hostname                          = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Address                           = smdw

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Datadir                           = /opt/greenplum/data2/primary/gpseg7

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Port                              = 6003

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-   Status

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      PID                               = 39880

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Configuration reports status as   = Up

20200909:10:23:17:138776 gpstate:mdw:gpadmin-[INFO]:-      Database status                   = Up

[gpadmin@mdw gpconfigs]$ 

[gpadmin@mdw gpconfigs]$ 


[gpadmin@mdw gpconfigs]$ gpstate -i 

20200909:10:23:51:139570 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: -i

20200909:10:23:51:139570 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0'

20200909:10:23:51:139570 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53'

20200909:10:23:51:139570 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...

20200909:10:23:51:139570 gpstate:mdw:gpadmin-[INFO]:-Loading version information

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   Host   Datadir                               Port   Version                                                                                                                                                                                                

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   mdw    /opt/greenplum/data/master/gpseg-1    6530   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   sdw2   /opt/greenplum/data/primary/gpseg0    6000   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   sdw2   /opt/greenplum/data/primary/gpseg1    6001   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   sdw2   /opt/greenplum/data2/primary/gpseg2   6002   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   sdw2   /opt/greenplum/data2/primary/gpseg3   6003   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   smdw   /opt/greenplum/data/primary/gpseg4    6000   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   smdw   /opt/greenplum/data/primary/gpseg5    6001   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   smdw   /opt/greenplum/data2/primary/gpseg6   6002   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-   smdw   /opt/greenplum/data2/primary/gpseg7   6003   PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53

20200909:10:23:52:139570 gpstate:mdw:gpadmin-[INFO]:-All segments are running the same software version


[gpadmin@mdw gpconfigs]$ gpstate -e 

20200909:10:22:56:138257 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: -e

20200909:10:22:56:138257 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0'

20200909:10:22:56:138257 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53'

20200909:10:22:56:138257 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...

20200909:10:22:56:138257 gpstate:mdw:gpadmin-[INFO]:-Physical mirroring is not configured

[gpadmin@mdw gpconfigs]$ 



備註:目前為止資料庫已經安裝和操作完畢,預設只有本地可以連資料庫。如果需要別的機器可以連,需要修改gp_hba.conf檔案:


vim $MASTER_DATA_DIRECTORY/pg_hba.conf 

#新增

host all gpadmin 0.0.0.0/0 md5

執行gpstop -u使配置生效


在從庫上連線master測試:

$ psql -h 192.168.1.1 -d gp_sydb -p 6530

psql (9.4.24)

Type "help" for help.


gp_sydb=# 


修改gpadmin密碼:

gp_sydb=# alter user gpadmin with password 'gpadmin';

ALTER ROLE


從庫指定DB連線:


[gpadmin@smdw ~]$ psql -U gpadmin -h 192.168.1.1 -d gp_sydb -p 6530

Password for user gpadmin: 

psql (9.4.24)

Type "help" for help.


gp_sydb=# \l

                               List of databases

   Name    |  Owner  | Encoding |  Collate   |   Ctype    |  Access privileges  

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

 gp_sydb   | gpadmin | UTF8     | en_US.utf8 | en_US.utf8 | 

 postgres  | gpadmin | UTF8     | en_US.utf8 | en_US.utf8 | 

 template0 | gpadmin | UTF8     | en_US.utf8 | en_US.utf8 | =c/gpadmin         +

           |         |          |            |            | gpadmin=CTc/gpadmin

 template1 | gpadmin | UTF8     | en_US.utf8 | en_US.utf8 | =c/gpadmin         +

           |         |          |            |            | gpadmin=CTc/gpadmin

(4 rows)


建立測試庫:

gp_sydb=# create database test;

CREATE DATABASE


gp_sydb=# \c test

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

test=# 

test=# 

test=# create table test (id int primary key,name varchar(10));

CREATE TABLE

test=# 

test=# 

test=# \d test

            Table "public.test"

 Column |         Type          | Modifiers 

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

 id     | integer               | not null

 name   | character varying(10) | 

Indexes:

    "test_pkey" PRIMARY KEY, btree (id)

Distributed by: (id)




test=# insert into test values(1,'zhengzhou');

INSERT 0 1

test=# insert into test values(2,'hangzhou'); 

INSERT 0 1

test=# insert into test values(3,'wenzhou'); 

INSERT 0 1

test=# insert into test values(4,'suizhou');

INSERT 0 1

test=# select * from test;

 id |   name    

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

  1 | zhengzhou

  3 | wenzhou

  4 | suizhou

  2 | hangzhou

(4 rows)


增加standy master方法:

[gpadmin@mdw ~]$ gpinitstandby -s sdw2

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Validating environment and parameters for standby initialization...

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Checking for data directory /opt/greenplum/data/master/gpseg-1 on sdw2

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:------------------------------------------------------

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master initialization parameters

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:------------------------------------------------------

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum master hostname               = mdw

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum master data directory         = /opt/greenplum/data/master/gpseg-1

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum master port                   = 6530

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master hostname       = sdw2

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master port           = 6530

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum standby master data directory = /opt/greenplum/data/master/gpseg-1

20200909:14:29:55:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Greenplum update system catalog         = On

Do you want to continue with standby master initialization? Yy|Nn (default=N):

> Y

20200909:14:30:02:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Syncing Greenplum Database extensions to standby

20200909:14:30:02:200079 gpinitstandby:mdw:gpadmin-[INFO]:-The packages on sdw2 are consistent.

20200909:14:30:02:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Adding standby master to catalog...

20200909:14:30:02:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Database catalog updated successfully.

20200909:14:30:02:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Updating pg_hba.conf file...

20200909:14:30:04:200079 gpinitstandby:mdw:gpadmin-[INFO]:-pg_hba.conf files updated successfully.

20200909:14:30:16:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Starting standby master

20200909:14:30:16:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Checking if standby master is running on host: sdw2  in directory: /opt/greenplum/data/master/gpseg-1

20200909:14:30:26:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Cleaning up pg_hba.conf backup files...

20200909:14:30:27:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Backup files of pg_hba.conf cleaned up successfully.

20200909:14:30:27:200079 gpinitstandby:mdw:gpadmin-[INFO]:-Successfully created standby master on sdw2


檢視standby master狀態:

[gpadmin@mdw ~]$ gpstate -f

20200909:14:38:04:211012 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: -f

20200909:14:38:04:211012 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0'

20200909:14:38:04:211012 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.24 (Greenplum Database 6.9.0 build commit:ef010af28862a0fed172ca96620cc1037aac71a0) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Jun 29 2020 22:58:53'

20200909:14:38:04:211012 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:-Standby master details

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:-----------------------

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:-   Standby address          = sdw2

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:-   Standby data directory   = /opt/greenplum/data/master/gpseg-1

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:-   Standby port             = 6530

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:-   Standby PID              = 158229

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:-   Standby status           = Standby host passive

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--pg_stat_replication

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--WAL Sender State: streaming

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--Sync state: sync

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--Sent Location: 0/C0000A8

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--Flush Location: 0/C0000A8

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--Replay Location: 0/C0000A8

20200909:14:38:05:211012 gpstate:mdw:gpadmin-[INFO]:--------------------------------------------------------------

[gpadmin@mdw ~]$ 



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2726898/,如需轉載,請註明出處,否則將追究法律責任。

相關文章