2017년 10월 31일 화요일

Greenplum Workload Management(gp-wlm)


Greenplum Workload Mangement (gp-wlm)


1)        Greenplum workload Management 란?


n  참고 URL
               -       http://gpcc.docs.pivotal.io/300/gp-wlm/topics/gpwlm-docs.html
               -       http://gpcc.docs.pivotal.io/210/gp-wlm/welcome.html

2)        gp-wlm 설치


n  사전 준비 사항(Prerequisites)
               -       Red Hat Enterprise Linux (RHEL) 64-bit 5.5+ or 6 or CentOS 64-bit 5.5+ or 6
               -       Greenplum Database version 4.3.x
               -       Pivotal Greenplum Command Center installer

n  설치 파일
                -       Network.pivotal.io 에서 다운로드
                -       다운로드 위치: Greenplum Command Center
                -       설치 파일 : Greenplum Database -- Command Center 3.0.1 설치 후
                                /usr/local/greenplum-cc-web 하위 경로에 gp-wlm-1.6.0.bin 설치 파일이 있음.

n  Gp-wlm 설치
               -       설치 경로를 /home/gpadmin 로 설치해야지만 가능(gpadmin 계정을 이용하기 때문)
               -       /usr/local/gp-wlm 으로 할 경우, 설치시 에러 발생



 

$ su – gpadmin

$ cd /usr/local/greenplum-cc-web

$ chmod +x gp-wlm-1.6.0.bin

$ ./gp-wlm-1.6.0.bin --install=/home/gpadmin/

## 재설치가 필요할 경우

$ ./gp-wlm-1.6.0.bin --install=/home/gpadmin/ --force

 

## gp-wlm_path.sh 를 환경 설정 파일에Source 함.

$ vi ~/.bash_profile

. /home/gpadmin/gp-wlm/gp-wlm_path.sh

 

## 삭제시

$ /home/gpadmin/gp-wlm/bin/uninstall --symlink /home/gpadmin/gp-wlm
 

3)        gp-wlm 서비스


n  gp-wlm 구동 utility를 위한 경로
           -       /home/gpadmin/gp-wlm/bin/svc-mgr.sh
           -       $ svc-mgr.sh –help
 
n  gp-wlm 실행 Command
 


구  분

명령어

Gp-wlm Start

./svc-mgr.sh --service=all --action=cluster-start

Gp-wlm Stop

./svc-mgr.sh --service=all --action=cluster-stop

Gp-wlm 상태

./svc-mgr.sh --service=all --action=cluster-status

Gp-wlm Restart

./svc-mgr.sh --service=all --action=cluster-restart

Gp-wlm enable

./svc-mgr.sh --service=all --action=cluster-enable

Gp-wlm disable

./svc-mgr.sh --service=all --action=cluster-disable

 
n  gp-wlm 상태 확인(정상적인 Case)



## 특정 호스트에서 수행

./svc-mgr.sh --service=all --action=status

RabbitMQ is running out of the current installation. (PID=22541)

agent (pid 22732) is running...

cfgmon (pid 22858) is running...

rulesengine (pid 22921) is running...

 

## 클러스터 수행

[gpadmin@gpmdw bin]$ ./svc-mgr.sh --service=all --action=cluster-status

gpmdw.gphd.local:

RabbitMQ is running out of the current installation. (PID=7396)

gpsdw1.gphd.local:

RabbitMQ is running out of the current installation. (PID=4047)

gpsdw2.gphd.local:

RabbitMQ is running out of the current installation. (PID=4027)

agent (pid 7614) is running...

gpsdw1.gphd.local:

agent (pid 4320) is running...

gpsdw2.gphd.local:

agent (pid 4300) is running...

cfgmon (pid 7766) is running...

gpsdw1.gphd.local:

cfgmon (pid 4481) is running...

gpsdw2.gphd.local:

cfgmon (pid 4461) is running...

rulesengine (pid 7850) is running...

gpsdw1.gphd.local:

rulesengine (pid 4561) is running...

