问题描述:
Ubuntu系统上用docker启动四个容器,一个模拟master节点,剩下三个模拟segment节点。部署greenplum完毕想安装GPCC,按教程需要先设置shared_preload_libraries为 metrics_collector。结果设置后重启greenplum失败,后在各segment的postgresql.conf中删除该参数,一不小心少删了几个segment,倒是能够重启成功,但是有几个segment一直是挂的,试了无数遍gprecoverseg、gprecoverseg -i recover.conf都不管用,均报如下错误:
20231209:06:26:41:005540 gprecoverseg:196afe030ab2:gpadmin-[INFO]:-Did not start the following segments due to failure while updating the port.Please update the port in postgresql.conf located in the segment’s data directory
20231209:06:26:41:005540 gprecoverseg:196afe030ab2:gpadmin-[INFO]:- hostname: 468b6785b82d; port: 7000; datadir: /home/gpadmin/gpdata/gpdatam1/gpseg6
20231209:06:26:41:005540 gprecoverseg:196afe030ab2:gpadmin-[INFO]:- hostname: 468b6785b82d; port: 7001; datadir: /home/gpadmin/gpdata/gpdatam2/gpseg7
20231209:06:26:41:005540 gprecoverseg:196afe030ab2:gpadmin-[INFO]:-Triggering FTS probe
20231209:06:26:41:005540 gprecoverseg:196afe030ab2:gpadmin-[ERROR]:-gprecoverseg failed. Please check the output for more details.
提示我segment的postgresql.conf中端口号有问题,但我多次确认,端口号没有问题。
解决方案:
死马当活马医,直接将系统表中被标记为down的segment人为改为up。先停掉整个greenplum集群:
gpstop -M fast
以管理模式单独登录master节点:
gpstart -m
进入到master数据库中(其实master数据库有三个template0,template1和postgres,这三个是全局的,进哪一个都一样):
PGOPTIONS=’-c gp_session_role=utility’ psql template1 (注意使用英文引号)
获取系统表的DML权限,以便后续修改状态:
set allow_system_table_mods=true;
先备份系统表防止出问题:
create table gp_segment_configuration_bak as select * from gp_segment_configuration
人为修改系统表,将down掉的节点状态全部修改为up:
update gp_segment_configuration SET status=‘u’ where status=‘d’; (注意使用英文引号)
退出数据库后台,然后关闭master节点:
\q
gpstop -m
最后将数据库正常启动:
gpstart -a
再检查就发现已经全部启动了:
gpstate -e
参考文章: