{"rsdb":{"rid":"155944","subhead":"","postdate":"0","aid":"117061","fid":"57","uid":"1","topic":"1","content":"

\u5b89\u88c5Postgresql<\/p>

--------------------------------------------------------------------------------<\/p>

# \u5b89\u88c5postgresql\u670d\u52a1\u5668
yum install postgresql-server
#\u4f9d\u8d56\u5305\u662f\u5426\u5b89\u88c5
Y\/N Y<\/p>

#\u7b2c\u4e09\u65b9\u8d21\u732e\u5305
yum install postgresql-contrib
#\u4f9d\u8d56\u5305\u662f\u5426\u5b89\u88c5
Y\/N Y<\/p>

\u5b89\u88c5\u6210\u529f\u540e\uff0c\u6570\u636e\u5e93<\/a>\u72b6\u6001<\/p>

\u5c1d\u8bd5\u542f\u52a8\u6570\u636e\u5e93<\/a>\uff0c\u4f46\u62a5\u9519\uff0c\u9700\u8981\u5148\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55<\/p>

[root@localhost hadoop]# service postgresql start
\/var\/lib\/pgsql\/data is missing.Use \"service postgresql initdb\" to initialize the cluster first.
[root@localhost hadoop]# service postgresql initdb
Initializing database: [OK]<\/p>

\u542f\u52a8\u6570\u636e\u5e93<\/p>

--------------------------------------------------------------------------------<\/p>

\u901a\u8fc7service\u547d\u4ee4\u542f\u52a8Postgresql\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u9ed8\u8ba4\u5728\u5b89\u88c5\u65f6\u4f1a\u521b\u5efapostgres\u7528\u6237\u5e76\u5b89\u88c5\u5230\u6b64\u7528\u6237\u4e0b\u3002\u800cPostgresql \u7684\u9ed8\u8ba4\u6570\u636e\u5e93\u4e5f\u662f\u7528\u6b64\u7528\u6237\u547d\u540d\u7684\u3002<\/p>

[root@localhost hadoop]# service postgresql start
Starting postgresql service: [ OK ]
[root@localhost hadoop]# su - postgres
-bash-4.1$ psql
psql (8.4.20)
Type \"help\" for help.<\/p>

postgres=# \\l
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c\/postgres
: postgres=CTc\/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c\/postgres
: postgres=CTc\/postgres
(3 rows)<\/p>

postgres=#<\/p>

\u57fa\u672c\u53c2\u6570\u8bbe\u7f6e<\/p>

--------------------------------------------------------------------------------<\/p>

\u5728Centos\u4e0b\uff0c\u9ed8\u8ba4\u7684\u6570\u636e\u76ee\u5f55\u5728 \/var\/lib\/pgsql\/data \u4e0b \uff0c\u914d\u7f6e\u7684\u53c2\u6570\u6587\u4ef6\u5c31\u5728\u6b64\u76ee\u5f55\u4e0b\u3002<\/p>

-bash-4.1$ ls -l
total 80
drwx------ 5 postgres postgres 4096 Nov 16 07:43 base
drwx------ 2 postgres postgres 4096 Nov 17 23:51 global
drwx------ 2 postgres postgres 4096 Nov 16 07:43 pg_clog
-rw------- 1 postgres postgres 3533 Nov 17 22:05 pg_hba.conf
-rw------- 1 postgres postgres 1631 Nov 16 07:43 pg_ident.conf
drwx------ 2 postgres postgres 4096 Nov 18 00:00 pg_log
drwx------ 4 postgres postgres 4096 Nov 16 07:43 pg_multixact
drwx------ 2 postgres postgres 4096 Nov 18 00:00 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Nov 16 07:43 pg_subtrans
drwx------ 2 postgres postgres 4096 Nov 16 07:43 pg_tblspc
drwx------ 2 postgres postgres 4096 Nov 16 07:43 pg_twophase
-rw------- 1 postgres postgres 4 Nov 16 07:43 PG_VERSION
drwx------ 3 postgres postgres 4096 Nov 16 07:43 pg_xlog
-rw------- 1 postgres postgres 16877 Nov 17 21:54 postgresql.conf
-rw------- 1 postgres postgres 57 Nov 17 23:51 postmaster.opts
-rw------- 1 postgres postgres 45 Nov 17 23:51 postmaster.pid<\/p>

\u914d\u7f6e\u8fdc\u7a0b\u767b\u5f55\u6570\u636e\u5e93<\/p>

1. \u4fee\u6539 postgresql.conf \u6587\u4ef6\uff0c\u914d\u7f6ePostgreSQL\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u76f8\u5e94\u7684\u53c2\u6570<\/p>

listen_addresses = '*' # PostgreSQL\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9ed8\u8ba4\u662f\u53ea\u63a5\u53d7\u6765\u5728\u672c\u673alocalhost\u7684\u8fde\u63a5\u8bf7\u6c42\uff0c\u6b64\u5904\u5c06\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u76d1\u542c\u6a21\u5f0f\u4fee\u6539\u4e3a\u76d1\u542c\u6240\u6709\u4e3b\u673a\u53d1\u51fa\u7684\u8fde\u63a5\u8bf7\u6c42
port = 5432 # \u9ed8\u8ba4\u7aef\u53e3\uff0c\u4fee\u6539\u540e\u8981\u91cd\u542f\u6570\u636e\u5e93<\/p>

2. \u4fee\u6539 pg_hba.conf \u6587\u4ef6\uff0c\u914d\u7f6e\u5bf9\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650<\/p>

\"\"<\/p>

\u5728\u6700\u540e\u4e00\u884c\u52a0\u4e0a\u914d\u7f6e\uff0c\u8868\u793a\u5141\u8bb8\u7f51\u6bb5192.168.191.0\u4e0a\u7684\u6240\u6709\u4e3b\u673a\u4f7f\u7528\u6240\u6709\u5408\u6cd5\u7684\u6570\u636e\u5e93\u7528\u6237\u540d\u8bbf\u95ee\u6570\u636e\u5e93\uff0c<\/p>

24\u662f\u5b50\u7f51\u63a9\u7801\uff0c\u8868\u793a\u5141\u8bb8IP\u8303\u56f4\u5728 192.168.191.0--192.168.191.255 \u7684\u8ba1\u7b97\u673a\u8bbf\u95ee\u3002<\/p>

3. \u6d4b\u8bd5\u8fdc\u7a0b\u767b\u5f55<\/p>

\u9996\u5148\u4fee\u6539\u9ed8\u8ba4\u6570\u636e\u5e93\u7528\u6237\u767b\u5f55\u5bc6\u7801<\/p>

-bash-4.1$ psql
psql (8.4.20)
Type \"help\" for help.<\/p>

postgres=# \\password<\/p>

\u6309\u63d0\u793a\u4fee\u6539\u5bc6\u7801\u3002<\/p>

\u7136\u540e\u518d\u4ece\u53e6\u4e00\u53f0\u5c40\u57df\u7f51\u673a\u5668\u4e0a\u767b\u5f55<\/p>

psql -U postgres -d postgres -h 192.168.191.5 -p 5432 -- \u6210\u529f<\/p>

\u5176\u4e2d \u2013u \u6307\u5b9a\u7528\u6237\uff0c-d \u6307\u5b9a\u6570\u636e\u5e93\u540d \uff0c-h \u6307\u5b9ahost\uff0c-p \u7aef\u53e3\u53f7\uff0c\u6309\u63d0\u793a\u8f93\u5165\u5bc6\u7801\u3002<\/p>

\u53e6\u5916\uff0c\u53ef\u89c6\u5316\u5ba2\u6237\u7aef\u63a8\u8350\u7528DBeaver\u3002<\/p>

\"\"<\/p>

------------------------------------\u534e\u4e3d\u4e3d\u7684\u5206\u5272\u7ebf------------------------------------<\/p>

------------------------------------\u534e\u4e3d\u4e3d\u7684\u5206\u5272\u7ebf------------------------------------<\/p>","orderid":"0","title":"Linux\u4e0b\u5b89\u88c5PostgreSQL","smalltitle":"","mid":"0","fname":"\u6570\u636e\u5e93\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"79","pages":"1","comments":"0","posttime":"2017-01-02 08:14:57","list":"1483316097","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"http:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Linux<\/A> \u5b89\u88c5<\/A> PostgreSQL<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.31","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Linux\u4e0b\u5b89\u88c5PostgreSQL","lastview":"1495486281","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}