gpsdw2.gphd.local:

rulesengine (pid 4545) is running...

svcmon (pid 8001) is running...

gpsdw1.gphd.local:

svcmon (pid 4899) is running...

gpsdw2.gphd.local:

svcmon (pid 4876) is running...

[gpadmin@gpmdw bin]$

4)        gp-wlm 사용법




Usage: gp-wlm [-g | gptop]

            [--rq-add= with ]

            [--rq-delete=]

            [--rq-modify= with ] [--rq-show=all]

            [--rq-useradd= to ]

            [--rq-userdel= from ]

            [--rule-add=[transient] ]

            [--rule-delete=all|] [--rule-dump=] [--rule-import=]

            [--rule-modify=[transient] ] [--rule-restore=]

            [--rule-show=all| [ ]]

            [--describe=]

            [--config-show ] [--config-describe ]

            [--config-modify =]

            [--set-domain=] [--set-host=] [--schema-path=]

            [--version] [--help] [--usage]Usage: gp-wlm [-g | gptop]

            [--rq-add= with ]

            [--rq-delete=]

            [--rq-modify= with ] [--rq-show=all]

            [--rq-useradd= to ]

            [--rq-userdel= from ]

            [--rule-add=[transient] ]

            [--rule-delete=all|] [--rule-dump=] [--rule-import=]

            [--rule-modify=[transient] ] [--rule-restore=]

            [--rule-show=all| [ ]]

            [--describe=]

            [--config-show ] [--config-describe ]

            [--config-modify =]

            [--set-domain=] [--set-host=] [--schema-path=]

            [--version] [--help] [--usage]

5)        gptop (모니터링)


n  putty 설정
            -       Connection > Data > Terminal Details > Terminal-type String : xterm-color 또는 putty 로 설정
            -       Window > Translatioin > Remote Character set: Use font encoding 으로 설정

n  putty 설정 화면



 

 
 
 
 
 
 
 


n  putty 에서 gptop 수행 화면
           -       메뉴를 위해서는 F2를 클릭하고 좌/우 화살표(<- -="">) 로 원하는 모니터링 가능 함.




 

6)        Rule 적용

   n  Rule 기본 기능

-       host:throttle_gpdb_query  : 쿼리 수행 시 CPU, Memory, IO 제어 
           -       host:pg_cancel_backend    : 쿼리 취소 기능
           -       pg_terminate_backend   : 쿼리 취소 기능
           -       gpdb_record                          : 임계치의 시스템 리소스를 사용했을 때 로깅 기능
 
n  Rule 적용 범위

-       계정 / 세션 / Host / 프로세스 /
            -       시스템 리소스 : cpu/memory/io

n  Rule 적용



 

$ gp-wlm

## 적용된 Rule 확인

gpmdw.gphd.local/gpdb-cluster> rule show all

 

--- Name ---    ----------- Expression -----------

 udba_ss_tot_cpu_throttle_log    gpdb_record(message="udba_ss_tot_cpu_throttle_log") when session_id:host:total_cpu > 100 and  session_id:host:pid:usename = 'udba'

 

 udba_ss_tot_cpu_throttle        host:throttle_gpdb_query(max_cpu=5) when session_id:host:total_cpu > 200 and  session_id:host:pid:usename = 'udba' and session_id:host:pid:runtime > 0

 

7)        Rule 샘플


n  Rule 적용시 주의 사항
         -       한줄로 Command 를 수행해야 함.(여러 라인으로 Command 수행시 에러 발생)

n  Record high cpu utilization queries
         -       Cpu 임계치 이상일 경우 DB 로그 적재
                     (실제 파일로 보관되며, external table 로 확인이 가능 함)



 

rule add simple gpdb_record(message="Too much cpu for gpadmin")

when session_id:host:total_cpu > 100

and session_id:host:pid:usename = ‘gpadmin’

 


n  Throttle the cpu utilization of a query
         -       개별 프로세스 CPU Max 를 설정 함.



 


when host:pid:cpu_util > 20

