溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

【Postgresql】postgresql9.3.9版本部署

發(fā)布時間:2020-06-19 17:05:45 來源:網(wǎng)絡(luò) 閱讀:1209 作者:Taibai_wu 欄目:數(shù)據(jù)庫

安裝方式:源碼包安裝
安裝環(huán)境:linux—Centos 6.5

  1. 下載Postgresql源碼包
    wget http://ftp.postgresql.org/pub/source/v9.3.9/postgresql-9.3.9.tar.bz2
    #地址可更改,需要其他包進(jìn) http://ftp.postgresql.org/pub/source 查找下載即可
  2. 解壓該文件
    tar xjvf postgresql-9.3.9.tar.bz2
  3. 進(jìn)入解壓后的目錄
    cd postgresql-9.3.9/
  4. 查看INSTALL文件。

    INSTALL文件中Short Version部分解釋了如何安裝postgresql的命令,Requirements部分描述了安裝postgresql所依賴的lib,比較長,先 configure試一下,如果出現(xiàn)error,那么需要檢查是否滿足了Requirements的要求。
    如果報rebline缺失等錯誤,需要先安裝相應(yīng)的依賴包。

    Short Version
    ./configure
    gmake
    su
    gmake install
    adduser postgres
    mkdir /usr/local/pgsql/data
    chown postgres /usr/local/pgsql/data
    su - postgres
    /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
    /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
    /usr/local/pgsql/bin/createdb test
    /usr/local/pgsql/bin/psql test
  5. 按順序執(zhí)行如上short中命令,開始編譯安裝postgrepsql數(shù)據(jù)庫。

    1)./configure

    在這一步中可能會報缺少redeline或者zlib等等環(huán)境依賴缺失問題,通過yum下載相關(guān)缺失軟件即可。例如:yum install -y readline-devel

    2) make
    3) make install
    4)添加Postgresql管理啟動用戶postgres
    useradd postgres
    passwd postgres
    5)創(chuàng)建數(shù)據(jù)庫文件存儲文件夾
    mkdir /usr/local/pgsql/data
    6) 改變先前目錄的文件夾的權(quán)限
    chown -R postgres.postgres /usr/local/pgsql
    7)切換用戶
    su - postgres
    8)綁定數(shù)據(jù)庫文件存儲目錄
    /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
    #or: export PATH=$PATH:/usr/local/pgsql/bin/
    9)啟動數(shù)據(jù)庫
    /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data >>logfile 2>&1?
    #這一步是用pg_ctl命令指定數(shù)據(jù)目錄啟動 啟動日志放于Logfile中 還有其他啟動方式也可以
    10)創(chuàng)建測試數(shù)據(jù)庫——test,并插入數(shù)據(jù)測試(選做)
    /usr/local/pgsql/bin/createdb test
    /usr/local/pgsql/bin/psql test

     psql (9.3.9)
    Type "help" for help.
    test=#
    test=# create table table1 (
    test(# id integer
    test(# );
    CREATE TABLE
    test=#
    test=# insert into table1 values(1);
    INSERT 0 1
    test=# select * from table1;
    Id

查詢到插入的數(shù)據(jù),至此數(shù)據(jù)庫部署完成。
下一篇講到9.3.9版本基于流復(fù)制的方式雙機(jī)熱備的方式。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI