GreenPlum數據庫故障恢復測試

本文介紹gpdb的master故障及恢復測試以及segment故障恢復測試。

環境介紹:
Gpdb版本:5.5.0 二進制版本
操作系統版本: centos linux 7.0
Master segment: 192.168.1.225/24 hostname: mfsmaster
Stadnby segemnt: 192.168.1.227/24 hostname: server227
Segment 節點1: 192.168.1.227/24 hostname: server227
Segment 節點2: 192.168.1.17/24 hostname: server17
Segment 節點3: 192.168.1.11/24 hostname: server11
每個segment節點上分別運行一個primary segment和一個mirror segment

一、查看原始狀態

select * from gp_segment_configuration;

GreenPlum數據庫故障恢復測試

$ gpstate -f
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-Starting gpstate with args: -f
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 5.5.0 build commit:67afa18296aa238d53a2dfcc724da60ed2f944f0'
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.3.23 (Greenplum Database 5.5.0 build commit:67afa18296aa238d53a2dfcc724da60ed2f944f0) on x86_64-pc-linux-gnu, compiled by GCC gcc (GCC) 6.2.0, 64-bit compiled on Feb 17 2018 15:23:55'
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-Obtaining Segment details from master...
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-Standby master details
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-----------------------
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-   Standby address          = server227
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-   Standby data directory   = /home/gpadmin/master/gpseg-1
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-   Standby port             = 5432
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-   Standby PID              = 22279
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:-   Standby status           = Standby host passive
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--------------------------------------------------------------
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--pg_stat_replication
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--------------------------------------------------------------
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--WAL Sender State: streaming
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--Sync state: sync
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--Sent Location: 0/CF2C470
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--Flush Location: 0/CF2C470
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--Replay Location: 0/CF2C470
20180320:13:50:38:021814 gpstate:mfsmaster:gpadmin-[INFO]:--------------------------------------------------------------

二、master主從切換
1、模擬當前主庫宕機,這里直接采用killall gpadmin用戶下的所有進程來模擬
GreenPlum數據庫故障恢復測試
2、在master standby節點(227服務器上)進行執行切換命令,提升227為master

$ gpactivatestandby -d master/gpseg-1/
20180320:13:53:20:030558 gpactivatestandby:server227:gpadmin-[INFO]:------------------------------------------------------
20180320:13:53:20:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Standby data directory    = /home/gpadmin/master/gpseg-1
20180320:13:53:20:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Standby port              = 5432
20180320:13:53:20:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Standby running           = yes
20180320:13:53:20:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Force standby activation  = no
20180320:13:53:20:030558 gpactivatestandby:server227:gpadmin-[INFO]:------------------------------------------------------
Do you want to continue with standby master activation? Yy|Nn (default=N):
> y
20180320:13:53:26:030558 gpactivatestandby:server227:gpadmin-[INFO]:-found standby postmaster process
20180320:13:53:26:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Updating transaction files filespace flat files...
20180320:13:53:26:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Updating temporary files filespace flat files...
20180320:13:53:26:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Promoting standby...
20180320:13:53:26:030558 gpactivatestandby:server227:gpadmin-[DEBUG]:-Waiting for connection...
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Standby master is promoted
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Reading current configuration...
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[DEBUG]:-Connecting to dbname='postgres'
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Writing the gp_dbid file - /home/gpadmin/master/gpseg-1/gp_dbid...
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-But found an already existing file.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Hence removed that existing file.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Creating a new file...
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Wrote dbid: 1 to the file.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Now marking it as read only...
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Verifying the file...
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:------------------------------------------------------
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-The activation of the standby master has completed successfully.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-server227 is now the new primary master.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-You will need to update your user access mechanism to reflect
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-the change of master hostname.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Do not re-start the failed master while the fail-over master is
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-operational, this could result in database corruption!
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-MASTER_DATA_DIRECTORY is now /home/gpadmin/master/gpseg-1 if
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-this has changed as a result of the standby master activation, remember
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-to change this in any startup scripts etc, that may be configured
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-to set this value.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-MASTER_PORT is now 5432, if this has changed, you
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-may need to make additional configuration changes to allow access
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-to the Greenplum instance.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Refer to the Administrator Guide for instructions on how to re-activate
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-the master to its previous state once it becomes available.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-Query planner statistics must be updated on all databases
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-following standby master activation.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:-When convenient, run ANALYZE against all user databases.
20180320:13:53:27:030558 gpactivatestandby:server227:gpadmin-[INFO]:------------------------------------------------------

3、測試提升后的主庫是否正常

$ psql -d postgres -c 'ANALYZE'
postgres=# select * from gp_segment_configuration;

GreenPlum數據庫故障恢復測試
4、這里可能需要同步配置一下pg_hba.conf文件,才能通過客戶端進行遠程連接
GreenPlum數據庫故障恢復測試
到這里我們已經完成了master節點的故障切換工作。