and session_id:host:pid:usename = 'gpadmin'

and session_id:host:pid:runtime > 20

 

 
n  Cancel any query running longer than 120 seconds
         -       개별 프로세스 CPU Max 를 설정 함.



 

rule add kill_long pg_terminate_backend()

when session_id:host:pid:runtime > 120

 

n  Throttle and even out skew
        -       개별 프로세스 CPU Max 를 설정 함.



 

rule add skewrule host:throttle_gpdb_query(max_cpu=50)

when session_id:host:total_cpu > 100

and session_id:host:pid:current_query =~ /select.*skewtest/

 

n  Complex rule
         -       개별 프로세스 CPU Max 를 설정 함.



 

rule add comborule gpdb_record(message="My Message")

when ((session_id:host:total_cpu > 90 and session_id:host:pid:runtime > 45)

or session_id:cpu_skew > 20)

and session_id:host:pid:current_query =~ /select.*test/

 

 
n  Record queries with high memory usage
         -       개별 프로세스 CPU Max 를 설정 함.



 

rule add transient mem_high_segment_useage_20

gpdb_record(message=”MEM: high segment pctusage - 20%”) when

host:pid:resident_size_pct > 20

and session_id:host:pid:usename =~/.*/

 
 

n  Record queries with memory (rss) skew above 10%
         -       개별 프로세스 CPU Max 를 설정 함.



 

rule add mem_skew_10 gpdb_record(message="MEM: query skew 10")

when session_id:resident_size_pct_skew > 10

and session_id:host:pid:usename =~/.*/

 

 

n  특정 계정의 세션에서 Total CPU가 100 일 때 로그남기고, CPU 조절하는 Case



 

rule add udba_ss_tot_cpu_throttle_log gpdb_record(message="udba_ss_tot_cpu_throttle_log") when session_id:host:total_cpu > 100 and  session_id:host:pid:usename = 'udba'

 

rule add modify udba_ss_tot_cpu_throttle_log gpdb_record(message="udba_ss_tot_cpu_throttle_log") when session_id:host:total_cpu > 100 and  session_id:host:pid:usename = 'udba'

 

rule modify udba_ss_tot_cpu_throttle host:throttle_gpdb_query(max_cpu=10) when session_id:host:total_cpu > 100 and  session_id:host:pid:usename = 'udba'

 

n  Rule 수정(modify)



 

rule add  udba_ss_tot_cpu_throttle host:throttle_gpdb_query(max_cpu=10) when session_id:host:total_cpu > 100 and  session_id:host:pid:usename = 'udba'

 

rule modify udba_ss_tot_cpu_throttle host:throttle_gpdb_query(max_cpu=10) when session_id:host:total_cpu > 200 and  session_id:host:pid:usename = 'udba'

 

8)        CPU / Memory 리소스 모니터링


n  Rule 수정(modify)



 

[gpadmin@gpsdw1 ~]$ cat chk_process.sh

DT=`date "+%Y-%M-%d %H:%M:%S"`

HEADER="=========Date========|===Session===|=Pcnt=|==Cpu==|==Mem=="

for i in `seq 1 14200`

do

 

    echo $HEADER | awk -F"|" '{print $1"\t"$2"\t"$3"\t"$4"\t"$5}'

    ps auxwww | grep gpadmin | grep postgres | grep con | grep -v grep | awk '{cpu[$17] += $3}{ cnt[$17] += 1}{mem[$17] += $4}  END {for ( i in cpu) print i"\t\t" cnt[i]"\t"cpu[i]"\t"mem[i]}' | awk -F"\t" '{ if($2>40 || $3>300 || $4>10)print $0}' | awk -v date=`date "+%Y-%M-%d_%H:%M:%S"` '{print date"\t" $0}'

 

    echo

    sleep 2

done

[gpadmin@gpsdw1 ~]$

 

[gpadmin@gpsdw1 ~]$ ./chk_process.sh

=========Date========   ===Session===   =Pcnt=  ==Cpu== ==Mem==

