달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'Work/PostgreSQL'에 해당되는 글 32

  1. 2014.07.01 pl/r 설치
  2. 2014.06.25 External table
  3. 2013.03.15 Backup & Restore
  4. 2013.03.13 Postgresql 9.2 Install 및 pg_hint_plan 적용
  5. 2013.03.13 PostgreSQL Streaming Replication
  6. 2012.09.17 Postgresql 9.2.0 발표 1
  7. 2012.08.01 pg_resetxlog 사용
  8. 2012.08.01 N-gram Full text Search test
2014. 7. 1. 10:35

pl/r 설치 Work/PostgreSQL2014. 7. 1. 10:35

R 이라고... SAS나 SPSS 같은... 통계쪽에서 사용하는 패키지가 있다. 

PL/R은 R 통계 컴퓨팅 언어로 PostgreSQL의 함수들과 집계 함수를 작성 할 수있는 PostgreSQL의 언어 확장이다.


CentOS에 설치된 Postgresql-9.2 에서는 기본적으로 제공하지 않지만... yum을 이용하여 pl/r을 설치할 수 있다.


[root@syslog ~]# yum search plr

.

.

.

[root@syslog ~]# yum install plr92.x86_64

.

.

.

[root@syslog ~]# su - postgres

[postgres@syslog ~]$ cd /usr/pgsql-9.2/share/extension/

[postgres@syslog extension]$ ls

.

.

.

plr--8.3.0.15.sql

plr.control

plr.sql

plr--unpackaged--8.3.0.15.sql

.

.

.

extension을 설치할 준비는 끝났다.


설치한다.

[postgres@syslog extension]$ psql -d mgtdb 

psql (8.4.20, server 9.2.8)

WARNING: psql version 8.4, server version 9.2.

         Some psql features might not work.

Type "help" for help.


mgtdb=# 

mgtdb=# create extension plr;

CREATE EXTENSION


설치가 잘 되었는지 간단한 테스트!

mgtdb=# SELECT * FROM plr_environ();

        name        |                                                 value                                                 

--------------------+-------------------------------------------------------------------------------------------------------

 HOSTNAME           | syslog.nips.local

 SHELL              | /bin/bash

 TERM               | linux

 HISTSIZE           | 1000

 QTDIR              | /usr/lib64/qt-3.3

 QTINC              | /usr/lib64/qt-3.3/include

 USER               | postgres

 TMOUT              | 900

 MAIL               | /var/spool/mail/postgres

 PATH               | /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/postgres/bin

 PWD                | /home/postgres

 LANG               | en_US.UTF-8

 HISTCONTROL        | ignoredups

 SHLVL              | 1

 HOME               | /home/postgres

 LOGNAME            | postgres

 QTLIB              | /usr/lib64/qt-3.3/lib

 CVS_RSH            | ssh

 PGDATA             | /var/lib/pgsql/9.2/data

 LESSOPEN           | |/usr/bin/lesspipe.sh %s

 HISTTIMEFORMAT     | %F %T IP: ID:postgres  

 G_BROKEN_FILENAMES | 1

 _                  | /usr/pgsql-9.2/bin/postmaster

 PGLOCALEDIR        | /usr/pgsql-9.2/share/locale

 PGSYSCONFDIR       | /etc/sysconfig/pgsql

 LC_COLLATE         | en_US.UTF-8

 LC_CTYPE           | en_US.UTF-8

 LC_MESSAGES        | en_US.UTF-8

 LC_MONETARY        | C

 LC_NUMERIC         | C

 LC_TIME            | C

(31 rows)


mgtdb=# 


reference : http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgresql_plr_tut01

:
Posted by Elick
2014. 6. 25. 16:47

External table Work/PostgreSQL2014. 6. 25. 16:47

Oracle에서는 External table 이라는 기능을 잘 사용했었다.

Postgresql에서도 비슷한 기능이 9.1 부터 지원된다고 해서 테스트 해보았다.


-- 일단 extention을 설치. 

CREATE EXTENSION file_fdw;


-- 서버 생성.

CREATE SERVER file_fdw_server FOREIGN DATA WRAPPER file_fdw


-- FOREIGN TABLE 생성.

CREATE FOREIGN TABLE work_01.fdw_test (

id_kipi varchar(32)

) SERVER file_fdw_server

OPTIONS (format 'text', filename '/mnt/splee/fdw_test.txt', delimiter ',', null '');


select * from work_01.fdw_test;