三、添加新的master standby
1、 在225服務器上執行gpstart -a命令啟動gpdb數據庫的時候報錯”error: Standby active, this node no more can act as master”。當standby 提升為master的時候,原master服務器從故障中恢復過來,需要以standby的角色加入
GreenPlum數據庫故障恢復測試
2、在原master服務器225上的數據進行備份

$ cd master/
$ ls
gpseg-1
$ mv gpseg-1/ backup-gpseg-1

3、在當前master服務器227上進行 gpinitstandby添加225為standby

$ gpinitstandby -s mfsmaster
$ gpstate -f

GreenPlum數據庫故障恢復測試
四、primary segment和mirror segment切換
1、首先我們來捋一下當前的數據庫環境
Master segment: 192.168.1.227/24 hostname: server227
Stadnby segemnt: 192.168.1.225/24 hostname: mfsmaster
Segment 節點1: 192.168.1.227/24 hostname: server227
Segment 節點2: 192.168.1.17/24 hostname: server17
Segment 節點3: 192.168.1.11/24 hostname: server11
每個segment節點上分別運行一個primary segment和一個mirror segment

2、接著我們采用同樣的方式把227服務器上gpadmin用戶的所有進行殺掉

$ killall -u gpadmin

3、在225服務器上執行切換master命令

$ gpactivatestandby -d master/gpseg-1/

4、完成切換后使用客戶端工具連接查看segment狀態,可以看到227服務器上的server227
的primary和mirror節點都已經宕機了。
GreenPlum數據庫故障恢復測試
5、這里為了方面查看,我們使用greenplum-cc-web工具來查看集群狀態

$ gpcmdr --start hbjy

GreenPlum數據庫故障恢復測試
需要將pg_hba.conf文件還原回去,因為227上所有的segment已經宕掉,執行gpstop -u命令會有報錯
GreenPlum數據庫故障恢復測試
在segment status頁面中可以看到當前segment的狀態是異常的。server11上有兩組的primary segment,這很危險,如果不幸server11也宕機了,整個集群的狀態就變成不可用了。
GreenPlum數據庫故障恢復測試
6、將server227做為master standby重新加入集群

$ cd master/
$ mv gpseg-1/ backupgpseg-1
$ gpinitstandby -s server227

GreenPlum數據庫故障恢復測試
7、在master上重啟集群

$ gpstop -M immediate
$ gpstart -a

8、在master上恢復集群

$ gprecoverseg 

GreenPlum數據庫故障恢復測試
雖然所有的segment均已啟動,但server11上有還是有兩組的primary segment
GreenPlum數據庫故障恢復測試
9、在master上恢復segment節點分布到原始狀態

$ gprecoverseg -r

GreenPlum數據庫故障恢復測試
參考文檔:
http://greenplum.org/docs/520/admin_guide/highavail/topics/g-restoring-master-mirroring-after-a-recovery.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278272.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278272.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278272.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

書評:Just the Computer Essentials(Vista)

Normally we try and focus on articles about how to customize your computer, but today we’ll take a break from that and do a book review. This is something I’ve not done before, so any suggestions or questions will be welcomed in the comments. 通常&#x…

RxSwift筆記七其他操作符

簡介 git地址: https://github.com/ReactiveX/RxSwift參考資料:http://t.swift.gg/d/2-rxswiftReactiveX是通過可觀察的流實現異步編程的一種API,它結合了觀察者模式、迭代器模式和函數式編程的精華,RxSwift 是 ReactiveX 編程思想的一種實現。 復制代碼…

python學習

為了學會能學&#xff0c;不負時間&#xff0c;為了那簡練的美&#xff01; 為了一片新天地。 /t 對齊 python : # 99乘法表i 0while i < 9 : i 1 j 0 while j < i : j 1 print(j ,* , i,"" , i*j , end\t) #空格不能對齊 制表符…

hey 安裝_如何在助理揚聲器上調整“ Hey Google”的靈敏度

hey 安裝Vantage_DS/ShutterstockVantage_DS / ShutterstockThe Google Assistant is a useful tool that allows you to control your smart home, check the weather, and more. Unfortunately, the Assistant might not hear you in a noisy environment or it might activa…

EXCEL如何進行多條件的數據查找返回

在使用EXCEL時經常會碰到一個表里的同一款產品每天的銷量都不一樣&#xff0c;然后我們需要查導出每一款產品每天的銷量&#xff0c;即一對多條件查找。這個教復雜&#xff0c;我們要用到好幾個函數的綜合&#xff0c;下面小編來教你吧。 工具/原料 EXCEL軟件&#xff08;本文使…

如何將Google幻燈片轉換為PowerPoint

If someone sent you a presentation on Google Slides, but you’d rather work on it in Microsoft PowerPoint, you can easily convert it to a .pptx file in just a few simple steps. Here’s how it’s done. 如果有人在Google幻燈片上向您發送了演示文稿&#xff0c;但…