2017-54-12_12:54:29     con2107         112     82.6    22.6

 

=========Date========   ===Session===   =Pcnt=  ==Cpu== ==Mem==

2017-54-12_12:54:31     con2107         112     82.7    22.6

 

=========Date========   ===Session===   =Pcnt=  ==Cpu== ==Mem==

2017-54-12_12:54:33     con2107         112     80.2    22.6

 

 
 
 

2017년 10월 12일 목요일

Greenplum 4.x 백업 에러

Greenplum 에서 백업 실패시 확인할 사항

1. gpcrondump 로그 
20170920:15:20:20:015168 gpcrondump:mdw:gpadmin-[INFO]:-Starting Dump process
20170920:15:28:56:022485 gpcrondump:mdw:gpadmin-[INFO]:-Starting gpcrondump with args: -x edu --table-file=/home/gpadmin/utilities/command/backup_tables_list_p1997 --prefix p1997 -u /data/backup -a
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Directory /data/backup/db_dumps/20170920 exists
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Checked /data/backup on master
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Configuring for single-database, include-table dump
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Validating disk space
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Creating filter file: /data/backup/db_dumps/20170920/p1997_gp_dump_20170920152856_filter
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Creating filter file: /data/backup/db_dumps/20170920/p1997_gp_dump_20170920152856_table
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Adding compression parameter
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Adding --prefix
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Adding --no-expand-children
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Dump process command line gp_dump -p 5432 -U gpadmin --gp-d=/data/backup/db_dumps/20170920 --gp-r=/data/backup/db_dumps/20170920 --gp-s=p --gp-k=20170920152856 --no-lock --gp-c --prefix=p1997_ --no-expand-children "edu" --table-file=/tmp/include_dump_tables_filewsQMRa
20170920:15:28:57:022485 gpcrondump:mdw:gpadmin-[INFO]:-Starting Dump process
20170920:15:39:04:022485 gpcrondump:mdw:gpadmin- [WARNING]:-Dump process returned exit code 1
20170920:15:39:04:022485 gpcrondump:mdw:gpadmin-[INFO]:-Timestamp key = 20170920152856
20170920:15:39:04:022485 gpcrondump:mdw:gpadmin-[INFO]:-Checked master status file and master dump file.
20170920:15:39:04:022485 gpcrondump:mdw:gpadmin-[INFO]:-Inserted dump record into public.gpcrondump_history in edu database
20170920:15:39:04:022485 gpcrondump:mdw:gpadmin-[WARNING]:-Dump request was incomplete, not rolling back because -r option was not supplied
20170920:15:39:04:022485 gpcrondump:mdw:gpadmin-[INFO]:-Sending mail to slee@pivotal.io
20170920:15:39:04:022485 gpcrondump:mdw:gpadmin-[ ERROR]:-gpcrondump error: Dump incomplete, rollback not processed
[gpadmin@mdw gpAdminLogs]$


2. gp_dump 로그 
[gpadmin@mdw 20170920]$ cat p1997_gp_dump_20170920152856.rpt

Greenplum Database Backup Report
Timestamp Key: 20170920152856
gp_dump Command Line: -p 5432 -U gpadmin --gp-d=/data/backup/db_dumps/20170920 --gp-r=/data/backup/db_dumps/20170920 --gp-s=p --gp-k=20170920152856 --no-lock --gp-c --prefix=p1997_ --no-expand-children edu --table-file=/tmp/include_dump_tables_filewsQMRa
Pass through Command Line Options: --prefix p1997_ --table-file /tmp/include_dump_tables_filewsQMRa
Compression Program: gzip
Backup Type: Full

