[gpadmin1@hadoop1 ~]$ gpstate -f
20101027:17:03:55:gpstate:hadoop1:gpadmin1-[INFO]:-Starting gpstate with args: -f
20101027:17:03:55:gpstate:hadoop1:gpadmin1-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.0.1.0 build 1'
20101027:17:03:55:gpstate:hadoop1:gpadmin1-[INFO]:-Obtaining Segment details from master...
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:-Standby master details
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:-----------------------
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:- Standby address = hadoop2
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:- Standby data directory = /home/gpadmin1/gp4master/aligp-1
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:- Standby port = 2345
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:- Standby PID = 26665
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:- Standby status = Standby host passive
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--------------------------------------------------------------
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--gp_master_mirroring table
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--------------------------------------------------------------
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--Summary state: Not Synchronized
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--Detail state: Connection error
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--Log time: 2010-10-28 06:55:20+08
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--Error message: error received sending data to standby master: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
20101027:17:03:56:gpstate:hadoop1:gpadmin1-[INFO]:--------------------------------------------------------------
使用gpinitstandby来进行恢复
[gpadmin1@hadoop1 ~]$ gpinitstandby -s hadoop2 -n
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Validating environment and parameters for standby initialization...
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Checking for filespace directory /home/gpadmin1/gp4master/aligp-1 on hadoop2
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:------------------------------------------------------
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum standby master initialization parameters
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:------------------------------------------------------
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum master hostname = hadoop1
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum master data directory = /home/gpadmin1/gp4master/aligp-1
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum master port = 2345
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum standby master hostname = hadoop2
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum standby master port = 2345
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum standby master data directory = /home/gpadmin1/gp4master/aligp-1
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum update system catalog = Off
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Greenplum stop database mode = smart
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:------------------------------------------------------
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:- Filespace locations
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:------------------------------------------------------
20101027:17:07:10:gpinitstandby:hadoop1:gpadmin1-[INFO]:-pg_system -> /home/gpadmin1/gp4master/aligp-1
Do you want to continue with standby master initialization? Yy|Nn (default=N):
> y
20101027:17:07:11:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Stopping database...
20101027:17:07:20:gpinitstandby:hadoop1:gpadmin1-[INFO]:--n option given, skipping catalog update
20101027:17:07:20:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Forcing changed blocks to disk for filespace /home/gpadmin1/gp4master/aligp-1...
20101027:17:07:21:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Copying filespace directory to hadoop2
20101027:17:07:24:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Removing pg_hba.conf backup...
20101027:17:07:24:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Starting database in production mode...
20101027:17:07:32:gpinitstandby:hadoop1:gpadmin1-[INFO]:-Successfully syncronized standby master.
[gpadmin1@hadoop1 ~]$ gpstate -f
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:-Starting gpstate with args: -f
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 4.0.1.0 build 1'
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:-Obtaining Segment details from master...
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:-Standby master details
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:-----------------------
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:- Standby address = hadoop2
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:- Standby data directory = /home/gpadmin1/gp4master/aligp-1
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:- Standby port = 2345
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:- Standby PID = 27597
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:- Standby status = Standby host passive
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:--------------------------------------------------------------
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:--gp_master_mirroring table
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:--------------------------------------------------------------
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:--Summary state: Synchronized
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:--Detail state:
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:--Log time: 2010-10-28 07:07:31+08
20101027:17:09:20:gpstate:hadoop1:gpadmin1-[INFO]:--------------------------------------------------------------
我们看到STANDBY和MASTER已经同步了。gpinitstandby的帮助中-n参数的说明如下
-n (resynchronize)
Use this option if you already have a standby master configured, and just want to resynchronize the data between the primary and backup master host. The Greenplum system catalog tables will not be updated.
除了使用gpstate -f来查看STANDBY的信息外,还可以通过gp_master_mirroring来查看
aligputf8=# select * from gp_master_mirroring;
summary_state | detail_state | log_time | error_message
------------------+------------------+------------------------+------------------------------------------------------------------------------------------
Not Synchronized | Connection error | 2010-10-28 06:55:20+08 | error received sending data to standby master: server closed the connection unexpectedly
: This probably means the server terminated abnormally
: before or while processing the request.
:
(1 row)
修复以后
aligputf8=# select * from gp_master_mirroring;
summary_state | detail_state | log_time | error_message
---------------+--------------+------------------------+---------------
Synchronized | | 2010-10-28 07:07:31+08 |
(1 row)
下面再附上一段对STANDBY的说明
The standby master is kept up to date by a replication process (gpsyncagent ), which runs on the standby master host and keeps the data between the primary and standby masters synchronized. Until a failure occurs in the primary master, no actual Greenplum Database master server is running on the standby master host -- only the replication process.
我们可以GREP一下看看
[gpadmin1@hadoop2 pg_log]$ ps -ef | grep gpsyncagent
gpadmin1 27710 27597 0 17:07 ? 00:00:00 postgres: port 2345, gpsyncagent process con1 idle
gpadmin1 28447 14409 0 17:32 pts/0 00:00:00 grep gpsyncagent