greenPlum使用手册

Posted fann

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了greenPlum使用手册相关的知识,希望对你有一定的参考价值。

Greenplum使用简明手册

GP服务启停
su - gpadmin

gpstart #正常启动

gpstop #正常关闭

gpstop -M fast #快速关闭

gpstop –r #重启

gpstop –u #重新加载配置文件

登陆与退出Greenplum
#正常登陆

psql gpdb

psql -d gpdb -h gphostm -p 5432 -U gpadmin

#使用utility方式

PGOPTIONS="-c gp_session_role=utility" psql -h -d dbname hostname -p port

#退出

在psql命令行执行\q

参数查询
psql -c ‘SHOW ALL;‘ -d gpdb

gpconfig --show max_connections

创建数据库
createdb -h localhost -p 5432 dhdw

创建GP文件系统
# 文件系统名

gpfsdw

# 子节点,视segment数创建目录

mkdir -p /gpfsdw/seg1

mkdir -p /gpfsdw/seg2

chown -R gpadmin:gpadmin /gpfsdw

# 主节点

mkdir -p /gpfsdw/master

chown -R gpadmin:gpadmin /gpfsdw

gpfilespace -o gpfilespace_config

gpfilespace -c gpfilespace_config

创建GP表空间
psql gpdb

create tablespace TBS_DW_DATA filespace gpfsdw;

SET default_tablespace = TBS_DW_DATA;

删除GP数据库
gpdeletesystem -d /gpmaster/gpseg-1 -f

查看segment配置

select * from gp_segment_configuration;

文件系统

select * from pg_filespace_entry;

磁盘、数据库空间

SELECT * FROM gp_toolkit.gp_disk_free ORDER BY dfsegment;

SELECT * FROM gp_toolkit.gp_size_of_database ORDER BY sodddatname;

日志

SELECT * FROM gp_toolkit.__gp_log_master_ext;

SELECT * FROM gp_toolkit.__gp_log_segment_ext;

表描述

/d+ <tablename>

表分析

VACUUM ANALYZE tablename;

表数据分布

SELECT gp_segment_id, count(*) FROM <table_name> GROUP BY gp_segment_id;

表占用空间

SELECT relname as name, sotdsize/1024/1024 as size_MB, sotdtoastsize as toast, sotdadditionalsize as other

FROM gp_toolkit.gp_size_of_table_disk as sotd, pg_class

WHERE sotd.sotdoid = pg_class.oid ORDER BY relname;

索引占用空间

SELECT soisize/1024/1024 as size_MB, relname as indexname

FROM pg_class, gp_toolkit.gp_size_of_index

WHERE pg_class.oid = gp_size_of_index.soioid

AND pg_class.relkind=‘i‘;

OBJECT的操作统计

SELECT schemaname as schema, objname as table, usename as role, actionname as action, subtype as type, statime as time

FROM pg_stat_operations

WHERE objname = ‘<name>‘;

SELECT locktype, database, c.relname, l.relation, l.transactionid, l.transaction, l.pid, l.mode, l.granted, a.current_query

FROM pg_locks l, pg_class c, pg_stat_activity a

WHERE l.relation=c.oid

AND l.pid=a.procpid

ORDER BY c.relname;

队列

SELECT * FROM pg_resqueue_status;

 

加载(LOAD)数据到Greenplum数据库
gpfdist外部表

# 启动服务

gpfdist -d /share/txt -p 8081 –l /share/txt/gpfdist.log &

# 创建外部表,分隔符为’/t’

drop EXTERNAL TABLE TD_APP_LOG_BUYER;

CREATE EXTERNAL TABLE TD_APP_LOG_BUYER (

IP text,

ACCESSTIME text,

REQMETHOD text,

URL text,

STATUSCODE int,

REF text,

name text,

VID text)

LOCATION (‘gpfdist://gphostm:8081/xxx.txt‘)

FORMAT ‘TEXT‘ (DELIMITER E‘/t‘

FILL MISSING FIELDS) SEGMENT REJECT LIMIT 1 percent;

# 创建普通表

create table test select * from TD_APP_LOG_BUYER;

# 索引

# CREATE INDEX idx_test ON test USING bitmap (ip);

# 查询数据

select ip , count(*) from test group by ip order by count(*);

gpload

# 创建控制文件

# 加载数据

gpload -f my_load.yml

copy

COPY country FROM ‘/data/gpdb/country_data‘

WITH DELIMITER ‘|‘ LOG ERRORS INTO err_country

SEGMENT REJECT LIMIT 10 ROWS;

从Greenplum数据库卸载(UNLOAD)数据
gpfdist外部表

# 创建可写外部表

CREATE WRITABLE EXTERNAL TABLE unload_expenses

( LIKE expenses )

LOCATION (‘gpfdist://etlhost-1:8081/expenses1.out‘,

‘gpfdist://etlhost-2:8081/expenses2.out‘)

FORMAT ‘TEXT‘ (DELIMITER ‘,‘)

DISTRIBUTED BY (exp_id);

# 写权限

GRANT INSERT ON writable_ext_table TO <name>;

# 写数据

INSERT INTO writable_ext_table SELECT * FROM regular_table;

copy

COPY (SELECT * FROM country WHERE country_name LIKE ‘A%‘) TO ‘/home/gpadmin/a_list_countries.out‘;

执行sql文件

psql gpdbname –f yoursqlfile.sql

或者psql登陆后执行

\i yoursqlfile.sql

以上是关于greenPlum使用手册的主要内容,如果未能解决你的问题,请参考以下文章

Greenplum-cc-web安装

OpenCV中文手册如何使用

hbs使用手册

谁有FreeBSD的使用手册啊?

Apache Druid的SQL查询使用手册

STM32相关手册使用记录