Individual Results
        segment 2 (dbid 4) Host sdw3.gphd.local Port 40000 Database edu BackupFile /data/backup/db_dumps/20170920/p1997_gp_dump_2_4_20170920152856.gz: Failed with error:
{ Lost response from dump agent with dbid 4 on host sdw3.gphd.local after 10 minutes.
}
        segment 1 (dbid 3) Host sdw2.gphd.local Port 40000 Database edu BackupFile /data/backup/db_dumps/20170920/p1997_gp_dump_1_3_20170920152856.gz: Succeeded
        segment 0 (dbid 2) Host sdw1.gphd.local Port 40000 Database edu BackupFile /data/backup/db_dumps/20170920/p1997_gp_dump_0_2_20170920152856.gz: Succeeded
        Master (dbid 1) Host mdw Port 5432 Database edu BackupFile /data/backup/db_dumps/20170920/p1997_gp_dump_-1_1_20170920152856.gz: Succeeded
        Master (dbid 1) Host mdw Port 5432 Database edu BackupFile /data/backup/db_dumps/20170920/p1997_gp_dump_-1_1_20170920152856.gz_post_data: Succeeded

gp_dump utility finished unsuccessfully with  1  failures.
[gpadmin@mdw 20170920]$

3. sdw3의 pg_log
제 PC VM 에서 테스트하여 시간은 맞지 않지만, 해당 시점에 에러가 발생된 건입니다.

[gpadmin@sdw3 pg_log]$ gplogfilter -t gpdb-2017-09-20*.csv

----------  /data/primary/gpseg2/pg_log/gpdb-2017-09-20_120055.csv ----------
2017-09-20 12:00:55.590986 KST|gpadmin|postgres|p4513|th-1626073312|[local]||2017-09-20 12:00:55 KST|0|||seg-1|||||FATAL: |57M01|the database system is in mirror or uninitialized mode|||||||0||postmaster.c|2972|
2017-09-20 13:03:45.880945 KST|gpadmin|edu|p15859|th-1626073312|172.16.150.133|53745|2017-09-20 13:03:45 KST|1010065|con165||seg-1|||x1010065|sx1|FATAL: |28000|no pg_hba.conf entry for host "172.16.150.133", user "gpadmin", database "edu", SSL off|||||||0||auth.c|608|
2017-09-20 13:08:25.416389 KST|gpadmin|edu|p16729|th-1626073312|172.16.150.133|53747|2017-09-20 13:08:25 KST|1010139|con183||seg-1|||x1010139|sx1|FATAL: |28000|no pg_hba.conf entry for host "172.16.150.133", user "gpadmin", database "edu", SSL off|||||||0||auth.c|608|
       in:      89 lines,      89 log entries; timestamps from 2017-09-20 12:00:55.590986 to 2017-09-20 13:09:11.920432
    match:       3 lines,       3 log entries; timestamps from 2017-09-20 12:00:55.590986 to 2017-09-20 13:08:25.416389
      out:       3 lines,       3 log entries; timestamps from 2017-09-20 12:00:55.590986 to 2017-09-20 13:08:25.416389
----------  /data/primary/gpseg2/pg_log/gpdb-2017-09-20_130947.csv ----------
2017-09-20 13:09:48.439091 KST|gpadmin|postgres|p17142|th-1876691168|[local]||2017-09-20 13:09:48 KST|0|||seg-1|||||FATAL: |57M01|the database system is in mirror or uninitialized mode|||||||0||postmaster.c|2972|
       in:      95 lines,      95 log entries; timestamps from 2017-09-20 13:09:48.439091 to 2017-09-20 14:02:21.339605
    match:       1 lines,       1 log entries; timestamps from 2017-09-20 13:09:48.439091 to 2017-09-20 13:09:48.439091
      out:       1 lines,       1 log entries; timestamps from 2017-09-20 13:09:48.439091 to 2017-09-20 13:09:48.439091
[gpadmin@sdw3 pg_log]$

4. 환경 구성
VM 환경 구성
mdw: 172.16.150.130
sdw1: 172.16.150.131
sdw2: 172.16.150.132
sdw3: 172.16.150.133

5. 발생 원인
초기 VM 구성시 DHCP으로 구성하여, 초기 구성시와 현재 IP가 달라진 상태인데,
백업시에는 세그먼트 인스턴스가 자신의 인스턴스에 접속하고, 마스터에서 접속하는 경우가 있습니다.

