docker安装Greenplum

2022-10-27 13:39:23 浏览数 (3)

Greenplum是业界最快最高性价比的关系型分布式数据库,它在开源的PostgreSQL的基础上采用MPP架构(Massive Parallel Processing,海量并行处理),具有强大的大规模数据分析任务处理能力。

# 1.下载镜像

代码语言:javascript复制
docker pull pivotaldata/gpdb-devel

# 2.运行容器

代码语言:javascript复制
docker run -it -p 15430:15432 --name gpdb0 -v /root/greenplum-db-gpdb-sandbox-tutorials-d734733/:/workspace/gpdb/tutorials -d pivotaldata/gpdb-devel

# 3.进入容器

代码语言:javascript复制
docker exec -it gpdb0 bash

# 4.首次切换gpadmin用户,自动启动gp数据库

代码语言:javascript复制
bash-4.1# su gpadmin
/workspace/gpdb/gpAux/gpdemo /workspace/gpdb
======================================================================
            ______  _____  ______  _______ _______  _____
           |  ____ |_____] |      |______ |  |  | |     |
           |_____| |       |_____/ |______ |  |  | |_____|

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


  This is a demo of the Greenplum Database system.  We will create
  a cluster installation with master and 6 segment instances
  (3 primary & 3 mirror).

    GPHOME ................. : /usr/local/gpdb
    MASTER_DATA_DIRECTORY .. : /workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1

    MASTER PORT (PGPORT) ... : 15432
    SEGMENT PORTS .......... : 25432 25433 25434 25435 25436 25437 25438 25439 25440 25441 25442 25443

  NOTE(s):

    * The DB ports identified above must be available for use.
    * An environment file gpdemo-env.sh has been created for your use.

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

==========================================================================================
executing:
  /usr/local/gpdb/bin/gpinitsystem -a -c clusterConfigFile -l /workspace/gpdb/gpAux/gpdemo/datadirs/gpAdminLogs ""
==========================================================================================


。。。省略部分输出



            gp_opt_version             
---------------------------------------
 Server has been compiled without ORCA
(1 row)

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


/workspace/gpdb

# 5.创建用户

代码语言:javascript复制
bash-4.1$ createuser -P dlw  
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
NOTICE:  resource queue required -- using default resource queue "pg_default"

# 6.创建数据库

代码语言:javascript复制
bash-4.1$ createdb dlwdb
bash-4.1$ psql dlwdb    
psql (8.3.23)
Type "help" for help.
执行help查看命令帮助
dlwdb=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  copyright for distribution terms
       h for help with SQL commands
       ? for help with psql commands
       g or terminate with semicolon to execute query
       q to quit

# 7.添加用户

代码语言:javascript复制
dlwdb=# CREATE USER cyj WITH PASSWORD 'cyj' NOSUPERUSER;            
NOTICE:  resource queue required -- using default resource queue "pg_default"
CREATE ROLE

# 8.创建用户组并添加用户进去

代码语言:javascript复制
dlwdb=# CREATE ROLE dcyls;
NOTICE:  resource queue required -- using default resource queue "pg_default"
CREATE ROLE
dlwdb=# GRANT dcyls TO dlw,cyj; 
GRANT ROLE
dlwdb=# du
                       List of roles
 Role name |            Attributes             | Member of 
----------- ----------------------------------- -----------
 cyj       |                                   | {dcyls}
 dcyls     | Cannot login                      | {}
 dlw       | Create DB                         | {dcyls}
 gpadmin   | Superuser, Create role, Create DB | {}

# 9.重启容器

容器暂停后,下次启动会出现报错,提示ssh连接问题

