postgresql 源碼編譯安裝

01. 環(huán)境描述

centos6.5:https://www.centos.org/download/
postgresql9.5.4:https://www.postgresql.org/ftp/source/v9.5.4/

02. 安裝基礎(chǔ)軟件

基礎(chǔ)軟件在reference手冊(cè)分為必選和可選兩部分,主要是gcc編譯器和相關(guān)的庫(kù)。

yum install -y gcc
yum install -y glibc
yum install -y glibc-devel
yum install -y readline-devel
yum install -y zlib-devel

03. 創(chuàng)建用戶(hù)和目錄

創(chuàng)建用戶(hù)和組

groupadd postgres
useradd -g postgres -s /bin/bash -d /home/postgres -m postgres

創(chuàng)建軟件介質(zhì)目錄

mkdir -p /opt/postgresql/9.5.4

創(chuàng)建數(shù)據(jù)目錄

mkdir -p /pg/data/
mkdir -p /pg/archive/
mkdir -p /pg/backup/

配置權(quán)限

chown postgres.postgres -R /opt/postgresql/9.5.4
chown postgres.postgres -R /pg/

04. 編譯安裝軟件

解壓源碼

tar -zxvf postgresql-9.5.4.tar.gz
cd postgresql-9.5.4

編譯軟件

./configure --prefix=/opt/postgresql/9.5.4
make
make install
make check

make check命令在initdb時(shí)由于是在root用戶(hù)不能啟動(dòng)實(shí)例導(dǎo)致異常。

05. 配置用戶(hù)環(huán)境變量

vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/opt/postgresql/9.5.4/bin
source ~/.bash_profile

06. 初始化并數(shù)據(jù)庫(kù)

initdb -d /pg/datapg_ctl -D /pg/data -l /pg/alert.log start

07. 配置數(shù)據(jù)庫(kù)

登陸數(shù)據(jù)庫(kù)并修改密碼

psql -U postgres
postgres-# \password
Enter new password:
Enter it again:

配置監(jiān)聽(tīng)遠(yuǎn)程訪問(wèn)數(shù)據(jù)庫(kù)時(shí)需要配置監(jiān)聽(tīng)

cd /pg/datavi postgresql.conf

#找到listen_addresses參數(shù),增加一行
listen_addresses = '*'

08. reference

postgresql 官方在線參考手冊(cè)
https://www.postgresql.org/docs/9.5/static/index.html
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容