이때 초기 구성때의 IP가 설정이 되어 있어, 백업을 시작하거나 완료되는 시점에 에러가 떨어지는 경우
반드시 에러 발생된 세그먼트의 DB로그와 마스터의 DB로그 확인할 필요가 있습니다.

sdw3 (172.16.150.133) 장비에서 sdw3에 접속할 때 에러가 떨어진 상태입니다.
즉,  Master / Standby Master / Segment 의 pg_hba.conf 파일에 접속 권한을 설정했는지 확인해야 합니다.

## sdw3 의 pg_hba.conf 파일
# "local" is for Unix domain socket connections only
local   all         all                               trust
host    all         all         127.0.0.1/24          trust
# IPv6 local connections:
host    all         all         ::1/128               trust
host all all ::1/128 trust
host all all 172.16.150.130/32 trust    ### IP를 추가
host all all 172.16.150.133/32 trust    ###IP를 추가
host all all fe80::20c:29ff:fe7c:7d38/128 trust
host all gpadmin 172.16.150.131/32 trust
host all gpadmin ::1/128 trust
host all gpadmin fe80::20c:29ff:fe78:1aca/128 trust
# standby master host ip addresses
host    all     gpadmin 172.16.150.129/32       trust
# standby master host ip addresses
host    all     gpadmin 172.16.150.130/32       trust
# standby master host ip addresses

host    all     gpadmin 172.16.150.128/32       trust
[gpadmin@sdw3 gpseg2]$

해당 IP를 추가하고 난뒤에는 정상적으로 수행 됨.

Greenplum 4.x 백업


1. 특정 파티션 백업 

## 백업 받을 리스트
[gpadmin@mdw command]$ cat backup_tables_list_p1997
edu_sch.lineitem_1_prt_p1997
edu_sch.orders_1_prt_p1997
[gpadmin@mdw command]$

## 사전 테이블/파티션 건수 체크
[gpadmin@mdw command]$ psql -ef cnt.sql
Timing is on.
select 'edu_sch.lineitem', count(*) from edu_sch.lineitem;
     ?column?     |  count
------------------+---------
 edu_sch.lineitem | 6001215
(1 row)

Time: 1026.143 ms
select 'edu_sch.orders', count(*) from edu_sch.orders;
    ?column?    |  count
----------------+---------
 edu_sch.orders | 1500000
(1 row)

Time: 268.886 ms
select 'edu_sch.lineitem_1_prt_p1997',  count(*) from edu_sch.lineitem_1_prt_p1997;
           ?column?           | count
------------------------------+--------
 edu_sch.lineitem_1_prt_p1997 | 911395
(1 row)

Time: 98.645 ms
select 'edu_sch.orders_1_prt_p1997', count(*) from edu_sch.orders_1_prt_p1997;
          ?column?          | count
----------------------------+--------
 edu_sch.orders_1_prt_p1997 | 227783
(1 row)

Time: 23.260 ms

