greenplum-add-mirror

操作要求

  • greenplum版本: v5.14.0
  • 操作系统: centos:7 / 1804.02

root用户下创建mirror文件目录

gpssh新建文件夹

1
$ gpssh -f /home/gpadmin/conf/seglist -e "mkdir /data/mirror"

gpssh修改文件权限

1
$ gpssh -f /home/gpadmin/conf/seglist -e "chown gpadmin:gpadmin /data/mirror"

进入gpadmin用户

1
$ su - gpadmin

创建addmirror配置文件

1
2
# 创建addmirror配置文件
$ gpaddmirrors -o ./addmirror

注:/data/mirror 是自己输入的mirror存储地址

1
2
3
4
5
6
$ cat addmirror

# 自动升成了一下内容(根据你安装的greenplum)
filespaceOrder=
mirror0=0:gppro3:7000:8000:9000:/data/mirror/gpseg0
mirror1=1:gppro2:7000:8000:9000:/data/mirror/gpseg1

执行gpaddmirror

1
$ gpaddmirrors -i addmirror -v -B 1
  • -v:打印详细的日志信息。
  • -B:并行启动的镜像设置进程数量,最多10个并行

常见问题

1、perl

问题描述

1
perl: command not found

解决办法

1
2
# 安装perl, root用户下
$ gpssh -f /home/gpadmin/conf/hostlist -e "yum install -y perl"

2、mirror已经存在

问题描述

1
gpaddmirrors error: GPDB physical mirroring cannot be added.  The cluster is already configured with physical mirroring.

解决办法

清空mirror储存内的数据,执行remove_mirror.sh脚本(gpadmin用户下)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$ cat remove_mirror.sh


#!/bin/bash
set -e

check_health()
{
count=$(psql -t -A -c "select count(*) from gp_segment_configuration where preferred_role <> role and role = 'p' and status = 'u';")
if [ "$count" -eq "0" ]; then
echo "Database healthy. Continuing..."
else
echo "ERROR! Please run gpstate and fix any segments that are down."
fi
}
start_normal()
{
counter=$(ps -ef | grep postgres | grep "\-D" | wc -l)

if [ "$counter" -eq "0" ]; then
gpstart -a
else
echo "Database already started."
fi
}
stop_normal()
{
counter=$(ps -ef | grep postgres | grep "\-D" | wc -l)
if [ "$counter" -eq "0" ]; then
echo "Database already stopped."
else
gpstop -a -M fast
fi
}
start_admin_mode()
{
gpstart -m << EOF
y
EOF
}
alter_database()
{
PGOPTIONS='-c gp_session_role=utility' psql -c "SET allow_system_table_mods=dml; update gp_fault_strategy set fault_strategy = 'n';"
PGOPTIONS='-c gp_session_role=utility' psql -c "SET allow_system_table_mods=dml; delete from gp_segment_configuration where role = 'm';"
PGOPTIONS='-c gp_session_role=utility' psql -c "SET allow_system_table_mods=dml; update gp_segment_configuration set replication_port = null;"
PGOPTIONS='-c gp_session_role=utility' psql -c "SET allow_system_table_mods=dml; delete from pg_filespace_entry f where not exists (select null from gp_segment_configuration g where f.fsedbid = g.dbid);"
}
stop_admin_mode()
{
gpstop -m
}

start_normal
check_health
stop_normal
start_admin_mode
alter_database
stop_admin_mode
start_normal

运行remove_mirror.sh

1
2
3
# gpadmin用户下

$ PGDATABASE=postgres bash remove_mirror.sh

重新执行gpaddmirrors