postgresql
出典: wiki.nodoka.org
目次 |
postgresql-8.3.7のインストール
cd /usr/local/src wget ftp://ftp2.jp.postgresql.org/pub/postgresql/source/v8.3.7/postgresql-8.3.7.tar.gz tar xvzf postgresql-8.3.7.tar.gz cd postgresql-8.3.7 ./configure \ --prefix=/usr/local/pgsql make make install useradd -u 26 -d /home/postgres -m -s /bin/bash postgres chown -R postgres /usr/local/pgsql su - postgres -c "/usr/local/pgsql/bin/initdb -E EUC_JP -D /usr/local/pgsql/data"
共有メモリ設定
sysctl kernel.shmmax echo "kernel.shmmax = 1127428915" >> /etc/sysctl.conf sysctl -p sysctl kernel.shmmax
設定ファイル作成
vi /usr/local/pgsql/data/postgresql.conf
#listen_addresses = 'localhost' # what IP address(es) to listen on; listen_addresses = 'localhost, 192.168.0.200' : #### shared_buffers = 24MB # min 128kB or max_connections*16kB shared_buffers = 1GB : #work_mem = 1MB # min 64kB work_mem = 10MB : #wal_sync_method = fsync # the default is the first option wal_sync_method = open_sync : #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each checkpoint_segments = 8 : #client_min_messages = notice # values in order of decreasing detail: client_min_messages = warning |
vi /usr/local/pgsql/data/pg_hba.conf
host all all 192.168.0.200/32 trust |
起動ファイル作成
cd /usr/local/src/postgresql-8.3.7 cp contrib/start-scripts/linux /etc/init.d/postgresql /etc/init.d/postgresql start
TIPS
- 圧縮ファイルでデータダンプ
pg_dump -U USERNAME -h HOSTNAME -d DBNAME -Fc > /home/postgres/DBNAME.dmp
- 圧縮ファイルでデータリストア
pg_restore -U USERNAME -h HOSTNAME -d DBNAME /home/postgres/DBNAME.dmp
- 処理中プロセス確認
select * from pg_stat_activity;
- パラメータ確認
show all; show shared_buffers;
- PK追加
ALTER TABLE table_name ADD CONSTRAINT pk_name PRIMARY KEY(column_name);
- ログインユーザーの権限確認
\z