2019년 2월 6일 수요일

Greenplum - kafka 연동 (gpkafka)

----------------------------------------------
0. gpkafka 스크립트 
----------------------------------------------
1) 초기 작성자 : 박영호 (ypark.pivotal.io)
2) kafka & Greenplum Docker 작성자: 홍종현(jhong@pivotal.io)


----------------------------------------------
1. Kafka docker 컨테이너 구성
----------------------------------------------
(1) docker 이미지 가져오기
docker pull centos:6.8
(2) docker 이미지 확인
docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              6.8                 e54faac158ff        5 weeks ago         195MB
(3) docker 컨테이너 생성 (kafkalab)
docker run --name kafkalab --hostname testdk -it e54faac158ff /bin/bash
(4) 필수패키지 설치
yum install -y net-tools which openssh-clients openssh-server less zip unzip iproute.x86_64 java wget
(5) root 패스워드 변경 (optional)
passwd
(6) key 인증
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
(7) ssh 데몬 시작 (docker container를 새로 시작할 때 항상 매뉴얼로 수행)     
/usr/sbin/sshd
(8) /etc/hosts 확인
172.17.0.2      testdk
(9) /etc/sysconfig/network 의 hostname변경
HOSTNAME=testdk


--------------------------------------------------
2.zookeeper 설치
--------------------------------------------------
(1) 다운로드
cd /root
wget http://apache.mirror.cdnetworks.com/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
(2) 설치 및 구성
cd /usr/local/
tar xvfz /root/zookeeper-3.4.13.tar.gz
ln -s zookeeper-3.4.13 zookeeper
     
mkdir /zdata
echo 1 > /zdata/myid
cd /usr/local/zookeeper/conf/
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
==>
server.1=localhost:2888:3888
--------------------------------------------------
3.Kafka 설치
--------------------------------------------------
(1) 다운로드
cd /root
wget http://apache.mirror.cdnetworks.com/kafka/2.0.0/kafka_2.12-2.0.0.tgz
(2) 설치 및 구성
cd /usr/local
tar xvfz /root/kafka_2.12-2.0.0.tgz
ln -s kafka_2.12-2.0.0/ kafka
mkdir /kdata1 /kdata2
vi /usr/local/kafka/config/server.properties
==>
broker.id=1
log.dirs=/kdata1,/kdata2
zookeeper.connect=localhost:2181/greenplum-kafka
(4) 테스트 데이터 구성
vi /tmp/sample_data.csv
==>
"1313131","12","1313.13"
"3535353","11","761.35"
"7979797","10","4489.00"
"7979797","11","18.72"
"3535353","10","6001.94"
"7979797","12","173.18"
"1313131","10","492.83"
"3535353","12","81.12"
"1313131","11","368.27"


----------------------------------------------
4. Greenplum docker 컨테이너 구성
----------------------------------------------
(1) docker 이미지 확인
docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              6.8                 e54faac158ff        5 weeks ago         195MB
(2) docker 컨테이너 생성 (kafkalab)
docker run --name dblab --hostname dwserver -it e54faac158ff /bin/bash
(3) 필수패키지 설치
yum install -y net-tools which openssh-clients openssh-server less zip unzip iproute.x86_64
(4) root 패스워드 변경 (optional)
passwd
(5) key 인증
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
(6) ssh 데몬 시작 (docker container를 새로 시작할 때 항상 매뉴얼로 수행)     
/usr/sbin/sshd
(7) /etc/hosts 확인
172.17.0.3      dwserver
172.17.0.2      testdk           <== 추가
(8) /etc/sysconfig/network 의 hostname변경
HOSTNAME=dwserver
(9) /etc/security/limits.conf 추가
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
(10) user,group 생성
groupadd -g 501 gpadmin
useradd -g 501 -u 501 -m -d /home/gpadmin -s /bin/bash gpadmin
chown -R gpadmin:gpadmin /home/gpadmin
echo gpadmin | passwd  gpadmin --stdin
(11) ssh testdk 확인


--------------------------------------------------
5. Greenplum 설치
--------------------------------------------------
(1) 제품 업로드 (host prompt에서)
docker cp greenplum-db-5.11.3-rhel6-x86_64.zip dblab:/root
(2) 압축해제
unzip greenplum*
(3) 제품설치
./greenplum-db-5.11.3-rhel6-x86_64.bin
(4) 디렉토리 구성
mkdir -p /data/primary /data/master
chown -R gpadmin:gpadmin /data


