달력

8

« 2012/8 »

  • 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

'2012/08'에 해당되는 글 2

  1. 2012.08.01 pg_resetxlog 사용
  2. 2012.08.01 N-gram Full text Search test
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