Æ÷½ºÆ®±×·¹½º´Â ftp://ftp.postgresql.org/pub ¿¡¼ postgresql-7.0.3.tar.gz¸¦ ´Ù¿î¹Þ°í, root À¯Àú·Î ¼³Ä¡ÇÑ´Ù. ´ÙÀ½Àº ¾ÐÃàÀ» Ǫ´Â ¿¹ÀÌ´Ù.
$ cd /usr/local/src
$ tar zxvf postgresql-7.0.3.tar.gz
Configure , make , make install¸¦ ÇÑ´Ù. ´ÙÀ½Àº configure, make ¹× make install ¿¹ÀÌ´Ù.
$ cd /usr/local/src/postgresql-7.0.3/src
$ ./configure --enable-multibyte \
--enable-locale \
--with-tcl
$
$ make
$ make install
$
$ cd ../doc
$ make install
$
$ adduser postgres
$ chown -R postgres:postgres /usr/local/pgsql
ȯ°æ ¼³Á¤À» ÇÑ´Ù. ȯ°æ¼³Á¤Àº /etc/ld.so.conf ¿Í /etc/profile ¸¸À» ÆíÁýÇÑ´Ù.
´ÙÀ½Àº ȯ°æ¼³Á¤ ¿¹ÀÌ´Ù.
$ vi /etc/ld.so.conf
/usr/local/pgsql/lib <=¸¶Áö¸· ¶óÀο¡ Ãß°¡
$
$ /sbin/ldconfig
$
$ vi /etc/profile
...
...
PGDATA=/usr/local/pgsql/data
PGLIB=/usr/local/pgsql/lib
MANPATH=$MANPATH:/usr/local/pgsql/man
PATH=$PATH:/usr/local/pgsql/bin
export PGDATA PGLIB MANPATH PATH
$
$ . /etc/profile
$
¼³Ä¡¸¦ ¿Ï·áÇϸé ù ½ÇÇàÀ» ÇÒ Áغñ°¡ µÇ¾ú´Ù. ´ÙÀ½Àº ½ÇÇà ¿¹ÀÌ´Ù.
$ su - postgres
$ initdb -E EUC_KR
$ pg_ctl start
initdb ´Â Æ÷½ºÆ®±×·¹½ºÀÇ µ¥ÀÌŸº£À̽ºµéÀ» °ü¸®Çϱâ À§ÇÑ Á¤º¸ ¹× µ¥ÀÌŸº£À̽º¸¦ ÀúÀåÇÒ µð·ºÅ丮¸¦ ¸¸µé¸ç, Æ÷½ºÆ®±×·¹½º°¡ ±âµ¿µÇ±âÀü¿¡ ½ÇÇàµÇ¾îÁ®¾ß ÇÑ´Ù. ±âŸ Æ÷½ºÆ®±×·¹½º¿Í °ü·ÃµÈ ¿©·¯°¡Áö ÃʱâÈ ÀÛ¾÷À» ÇÑ´Ù.
initdb ´Â ȯ°æº¯¼ö PGDATA °ªÀ» ÂüÁ¶ÇÏ¿© /pgsql_base_dir/data µð·ºÅ丮¸¦ ¸¸µé¸ç /pgsql_base_dir/data/base µð·ºÅ丮¿¡ °¢ µ¥ÀÌŸº£À̽ºµéÀÌ ÀúÀåµÈ´Ù.
Âü°í·Î Æ÷½ºÆ®±×·¹½ºÀÇ initdb ½ÇÇà ÈÄ template1À̶ó´Â µ¥ÀÌŸº£À̽º°¡ »ý¼ºµÈ´Ù.
initlocationÀº ´Ù¸¥ PGDATA ¸¦ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù. Áï µ¥ÀÌŸº£À̽º°¡ $PGDATA¿ÜÀÇ ´Ù¸¥ µð·ºÅ丮¿¡ ÀúÀåµÉ ¼ö ÀÖ´Ù. ´ÙÀ½Àº initlocationÀÇ È°¿ë ¿¹ ¹× µ¥ÀÌŸº£À̽º »ý¼º ¿¹ÀÌ´Ù.
$ su - postgres
$ export PGDTA2=/usr/local/pgsql/data2
$ export PGDTA3=/usr/local/pgsql/data3
$ export PGDTA4=/usr/local/pgsql/data4
$ initlocation PGDATA2
The location will be initialized with username "postgres".
This user will own all the files and must also own the server process.
Creating directory /usr/local/pgsql/data2
Creating directory /usr/local/pgsql/data2/base
initlocation is complete.
You can now create a database using
CREATE DATABASE <db_name> WITH LOCATION='PGDATA2';
in SQL,
or
createdb <db_name> -D 'PGDATA2'
from thr shell.
$
$ initlocation PGDATA3
The location will be initialized with username "postgres".
This user will own all the files and must also own the server process.
Creating directory /usr/local/pgsql/data3
Creating directory /usr/local/pgsql/data3/base
initlocation is complete.
You can now create a database using
CREATE DATABASE <db_name> WITH LOCATION='PGDATA3';
in SQL,
or
createdb <db_name> -D 'PGDATA3'
from thr shell.
$
$ initlocation PGDATA4
The location will be initialized with username "postgres".
This user will own all the files and must also own the server process.
Creating directory /usr/local/pgsql/data4
Creating directory /usr/local/pgsql/data4/base
initlocation is complete.
You can now create a database using
CREATE DATABASE <db_name> WITH LOCATION='PGDATA4';
in SQL,
or
createdb <db_name> -D 'PGDATA4'
from thr shell.
$
$ pg_ctl start
$
$ createdb ngd_db1 -D 'PGDATA2'
CREATE DATABASE
$
$ psql ngd_db1
...
ngd_db1=# create database test_db with location='PGDATA2';
CREATE DATABASE
ngd_db1=# \q
$
$ psql test_db
..
test_db=# \q
$
$ createdb ngd_db2 -D 'PGDATA3'
CREATE DATABASE
$
$ psql ngd_db2
...
ngd_db2=# \q
$
$ createdb ngd_db3 -D 'PGDATA4'
CREATE DATABASE
$
$ psql ngd_db3
...
ngd_db3=# \q
$
"template1" µ¥ÀÌŸº£À̽º´Â Æ÷½ºÆ®±×·¹½ºÀÇ "initdb"¸í·ÉÀ» ÅëÇØ Á¦ÀÏ Ã³À½ »ý¼ºµÇ´Â µ¥ÀÌŸº£À̽ºÀÌ´Ù. »õ·Î »ý¼ºµÇ´Â µ¥ÀÌŸº£À̽ºµéÀ» À§ÇÑ ±âº»ÀûÀΠƲ(template) ¿ªÇÒÀ» ÇÑ´Ù.
´ÙÀ½ÀÇ ¿¹¿¡¼ $PGDATA ¸¦ »èÁ¦ÇÑ´Ù. ¸¸¾à ÀÚ½ÅÀÇ Áß¿äÇÑ µ¥ÀÌŸ¸¦ °¡Áö°í ÀÖ´Â µ¥ÀÌŸº£À̽º°¡ ÀÖ´Ù¸é ÀÌ ¿¹´Â ±×³É ´«À¸·Î¸¸ º¸°í µû¶óÇÏÁö ¸»±â¸¦ ¹Ù¶õ´Ù. -- ÁÖÀÇ ¿ä¸Á
template1 Àº óÀ½ »ý¼ºµÇ´Â µ¥ÀÌŸº£À̽º¿¡°Ô ÀÚ½ÅÀÇ ¼Ó¼ºÀ» Á¦°øÇÏ¿© »ó¼ÓÄÉÇÑ´Ù. ¶ÇÇÑ template1ÀÌ ¼ÒÀ¯ÇÑ Å×À̺í Áß »ç¿ëÀÚ°¡ ÀÛ¼ºÇÑ Å×À̺íÀÌ ÀÖ´Ù¸é ÀÌ ¶ÇÇÑ »õ·Î »ý¼ºµÇ´Â µ¥ÀÌŸº£À̽º¿¡ »ó¼ÓµÈ´Ù.
´ÙÀ½Àº template1ÀÇ »ó¼Ó ¿¹¸¦ º¸¿©ÁØ´Ù.
$ su - postgres
$ pg_ctl stop
$ rm -rf /usr/local/pgsql/data
$ export PGDATA2=/usr/local/pgsql/data2
$ initdb -E EUC_KR
$ initlocation PGDATA2
À§ÀÇ °úÁ¤À» °ÅÄ¡¸é¼ Æ÷½ºÆ®±×·¹½º´Â ¹°¸®ÀûÀ¸·Î ¼·Î ´Ù¸¥ µ¥ÀÌŸº£À̽º ÀúÀå¼Ò¸¦ °¡Áø´Ù. (PGDATA, PGDTA2)
$ pg_ctl start
$ createlang plpgsql template1
CREATE LANGUAGE
$ psql template1
...
template1=# create table temp_tab (
id_temp int4 ,
name_temp text
);
CREATE
template1=# \q
$
$ createdb ngd_db1
CREATE DATABASE
$ createdb ngd_db2 -D 'PGDATA2'
CREATE DATABASE
$ psql ngd_db1
...
ngd_db1=# \d
List of relations
Name | Type | Owner
-----------+----------+----------
temp_tab | table | postgres
(1 row)
ngd_db1=# select * from pg_database;
lananem |..| lancompiler
------------+--+--------------
internal |..| n/a
C |..| /bin/cc
sql |..| postgres
plpgsql |..| PL/pgSQL
(4 rows)
ngd_db1=# \q
$ psql ngd_db2
...
ngd_db2=# \d
List of relations
Name | Type | Owner
-----------+----------+----------
temp_tab | table | postgres
(1 row)
ngd_db2=# select * from pg_database;
lananem |..| lancompiler
------------+--+--------------
internal |..| n/a
C |..| /bin/cc
sql |..| postgres
plpgsql |..| PL/pgSQL
(4 rows)
ngd_db2=# \q
$
pg_ctlÀº ½© ½ºÅ©¸³Æ®ÀÌ¸ç Æ÷½ºÆ®±×·¹½ºÀÇ ½ÇÇà,ÁßÁö,Àç½ÇÇàµîÀ» ÇÏ¸ç ¶ÇÇÑ, ½ÇÇà »óŵîÀ» º¸¿©ÁÖ´Â À¯Æ¿¸®Æ¼ÀÌ´Ù.
´ÙÀ½Àº pg_ctlÀÇ ½ÇÇà ¿¹ÀÌ´Ù.
$ su - postgres
$ pg_ctl start
// À§ÀÇ ¶óÀÎÀº Æ÷½ºÆ®±×·¹½º¸¦ ½ÇÇàÇÑ´Ù.
$ su - postgres
$ pg_ctl -w start
// À§ÀÇ ¶óÀÎÀº Æ÷½ºÆ®±×·¹½º¸¦ ½ÇÇàÇÏÁö¸¸, ¹Ù·Î ½ÇÇàÇÏ´Â °ÍÀÌ ¾Æ´Ï¶ó
// Á¤»óÀûÀ¸·Î ½ÇÇàÇÒ ¶§±îÁö ÀÏÁ¤½Ã°£ ´ë±âÇÑ´Ù.
// "-w"´Â "wait"¸¦ ÀǹÌÇÑ´Ù.
// ´ÙÀ½Àº "pg_ctl -w start' ÇÑ ÈÄÀÇ ¿¹ÀÌ´Ù.
$ pg_ctl -w start
Waiting for postmaster starting up...DEBUG: Data Base System is
starting up at Tue Mar 20 01:01:50 2001
DEBUG: Data Base System was shut down at Thu Mar 15 19:29:15 2001
DEBUG: Data Base System is in production state at Tue Mar 20 01:01:50 2001
done.
postmaster successfully started up.
$
$ su - postgres
$ pg_ctl restart
// À§ÀÇ ¶óÀÎÀº "pg_ctl"À» Àç½ÇÇàÇÑ´Ù.
$ su - postgres
$ pg_ctl stop
// Æ÷½ºÆ®±×·¹½ºÀÇ ½ÇÇàÀ» ¸ØÃá´Ù.
$ su - postgres
$ pg_ctl status
//À§ÀÇ ¶óÀÎÀº "pg_ctl"ÀÇ ½ÇÇà »óŸ¦ º¸¿©ÁØ´Ù.
$ su - postgres
$ pg_ctl status
pg_ctl: postmaster is running (pid: 899)
options are:
/usr/local/pgsql/bin/postmaster
-p 5432
-D /usr/local/pgsql/data
-B 64
-b /usr/local/pgsql/bin/postgres
-N 32
$
´ÙÀ½Àº pg_ctl statusÀÇ °á°ú¿¡ ´ëÇÑ ¼³¸íÀÌ´Ù.
$PGDATA´Â ÀϹÝÀûÀ¸·Î "/usr/local/pgsql/data" À» °ªÀ¸·Î °¡Áø´Ù. ÀÌ·¯ÇÑ $PGDATA µð·ºÅ丮¿¡´Â pg_ctlÀÇ ½ÇÇà½Ã°£¿¡ ÂüÁ¶ÇÒ ¿É¼ÇµéÀ» ÀúÀåÇÏ´Â ÆÄÀÏÀÌ ÀÖ´Ù.
¹Ù·Î "postmaster.opts.default" ¶ó´Â ÆÄÀÏÀÌ´Ù. ÀÌ ÆÄÀÏ¿¡´Â ´ÙÀ½°ú °°Àº ¿É¼ÇÀÌ ÀúÀåµÉ ¼ö ÀÖ´Ù.
-N 64 -B 256 -o '-F -S 1024'
À§ÀÇ "-N" Àº µ¿½Ã¿¡ ½ÇÇàµÉ ÇÁ·Î¼¼½ºÀÇ ÃÖ´ë°³¼ö¸¦ Á¤ÀÇÇϸç "-B" ´Â °¢ Æ÷·Î¼¼½ºµéÀÌ »ç¿ëÇÒ ¹öÆÛÀÇ Å©±â¸¦ Á¤ÀÇÇϸç, ÀÌ ¶§ ¹öÆÛÀÇ Å©±â´Â ÃÖ¼ÒÇÑ ÇÁ·Î¼¼½º ÃÖ´ë°³¼öÀÇ µÎ¹èÀ̾î¾ß ÇÑ´Ù.
-o ´Â postgres ÇÁ·Î¼¼½º¿¡ ´ëÇÑ ¿É¼ÇÀ» Á¤ÀÇÇϸç "-F" ´Â °¢°¢ÀÇ Æ®·£Àè¼ÇÀÇ °á°ú°ªÀ» ÀúÀåÇϱâ À§ÇÑ fsync() È£ÃâÀ» disable ÇÑ´Ù. Áï, -F ´Â Bool ÀÇ °ªÀ» Áö´Ñ´Ù.
"-S" ´Â "odrer by" ³ª "join" µîÀÇ sorting À» ÇÒ ¶§ »ç¿ëÇÏ´Â Sorting Buffer ÀÇ Å©±â¸¦ Á¤ÀÇÇÑ´Ù. ÀÌ ¶§ ¼ÒÆÃ ¹öÆÛÀÇ Å©±â°¡ ÀÛÀ¸¸é, ¼ÒÆÃ µ¿ÀÛÁß Á¤ÀÇµÈ ¹öÆÛº¸´Ù ¸¹Àº Å©±â¸¦ ¿ä±¸ ÇÑ´Ù¸é µð½ºÅ©¿¡ ³ª¸ÓÁö ÇÊ¿äÇÑ ¹öÆÛ¸¦ ½º¿ÒÇÎ(swap)ÇÑ´Ù.
´ç¿¬È÷ µð½ºÅ©¸¦ ¹öÆÛ·Î »ç¿ëÇÏ´Â ½º¿ÒÇÎÀÌ ÀÌ·ç¾îÁö¸é ¼ÒÆÃÀÇ ¼Óµµ°¡ ´À·ÁÁö°Ô µÈ´Ù.
pg_hba.conf´Â Æ÷½ºÆ®±×·¹½ºÀÇ »ç¿ëÀÚµéÀÇ Á¢±Ù ±ÇÇÑ ¼³Á¤ ÆÄÀÏÀ̸ç $PGDATA µð·ºÅ丮¿¡ À§Ä¡ÇÑ´Ù.
±âŸ ÀÚ¼¼ÇÑ ³»¿ëÀº Æ÷½ºÆ®±×·¹½º ¸Å´º¾óÀ̳ª DSNÀ» Âü°íÇϱ⠹ٶõ´Ù.