Docker 中部署 Greenplum

2023年 8月 12日 75.7k 0

一、环境准备Dockerdocker-composecentos:7.5.1804 的 docker 镜像greenplum-db-5.14.0-rhel7-x86_64.bin 二进制文件1、查看 docker 和 docker-compose 版本

[bigdata@local-vm-320 gp]$ docker -v

Docker version 19.03.5, build 633a0ea

[bigdata@local-vm-320 gp]$ docker-compose -v

docker-compose version 1.25.1, build a82fef0

2、greenplum-db 下载地址:

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

二、准备 gp docker 环境1、创建 GreenPlum Docker 镜像文件 Dockerfile

FROM centos:7.5.1804RUN yum -y update; yum clean allRUN yum install -y \ net-tools \ ntp \ openssh-server \ openssh-clients \ less \ iproute \ which; yum clean allRUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''RUN groupadd gpadminRUN useradd gpadmin -g gpadminRUN echo gpadmin | passwd gpadmin --stdinENTRYPOINT ["/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

三、部署 gp1、通过 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文件。

[bigdata@local-vm-320 ~]$ docker exec -it gpdb-mdw /bin/bash[root@2e9585e22e2e /]# su - gpadminLast login: Sat May 9 07:26:03 UTC 2020 from 2e9585e22e2e on pts/6

3、执行greenplum的bin文件,将其安装在/home/gpadmin目录下.

[gpadmin@2e9585e22e2e ~]$ 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 toaccept 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 availablefor download at http://gpdb.docs.pivotal.io********************************************************************************[gpadmin@67758e384c8c ~]$ lsgreenplum-db greenplum-db-5.14.0 greenplum-db-5.14.0-rhel7-x86_64.bin

4、创建目录 /home/gpadmin/gpconfig/ 和 文件 hostlist、seglist

[gpadmin@2e9585e22e2e ~]$ mkdir -p /home/gpadmin/gpconfig/

[gpadmin@2e9585e22e2e ~]$ cd /home/gpadmin/gpconfig/

[gpadmin@2e9585e22e2e ~]$ vi hostlist

[gpadmin@2e9585e22e2e ~]$ vi seglist

hostlist 内容如下

mdwsdw1sdw2

seglist 内容如下

sdw1sdw2

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

[gpadmin@2e9585e22e2e ~]$ cd

[gpadmin@2e9585e22e2e ~]$ source ~/greenplum-db/greenplum_path.sh

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

[gpadmin@2e9585e22e2e ~]$ gpssh-exkeys -f /home/gpadmin/gpconfig/hostlist

输入 sdw1 密码:gpadmin

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

[gpadmin@2e9585e22e2e ~]$ gpseginstall -f /home/gpadmin/gpconfig/seglist

8、Confirm installation

[gpadmin@2e9585e22e2e ~]$ gpssh -f ~/gpconfig/hostlist -e ls -l $GPHOME

9、Creating the Data Storage Areas

on master

[gpadmin@2e9585e22e2e ~]$ mkdir -p ~/data/master

on segments

[gpadmin@2e9585e22e2e ~]$ gpssh -f ~/gpconfig/seglist -e "mkdir -p ~/data/primary"[sdw1] mkdir -p ~/data/primary[sdw2] mkdir -p ~/data/primary[gpadmin@2e9585e22e2e ~]$ 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

[gpadmin@67758e384c8c ~]$ 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

12、run the initialization utility

[gpadmin@2e9585e22e2e ~]$ gpinitsystem -c gpconfig/gpinitsystem_config -h gpconfig/seglist

参考内容如下:

[gpadmin@2e9585e22e2e ~]$ 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_config20200509:07:37:09:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Locale has not been set in gpconfig/gpinitsystem_config, will set to default value20200509:07:37:09:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Locale set to en_US.utf820200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[WARN]:-Master hostname mdw does not match hostname output20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking to see if mdw can be resolved on this host20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Can resolve mdw to this host20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-No DATABASE_NAME set, will exit following template1 updates20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-MASTER_MAX_CONNECT not set, will set to default value 25020200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checking configuration parameters, Completed20200509: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 array20200509:07:37:10:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Commencing multi-home checks, Completed20200509: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 host20200509: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, Completed20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Database Creation Parameters20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:---------------------------------------20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master Configuration20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:---------------------------------------20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master instance name = Greenplum Data Platform20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master hostname = mdw20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master port = 543220200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master instance dir = /home/gpadmin/data/master/gpseg-120200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master LOCALE = en_US.utf820200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Greenplum segment prefix = gpseg20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master Database = 20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master connections = 25020200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master buffers = 128000kB20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Segment connections = 75020200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Segment buffers = 128000kB20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Checkpoint segments = 820200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Encoding = UNICODE20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Postgres param file = Off20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Initdb to be used = /home/gpadmin/greenplum-db/./bin/initdb20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-GP_LIBRARY_PATH is = /home/gpadmin/greenplum-db/./lib20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-HEAP_CHECKSUM is = on20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-HBA_HOSTNAMES is = 020200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Ulimit check = Passed20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Array host connect type = Single hostname per node20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Master IP address [1] = 172.24.0.320200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Standby Master = Not Configured20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Primary segment # = 120200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total Database segments = 220200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Trusted shell = ssh20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Number segment hosts = 220200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Mirroring config = OFF20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:----------------------------------------20200509:07:37:14:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Greenplum Primary Segment Configuration20200509: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 020200509: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):> y20200509: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 mode20200509:07:37:45:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Commencing parallel build of primary segment instances20200509: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 status20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:------------------------------------------------20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total processes marked as completed = 220200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total processes marked as killed = 020200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Total processes marked as failed = 020200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:------------------------------------------------20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Deleting distributed backout files20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Removing back out file20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-No errors generated from parallel processes20200509:07:38:00:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Restarting the Greenplum instance in production mode20200509: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-120200509: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 information20200509: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 database20200509: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=2e9585e22e2e20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=immediate20200509:07:38:02:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Master segment instance directory=/home/gpadmin/data/master/gpseg-120200509:07:38:04:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Attempting forceful termination of any leftover master process20200509:07:38:06:004564 gpstop:2e9585e22e2e:gpadmin-[INFO]:-Terminating processes for segment /home/gpadmin/data/master/gpseg-120200509:07:38:07:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Starting gpstart with args: -a -l /home/gpadmin/gpAdminLogs -d /home/gpadmin/data/master/gpseg-120200509: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 mode20200509:07:38:12:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information20200509: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 era20200509:07:38:13:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Master Started...20200509:07:38:14:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Shutting down master20200509: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 = 220200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:- Failed segment starts = 020200509:07:38:29:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 020200509: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 active20200509:07:38:33:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-No standby master configured. skipping...20200509:07:38:33:004590 gpstart:2e9585e22e2e:gpadmin-[INFO]:-Database successfully started20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Completed restart of Greenplum instance in production mode20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Scanning utility log file for any warning messages20200509: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 errors20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[WARN]:-were generated during the array creation20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Please review contents of log file20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-/home/gpadmin/gpAdminLogs/gpinitsystem_20200509.log20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-To determine level of criticality20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-These messages could be from a previous run of the utility20200509: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 created20200509: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 following20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-1. Ensure that the greenplum_path.sh file is sourced20200509: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 scripts20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:- Example gpstate -d /home/gpadmin/data/master/gpseg-120200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Script log file = /home/gpadmin/gpAdminLogs/gpinitsystem_20200509.log20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-To remove instance, run gpdeletesystem utility20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-To initialize a Standby Master Segment for this Greenplum instance20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Review options for gpinitstandby20200509: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 gpinitsystem20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-has been configured to allow all hosts within this new20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-array to intercommunicate. Any hosts external to this20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-new array must be explicitly added to this file20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-Refer to the Greenplum Admin support guide which is20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-located in the /home/gpadmin/greenplum-db/./docs directory20200509:07:38:33:002513 gpinitsystem:2e9585e22e2e:gpadmin-[INFO]:-------------------------------------------------------

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

如红色字体

四、如何使用 gp1、配置环境变量

vi ~/.bashrc

增加如下内容

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

source ~/greenplum-db/greenplum_path.sh

配置生效

source ~/.bashrc

2、登录 gp

[gpadmin@2e9585e22e2e lib]$ psql -d postgres -h localhost -p 5432 -U gpadmin psql (8.3.23)Type "help" for help.

postgres=# \cYou 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 roleCommand: CREATE ROLEDescription: define a new database roleSyntax: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文件,来赋予用户的远程登录权限。

[gpadmin@2e9585e22e2e gpseg-1]$ cd /home/gpadmin/data/master/gpseg-1[gpadmin@2e9585e22e2e gpseg-1]$ vi pg_hba.conf

增加如下内容

host all guanjiangmiao 0.0.0.0/0 md5

5、通过gpstop –u命令重新加载配置文件,使之生效后,guanjiangmiao 用户即可远程访问数据库了。

[gpadmin@ca279251422f greenplum-db]$ pwd/home/gpadmin/greenplum-db[gpadmin@ca279251422f greenplum-db]$ bin/gpstop -u

[gpadmin@a5b60ff4b8b9 greenplum-db]$ psql -d postgres -h 127.0.0.1 -p 5432 -U guanjiangmiaoPassword 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

[gpadmin@ca279251422f bin]$ gpstop -uImportError: No module named site

解决步骤:

(1)查找site相关文件的路径

[root@ca279251422f /]# 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)增加路径到环境变量

[gpadmin@ca279251422f ~]$ 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

[gpadmin@ca279251422f greenplum-db]$ bin/gpstop -uTraceback (most recent call last): File "bin/gpstop", line 9, in 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!

[gpadmin@ca279251422f greenplum-db]$ bin/gpstop -u20200511:02:37:34:002935 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -u20200511: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.shexport MASTER_DATA_DIRECTORY=/home/gpadmin/data/master/gpseg-1export PGPORT=5432export PGUSER=gpadmin

(2)让配置生效

source greenplum_path.sh

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

[gpadmin@ca279251422f greenplum-db]$ bin/gpstop -u 20200511:03:15:35:000105 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -u20200511: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

[gpadmin@ca279251422f gpseg-1]$ gpstop -af20200511:03:43:08:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -af20200511: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 information20200511: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 database20200511: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=ca279251422f20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Detected 0 connections to database20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Using standard WAIT mode of 120 seconds20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=fast20200511:03:43:11:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Master segment instance directory=/home/gpadmin/data/master/gpseg-120200511:03:43:13:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Attempting forceful termination of any leftover master process20200511:03:43:14:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Terminating processes for segment /home/gpadmin/data/master/gpseg-120200511:03:43:15:000464 gpstop:ca279251422f:gpadmin-[INFO]:-No standby master host configured20200511:03:43:15:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Targeting dbid [2, 3] for shutdown20200511: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 completed20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-100.00% of jobs completed20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-----------------------------------------------------20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:- Segments stopped successfully = 220200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:- Segments with errors during stop = 020200511: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 reported20200511:03:43:22:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Cleaning up leftover gpmmon process20200511:03:43:23:000464 gpstop:ca279251422f:gpadmin-[INFO]:-No leftover gpmmon process found20200511:03:43:23:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Cleaning up leftover gpsmon processes20200511:03:43:24:000464 gpstop:ca279251422f:gpadmin-[INFO]:-No leftover gpsmon processes on some hosts. not attempting forceful termination on these hosts20200511:03:43:24:000464 gpstop:ca279251422f:gpadmin-[INFO]:-Cleaning up leftover shared memory[gpadmin@ca279251422f gpseg-1]$ gpstart -a20200511:03:43:34:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Starting gpstart with args: -a20200511: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 mode20200511:03:43:39:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information20200511: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 era20200511:03:43:40:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Master Started...20200511:03:43:41:000555 gpstart:ca279251422f:gpadmin-[INFO]:-Shutting down master20200511: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 = 220200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:- Failed segment starts = 020200511:03:43:57:000555 gpstart:ca279251422f:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 020200511: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 active20200511: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[gpadmin@ca279251422f gpseg-1]$ [gpadmin@ca279251422f gpseg-1]$ gpstop -u20200511:03:44:18:000634 gpstop:ca279251422f:gpadmin-[INFO]:-Starting gpstop with args: -u20200511: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 information20200511: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..

本文来源:https://blog.csdn.net/magic_kid_2010/article/details/106020689

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论