--------------------------------------------------
6. Greenplum 초기화
--------------------------------------------------
(1) docker 컨테이너로 접속
docker exec -it dblab /bin/bash
만약 컨테이너가 수행중이지 않을때는
docker start dblab 먼저 수행
(2) gpadmin으로 스위치
su - gpadmin
(3) 구성파일 셋업
source /usr/local/greenplum-db/greenplum_path.sh
cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config .
vi gpinitsystem_config
==>
MASTER_HOSTNAME=dwserver
declare -a DATA_DIRECTORY=(/data/primary /data/primary /data/primary)
(4) 설치 호스트 설정
vi /tmp/host
==>
dwserver
(5) 초기화
gpssh-exkeys -f /tmp/host
gpinitsystem -c gpinitsystem_config -h /tmp/host
(6) gpadmin 환경설정
vi /home/gpadmin/.bash_profile
==>
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
source /usr/local/greenplum-db/greenplum_path.sh
(7) 테스트 DB 환경 구성
createdb testdb
psql testdb -c "CREATE TABLE data_from_kafka( customer_id int8, expenses decimal(9,2), tax_due decimal(7,2)) distributed by (customer_id)"
(8) kafka load 구성파일 설정
 vi /home/gpadmin/loadcfg.yaml
==>
DATABASE: testdb
USER: gpadmin
HOST: localhost
PORT: 5432
KAFKA:
   INPUT:
     SOURCE:
        BROKERS: testdk:9092
        TOPIC: topic_for_gpkafka
     COLUMNS:
        - NAME: cust_id
          TYPE: int
        - NAME: __IGNORED__
          TYPE: int
        - NAME: expenses
          TYPE: decimal(9,2)
     FORMAT: csv
     ERROR_LIMIT: 125
   OUTPUT:
     TABLE: data_from_kafka
     MAPPING:
        - NAME: customer_id
          EXPRESSION: cust_id
        - NAME: expenses
          EXPRESSION: expenses
        - NAME: tax_due
          EXPRESSION: expenses * .0725
   COMMIT:
     MINIMAL_INTERVAL: 10


-------------------------------------------------
7.kafka 기동
--------------------------------------------------
(1) zookeeper 기동
/usr/local/zookeeper/bin/zkServer.sh start
/usr/local/zookeeper/bin/zkServer.sh status
(2) Kafka 기동
/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
(참고) 중지
/usr/local/kafka/bin/kafka-server-stop.sh
/usr/local/zookeeper/bin/zkServer.sh stop


--------------------------------------------------
8.Kafka topic 생성 및 체크
--------------------------------------------------
(1) 토픽생성
/usr/local/kafka/bin/kafka-topics.sh --zookeeper localhost:2181/greenplum-kafka --topic topic_for_gpkafka --partitions 1 --replication-factor 1 --create
(2) 확인
/usr/local/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181/greenplum-kafka
(참고) /usr/local/kafka/bin/kafka-topics.sh --zookeeper localhost:2181/greenplum-kafka --topic topic_for_gpkafka --delete
(3) 데이터 생성
/usr/local/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topic_for_gpkafka < /tmp/sample_data.csv
(4) 확인
/usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic_for_gpkafka --from-beginning


--------------------------------------------------
9. 데이터 로드
--------------------------------------------------
(1) 1회 수행
gpkafka load --quit-at-eof ./loadcfg.yaml
(2) 연속 대기
gpkafka load ./loadcfg.yaml

--------------------------------------------------
10. gpkafka 동영상
--------------------------------------------------
https://www.youtube.com/watch?v=YqTrLb4sqmU

2018년 4월 19일 목요일

Greenplum 개발 가이드 요약


1.      데이터 분산


  • 각 세그먼트/노드별 데이터 분산이 성능에 가장 중요.
  • 분산키는 명시적으로 정의 (ex, distributed by (컬럼1))
  • PK, UK 있을 경우: PK/UK 컬럼 중 분산도가 좋고, Join 이 많은 컬럼을 대상으로 1~2개 컬럼
  • PK, UK 없을 경우: 분산도가 좋고, Join 이 빈번하게 발생할 컬럼
  • Ex) Device ID, 회원 ID
  • 분산도 확인: Select gp_segment_id, count(*) from Tablename group by gp_segment_id

2.      데이터 모델


  • 비정규화된 스키마 설계 필요(성능적인 측면 고려 시)
    • 매번 여러 개의 디멘젼 테이블이 조인 될 경우 통합 디멘전 테이블 생성
  • 테이블간의 조인 발생 컬럴은 동일한 데이터 타입으로 생성
  • Char Type (사용 금지) => Varchar Type 사용 (함수 사용시 형변환 때문)
  • Database Object10만개 미만 권고(select count(*) from pg_class)

3.      압축


  • Row 단위의 트랜젝션 처리: Insert / update /delete 되는 테이블에는 비압축(마스터성 테이블)
  • 대용량 단위의 트랜젝션 처리: insert/update/delete 되는 테이블에 압축 적용(Fact 테이블)
  • 압축시 옵션:  Compress level 5, zlib 으로 적용

