Docker启动单机版GreenPlum(GPDB)数据库

下载镜像

# docker pull pivotaldata/gpdb-devel

运行容器

# docker run -it -p 15430:15432 --name gpdb0 -v /root/greenplum-db-gpdb-sandbox-tutorials-d734733/:/workspace/gpdb/tutorials -d pivotaldata/gpdb-devel

进入容器

# docker exec -it gpdb0 bash

首次切换gpadmin用户,会自动启动gp数据库

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

创建用户

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"

创建数据库

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

在数据库中创建用户

dlwdb=# CREATE USER cyj WITH PASSWORD 'cyj' NOSUPERUSER;            
NOTICE:  resource queue required -- using default resource queue "pg_default"
CREATE ROLE

创建用户组并添加用户进去

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 | {}

重启容器

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值