### 백업 
[gpadmin@mdw command]$ gpcrondump -x edu --table-file=/home/gpadmin/utilities/command/backup_tables_list_p1997 --prefix p1997 -u /data/backup -a   --rsyncable
20171013:10:39:43:103761 gpcrondump:mdw:gpadmin-[INFO]:-Starting gpcrondump with args: -x edu --table-file=/home/gpadmin/utilities/command/backup_tables_list_p1997 --prefix p1997 -u /data/backup -a --rsyncable
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Directory /data/backup/db_dumps/20171013 exists
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Checked /data/backup on master
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Configuring for single-database, include-table dump
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Validating disk space
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Creating filter file: /data/backup/db_dumps/20171013/p1997_gp_dump_20171013103943_filter
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Creating filter file: /data/backup/db_dumps/20171013/p1997_gp_dump_20171013103943_table
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Adding compression parameter
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Adding --prefix
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Adding --no-expand-children
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump process command line gp_dump -p 5432 -U gpadmin --gp-d=/data/backup/db_dumps/20171013 --gp-r=/data/backup/db_dumps/20171013 --gp-s=p --gp-k=20171013103943 --no-lock --gp-c --prefix=p1997_ --no-expand-children "edu" --table-file=/tmp/include_dump_tables_fileAUmHhc --rsyncable
20171013:10:39:44:103761 gpcrondump:mdw:gpadmin-[INFO]:-Starting Dump process
20171013:10:39:53:103761 gpcrondump:mdw:gpadmin-[INFO]:-Releasing pg_class lock
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump process returned exit code 0
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Timestamp key = 20171013103943
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Checked master status file and master dump file.
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Inserted dump record into public.gpcrondump_history in edu database
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump status report
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:----------------------------------------------------
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Target database                          = edu
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump subdirectory                        = 20171013
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump type                                = Full database
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Clear old dump directories               = Off
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump start time                          = 10:39:43
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump end time                            = 10:39:54
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Status                                   = COMPLETED
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump key                                 = 20171013103943
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Dump file compression                    = On
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Vacuum mode type                         = Off
20171013:10:39:54:103761 gpcrondump:mdw:gpadmin-[INFO]:-Exit code zero, no warnings generated
20171013:10:39:55:103761 gpcrondump:mdw:gpadmin-[INFO]:----------------------------------------------------
20171013:10:39:55:103761 gpcrondump:mdw:gpadmin-[INFO]:-Sending mail to slee@pivotal.io
You have new mail in /var/spool/mail/gpadmin
[gpadmin@mdw command]$

### 백업 정상여부 확인
[gpadmin@mdw 20171013]$ pwd
/data/backup/db_dumps/20171013
[gpadmin@mdw 20171013]$ cat p1997_gp_dump_20171013103810.rpt

Greenplum Database Backup Report
Timestamp Key: 20171013103810
gp_dump Command Line: -p 5432 -U gpadmin --gp-d=/data/backup/db_dumps/20171013 --gp-r=/data/backup/db_dumps/20171013 --gp-s=p --gp-k=20171013103810 --no-lock --gp-c --prefix=p1997_ --no-expand-children edu --table-file=/tmp/include_dump_tables_filewXn_1e --rsyncable
Pass through Command Line Options: --prefix p1997_ --table-file /tmp/include_dump_tables_filewXn_1e --rsyncable
Compression Program: gzip
Backup Type: Full

Individual Results
        segment 2 (dbid 4) Host sdw3.gphd.local Port 40000 Database edu BackupFile /data/backup/db_dumps/20171013/p1997_gp_dump_2_4_20171013103810.gz: Succeeded
        segment 1 (dbid 3) Host sdw2.gphd.local Port 40000 Database edu BackupFile /data/backup/db_dumps/20171013/p1997_gp_dump_1_3_20171013103810.gz: Succeeded
        segment 0 (dbid 2) Host sdw1.gphd.local Port 40000 Database edu BackupFile /data/backup/db_dumps/20171013/p1997_gp_dump_0_2_20171013103810.gz: Succeeded
        Master (dbid 1) Host mdw Port 5432 Database edu BackupFile /data/backup/db_dumps/20171013/p1997_gp_dump_-1_1_20171013103810.gz: Succeeded
        Master (dbid 1) Host mdw Port 5432 Database edu BackupFile /data/backup/db_dumps/20171013/p1997_gp_dump_-1_1_20171013103810.gz_post_data: Succeeded

gp_dump utility finished successfully.
[gpadmin@mdw 20171013]$

### 특정 파티션 Truncate
[gpadmin@mdw command]$ cat trunc.sql
truncate table edu_sch.lineitem_1_prt_p1997;
truncate table edu_sch.orders_1_prt_p1997;

[gpadmin@mdw command]$ psql -ef trunc.sql
Timing is on.
truncate table edu_sch.lineitem_1_prt_p1997;
TRUNCATE TABLE
Time: 120.545 ms
truncate table edu_sch.orders_1_prt_p1997;
TRUNCATE TABLE
Time: 65.295 ms
[gpadmin@mdw command]$

