[关闭]
@zhangyy 2020-10-26T14:49:51.000000Z 字数 4183 阅读 146

geenplum 的 扩展

greenplum系列



一: greenplum的扩容

  1. 数据量的增加,磁盘空间不足
  2. 查询慢,性能跟不上,CPU,磁盘IO
  3. 网络传输量增加,网卡限制
  4. 扩容一般指扩segment:
  5. 横向扩展:增加segment 机器,3台主机:3seg >>> 6 台主机 3 seg,一般是物理主机性能不够,数据库性能足够/不足
  6. 纵向扩展:扩单个主机上面的segment服务,3台主机:3 seg >> 3 主机:6 seg 一般是 物理主机性能足够,数据库性能不足

  1. 纵向扩展,加机器,整体流程
  2. 1. 新机器环境准备,信任关系
  3. 2. 新机器需要安装GP数据库软件
  4. 3. 原集群的一些操作准备
  5. 4. 扩容操作(6.x 之后可以在线扩容)
  6. 5. 数据重新分布
  7. 6. 统计信息需要更新
  8. 7.元数据一致性验证

二:横向扩容

  1. 1.数据准备
  2. create role itpux with login password 'itpux';
  3. alter role itpux superuser createdb createrole replication;
  4. create database itpuxdb WITH OWNER itpux ENCODING ='UTF8';

image_1el53k1r0ck9qhlblduce6uq29.png-81.9kB

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

image_1el546ub2k64pl31gi1184o1hm02m.png-110.1kB

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

image_1el547sqk1vrd42e16uaca81uc33.png-58.8kB

image_1el549c36a87175o1cio8qrh1a3g.png-31.9kB

  1. 存在索引

image_1el54q6d1oljtdu1r9o19721piu3t.png-53.9kB

  1. 创建主机文件
  2. all_hosts.txt 原来的所有主机
  3. ---
  4. node01.vpc.flyfish.cn
  5. node02.vpc.flyfish.cn
  6. node03.vpc.flyfish.cn
  7. node04.vpc.flyfish.cn
  8. node05.vpc.flyfish.cn
  9. ----
  10. all_seg.txt 所有的segment 主机
  11. ---
  12. node03.vpc.flyfish.cn
  13. node04.vpc.flyfish.cn
  14. node05.vpc.flyfish.cn
  15. ---
  16. 新主机文件:
  17. all_hosts_20201023.txt
  18. -------
  19. node01.vpc.flyfish.cn
  20. node02.vpc.flyfish.cn
  21. node03.vpc.flyfish.cn
  22. node04.vpc.flyfish.cn
  23. node05.vpc.flyfish.cn
  24. node06.vpc.flyfish.cn
  25. node07.vpc.flyfish.cn
  26. -------
  27. all_seg_20201023.txt
  28. ---
  29. node03.vpc.flyfish.cn
  30. node04.vpc.flyfish.cn
  31. node05.vpc.flyfish.cn
  32. node06.vpc.flyfish.cn
  33. node07.vpc.flyfish.cn
  34. ----
  35. seg_host_20201023.txt
  36. ---
  37. node06.vpc.flyfish.cn
  38. node07.vpc.flyfish.cn
  39. ---

  1. cd /usr/local/greenplum-db/config
  2. 创建all_hosts_20201023.txt all_seg_20201023.txt seg_host_20201023.txt
  3. 三个文件将内容 填进去

  1. 打开新增加的主机
  2. node06.vpc.flyfish.cn
  3. node07.vpc.flyfish.cn
  4. 两台主机

  1. node06.vpc.flyfish.cn 环境初始化:同安装时候一样
  2. node07.vpc.flyfish.cn 环境初始化:同安装时候一样
  3. 一直到:
  4. .......
  5. ----
  6. chown -R gpadmin:gpadmin /usr/local/greenplum*
  7. chmod -R 775 /usr/local/greenplum*
  8. chmod -R 775 /greenplum
  9. chown -R gpadmin:gpadmin /greenplum
  10. ----
  11. 然后做gpadmin无密钥登录:
  12. 增加 新增节点的的密钥之后测试:
  13. gpssh -f /usr/local/greenplum-db/config/all_hosts_20201023.txt -e 'ls -ls /greenplum'
  14. gpssh -f /usr/local/greenplum-db/config/seg_hosts_20201023.txt -e 'ls -ls /greenplum'
  15. gpssh -f /usr/local/greenplum-db/config/all_hosts_20201023.txt -e 'date'

image_1el56m3a81br05p5duiunpis9.png-99.1kB

image_1el56r9j11ujg14a11eq11aii1jlvm.png-153.7kB

image_1el56qitu18k1vnk1dvq1km6bgv9.png-117.4kB

image_1el56uvmp1qdipsf81b1c7o1or913.png-176kB

  1. 元数据监测
  2. gpcheckcat -O -v

image_1el573q4fnpv1973j1c1s24c4q1g.png-160.5kB


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

