下载镜像
# 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 | {}
重启容器

最低0.47元/天 解锁文章
1651

被折叠的 条评论
为什么被折叠?



