GreenPlum 实用手册(日常维护)
1.0 数据库的连接设置
1.0 数据库安装成功后,首先编辑连接配置:
打开$MASTER_DATA_DIRECTORY/pg_hba.conf进行编辑,拿当前安装的数据库举例:
vi /opt/greenplum/master/gpseg-1/pg_hba.conf
添加:
#host database role CIDR-address authentication-method
host all gpadmin 0.0.0.0/0 trust
或
host all all 0.0.0.0/0 md5
其中:trust表示信任关系,连接时无需输入密码;而为md5时,需要输入密码。
2.0 编辑结束保存后,执行如下命令:
gpstop -u
-u:不停止数据库,只加载pg_hba.conf 和postgresql.conf中运行时参数,当改动参数配置时候使用。
//表示gp重新加载
2.0 限制数据库的并发连接
配置文件所在位置:$MASTER_DATA_DIRECTORY/postgresql.conf,打开进行编辑(一般默认250,也可不做修改),如:
vi /opt/greenplum/master/gpseg-1/postgresql.conf
修改master主机配置为:
max_connections=100
max_prepared_transactions=100
修改segment主机配置为:
max_connections=500
max_prepared_transactions=100
变更允许连接数,步骤如下:
a) 在master主机上用gpadmin用户登录;
b) 执行:source /usr/local/greenplum-db/greenplum_path.sh
c) 设置max_connections、参数值
$ gpconfig -c max_connections -v 100 -m 500
$ gpconfig -c max_prepared_transactions -v 100
d) 重启GP数据库
gpstop –r
e) 在master主机与segment主机执行下面操作来进行check,
gpconfig -s max_connections
3.0 数据库的登录与退出
#正常登陆
psql gpdb
psql -d gpdb -h gphostm -p 5432 -U gpadmin
-c, --command=COMMAND run only single command (SQL or internal) and exit
-d, --dbname=DBNAME database name to connect to (default: "gpadmin")
-h, --host=HOSTNAME database server host or socket directory (default: "local socket")
-p, --port=PORT database server port (default: "5432")
-U, --username=USERNAME database user name (default: "gpadmin")
如:启动template1默认的数据库 psql -d template1
进入已连接的数据库,查看帮助信息,如下:
template1=# 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
#使用utility方式
PGOPTIONS="-c gp_session_role=utility" psql -h -d dbname hostname -p port
#退出
在psql命令行执行\q
4.0 创建数据库
4.1 创建用户及权限
进入template1数据库后,:
create user noas with LOGIN CONNECTION LIMIT 250 ENCRYPTED PASSWORD 'noas' ;
4.2 创建gpfilespace,如下:
gpadmin@linux-82:~> gpfilespace -o gpfilespace_config
20140418:14:21:07:058871 gpfilespace:linux-82:gpadmin-[INFO]:-
A tablespace requires a file system location to store