GPDB43 Administrator Guide--第七章 扩展greenplum系统

第七章 扩展greenplum系统

 

一、greenplum扩展概述

        系统扩展的几个阶段:

        1.增加并测试新硬件--安装OS系统、准备greenplum环境、安装greenplum软件;

        2.初始化新segment--gpexpand

        3.重新分布表--重新分布表及数据,gpexpand工具;

gpexpand的典型操作如下:

        a.创建扩展文件:gpexpand -f hosts_file

        b.初始化segment并创建扩展schema:gpexpand -i input_file -D database_name

        c.重新分布表:gpexpand -d duration

        d.移除扩展schema(expansion schema):gpexpand -c

二、计划greenplum扩展

(一)扩展的检查列表

  • Online Pre-Expansion Tasks(* System is up and available )

        1.设计执行订购、架设、组网新硬件平台

        2.设计数据库扩展计划。每个主机的segment数量、性能测试、创建expansion schema和表分布调度间隔等计划;

        3.执行schema dump

        4.新主机上安装greenplum数据库

        5.建立新主机的ssh等效性(gpssh-exkeys)

        6.验证新硬件的OS环境(gpcheck)

        7.验证新硬件磁盘IO和内存带宽(gpcheckperf)

        8.验证master data directory下pg_log、gpperfmon/data目录中没有特别大的文件

        9.验证无catalog问题(gpcheckcat)

        10.准备expansion输入文件(gpexpand)

  • Offline Expansion Tasks(* The system is locked and unavailable to all user activity during this process. )

        1.结合新硬件与现有硬件,验证OS系统环境(gpcheck)

        2.结合新硬件与现有硬件,验证磁盘IO和内存带宽(gpcheckperf)

        3.初始化新的segment,并创建expansion schema (gpexpand-i input_file)

  • Online Expansion and Table Redistribution(* System is up and available )

        1.开始表的重新分布前,停止任何自动快照进程或者其他消耗硬盘空间的进程

        2.重新分布表(gpexpand)

        3.移除expansion schema(gpexpand -c)

        4.运行analyze,更新分布统计;扩展过程中使用gpexpand -a ,扩展后,使用analyze

(二)计划硬件平台

(三)计划初始化新segment

如果现有的系统segment配置了mirror,则新segment必须配置mirror;如果现有系统segment没有配置了mirror,则新segment也不能配置mirror;

? Spread Mirroring — Add at least one more host to the array than the number of segments per host.The number of separate hosts must be greater than the number of segment instances per host to ensure even spreading.(例如:每个主机有四个segment实例,新增主机数应该至少4+1)

? Grouped Mirroring — Add at least two new hosts so the mirrors for the first host can reside on the second host, and the mirrors for the second host can reside on the first. For more information, see About Segment Mirroring

  • 为每个host增加segment

   默认情况下,新主机应该初始化与现有主机上primary segment一样多。您可以为每台主机增加segment或者添加新segment。例如,如果现有主机目前拥有每台主机两个segment,你可以使用gpexpand初始化现有主机上的两个附加segment达到共四个segment,并在新主机上添加四个新segment。创建一个扩展输入文件的交互过程中会提示此选项;输入文件格式允许你手动指定新的细分目录。欲了解更多信息,请参阅"Creating an Input File for System Expansion"。

  • 关于expansion schema

   初始化过程中,gpexpand创建expansion schema。如果初始化时没有指定数据库(gpexpand -D),则schema创建在GPDATABASE环境变量指定的数据库中;

expansion schema中保存了每个表的元数据,它的状态可以通过expansion进程跟踪到;expansion schema由两个表和一个视图组成,这些表和视图用于跟踪expansion操作过程。

? gpexpand.status

? gpexpand.status_detail

? gpexpand.expansion_progress

   通过修改gpexpand.status_detail控制expansion进程;例如,删除记录则可以阻止表扩展到新segment;通过修改rank值可以控制表重新分布数据的顺序;更多信息参考“表重新分布的排名”

 

(四)计划表重新分布

1.大规模greenplum系统下管理重新分布

   可以通过管理重新分布表的顺序,帮助调整磁盘空间的使用和查询性能的用户;表重新分布阶段需要考虑的因素是表重新分布时在表上的排他锁的影响;如果用户在使用表,重新分布操作则会延时,重新分布时表不能被访问;

   如果系统空间足够的话,可以优先重新分布使用频繁的表,使之恢复到最佳查询性能;

   如果系统空间不够的话,则需要优先重新分布小表,腾挪空间;重新分布表时考虑排它锁的影响,避开高峰时段;