/*

결과 잘 나옴.!!!

*/


file_fdw 라는 확장을 설치 후 위처럼 테스트를 진행했는데... 굉장히 간단하게 성공...

쓸만하다...

:
Posted by Elick
2013. 3. 15. 13:49

Backup & Restore Work/PostgreSQL2013. 3. 15. 13:49

대부분 데이터베이스가 그렇듯이... Postgresql도 백업과 복구가 존재한다.

백업은 크게 논리백업과 물리백업으로 나누어지고... 물리백업은 pg_basebackup 툴을 이용한 백업과 저수준 API를 이용한 백업으로 나누어진다.

 

논리 백업은 os 상에서 pg_dump 라는 uitl 로 하면 된다. 여러가지 옵션이 있어서 다르지만, 복구에 필요한 script가 파일로 생성되는 형태이다.

물리백업은 오라클의 hot backup 과 유사하다. pg_basebackup 을 이용한 간단한 방법이 있다. 검색하면 내용이 많이 나오는 듯.... 저수준 API를 이용한 방법은 psql 상에서 select pg_start_backup (...), select pg_stop_backup (...) 을 이용하게 된다. 마찬가지로 자세한 것은 google에...

 

이외에... PostgreSQL 8.3 이상 버전이면 BARMAN 이라는 백업복구툴을 이용할 수 있을 듯 하다.

