初期設定
ダウンロード
インストール
インストール
cd /usr/local/src/
tar zxf postgresql-9.0.1.tar.gz
cd postgresql-9.0.1
./configure \
--prefix=/usr/local/pgsql \
--with-pgport=5432 \
--with-perl --with-python
make
make install
ユーザー作成
useradd -d /home/postgres -m postgres
passwd postgres
権限変更
chown postgres:postgres -R /usr/local/pgsql
環境変数設定
su - postgres
vi ~/.bash_profile
#####################################################
export PATH="$PATH":/usr/local/pgsql/bin
export POSTGRES_HOME=/usr/local/pgsql
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export MANPATH="$MANPATH":$POSTGRES_HOME/man
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB"
#####################################################
source ~/.bash_profile
初期設定
su - postgres
initdb --encoding=UTF-8
起動確認
pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/serverlog start
pg_ctl -D /usr/local/pgsql/data stop
自動起動
cp contrib/start-scripts/linux /etc/rc.d/init.d/postgres
chmod 755 /etc/rc.d/init.d/postgres
chkconfig --add postgres
/etc/init.d/postgres start
ポート開放
/sbin/iptables -I INPUT -p tcp -m tcp --dport 5432 --syn -j ACCEPT
/sbin/iptables -I INPUT -p udp -m udp --dport 5432 -j ACCEPT
ユーザー、データベース作成
$ createuser -d -s -r -l -P testuser
Enter password for new role: ←パスワード入力
Enter it again: ←パスワード入力
$ createdb -O testuser -W testdb
Password: ←パスワード入力
$
設定ファイル編集
##設定ファイルの編集1
vi /usr/local/pgsql/data/postgresql.conf ##左記のファイルを開く
################################################################################
listen_addresses = 'localhost,192.168.10.141' ##サーバのIPアドレスを指定
################################################################################
##設定ファイルの編集2
vi /usr/local/pgsql/data/pg_hba.conf ##左記の設定ファイルを開く
################################################################################
host all all 192.168.10.141 255.255.255.0 password ##リモートからの設定
################################################################################
##再起動
/etc/init.d/postgres restart
最終更新:2010年11月22日 07:20