@zhangyy
2021-07-02T14:24:49.000000Z
字数 2911
阅读 206
greenplum系列
gp的参数修改方法:
修改参数
gpconfig -c shared_buffers -v 129MB -m 126MB
gpconfig -c max_connections -v 1000 -m 300
gpconfig -s shared_buffers
gpconfig -s max_connections
gpstop -u
远程登录:
psql -h 192.168.3.121 -p5432 -U gpadmin
常见优化参数:
gpconfig -c gp_vmem_protect_limit -m 16384 -v 8196
gpconfig -c shared_buffers -m 4GB -v 2GB
gpconfig -c max_connections -m 500 -v 950
gpconfig -c max_prepared_transactions -m 600 -v 1000
gpconfig -c statement_mem -v 512MB
gpconfig -c work_mem -m 1024MB -v 1024MB
#(1)全局死锁检测开关
#在Greenplum 6中其默认关闭,需要打开它才可以支持并发更新/删除操作;
gpconfig -c gp_enable_global_deadlock_detector -v on
#(2) 禁用GPORCA优化器(据说GPDB6默认的优化器为:GPORCA)
gpconfig -c optimizer -v off
#(3)关闭日志
#此GUC减少不必要的日志,避免日志输出对I/O性能的干扰。
gpconfig -c log_statement -v none
#注意:参数配置修改后,我使用gpstop -u重新加了配置,并用gpconfig -s检查了各个参数确为修改成功。
gpconfig -c wal_buffers -v 256MB
#将WAL日志缓存调大。修改该参数需要重启实例。
gpconfig -c random_page_cost -v 10
#将随机访问代价开销调小,有利于查询走索引。
gpconfig -c checkpoint_segments -v 2 --skipvalidation
#GUC影响checkpoint主动刷盘的频率,默认值8会降低刷盘频率,但是每次刷盘的数据量较大,导致整个集群瞬时的性能下降。针对OLTP大量更新类语句适当调小此设置会增加刷盘频率,但由于每次刷盘数据量变小,平均性能会有较明显提升;Greenplum 5支持此GUC但是并无明显效果,这是由于Greenplum 5的性能瓶颈并不在于I/O,而是在表锁导致的串行化。
修改参数之后重启:
gpstop -M fast
gpstart
相关使用命令
select version();
查看分段:
select * from gp_segment_configuration order by content asc,dbid;
psql -h 192.168.100.13 -p55000 -U gpadmin
(
psql: FATAL: connections to primary segments are not allowed
DETAIL: This database instance is running as a primary segment in a Greenplum cluster and does not permit direct connections.
HINT: To force a connection anyway (dangerous!), use utility mode.
)
data 节点连接
PGOPTIONS='-c gp_session_role=utility' psql -h127.0.0.1 -p55000
PGOPTIONS='-c gp_session_role=utility' psql -h192.168.100.13 -p55000
psql -h192.168.100.11 -p5432 -U gpadmin
alter role gpadmin with password 'gpadmin';
cd /greenplum/gpdata/master/gpseg-1
vim pg_hba.conf
----
到最后加上:
host all all 0.0.0.0/0 md5
----
gpstop -u
新建一个查询:
create database flyfishdb [创建一个库]
create user flyfish with password 'flyfish123.com'(创建普通用户授权)
create table flyfish_table01 (id int,name varchar(10), age int); (建表)
insert into flyfish_table01 values(1,'flyfish02',30);
insert into flyfish_table01 values(1,'flyfish03',31);
insert into flyfish_table01 values(1,'flyfish04',32);
insert into flyfish_table01 values(1,'flyfish05',33);
insert into flyfish_table01 values(1,'flyfish06',34);
insert into flyfish_table01 values(1,'flyfish07',35);
查看数据分段:
select gp_segment_id,count(*) from flyfish_table01 group by gp_segment_id;
统计数据库下表大小(包含索引)
select schemaname,tablename,round(pg_total_relation_size(schemaname||'.'||tablename)/1024/1024) "Size_MB" from pg_tables group by 1,2 order by 3 desc;
统计所有库表大小:
select datname,pg_size_pretty(pg_database_size(datname)) from pg_database;
查看当前连接数
SELECT * FROM pg_stat_activity;
psql -d postgres -c "select count(*) from pg_stat_activity"
查看某个数据库的大小
select pg_size_pretty(pg_database_size('flyfish_table01'));
查看磁盘空间:
select dfhostname, dfspace,dfdevice from gp_toolkit.gp_disk_free order by dfhostname;
其他可以去gpcc 监控上面去看.