image_1el5783me4ug11ebior1j3817u71t.png-99kB


  1. 倒出唯一建
  2. cd /greenplum/soft/
  3. pg_dump -s -f itpuxdb-index.sql --gp-syntax itpuxdb
  4. cat itpuxdb-index.sql

image_1el57jdt3177p154v10c152h13f2a.png-127.2kB

image_1el57jqn4i1p7crbjp5h38ei2n.png-115.6kB


  1. 删掉 索引
  2. drop index indx_itpux_yg_jobid;

image_1el70lei097u1e6t1pp25f5hfs9.png-97.1kB

  1. 备份数据
  2. pg_dump / pgbackup
  3. pg_restore / pgrestore

  1. 扩容操作:
  2. cd /usr/local/greenplum-db/config
  3. gpexpand -f seg_hosts_20201026.txt (蒋增加的节点写进去)

image_1elhei2bb15gf1gp489e2rk1b7o9.png-216.8kB

image_1elheig0o1u4d1h98cfvqufg91m.png-188.3kB

image_1elhej9ov14ak1ao2ta5s5he5v13.png-183.9kB


  1. cat gpexpand_inputfile_20201026_120304

image_1elheju481bndvn4l4663t1inm1g.png-182.3kB

image_1elhj1thnlcgoioqaq1utp8n7m.png-304.7kB

  1. 在线扩容避免业务使用
  2. 可以改pg_hba.conf
  3. host all all 0.0.0.0/0 reject
  4. 然后重启 greenplum

  1. gpexpand -i gpexpand_inputfile_20201026_120304

image_1elhima6slvcrsqa2r17hrs719.png-365.7kB

image_1elhjco7si3o1vb3j77uno1eto13.png-57.4kB

image_1elhjd5ha1efo8ok1fe217o24og1g.png-81.2kB


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

image_1elhkhitr15ff6a01i9d35mscd1t.png-65.6kB

image_1elhkjajjrno210n28m9bsib2a.png-300.8kB

image_1elhkk9jh1qq2uvm3mrphlr6s2n.png-349.8kB

  1. select * from gpexpand.expansion_progress;
  2. 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;

image_1elhksnsic6olbgosgfr11n8h3h.png-111.6kB


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

image_1elhkumj67uh1ufo11tu1339c3l3u.png-53.1kB


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

image_1elhl5qcij3csl118l1j94s534b.png-61.4kB


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

image_1elhl8ieqaa3fc67nerpgdcf4o.png-185kB


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

image_1elhlcqfi1pk4ubm1d0u5s1qil55.png-76.7kB


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

image_1elhlg9aj6gtm8qr2r12csba55i.png-65.4kB


  1. 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;

image_1elhllg908ba15t1v6d1luc1qja5v.png-50.6kB


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

image_1elhlnoj01evjdcc1h2a1q7kja66c.png-49.3kB

  1. select * from gpexpand.status;

image_1elhlojph1crh11dq10qa1ikmd4i6p.png-62.6kB

  1. select * from gp_distribution_policy;

image_1elhlqoi11nvl1dr4okkj3qksb7j.png-55.2kB

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

image_1elhls39srj01gk44c313edhqk80.png-78.2kB


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

image_1elhm2p751hle1uv617fa6upu5f8q.png-109.8kB

  1. 在重新检查数据
  2. gpcheckcat -O -v

image_1elhm5sj3dl649p2s71olv1apt97.png-214.4kB

  1. 清掉扩容信息
  2. gpextend -c

image_1elhm85du13nsvrl1qcrb0o1gkk9k.png-173.5kB


三:纵向扩容

  1. 5个主segment主机,3p+3M=6个*5=30 segment
  2. 5个主segment主机,个扩展1P+1M 4P+4M=8个*5=40 segment

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

image_1elhn0ar55uu7qmc53e51i8ha1.png-48.7kB

  1. segment 所有主机
  2. cat all_seg_20201026.txt

image_1elhn65n9e37utia3e15ab1ue6ar.png-54.2kB


  1. gpexpand -f all_seg_20201026.txt

image_1elhn44f01lkj1qpj10r01svk1tb9ae.png-233.1kB

image_1elhn7qb68tg1l7215arida14khb8.png-146.7kB

image_1elhn8k6i1gm11mn01i21l4i1g22bl.png-257.1kB

image_1elhnblui16fkpog1kpqdkbblc2.png-465.7kB

image_1elhnccbe17bu17do11mh11cvjuncf.png-152.8kB

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

image_1elhnh3e01o8918gcrbu1sp6gn0cs.png-387.9kB


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

image_1elhnk1o213f25rg1m98130f1iktd9.png-119.1kB

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

image_1elhnmk6p1f7svveg221isdn5hdm.png-177.6kB

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

image_1elhno40110ii1c6015ippqcl04e3.png-93.2kB

  1. 将配置信息清掉
  2. gpexpand -c

image_1elhnrjlo1d1g1mumsfk1qqi1ro2eg.png-198.9kB


添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注