Greenplum add segments

来源:互联网 发布:base64加密 c语言 编辑:程序博客网 时间:2024/06/05 19:26
接前面的环境
新增两台服务器
192.168.100.34
192.168.100.142
两台服务器分别配置系统参数,建立相关数据目录,root执行以下命令
mkdir -p /data01/gpadmin/gpdata/primary_hank
mkdir -p /data01/gpadmin/gpdata/mirror_hank
mkdir -p /data01/gpadmin/gpdata/primary
mkdir -p /data01/gpadmin/gpdata/mirror
chown -R gpadmin.gpadmin /data01/gpadmin/gpdata/*


从主节点copy到新增节点
scp -r /usr/local/greenplum-db-4.3.12.0/ root@192.168.100.34:/usr/local
等同于以下命令
gpseginstall -f new_hosts
在以上完成后,在新增节点建立软链接
cd /usr/local
ln -s greenplum-db-4.3.12.0/ greenplum-db

new_hosts文件:
db-192-168-100-34
db-192-168-100-142


打通SSH
gpssh-exkeys  -e hostlist  -x new_hosts 
[STEP 1 of 5] create local ID and authorize on local host
  ... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped

[STEP 2 of 5] keyscan all hosts and update known_hosts file

[STEP 3 of 5] authorize current user on remote hosts
  ... send to db-192-168-100-34
  ... send to db-192-168-101-116
  ... send to db-192-168-100-217
  ... send to db-192-168-100-225

[STEP 4 of 5] determine common authentication file content

[STEP 5 of 5] copy authentication files to all remote hosts
  ... finished key exchange with db-192-168-100-34
  ... finished key exchange with db-192-168-101-116
  ... finished key exchange with db-192-168-100-217
  ... finished key exchange with db-192-168-100-225
.  .. finished key exchange with db-192-168-100-142
[INFO] completed successfully



做相关检查
gpcheck -f new_hosts
gpcheckperf -f new_hosts -d /data01/gpadmin/gpdata/primary -v 这里比较慢,要生成比较大的数据,可以选择跳过,或者修改大小


生成配置文件:
gpexpand -f new_hosts -D hank
以下为生成的两个文件
gpexpand_inputfile_20170321_175309
gpexpand_inputfile_20170321_175309.fs

cat gpexpand_inputfile_20170321_175309
db-192-168-100-142:db-192-168-100-142:40000:/data01/gpadmin/gpdata/primary/gpseg2:7:2:p:41000
db-192-168-100-34:db-192-168-100-34:50000:/data01/gpadmin/gpdata/mirror/gpseg2:10:2:m:51000
db-192-168-100-34:db-192-168-100-34:40000:/data01/gpadmin/gpdata/primary/gpseg3:8:3:p:41000
db-192-168-100-142:db-192-168-100-142:50000:/data01/gpadmin/gpdata/mirror/gpseg3:9:3:m:51000

对应格式:<hostname>:<address>:<port>:<fselocation>:<dbid>:<content>:<preferred_role>:<replication_port>

cat gpexpand_inputfile_20170321_175309.fs
filespaceOrder=hank
7:/data01/gpadmin/gpdata/primary_hank/gpseg2
10:/data01/gpadmin/gpdata/mirror_hank/gpseg2
8:/data01/gpadmin/gpdata/primary_hank/gpseg3
9:/data01/gpadmin/gpdata/mirror_hank/gpseg3

初始化segment
gpexpand -i gpexpand_inputfile_20170321_175309 -D hank

最后看到以下内容,执行成功
20170322:14:19:46:003798 gpexpand:db-192-168-101-115:gpadmin-[INFO]:-************************************************
20170322:14:19:46:003798 gpexpand:db-192-168-101-115:gpadmin-[INFO]:-Initialization of the system expansion complete.
20170322:14:19:46:003798 gpexpand:db-192-168-101-115:gpadmin-[INFO]:-To begin table expansion onto the new segments
20170322:14:19:46:003798 gpexpand:db-192-168-101-115:gpadmin-[INFO]:-rerun gpexpand
20170322:14:19:46:003798 gpexpand:db-192-168-101-115:gpadmin-[INFO]:-************************************************
20170322:14:19:46:003798 gpexpand:db-192-168-101-115:gpadmin-[INFO]:-Exiting...

重分布数据
gpexpand -d 10:10:00 -D hank


查看新segment,可见已经正常添加
postgres=# select a.dbid,a.content,a.role,a.port,a.hostname,b.fsname,c.fselocation from gp_segment_configuration a,pg_filespace b,pg_filespace_entry c where a.dbid=c.fsedbid and b.oid=c.fsefsoid order by content;
 dbid | content | role | port  |            hostname             |  fsname   |                fselocation                 
------+---------+------+-------+---------------------------------+-----------+--------------------------------------------
    1 |      -1 | p    |  1922 | db-192-168-101-115.sky-mobi.com | hank      | /data01/gpadmin/gpdata/master_hank/gpseg-1
    1 |      -1 | p    |  1922 | db-192-168-101-115.sky-mobi.com | pg_system | /data01/gpadmin/gpdata/master/gpseg-1
    6 |      -1 | m    |  1922 | db-192-168-101-116.sky-mobi.com | pg_system | /data01/gpadmin/gpdata/master/gpseg-1
    6 |      -1 | m    |  1922 | db-192-168-101-116.sky-mobi.com | hank      | /data01/gpadmin/gpdata/master_hank/gpseg-1
    2 |       0 | p    | 40000 | db-192-168-100-217.sky-mobi.com | pg_system | /data01/gpadmin/gpdata/primary/gpseg0
    2 |       0 | p    | 40000 | db-192-168-100-217.sky-mobi.com | hank      | /data01/gpadmin/gpdata/primary_hank/gpseg0
    4 |       0 | m    | 50000 | db-192-168-100-225.sky-mobi.com | pg_system | /data01/gpadmin/gpdata/mirror/gpseg0
    4 |       0 | m    | 50000 | db-192-168-100-225.sky-mobi.com | hank      | /data01/gpadmin/gpdata/mirror_hank/gpseg0
    5 |       1 | m    | 50000 | db-192-168-100-217.sky-mobi.com | pg_system | /data01/gpadmin/gpdata/mirror/gpseg1
    5 |       1 | m    | 50000 | db-192-168-100-217.sky-mobi.com | hank      | /data01/gpadmin/gpdata/mirror_hank/gpseg1
    3 |       1 | p    | 40000 | db-192-168-100-225.sky-mobi.com | pg_system | /data01/gpadmin/gpdata/primary/gpseg1
    3 |       1 | p    | 40000 | db-192-168-100-225.sky-mobi.com | hank      | /data01/gpadmin/gpdata/primary_hank/gpseg1
   10 |       2 | m    | 50000 | db-192-168-100-34               | hank      | /data01/gpadmin/gpdata/mirror_hank/gpseg2
   10 |       2 | m    | 50000 | db-192-168-100-34               | pg_system | /data01/gpadmin/gpdata/mirror/gpseg2
    7 |       2 | p    | 40000 | db-192-168-100-142              | hank      | /data01/gpadmin/gpdata/primary_hank/gpseg2
    7 |       2 | p    | 40000 | db-192-168-100-142              | pg_system | /data01/gpadmin/gpdata/primary/gpseg2
    9 |       3 | m    | 50000 | db-192-168-100-142              | pg_system | /data01/gpadmin/gpdata/mirror/gpseg3
    9 |       3 | m    | 50000 | db-192-168-100-142              | hank      | /data01/gpadmin/gpdata/mirror_hank/gpseg3
    8 |       3 | p    | 40000 | db-192-168-100-34               | hank      | /data01/gpadmin/gpdata/primary_hank/gpseg3
    8 |       3 | p    | 40000 | db-192-168-100-34               | pg_system | /data01/gpadmin/gpdata/primary/gpseg3


如果添加失败,需要进行回滚,找出原因,重新添加


启动限制模式,回滚。
gpstart -R  
gpexpand --rollback -D hank  //上面的两个配置文件一定不要删除,这里会读取文件进行回滚
gpstart -a   



PS:
这里如果ssh报错,可能是以下原因,修改PubkeyAuthentication为yes

gpssh-exkeys  -e hostlist  -x new_hosts

[STEP 1 of 5] create local ID and authorize on local host
  ... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped

[STEP 2 of 5] keyscan all hosts and update known_hosts file

[STEP 3 of 5] authorize current user on remote hosts
  ... send to db-192-168-100-34
  ***
  *** Enter password for db-192-168-100-34: 
[ERROR db-192-168-100-34] authentication check failed:
     Permission denied (gssapi-with-mic,password).


修改验证参数
cat /etc/ssh/sshd_config
PubkeyAuthentication yes
service sshd restart
1 0