代码语言:javascript复制
[root@summer ~]# docker restart gpdb0
gpdb0
[root@summer ~]# docker exec -it gpdb0 bash
bash-4.1# su gpadmin
bash-4.1$ gpstart
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Starting gpstart with args: 
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Gathering information and validating the environment...
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 4.3.99.00 build dev'
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Greenplum Catalog Version: '301605129'
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[WARNING]:-postmaster.pid file exists on Master, checking if recovery startup required
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Commencing recovery startup checks
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Have lock file /tmp/.s.PGSQL.15432 but no process running on port 15432
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-No Master instance process, entering recovery startup mode
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Clearing Master instance lock files
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Clearing Master instance pid file
20201127:07:28:50:000017 gpstart:487243160c73:gpadmin-[INFO]:-Starting Master instance in admin mode
20201127:07:28:53:000017 gpstart:487243160c73:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20201127:07:28:53:000017 gpstart:487243160c73:gpadmin-[INFO]:-Obtaining Segment details from master...
20201127:07:28:53:000017 gpstart:487243160c73:gpadmin-[INFO]:-Setting new master era
20201127:07:28:53:000017 gpstart:487243160c73:gpadmin-[INFO]:-Commencing forced instance shutdown
20201127:07:28:54:000017 gpstart:487243160c73:gpadmin-[INFO]:-Starting Master instance in admin mode
20201127:07:28:55:000017 gpstart:487243160c73:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20201127:07:28:55:000017 gpstart:487243160c73:gpadmin-[INFO]:-Obtaining Segment details from master...
20201127:07:28:55:000017 gpstart:487243160c73:gpadmin-[INFO]:-Setting new master era
20201127:07:28:55:000017 gpstart:487243160c73:gpadmin-[INFO]:-Master Started...
20201127:07:28:55:000017 gpstart:487243160c73:gpadmin-[INFO]:-Shutting down master
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:---------------------------
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-Master instance parameters
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:---------------------------
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-Database                 = template1
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-Master Port              = 15432
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-Master directory         = /workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-Timeout                  = 600 seconds
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-Master standby           = Off 
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:---------------------------------------
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-Segment instances that will be started
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:---------------------------------------
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-   Host           Datadir                                                             Port    Role
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast1/demoDataDir0          25432   Primary
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror1/demoDataDir0   25435   Mirror
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast2/demoDataDir1          25433   Primary
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror2/demoDataDir1   25436   Mirror
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast3/demoDataDir2          25434   Primary
20201127:07:28:57:000017 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror3/demoDataDir2   25437   Mirror

Continue with Greenplum instance startup Yy|Nn (default=N):
> y
20201127:07:29:16:000017 gpstart:487243160c73:gpadmin-[INFO]:-Commencing parallel primary and mirror segment instance startup, please wait...
. 
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-Process results...
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[ERROR]:-No segment started for content: 0.
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-dumping success segments: []
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-DBID:2  FAILED  host:'487243160c73' datadir:'/workspace/gpdb/gpAux/gpdemo/datadirs/dbfast1/demoDataDir0' with reason:'cmd had rc=255 completed=True halted=False
  stdout=''
  stderr='ssh: connect to host 487243160c73 port 22: Connection refused
''
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-DBID:5  FAILED  host:'487243160c73' datadir:'/workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror1/demoDataDir0' with reason:'cmd had rc=255 completed=True halted=False
  stdout=''
  stderr='ssh: connect to host 487243160c73 port 22: Connection refused
''
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-DBID:3  FAILED  host:'487243160c73' datadir:'/workspace/gpdb/gpAux/gpdemo/datadirs/dbfast2/demoDataDir1' with reason:'cmd had rc=255 completed=True halted=False
  stdout=''
  stderr='ssh: connect to host 487243160c73 port 22: Connection refused
''
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-DBID:6  FAILED  host:'487243160c73' datadir:'/workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror2/demoDataDir1' with reason:'cmd had rc=255 completed=True halted=False
  stdout=''
  stderr='ssh: connect to host 487243160c73 port 22: Connection refused
''
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-DBID:4  FAILED  host:'487243160c73' datadir:'/workspace/gpdb/gpAux/gpdemo/datadirs/dbfast3/demoDataDir2' with reason:'cmd had rc=255 completed=True halted=False
  stdout=''
  stderr='ssh: connect to host 487243160c73 port 22: Connection refused
''
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-DBID:7  FAILED  host:'487243160c73' datadir:'/workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror3/demoDataDir2' with reason:'cmd had rc=255 completed=True halted=False
  stdout=''
  stderr='ssh: connect to host 487243160c73 port 22: Connection refused
''
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------


20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-   Successful segment starts                                            = 0
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[WARNING]:-Failed segment starts                                                = 6   <<<<<<<<
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-   Skipped segment starts (segments are marked down in configuration)   = 0
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-Successfully started 0 of 6 segment instances <<<<<<<<
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[WARNING]:-Segment instance startup failures reported
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[WARNING]:-Failed start 6 of 6 segment instances <<<<<<<<
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[WARNING]:-Review /home/gpadmin/gpAdminLogs/gpstart_20201127.log
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:29:17:000017 gpstart:487243160c73:gpadmin-[INFO]:-Commencing parallel segment instance shutdown, please wait...
. 
 