4.      파티션


  • 파티션은 Range Partition 으로 구성
  • 서브 파티션은 가급적 미적용 관리상 어려움 발생
  • 테이블당 파티션을 200개 미만을 권고
  • 파티션에 인덱스를 2~3개 이상 사용시에는 파티션을 구간을 줄이는 것을 권고
    Ex) 월 파티션 => 일 파티션
    대용량/Index 테이블에 여러개 Index가 있을 경우 Data Loading 시 부하 발생 때문
  • Default 파티션 비적용 권고(모든 쿼리실행 시 Default 파티션 scan 발생)

5.      인덱스


  • 인덱스는 가급적 적게 사용 (short 쿼리에 대해서만 적용)
  • 파티션 테이블의 인덱스 컬럼과 파티션 컬럼은 달라야 함. (Local Index 이기 때문에 굳이 파티션 컬럼 사용할 필요 없음)
  • B-Tree index 사용

6.      쿼리


  1. 쿼리 유형



비권고

권고

In, not in, exists, not exists

Join, left outer join

Subquery, inline view

Join 절로 변환

With

Temp Table 로 변환

Distinct

Group by

decode

Case when 절로 변환

Where 절 파티션 컬럼에 Like 절 사용

Where  substr(yyyymmdd, 1,6) = ‘201601’

Where yyyymm like ‘201601%’

파티션 쿼리 수행시 Immutable operation 사용

Where yyyymmdd >= ‘20160101’ and yyyymmdd < ‘20160301’

Where yyyymmdd between  ‘20160101’ and ‘20160228’

 

  1. Short Query 튜닝

  • Index scan nested loop 옵션 설정

  • 쿼리 또는 계정별 옵션 설정
  • Enable_nestloop = true;
  • Random_page_cost = 1;

7.      사용자 테이블 배치 관리 (ETL 포함할 사항)


  • Analyze

  • Greenplum Database Cost Based Optimizer사용으로 통계 정보가 중요
  • 모든 배치 작업 뒤에는 Analyze 수행, 테이블/파티션 레벨

  • Vacuum
    • Delete / update 발생된 테이블은 Dirty Block 발생 방지 용도
    • Dirty Block 재 사용을 위하여 Vacuum 수행
    • 모든 배치 작업 뒤에는 Analyze 수행, 테이블/파티션 레벨
  • Reorg
    • Delete / update 발생된 테이블은 Dirty Block 발생 후에 조치 방법

8.      시스템 카탈로그 관리 (DBA 시스템 관리 목적)


  • 배치 관리(일배치) : Vacuum Analyze 카탈로그 테이블 수행

  • 모든 배치 작업 뒤에는 Analyze 수행, 테이블/파티션 레벨

  • 반년/연간계획:  Vacuum Full Analyze 카탈로그 테이블 수행

9.      ETL 방법


  • Data Loading

  • 권고 사항: Gpload 또는 external table 사용
  • 비권고 사항: ODBC 를 이용한 데이터 적재
  • Gpload 수행 후 vacuum 테이블 수행

  • ETL 수행 순서: Extract => Load => Transform
    • Gpload 수행 후 vacuum 테이블 수행

10. DBA


  • Resource Queue 설정

  • 계정별 Resource Queue 설정(동시 쿼리 수행수, Max Cost, Max Memory 설정)
  • 상세 설정은 DBA 지원 필요

11. 쿼리 플랜


  • 쿼리 플랜 확인 방법

  • Pgadmin 에서 F6 수행 또는 쿼리 제일 앞에 explain를 기입하고 실행

12. 성능 이슈 발생 확인 사항


  1. 프로젝트 종료 후 몇 개월 후에 배치가 서서히느려질 경우

  •  Dimension Table Bloated 된 경우, Vacuum 이 제대로 수행되지 않은 경우

  1. 잘 수행되는 배치가 갑자기 느려질 경우

  • 통계 정보가 제대로 수행되지 않아, 쿼리 플랜이 변경 된 경우
  • Analyze 가 수행이 되었는지 확인 필요

  1. 디스크 IO Busy 때문에 전반적으로 수행이 느린 경우

  • 테이블 압축 여부 확인
  • 테이블에 Index 개수 확인
  • 불 필요한 인덱스 삭제
  • Index Rebuild 검토
  • Fact 파티션 테이블일 경우 파티션 기간을 조절하여, Index 부하를 줄임.

  1. Short 쿼리가 느린 경우

  • 다른 세션에서 Disk IO를 많이 일으킬 경우 발생 가능
  • Index 테이블에 데이터 적재하는 경우 발생 가능성 있음.

  • Index 테이블 사이즈를 최소화 함.(파티션 기간 조정)

  1. 쿼리툴 접속이 느려지는 경우

  • Resource Queue Active session 확인
  • 시스템 카탈로그 테이블 사이즈 검토 및 Vacuum, index rebuild 검토

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

 

 
 
 

Greenplum Ghost Index

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