Greenplum生產環境信息同步到test環境中

目錄

1 安裝需要準備的環境

2 備份用戶信息

3 備份數據庫信息

4 備份schema和function與table的結構信息

5 生產與測試環境同步數據

5.1 打通生產與測試環境master節點的免密

5.2 編寫同步表的文件

5.3 編寫host文件

5.4 同步數據


最近測試環境進行了重新安裝,需要把生產上的信息同步到測試環境下,整理此思路。同步需要在相同大版本下執行

1 安裝需要準備的環境

1.1 安裝oracle常用函數
1.2 安裝pljava擴展插件
1.3 安裝get_table_structure函數
1.4 安裝dblink常用函數
1.5 安裝madlib庫
************

2 備份用戶信息
 

pg_dumpall -h hostname -p port -U username  -g  -f  filename

--
-- Greenplum Database cluster dump
--

\connect postgres

SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;

--
-- Roles
--

CREATE ROLE ******;
ALTER ROLE ****** WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN PASSWORD 'md51dc3eb975e5228e9f479eff******';
CREATE ROLE ******;
ALTER ROLE ****** WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN PASSWORD 'md57d0bf5a0f957489647878be******';
********


hostname : 服務器host
port : 端口
username  : gp用戶
filename : 需要保存的文件

3 備份數據庫信息
 

pg_dumpall -h hostname -p port -U username  -s  -f  filename

--
-- Greenplum Database cluster dump
--

\connect postgres

SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;

--
-- Roles
--
**
--
-- Database creation
--
*******


hostname : 服務器host
port : 端口
username  : gp用戶
filename : 需要保存的文件

4 備份schema和function與table的結構信息

time pg_dump -h hostname -p port -s -n schemaname -U username  dbname  -f  filename

--
-- Greenplum Database database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

SET default_with_oids = false;

--
-- Name: ods; Type: SCHEMA; Schema: -; Owner: gpadmin
--

CREATE SCHEMA ods;
*********************


hostname : 服務器host
port : 端口
username  : gp用戶
dbname  : db名字
filename : 需要保存的文件

5 生產與測試環境同步數據

5.1 打通生產與測試環境master節點的免密

gpssh-exkeys -h host1 -h host2

host1 : 生產集羣master節點
host2 : 測試集羣master節點

5.2 編寫同步表的文件

vim syn_table_list
chin***.schema1.tablename
*****

5.3 編寫host文件

$ cat  source_host_map_file 
gpsdw1,192.168.***.**
gpsdw2,192.168.***.**
gpsdw3,192.168.***.**
gpsdw4,192.168.***.**

5.4 同步數據

time  gptransfer --source-host=192.168.***.** --source-port=5432 --source-user=gpadmin -f syn_table_list --source-map-file=source_host_map_file -a --dest-host=192.168.***.** --dest-port=5432 --dest-database=chin*** --truncate

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章