2.压缩表和append-Optimized表的重新分布

  gpexpand重新分布数据时压缩表、append-Optimized表速度不一样;通常是:

  • 不压缩的append-Optimized表比堆表快10%左右
  • zlib压缩的append-Optimized表比不压缩的append-Optimized表慢80%
  • 系统带数据压缩功能(如,ZFS/LZJB)的则要花更多时间

3.带主键约束的表重新分布

gpexpand会报错而停止,如果有主键的表在重新分布时出现重复数据等情况下。因此,解决方法是清理重复数据或者删除主键约束,然后再重新运行gpexpand;

4.带用户定义数据类型的表的重新分布

带有用户定义数据类型的dropped columns的表不能执行重新分布;如果要重新分布这种表则需要使用create table as select 语句重建一个表,然后使用gpexpand工具时会移除dropped columns。(dropped columns?是什么呢)

5.分区表的重新分布

分区表重分布按照分区执行,read/write lock只对子表(分区)起作用;只有分区表的子表可设置为随机分布策略;

6.索引表的重新分布?

Because the gpexpand utility must re-index each indexed table after redistribution, a high level of indexing has a large performance impact. Systems with intensive indexing have significantly slower rates of table

redistribution.

 

三、准备与添加节点

(一)添加新节点到信任主机环境

        设置共分为三步:

        1.交换root ssh keys

# source /usr/local/greenplum-db/greenplum_path.sh

# gpssh-exkeys -f /home/gpadmin/existing_hosts_file -x  /home/gpadmin/new_hosts_file

***Enter password for root@hostname: <root_password>

        2.创建gpadmin 用户

# gpssh -f new_hosts_file '/usr/sbin/useradd gpadmin -d  /home/gpadmin -s /bin/bash'

# gpssh -f new_hosts_file 'echo gpadmin_password | passwd  gpadmin --stdin'

# gpssh -f new_hosts_file ls -l /home

        3.交换gpadmin ssh keys

# gpssh-exkeys -e /home/gpadmin/existing_hosts_file -x /home/gpadmin/new_hosts_file

***Enter password for gpadmin@hostname: <gpadmin_password>

 

(二)检查OS设置

$ su - gpadmin

$ gpcheck -f new_hosts_file

(三)验证磁盘IO和内存带宽

使用工具gpcheckperf;

$ gpcheckperf -f new_hosts_file -d /data1 -d /data2 -v

(四)整合(Integrating)新硬件

    gpstop关闭系统;然后执行测试,安装上两步;

 

四、初始化新segment

(一)创建Input File

交互模式创建Input File,需要明确的几件事:a.新主机数量;b.新主机名;c.现有主机的镜像策略;d.每个主机增加的segment数量

input files格式:

hostname:address:port:fselocation:dbid:content:preferred_role:replication_port

例子:

sdw5:sdw5-1:50011:/gpdata/primary/gp9:11:9:p:53011

sdw5:sdw5-2:50012:/gpdata/primary/gp10:12:10:p:53011

sdw5:sdw5-2:60011:/gpdata/mirror/gp9:13:9:m:63011

sdw5:sdw5-1:60012:/gpdata/mirror/gp10:14:10:m:63011

(二)运行gpexpand初始化新segment

1.gpadmin用户登录

2.$ gpexpand -i input_file -D database1

 

(三)回滚失败的扩展设置

$gpexpand --rollback -D database_name

 

五、重新分布表

(一)重新分布表的排名

通过修改gpexpand.status_detail的rank列值可以控制表重新分布数据的顺序。

 

=> UPDATE gpexpand.status_detail SET rank=10;

=> UPDATE gpexpand.status_detail SET rank=1 WHERE fq_name = 'public.lineitem';

=> UPDATE gpexpand.status_detail SET rank=2 WHERE fq_name = 'public.orders';

(二)gpexpand重新分布表数据

登录gpadmin用户:

    $ gpexpand -d 60:00:00   #连续运行60个小时

 

(三)监控表的重新分布

=# SELECT * FROM gpexpand.expansion_progress;

name | value

------------------------------+-----------------------

Bytes Left | 5534842880

Bytes Done | 142475264

Estimated Expansion Rate | 680.75667095996092 MB/s

Estimated Time to Completion | 00:01:01.008047

Tables Expanded | 4

Tables Left | 4

(6 rows)

=> SELECT status, expansion_started, source_bytes FROM

gpexpand.status_detail WHERE fq_name = 'public.sales';

status | expansion_started | source_bytes

-----------+----------------------------+--------------

COMPLETED | 2009-02-20 10:54:10.043869 | 4929748992

(1 row)

六、移除expansion schema

登录master主机gpadmin用户:$ gpexpand -c

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16976507/viewspace-1806827/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16976507/viewspace-1806827/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值