5.客户端接口和程序
5.1.配置客户端认证
5.1.1.允许连接到GPDB,在Master节点上编辑pg_hba.conf 文件
1) 依次查看Master节点和Slave节点中该文件:
| [gpadmin@master gpseg-1]$ pwd /data/master/gpseg-1 [gpadmin@master gpseg-1]$ cat pg_hba.conf # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only # IPv4 local connections: # IPv6 local connections: local all gpadmin ident host all gpadmin 127.0.0.1/28 trust host all gpadmin 192.168.80.200/24 trust host all gpadmin ::1/128 trust host all gpadmin fe80::20c:29ff:fe9d:3bd6/128 trust |
| [gpadmin@slave1 gpseg0]$ pwd /data/primary/gpseg0 [gpadmin@slave1 gpseg0]$ cat pg_hba.conf # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/24 trust # IPv6 local connections: host all all ::1/128 trust host all all ::1/128 trust host all all 192.168.80.200/32 trust host all all fe80::20c:29ff:fe9d:3bd6/128 trust host all gpadmin 192.168.80.201/32 trust host all gpadmin ::1/128 trust host all gpadmin fe80::250:56ff:fe24:a00/128 trust |
2) 编辑文件,示例文件如下所示:
| # allow the gpadmin user local access to all databases 允许gpadmin用户连接本机所有数据库 # using ident authentication local all gpadmin ident sameuser host all gpadmin 127.0.0.1/32 ident host all gpadmin ::1/128 ident host all dba 192.168.0.0/32 md5 host all all 192.168.0.0/32 ldap ldapserver=usldap1 ldapport=1389 ldapprefix="cn=" ldapsuffix=",ou=People,dc=company,dc=com” |
3) 保存并关闭文件
4) 重新加载pg_hba.conf使修改生效
| -u (reload pg_hba.conf and postgresql.conf files only)
This option reloads the pg_hba.conf files of the master and segments and the runtime parameters of the postgresql.conf files but does not shutdown the Greenplum Database array. Use this option to make new configuration settings active after editing postgresql.conf or pg_hba.conf. Note that this only applies to configuration parameters that are designated as runtime parameters. |
| [gpadmin@master gpseg-1]$ gpstop -u 20150324:22:44:04:008787 gpstop:master:gpadmin-[INFO]:-Starting gpstop with args: -u 20150324:22:44:04:008787 gpstop:master:gpadmin-[INFO]:-Gathering information and validating the environment... 20150324:22:44:04:008787 gpstop:master:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information 20150324:22:44:04:008787 gpstop:master:gpadmin-[INFO]:-Obtaining Segment details from master... 20150324:22:44:04:008787 gpstop:master:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 4.2.8.0 build 1' 20150324:22:44:04:008787 gpstop:master:gpadmin-[INFO]:-Signalling all postmaster processes to reload |
5.1.2.限制并发连接
1) 配置Server参数max_connections来实现
2) Segment的值不能小于Master,官方建议5~10倍,实际使用经验是2~3倍;因为在Segment需要执行多个进程,所以需要更多的连接;
3) 设置依赖的参数max_prepared_transactions,至少要和Master上的max_connections值一样大
4) 修改最大连接数
a) 停止数据库
b) 分别在Master和Segment上编辑postgresql.conf文件
修改max_connections和max_prepared_transactions参数
c) 重启数据库
| Master节点核心信息: port=5432
max_connections = 250
shared_buffers = 125MB max_prepared_transactions = 250
max_fsm_pages = 200000
gp_autostats_mode=on_no_stats # none, on_no_stats, on_change. see documentation for semantics. gp_autostats_on_change_threshold=2147483647 # [0..INT_MAX]. see documentation for semantics. log_autostats=off # print additional autostats information
datestyle = 'iso, mdy' # inserted by initdb
lc_messages = 'en |