@zhangyy
2020-10-26T06:49:51.000000Z
字数 4183
阅读 703
greenplum系列
数据量的增加,磁盘空间不足查询慢,性能跟不上,CPU,磁盘IO网络传输量增加,网卡限制扩容一般指扩segment:横向扩展:增加segment 机器,3台主机:3seg >>> 6 台主机 3 个seg,一般是物理主机性能不够,数据库性能足够/不足纵向扩展:扩单个主机上面的segment服务,3台主机:3 seg >> 3 台 主机:6 seg 一般是 物理主机性能足够,数据库性能不足
纵向扩展,加机器,整体流程1. 新机器环境准备,信任关系2. 新机器需要安装GP数据库软件3. 原集群的一些操作准备4. 扩容操作(6.x 之后可以在线扩容)5. 数据重新分布6. 统计信息需要更新7.元数据一致性验证
1.数据准备create role itpux with login password 'itpux';alter role itpux superuser createdb createrole replication;create database itpuxdb WITH OWNER itpux ENCODING ='UTF8';

---2. 导入数据验证:psql -U itpux -d itpuxdb -h192.168.100.11 < itpuxdb-itpux_yg.sql\c itpuxdb\du+\dt+

select gp_segment_id,count(*) from itpux_yg group by gp_segment_id;select * from pg_indexes where tablename='itpux_yg';select count(*) from itpux_yg;


存在索引

创建主机文件all_hosts.txt 原来的所有主机---node01.vpc.flyfish.cnnode02.vpc.flyfish.cnnode03.vpc.flyfish.cnnode04.vpc.flyfish.cnnode05.vpc.flyfish.cn----all_seg.txt 所有的segment 的 主机---node03.vpc.flyfish.cnnode04.vpc.flyfish.cnnode05.vpc.flyfish.cn---新主机文件:all_hosts_20201023.txt-------node01.vpc.flyfish.cnnode02.vpc.flyfish.cnnode03.vpc.flyfish.cnnode04.vpc.flyfish.cnnode05.vpc.flyfish.cnnode06.vpc.flyfish.cnnode07.vpc.flyfish.cn-------all_seg_20201023.txt---node03.vpc.flyfish.cnnode04.vpc.flyfish.cnnode05.vpc.flyfish.cnnode06.vpc.flyfish.cnnode07.vpc.flyfish.cn----seg_host_20201023.txt---node06.vpc.flyfish.cnnode07.vpc.flyfish.cn---
cd /usr/local/greenplum-db/config创建all_hosts_20201023.txt all_seg_20201023.txt seg_host_20201023.txt三个文件将内容 填进去
打开新增加的主机node06.vpc.flyfish.cnnode07.vpc.flyfish.cn两台主机
node06.vpc.flyfish.cn 环境初始化:同安装时候一样node07.vpc.flyfish.cn 环境初始化:同安装时候一样一直到:.......----chown -R gpadmin:gpadmin /usr/local/greenplum*chmod -R 775 /usr/local/greenplum*chmod -R 775 /greenplumchown -R gpadmin:gpadmin /greenplum----然后做gpadmin无密钥登录:增加 新增节点的的密钥之后测试:gpssh -f /usr/local/greenplum-db/config/all_hosts_20201023.txt -e 'ls -ls /greenplum'gpssh -f /usr/local/greenplum-db/config/seg_hosts_20201023.txt -e 'ls -ls /greenplum'gpssh -f /usr/local/greenplum-db/config/all_hosts_20201023.txt -e 'date'




元数据监测gpcheckcat -O -v

唯一建的处理select * from pg_indexes where indexdef like 'CREATE UNIQUE INDEX%' and tablename notlike 'pg_%' and tablename not like 'gp_%';

倒出唯一建cd /greenplum/soft/pg_dump -s -f itpuxdb-index.sql --gp-syntax itpuxdbcat itpuxdb-index.sql


删掉 索引drop index indx_itpux_yg_jobid;

备份数据pg_dump / pgbackuppg_restore / pgrestore
扩容操作:cd /usr/local/greenplum-db/configgpexpand -f seg_hosts_20201026.txt (蒋增加的节点写进去)



cat gpexpand_inputfile_20201026_120304


在线扩容避免业务使用可以改pg_hba.confhost all all 0.0.0.0/0 reject然后重启 greenplum
gpexpand -i gpexpand_inputfile_20201026_120304



psql -c "select hostname from gp_segment_configuration group by hostname;"psql -c "select * from gp_segment_configuration where status != 'u' or role !=preferred_role or mode != 's';"psql -c "select * from gp_segment_configuration order by content asc,dbid;"



select * from gpexpand.expansion_progress;select status,count(1),round(sum(source_bytes/1024/1024/1024),2) as size_gb from gpexpand.status_detail group by status order by 1;

select fq_name,expansion_started,expansion_finished,source_bytes from gpexpand.status_detail where status='IN PROGRESS';

select gp_segment_id,count(*) from itpux_yg group by gp_segment_id;

重新分布gpexpand -a -n 2 -d 00:05:00gpexpand -a -n 2 -d 05:30:00 >> gpexpand20200502.log &生产环境数据比较大要很多个小时

select gp_segment_id,count(*) from itpux_yg group by gp_segment_id;

查看平衡进度select * from gpexpand.expansion_progress;

select status,count(1),round(sum(source_bytes/1024/1024/1024),2) as size_gb from gpexpand.status_detail group by status order by 1;

select fq_name,expansion_started,expansion_finished,source_bytes from gpexpand.status_detail where status='IN PROGRESS';

select * from gpexpand.status;

select * from gp_distribution_policy;

select gp_segment_id,count(*) from itpux_yg group by gp_segment_id;

psql -d itpuxdb -h 192.168.1.11 < itpuxdb-index.sql 将数据索引导入进去

在重新检查数据gpcheckcat -O -v

清掉扩容信息gpextend -c

5个主segment主机,3p+3M=6个*5=30 segment5个主segment主机,个扩展1P+1M, 4P+4M=8个*5=40 segment
psql -c "select * from gp_segment_configuration order by content asc,dbid;"

segment 所有主机cat all_seg_20201026.txt

gpexpand -f all_seg_20201026.txt





gpssh -f /usr/local/greenplum-db/config/all_seg_20201026.txt -e 'ls -ls /greenplum/gpdata/primary'

psql -c "select * from gp_segment_configuration order by content asc,dbid;"

数据重新分布gpexpand -a -n 2 -d 00:05:00

select gp_segment_id,count(*) from itpux_yg group by gp_segment_id;

将配置信息清掉gpexpand -c