Linux 常用命令:文本查看篇

前言 Linux常用命令中&#xff0c;除了cat還有很多其他用于文本查看的命令。本文將簡單介紹一下這些文本查看的命令。 全文本顯示--cat cat可能是常用的一個文本查看命令了&#xff0c;使用方法也很簡單&#xff1a; cat file #全文本顯示在終端cat -n file #顯示全文本&#…

XP調整禁用頁面文件

NOTE: You shouldn’t disable your page file unless you really really know what you are doing. 注意&#xff1a;除非您真的很清楚自己在做什么&#xff0c;否則不應該禁用頁面文件。 If your computer has 1 GB of RAM or more, disabling the page file can speed up XP…

復制數據庫

1.首先手動創建新的數據庫 CREATE DATABASE new-DB DEFAULT CHARACTER SET utf8mb4; 2.使用mysqldump命令。結果&#xff0c;會連同數據一起復制過去。 mysqldump old-DB -u root -pXX --add-drop-table | mysql new-DB -u root -pXX轉載于:https://www.cnblogs.com/clcliangc…

labelme2coco問題:TypeError: Object of type 'int64' is not JSON serializable

最近在做MaskRCNN 在自己的數據&#xff08;labelme&#xff09;轉為COCOjson格式遇到問題&#xff1a;TypeError: Object of type int64 is not JSON serializable 原因是numpy的數據類型不能被json兼容 最簡單的做法是自己寫一個序列類 class MyEncoder(json.JSONEncoder):de…

如何在Windows 10的命令提示符中更改目錄

One of the first things you’ll need to learn as you become more familiar with Command Prompt on Windows 10 is how to change directories in the operating system’s file system. There are a few ways you can do this, so we’ll walk you through them. 隨著您對…

jQuery 購物車

html代碼 <!--shoppingCar start--> <table id"TB"> <tr> <td colspan"7" class"title"> <div class"img_box"> <div class"logo_box"> <img src"img/jd…

MySQL優化總結

2019獨角獸企業重金招聘Python工程師標準>>> 從這幾天看MySQL性能優化來看&#xff0c;基本的思路就是分分分&#xff0e;&#xff0e;&#xff0e; 1&#xff0c;分讀&#xff0c;用緩存來分攤讀表的壓力; 2&#xff0c;讀寫分離&#xff0c;主從分離&#xff0c;寫…

瘋狂java講義

封裝&#xff1a; 封裝&#xff1a;將對象狀態信息隱藏在對象內部&#xff0c;不允許外部程序直接訪問對象內部信息&#xff0c;而是用類所提供的方法訪問和操作。訪問控制符&#xff1a;private&#xff08;當前類訪問權&#xff09; ,protected&#xff08;子類訪問&#xff…

將背景色添加到Word 2007文檔中

Instead of using the standard white background with Word documents, here is how to add some background color to spice up your documents. 代替在Word文檔中使用標準的白色背景&#xff0c;這是如何添加一些背景顏色來為文檔增添色彩。 Open your word document and ch…

jquery實現增刪改(偽)-老男孩作業day13

使用jquery進行&#xff0c;文件的編寫&#xff0c;實現自增id,刪除&#xff0c;添加&#xff0c;編輯模式。 jquery放在本地&#xff0c;src"jquery_js.js" 可以改成其他&#xff0c;或者在線的路徑 readme<!DOCTYPE html> <html lang"en"> &…

uoj#119. 【UR #8】決戰圓錐曲線(線段樹+復雜度分析)

題解 傳送門 題解 然而要我來說我感覺只是個爆搜啊…… //minamoto #include<bits/stdc.h> #define R register #define ll long long #define ls (p<<1) #define rs (p<<1|1) #define fp(i,a,b) for(R int ia,Ib1;i<I;i) #define fd(i,a,b) for(R int ia…

如何在Raspberry Pi上設置兩因素身份驗證

Kiklas/ShutterstockKiklas /快門The Raspberry Pi is everywhere now, which is why it’s caught the eye of threat actors and cybercriminals. We’ll show you how to secure your Pi with two-factor authentication. Raspberry Pi現在無處不在&#xff0c;這就是為什么…

Laravel Passport里的授權類型介紹

本文來自pilishen.com----原文鏈接; 歡迎來和pilishen一起學習php&Laravel&#xff1b;學習群&#xff1a;109256050OAuth2是一個安全框架&#xff0c;控制著程序受保護部分的準入&#xff0c;主要是控制不同的客戶端如何來調取API&#xff0c;保證它們在請求相應資源的時候…

vue 開發環境搭建

1.創建vue項目 1.node js 生成項目&#xff0c;編譯項目 2.hbuilder 開發環境 1.下載安裝node js http://nodejs.cn/download/ 確認是否安裝成功 如果安裝不了 代碼錯誤2503 解決方法&#xff1a; 管理員命令運行cmd; cd\ cd C:\Users\Administrator\Desktop msiexec/package n…