20201127:07:29:18:000017 gpstart:487243160c73:gpadmin-[ERROR]:-gpstart error: Do not have enough valid segments to start the array.
  • 看下ssh服务,第一次启动的时候应该是启动脚本里附带了启动sshd服务,之后再启动,需要自己手动启动下sshd服务
代码语言:javascript复制
bash-4.1$ ps -e|grep ssh
bash-4.1$ service sshd restart
/etc/init.d/sshd: line 33: /etc/sysconfig/sshd: Permission denied
rm: cannot remove `/var/run/sshd.pid': Permission denied   [FAILED]
rm: cannot remove `/var/lock/subsys/sshd': Permission denied

Starting sshd: /etc/ssh/sshd_config: Permission denied
                                                           [FAILED]
bash-4.1$ service sshd start
/etc/init.d/sshd: line 33: /etc/sysconfig/sshd: Permission denied
Starting sshd: /etc/ssh/sshd_config: Permission denied
                                                           [FAILED]
bash-4.1$ exit
exit
bash-4.1# service sshd start
Starting sshd:                                             [  OK  ]
bash-4.1# su gpadmin
bash-4.1$ gpstart
20201127:07:38:51:000187 gpstart:487243160c73:gpadmin-[INFO]:-Starting gpstart with args: 
20201127:07:38:51:000187 gpstart:487243160c73:gpadmin-[INFO]:-Gathering information and validating the environment...
20201127:07:38:52:000187 gpstart:487243160c73:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 4.3.99.00 build dev'
20201127:07:38:52:000187 gpstart:487243160c73:gpadmin-[INFO]:-Greenplum Catalog Version: '301605129'
20201127:07:38:52:000187 gpstart:487243160c73:gpadmin-[INFO]:-Starting Master instance in admin mode
20201127:07:38:54:000187 gpstart:487243160c73:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20201127:07:38:54:000187 gpstart:487243160c73:gpadmin-[INFO]:-Obtaining Segment details from master...
20201127:07:38:55:000187 gpstart:487243160c73:gpadmin-[INFO]:-Setting new master era
20201127:07:38:55:000187 gpstart:487243160c73:gpadmin-[INFO]:-Master Started...
20201127:07:38:55:000187 gpstart:487243160c73:gpadmin-[INFO]:-Shutting down master
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:---------------------------
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-Master instance parameters
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:---------------------------
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-Database                 = template1
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-Master Port              = 15432
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-Master directory         = /workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-Timeout                  = 600 seconds
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-Master standby           = Off 
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:---------------------------------------
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-Segment instances that will be started
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:---------------------------------------
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-   Host           Datadir                                                             Port    Role
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast1/demoDataDir0          25432   Primary
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror1/demoDataDir0   25435   Mirror
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast2/demoDataDir1          25433   Primary
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror2/demoDataDir1   25436   Mirror
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast3/demoDataDir2          25434   Primary
20201127:07:38:56:000187 gpstart:487243160c73:gpadmin-[INFO]:-   487243160c73   /workspace/gpdb/gpAux/gpdemo/datadirs/dbfast_mirror3/demoDataDir2   25437   Mirror

Continue with Greenplum instance startup Yy|Nn (default=N):
> y
20201127:07:39:04:000187 gpstart:487243160c73:gpadmin-[INFO]:-Commencing parallel primary and mirror segment instance startup, please wait...
... 
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-Process results...
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-   Successful segment starts                                            = 6
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-   Failed segment starts                                                = 0
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-   Skipped segment starts (segments are marked down in configuration)   = 0
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-Successfully started 6 of 6 segment instances 
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-----------------------------------------------------
20201127:07:39:07:000187 gpstart:487243160c73:gpadmin-[INFO]:-Starting Master instance 487243160c73 directory /workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 
20201127:07:39:09:000187 gpstart:487243160c73:gpadmin-[INFO]:-Command pg_ctl reports Master 487243160c73 instance active
20201127:07:39:09:000187 gpstart:487243160c73:gpadmin-[INFO]:-No standby master configured.  skipping...
20201127:07:39:09:000187 gpstart:487243160c73:gpadmin-[INFO]:-Database successfully started
bash-4.1$ 

0 人点赞