### 복구
[gpadmin@mdw 20171013]$ gpdbrestore -t 20171013103943 --prefix p1997 -u /data/backup -v
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Starting gpdbrestore with args: -t 20171013103943 --prefix p1997 -u /data/backup -v
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Checking if MASTER_DATA_DIRECTORY env variable is set.
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Connecting to dbname='template1'
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Checking if MASTER_DATA_DIRECTORY env variable is set.
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Starting GpdbRestore
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Starting ValidateTimestamp
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Ending ValidateTimestamp
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Connecting to dbname='edu'
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-------------------------------------------
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Greenplum database restore parameters
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-------------------------------------------
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Restore type               = Full Database
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Database to be restored    = edu
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Drop and re-create db      = Off
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Restore method             = Restore specific timestamp
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Restore timestamp          = 20171013103943
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Restore compressed dump    = On
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Restore global objects     = Off
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Array fault tolerance      = f
20171013:10:57:56:119601 gpdbrestore:mdw:gpadmin-[INFO]:-------------------------------------------

Continue with Greenplum restore Yy|Nn (default=N):
> y
20171013:10:57:59:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Starting RestoreDatabase
20171013:10:57:59:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Starting ValidateSegments
20171013:10:58:00:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Ending ValidateSegments
20171013:10:58:00:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Adding --prefix
20171013:10:58:00:119601 gpdbrestore:mdw:gpadmin-[INFO]:-gp_restore commandline: gp_restore -i -h mdw.gphd.local -p 5432 -U gpadmin --gp-d=/data/backup/db_dumps/20171013 --gp-i --gp-k=20171013103943 --gp-l=p --gp-r=/data/backup/db_dumps/20171013 --status=/data/backup/db_dumps/20171013 --prefix=p1997_ --gp-c -d "edu":
20171013:10:58:08:119601 gpdbrestore:mdw:gpadmin-[INFO]:-gpdbrestore finished successfully
20171013:10:58:08:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Updating AO/CO statistics on master
20171013:10:58:08:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Connecting to dbname='edu'
20171013:10:58:08:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Connecting to dbname='edu'
20171013:10:58:08:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Commencing analyze of edu database, please wait
20171013:10:58:08:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Connecting to dbname='edu'
20171013:10:58:41:119601 gpdbrestore:mdw:gpadmin-[INFO]:-Analyze of edu completed without error
20171013:10:58:41:119601 gpdbrestore:mdw:gpadmin-[DEBUG]:-Ending RestoreDatabase
You have new mail in /var/spool/mail/gpadmin
[gpadmin@mdw 20171013]$

### 복구후 건수 점검
[gpadmin@mdw command]$ psql -ef cnt.sql
Timing is on.
select 'edu_sch.lineitem', count(*) from edu_sch.lineitem;
     ?column?     |  count
------------------+---------
 edu_sch.lineitem | 6001215
(1 row)

Time: 1079.016 ms
select 'edu_sch.orders', count(*) from edu_sch.orders;
    ?column?    |  count
----------------+---------
 edu_sch.orders | 1500000
(1 row)

Time: 345.850 ms
select 'edu_sch.lineitem_1_prt_p1997',  count(*) from edu_sch.lineitem_1_prt_p1997;
           ?column?           | count
------------------------------+--------
 edu_sch.lineitem_1_prt_p1997 | 911395
(1 row)

Time: 130.952 ms
select 'edu_sch.orders_1_prt_p1997', count(*) from edu_sch.orders_1_prt_p1997;
          ?column?          | count
----------------------------+--------
 edu_sch.orders_1_prt_p1997 | 227783
(1 row)

Time: 12.603 ms
[gpadmin@mdw command]$

Greenplum Ghost Index

Greenplum 7.6+에서 Ghost Index (Implied index)를 지원합니다. 1. Ghost Index 개념    - 컬럼 압축테이블(AO/CO)에 blockdirectory 옵션을 적용하여,        인덱스가 없더라도 Block...