([출처] PostgresDBA - http://www.postgresdba.com/bbs/board.php?bo_table=B13&wr_id=5)

 

 

 

 

:
Posted by Elick

Overview

 

Installation

USER
Commad
Description
root  
 yum updateOS Update
 rpm -Uvh http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpmPostgresql 9.2 repository 등록
 yum install postgresql92 postgresql92-server postgresql92-contribPostgresql 9.2 install
 service postgresql-9.2 initdbPostgresql 데이터베이스 초기화
postgres  
 postgresql.conf, pg_hba.conf 수정기본 설정
root  
 service postgresql-9.2 startPostgresql Servcie 실행
 wget "http://en.sourceforge.jp/frs/redir.php?m=iij&f=%2Fpghintplan%2F57713%2Fpg_hint_plan92-1.0.0-1.el6.x86_64.rpm"pg_hint_plan download
 yum localinstall pg_hint_plan92-1.0.0-1.el6.x86_64.rpmpg_hint_plan install
postgres  
 postgresql.conf 수정 : shared_preload_libraries = 'pg_hint_plan' 추가pg_hint_plan 환경 설정 변경
root  
 service postgresql-9.2 restartPostgresql 재시작
postgres  
 psqlpsql 실행
 

CREATE TABLE tbl (i int, j int);
INSERT INTO tbl SELECT x, x * 2 FROM generate_series (1, 10) x;
CREATE INDEX idx ON tbl (i);
VACUUM ANALYZE tbl;
EXPLAIN SELECT * FROM tbl WHERE i = 7;
/*+ IndexScan (tbl) */ EXPLAIN SELECT * FROM tbl WHERE i = 7;

실행계획 비교.

 

실행계획 확인

실행계획 확인
-bash-4.1$ psql
psql (9.2.3)
Type "help" for help.
postgres=# EXPLAIN SELECT * FROM tbl WHERE i = 7;
                    QUERY PLAN                    
---------------------------------------------------
 Seq Scan on tbl  (cost=0.00..1.12 rows=1 width=8)
   Filter: (i = 7)
(2 rows)
postgres=# /*+ IndexScan (tbl) */ EXPLAIN SELECT * FROM tbl WHERE i = 7;
                          QUERY PLAN                          
---------------------------------------------------------------
 Index Scan using idx on tbl  (cost=0.00..8.27 rows=1 width=8)
   Index Cond: (i = 7)
(2 rows)
postgres=# \q
-bash-4.1$


개인적 감상 : 이제 postgresql에서도 hint를 사용할 수 있다!!!


Hint List

  • 스캔 방식
    • SeqScan (table) 
      • 지정된 table에 대해 Seq Scan을 선택합니다.
    • TidScan (table) 
      • 지정된 table에 대해 Tid Scan을 선택합니다. 검색 조건에 ctid을 지정한 경우에만 유효합니다.
    • IndexScan (table index ...) 
      • 지정된 table에 대한 Index Scan을 선택합니다. index를 지정하면, 지정한 index에 비용이 최소가되는 Index Scan을 선택합니다. 
        그러나 index가 존재하지 않거나 지정된 index가 WHERE 절이나 JOIN 조건 등에 관련 않으면 Seq Scan을 선택합니다.
    • IndexOnlyScan (table index ...) 
      • 지정된 table에 대한 Index Onl??y Scan과 Index Scan 중 비용이 최소가되는 스캔 방식을 선택합니다.
         index를 지정하면, 지정한 index에서 Index Onl??y Scan과 Index Scan 중 비용이 최소가되는 스캔 방식을 선택합니다. 
        그러나 index가 존재하지 않거나 지정된 index가 WHERE 절이나 JOIN 조건 등에 관련 않으면 Seq Scan을 선택합니다. 
        또한 이러한 경우 외에도 index가 가지는 값뿐만 아니라 table의 값이 필요한 경우는 Index Scan을 선택합니다. PostgreSQL 9.2 이상이 필요합니다.
    • BitmapScan (table index ...) 
      • 지정된 table에 대해 Bitmap Scan을 선택합니다. 
        index를 지정하면, 지정한 index에 비용이 최소가되는 index를 선택합니다. 
        그러나 index가 존재하지 않거나 지정된 index가 WHERE 절이나 JOIN 조건 등에 관련 않으면 Seq Scan을 선택합니다.
    • NoSeqScan (table) 
      • 지정된 table에 대해 Seq Scan 이외 비용을 최소화하는 스캔 방식을 선택합니다. 
        그러나 다른 검색 방식을 선택할 수없는 경우는 Seq Scan을 선택합니다.
    • NoTidScan (table) 
      • 지정된 table에 대해 Tid Scan 이외 비용을 최소화하는 스캔 방식을 선택합니다.
    • NoIndexScan (table) 
      • 지정된 table에 대한 Index Scan 및 Index Onl??y Scan을 제외한 스캔 방식에서 비용을 최소화하는 스캔 방식을 선택합니다.
    • NoIndexOnlyScan (table) 
      • 지정된 table에 대한 Index Onl??y Scan 이외 비용을 최소화하는 스캔 방식을 선택합니다. (PostgreSQL 9.2 이상)
    • NoBitmapScan (table) 
      • 지정된 table에 대해 Bitmap Scan 이외 비용을 최소화하는 스캔 방식을 선택합니다.
  • 결합 방식
    • NestLoop (table table table ...) 지정된 table 간의 조인에 Nested Loop을 선택합니다.
    • HashJoin (table table table ...) 지정된 table 간의 조인에 Hash Join을 선택합니다.
    • MergeJoin (table table table ...) 지정된 table 간의 조인에 Merge Join을 선택합니다.
    • NoNestLoop (table table table ...) 지정된 table 간의 조인에 Nested Loop 이외의 결합 방식을 선택합니다.
    • NoHashJoin (table table table ...) 지정된 table 간의 조인에 Hash Join 이외의 결합 방식을 선택합니다.
    • NoMergeJoin (table table table ...) 지정된 table 간의 조인에 Merge Join 이외의 결합 방식을 선택합니다.
  • 조인 순서
    • Leading (table table table ...) 지정된 table을 지정한 순서대로 결합합니다.
  • GUC 매개 변수
    • Set (GUC 매개 변수 값) 쿼리 실행 계획을 작성하고있는 동안 만 지정된 GUC 매개 변수 값으로 변경합니다.


:
Posted by Elick
2013. 3. 13. 10:04

PostgreSQL Streaming Replication Work/PostgreSQL2013. 3. 13. 10:04

PostgreSQL Streaming Replication

Overview
  • 스트리밍 복제 (Streaming Replication)은 PostgreSQL 9.0 이상에서 사용 가능한 복제 기능.
  • Insert/Update/Delete, Create/Drop 가능한 1 개의 Master DB에 SELECT만 할 수 있는 여러 Standby DB에 복제하는 것
  • Standby DB의 변경 결과가 반영되기까지 약간의 지연이 있지만 비교적 지연은 적게, 마스터 DB에 영향 작은 복제 방식.
Purpose
  • 많은 SELECT Query의 Server 간 분산
  • Master DB 이상시 신속한 Fail over
  • Master DB의 Disk 장애에 대비한 실시간 Backup
9.0 에 비해 강화된 9.1의 기능
  • 동기화 복제 (변경 결과 도착 보장)
  • 기반 Backup의 간소화 (초기 Data 복제 도구)
  • 복제 상태를 확인하기위한 System view
  • Fail Over 지원 강화 (전용 명령 다른 Master Server에 다시 연결)
구성
  • Master 1EA(192.168.83.146), Slave 1EA(192.168.83.147)
구축 절차
  • Master
    • Postgresql 9.1 설치 (생략)
    • 복제용 사용자 생성

      -bash-4.1$ psql
      psql (9.1.7)
      Type "help" for help.
       
      postgres=# CREATE ROLE repl_user LOGIN REPLICATION PASSWORD 'xxxxxxxx';
      CREATE ROLE
      postgres=# \q
      -bash-4.1$
    • pg_hba.conf 수정

      vi $PGDATA/pg_hba.conf
      host all         all       127.0.0.1/32 trust
      host replication repl_user 127.0.0.1/32 md5
      host all         all       ::1/128      trust
      host replication repl_user ::1/128      md5
    • postgresql.conf 수정

      vi $PGDATA/postgresql.conf
      wal_level = hot_standby
      max_wal_sender = 2 # 대기 DB의 수 + 1
      # Archive 사용시
      archive_mode = on
      archive_command = 'cp "%p" /mnt/pgbackup/archive/"%f"'
      # Archive 미사용시
      archive_mode = off
      wal_keep_segments = 8 # 8-32가 기준
    • pg_basebackup 으로 Master를 Backup

      Base Backup
      -bash-4.1$
      -bash-4.1$ /usr/pgsql-9.1/bin/pg_basebackup -h localhost -U repl_user -D /mnt/pgbackup/cluster/ -xlog -c fast -P
      Password:
      35430/35430 kB (100%), 1/1 tablespace
      -bash-4.1$
  • Slave
    • Postgresql 9.1 설치 (생략)
    • Master의 Backup을 restore

      Master
      -bash-4.1$ rsync -ra /mnt/pgbackup/cluster/* root@192.168.83.147:/mnt/pgbackup/cluster/
      root@192.168.83.147's password:
      -bash-4.1$
      Slave
      -bash-4.1$ cd /mnt/pgbackup/cluster
      -bash-4.1$ cp -rf ./* /$PGDATA/
      -bash-4.1$
    • postgresql.conf 수정

      vi $PGDATA/postgresql.conf
      wal_level = minimal
      max_wal_sender = 0
      archive_command = 'cp "%p" /mnt/pgbackup/archive/"%f"'
      hot_standby = on
    • recovery.conf 생성

      vi $PGDATA/recovery.conf
      standby_mode = 'on'
      primary_conninfo = 'host=192.168.83.146 port=5432 user=repl_user password=xxxxxxxx'
  • Postgresql start
    • Master Start

      [root@localhost mnt]# service postgresql-9.1 start
      Starting postgresql-9.1 service:                           [  OK  ]
      [root@localhost mnt]#
    • Slave Start

      [root@localhost mnt]# service postgresql-9.1 start
      Starting postgresql-9.1 service:                           [  OK  ]
      [root@localhost mnt]#
복제상태 확인
  • Process
    • Master

      wal sender process 있는지 확인
      -bash-4.1$ ps -ef | grep postgres
      postgres  2927     1  0 Jan03 ?        00:00:00 /usr/pgsql-9.1/bin/postmaster -p 5432 -D /var/lib/pgsql/9.1/data
      postgres  2930  2927  0 Jan03 ?        00:00:00 postgres: logger process                                       
      postgres  2933  2927  0 Jan03 ?        00:00:01 postgres: writer process                                       
      postgres  2934  2927  0 Jan03 ?        00:00:01 postgres: wal writer process                                   
      postgres  2935  2927  0 Jan03 ?        00:00:00 postgres: autovacuum launcher process                          
      postgres  2936  2927  0 Jan03 ?        00:00:00 postgres: archiver process   last was 000000010000000000000006.00000020.backup
      postgres  2937  2927  0 Jan03 ?        00:00:00 postgres: stats collector process                              
      postgres  3194  2927  0 Jan03 ?        00:00:00 postgres: wal sender process repl_user 192.168.83.147(44356) streaming 0/7028558
      root      3227  2982  0 Jan03 pts/0    00:00:00 su - postgres
      postgres  3228  3227  0 Jan03 pts/0    00:00:00 -bash
      postgres  3695  3228  0 00:11 pts/0    00:00:00 ps -ef
      postgres  3696  3228  0 00:11 pts/0    00:00:00 grep postgres
      -bash-4.1$
    • Slave

      wal receiver process, startup process 있는지 확인.
      -bash-4.1$ ps -ef | grep postgres
      postgres  4212     1  0 Jan03 ?        00:00:00 /usr/pgsql-9.1/bin/postmaster -p 5432 -D /var/lib/pgsql/9.1/data
      postgres  4214  4212  0 Jan03 ?        00:00:00 postgres: logger process                                       
      postgres  4215  4212  0 Jan03 ?        00:00:00 postgres: startup process   recovering 000000010000000000000007
      postgres  4216  4212  0 Jan03 ?        00:00:01 postgres: writer process                                       
      postgres  4217  4212  0 Jan03 ?        00:00:00 postgres: stats collector process                              
      postgres  4218  4212  0 Jan03 ?        00:00:02 postgres: wal receiver process   streaming 0/7028558           
      root      4277  2961  0 Jan03 pts/0    00:00:00 su - postgres
      postgres  4278  4277  0 Jan03 pts/0    00:00:00 -bash
      postgres  4565  4278  9 00:12 pts/0    00:00:00 ps -ef
      postgres  4566  4278  0 00:12 pts/0    00:00:00 grep postgres
      -bash-4.1$

Fail Over
  • Master Service 중지

    Maseter Postgresql stop
    -bash-4.1$
    -bash-4.1$ exit
    logout
    [root@localhost mnt]# service postgresql-9.1 stop
    Stopping postgresql-9.1 service:                           [  OK  ]
    [root@localhost mnt]#
  • Slave 에서 DDL 실행 : 실패

    Slave Postgresql 상태 확인 및 DDL 실행
    -bash-4.1$
    -bash-4.1$ exit
    logout
    [root@localhost mnt]# service postgresql-9.1 status
     (pid  4212) is running...
    [root@localhost mnt]# su - postgres
    -bash-4.1$ psql -d db_test_01
    psql (9.1.6)
    Type "help" for help.
    db_test_01=# create table t_test_02 (col1 int);
    ERROR:  cannot execute CREATE TABLE in a read-only transaction
    db_test_01=# \q
    -bash-4.1$
  • pg_ctl promote 실행

    -bash-4.1$
    -bash-4.1$ /usr/pgsql-9.1/bin/pg_ctl promote -D $PGDATA
    server promoting
    -bash-4.1$
  • Slave 에서 DDL 실행 : 성공

    -bash-4.1$
    -bash-4.1$ psql
    psql (9.1.6)
    Type "help" for help.
    postgres=# create table t_test_02 (col1 int);
    CREATE TABLE
    postgres=# \q
    -bash-4.1$


Reference : 
http://lets.postgresql.jp/documents/technical/replication/1/


개인적 소감 : 생각보다 간단한 복제 설정이었음. 극단적인 환경에서 사용해보지 않아 성능적인 부분은 보장할 수 없지만, 평범한 환경에서라면 충분히 쓸만한 듯 함.

:
Posted by Elick
2012. 9. 17. 15:15

Postgresql 9.2.0 발표 Work/PostgreSQL2012. 9. 17. 15:15

2012 년 9 월 10 일 PostgreSQL Global Development Group은 오픈 소스 데이터베이스 업체 인 PostgreSQL의 최신 버전 9.2의 출시를 발표합니다. 5 월에 베타 버전이 출시 된 이후, 개발자와 벤더는 성능, 확장 성, 유연성 측면에서 이 릴리스가 크게 진보 한 것을 높이 평가했습니다.


1. 성능과 확장성 향상 : 64 코어까지의 선형 확장성, index-only scan, CPU 전력 소비 감소

- 초당 최고 350,000 번의 검색 Query (기존 대비 4 배 빠른)

- index-only scan에 의한 DW Query (기존 대비 2 배에서 20 배의 속도)

- 초당 최고 14,000 개의 update 작업 (기존 대비 5 배 빠른)

2. 계단식 복제 기능 추가

3. RANGE 형과 JSON을 지원


출처 : http://lets.postgresql.jp/news/9_2_release


-- 개인적으로 힌트나 좀 추가해주지... 라는 생각과 index-only scan 이 지금 추가된 것으로 보아 상용 DBMS 와의 경쟁에서 아직은 아쉽다라는 생각... 무료라는 것과 의외로 넓은 활용성이 엄청난 강점이지만... 지속적인 upgrade가 되는 것으로 보아 언젠가는 상용 DBMS를 따라 잡을 수 있을 것 같다는 기대감이 있습니다.


dowload : http://www.postgresql.org/download/

:
Posted by Elick
2012. 8. 1. 15:47

pg_resetxlog 사용 Work/PostgreSQL2012. 8. 1. 15:47

Database의 Transaction Log가 해당 Disk 혹은 Volume 을 모두 차지해서 Postgresql service가 내려가는 경우라 던가... 여타의 이유로 Postgresql service 를 시작하고자 하는데.. Transaction Log의 replay 를 막고자 하는 경우가 있다.

이 경우 pg_resetxlog 를 사용하면 된다. 당연히 Postgresql service 는 내려가 있는 상태에서 실행해야 한다.

login as: root
root@xxx.xxx.xxx.xxx'password:
Last login: Fri Jul 27 18:08:12 2012 from 10.3.4.34
*** [ 경고 WARNING ] **************************************************
- 부당한 접속, 자료의 변경, 유출 및 삭제 시 해당 법령에 의해 처벌 됨
- Any improper access and disclosure of material changes and deletions
  that becomes punishable by law.
***********************************************************************
[root@pgdb01 ~]# su - postgres
-bash-4.1$ cd /usr/pgsql-9.1/bin/
-bash-4.1$ ls -alh
total 6.8M
.
.
-rwxr-xr-x. 1 root root  29K Jun  4 09:20 pg_resetxlog
.
.
-bash-4.1$
-bash-4.1$ ./pg_resetxlog --help
pg_resetxlog resets the PostgreSQL transaction log.
Usage:
  pg_resetxlog [OPTION]... DATADIR
Options:
  -e XIDEPOCH     set next transaction ID epoch
  -f              force update to be done
  -l TLI,FILE,SEG force minimum WAL starting location for new transaction log
  -m XID          set next multitransaction ID
  -n              no update, just show extracted control values (for testing)
  -o OID          set next OID
  -O OFFSET       set next multitransaction offset
  -x XID          set next transaction ID
  --help          show this help, then exit
  --version       output version information, then exit
Report bugs to <pgsql-bugs@postgresql.org>.
-bash-4.1$ ./pg_resetxlog -f /var/lib/pgsql/9.1/data
Transaction log reset
-bash-4.1$ exit
logout
[root@pgdb01 ~]# service postgresql-9.1 start
Starting postgresql-9.1 service:                           [  OK  ]
[root@pgdb01 ~]#


:
Posted by Elick
2012. 8. 1. 15:08

N-gram Full text Search test Work/PostgreSQL2012. 8. 1. 15:08

Overview

pg_trgm의 모듈은 trigram 매칭으로 ASCII 영숫자 텍스트의 유사성을 결정하는 함수와 연산자를 제공.
이를 활용하여 앞뒤의 와일드카드가 포함된 검색을 빠르게 처리.


환경

  • CentOS
  • Postgresql 9.1.4
  • Postgresql의 pg_trgm.so Library
설정검사
  • pg_trgm.so Library 설치 확인 및 Extension 설치, 기능 test
login as: root
root@xxx.xxx.xxx.xxx's password:
Last login: Tue Jul 31 20:51:44 2012 from 10.3.4.34
*** [ 경고 WARNING ] **************************************************
- 부당한 접속, 자료의 변경, 유출 및 삭제 시 해당 법령에 의해 처벌 됨
- Any improper access and disclosure of material changes and deletions
  that becomes punishable by law.
***********************************************************************
[root@pgdb01 ~]# su - postgres
-bash-4.1$ cd /usr/pgsql-9.1/bin
-bash-4.1$ ./pg_config --libdir
/usr/pgsql-9.1/lib
-bash-4.1$ cd /usr/pgsql-9.1/lib
-bash-4.1$ ls -alh pg_trgm.so
-rwxr-xr-x. 1 root root 23K Jun  4 09:21 pg_trgm.so
-bash-4.1$ psql -d db_patent
psql (9.1.4)
Type "help" for help.
db_patent=# CREATE EXTENSION pg_trgm;
CREATE EXTENSION
db_patent=# \df
.
.
생략
.
.
(27 rows)
db_patent=#
db_patent=#  SELECT show_trgm('테스트');
               show_trgm
---------------------------------------
 {0xf5d371,0xf74fa4,0x016735,0x7349c7}

(1 row)
db_patent=#

Reference URL



:
Posted by Elick