標籤:style blog http color os io ar for 檔案
一、安裝
centos6.4伺服器IP:192.168.220.131
window7用戶端IP:192.168.199.218
在centos官網http://www.postgresql.org/download/linux/redhat/,通過如下指令安裝postgresql
yum install postgresql-server service postgresql initdbchkconfig postgresql on
貌似已經安裝過了,版本是8.4,因為看到update字樣。不管。
二、本地建立資料庫使用者和DB,測試連接
su postgres //切換到預設建立的postgres使用者psql //進入postgresql命令控制台CREATE USER root WITH PASSWORD ‘root‘;CREATE DATABASE rootdb WITH OWNER = root TEMPLATE = template0 ENCODING = ‘UNICODE‘;\q //退出postgresql命令控制台exit //退出postgres使用者到root使用者/usr/bin/psql -Uroot rootdb //測試本地環境使用者登入
三、windows7用戶端串連測試
1)關閉防火牆 service iptables stop
2)修改/var/lib/pgsql/data/postgresql.conf(修改內容listen_addresses = ‘*‘)後,提示錯誤
FATAL: no pg_hba.conf entry for host "192.168.220.1", user "root", database "rootdb", SSL off
2.1)重啟命令 service iptables restart
2.2)可能會提示失敗,查看log
2.2.1)確定log檔案位置,通過查看postgresql.conf檔案
# This is used when logging to stderr:logging_collector = on # Enable capturing of stderr and csvlog # into log files. Required to be on for # csvlogs. # (change requires restart)# These are only used if logging_collector is on:log_directory = ‘pg_log‘ # directory where log files are written, # can be absolute or relative to PGDATAlog_filename = ‘postgresql-%a.log‘ # log file name pattern, # can include strftime() escapes
2.2.2)查看log(tail -f /var/lib/pgsql/data/pg_log/postgresql-Sat.log )
LOG: database system was shut down at 2014-09-06 10:09:32 CSTLOG: database system is ready to accept connectionsLOG: autovacuum launcher started
3)修改/var/lib/pgsql/data/pg_hba.conf ,如下
# TYPE DATABASE USER CIDR-ADDRESS METHOD# "local" is for Unix domain socket connections onlylocal all all ident# IPv4 local connections:host all all 127.0.0.1/32 md5host all all 192.168.0.0/32 md5host all all 0.0.0.0/0 md5# IPv6 local connections:host all all ::1/128 ident
最後添加了host all all 0.0.0.0/0 md5這麼一段,成功串連。
centos6.4下面安裝postgresql以及用戶端遠端連線