Archive

Archive for December, 2011

[PostgreSQL] dblink

December 22, 2011 Leave a comment

dblink_connect

dblink_connect (text connstr) returns text
dblink_connect (text conname, text connstr) returns text

(example 1)
SELECT dblink_connect (‘connect_name’, ‘hostaddr=10.3.4.13 port=5432 dbname=db_kr_patent user=postgres password=xxxx’);

(example 2)
CREATE TABLE t_publish AS
SELECT id_kipi, publn_nat_cd_std, dnum_kipi, dnum_jgr, doc_kind_std, doc_publn_date
FROM dblink(‘jpnips_connect’,’select id_kipi, publn_nat_cd_std, dnum_kipi, dnum_jgr, doc_kind_std, doc_publn_date from t_publish’)
AS t1 (  id_kipi character varying(32),
publn_nat_cd_std character varying(8),
dnum_kipi character varying(32),
dnum_jgr character varying(32),
doc_kind_std character varying(8),
doc_publn_date character varying(16)
);

Advertisements

VirtualBox Guest Additions on Fedora 16

December 16, 2011 Leave a comment

디스플레이 설정
– 비디오 메모리 : 128 MB
– 3D 가속 : Enable

Fedora 16 설치

사전작업
# yum update
# yum install kernel-devel kernel-headers dkms gcc gcc-c++

VM 재부팅

Guest Additions 설치
– VM 창의 장치 메뉴에서 게스트 확장 설치 실행 (CD/DVD 장치가 마운트되어 있어야 함)
– /media 디렉토리 하위의 VBOXADDITIONS 디렉토리로 이동
– # ./VBoxLinuxAdditions.run
– (GNOME 3 쉘 사용하려면) # restorecon -R -v /opt

VM 재부팅 (완료)

postgreSQL on Fedora 16 (설치 및 환경설정)

December 14, 2011 Leave a comment

서버설치
# yum install postgresql-sever

pgadmin 설치
# yum install pgadmin3

데이터베이스 생성
# postgresql-setup initdb
(Fedora 16부터 명령어 변경됨. 이전에는 “# service postgresql initdb”)

서비스 시작
# service postgresql start

postgres 계정으로 접속 및 패스워드 설정
# su – postgres
-bash-4.2$ psql postgres
psql (9.1.2)
Type “help” for help.

postgres=# ALTER USER postgres WITH ENCRYPTED PASSWORD ‘사용할 패스워드 문자열’;
postgres=# \q
-bash-4.2$ exit

접근방식 (ident -> password) 및 메모리 사용 설정 변경
# vi /var/lib/pgsql/data/pg_hba.conf
——————————————————————————————-
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# “local” is for Unix domain socket connections only
local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            password
host    all             all             0.0.0.0/0                  password
# IPv6 local connections:
host    all             all             ::1/128                 password
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident
——————————————————————————————-

# vi /var/lib/pgsql/data/postgresql.conf
——————————————————————————————-
listen_addresses = ‘*’
port = 5432
max_connections = 100
shared_buffers = 4096MB (이와 같이 설정했을 때 postgresql 서비스가 시작되지 못하는 문제가 발생된다. 원래대로 32MB로 설정할 것)
——————————————————————————————-

서비스 재시작
# service postgresql restart

pgadmin3로 접속 및 작업
# pgadmin3