PostgreSQL Linux下的編譯安裝

環境:騰訊雲2G1M50G小機

Centos 7.2 X64

PostgreSQL 10.3

------------------------------------------------------

su權限進去

cd /usr/local/src/

wget https://ftp.postgresql.org/pub/source/v10.3/postgresql-10.3.tar.gz

#--https://www.postgresql.org/ftp/source/選擇相應的版本下載

下載完畢解壓該文件

tar xf postgresql-10.3.tar.gz

cd postgresql-10.3/

使用./configure對編譯安裝環境進行檢查,發現error一般是少了包,詳見./configure --help

./configure --prefix=/usr/local/postgresql

在這裏發下少了readline-devel的包,裝一個再./configure一次,下面是參考其他博文的導包和指定安裝路徑

yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++   openssl-devel cmake

./configure --prefix=/usr/local/pgsql --with-perl --with-python --with-libxml --with-libxslt

yum install -y readline-devel

ls
aclocal.m4  config.status  contrib    GNUmakefile     INSTALL   src
config      configure      COPYRIGHT  GNUmakefile.in  Makefile

config.log  configure.in   doc        HISTORY         README

make

make install

useradd postgres

chown -R postgres:postgres /usr/local/postgresql/

創建一個日誌目錄及文件

cd /usr/local/postgresql/

mkdir log

cd log

touch pg_server.log

chmod -R 777 pg_server.log

開放5432端口

firewall-cmd --zone=public --add-port=5432/tcp --permanent

firewall-cmd --reload

firewall-cmd --zone=public --list-ports

su - postgres

vi .bash_porfile

# User specific environment and startup programs

PGHOME=/usr/local/postgresql

export PGHOME
PGDATA=/usr/local/postgresql/data
export PGDATA

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin

source ./.bash_profile

檢查環境變量是否生效

which psql

psql -V

initdb --help 可以查看初始化相關信息

initdb

cd /usr/local/postgresql/data

查看相關目錄信息;base目錄是表空間目錄,global目錄是相關全局變量的目錄,pg_hba.conf訪問控制配置和postgresql.conf主配置

vi pg_hba.conf

添加一行host all all 0.0.0.0/0 md5

vi postgresql.conf

開放相關連接權限,修改部分參數,默認開放的權限跟Win不一樣

pg_ctl start -l /usr/local/postgresql/log/pg_server.log

可以查看相關運行情況

ps -ef|grep postgresql

psql顯示相關版本信息

psql

設置密碼

\password

退出psql狀態

\q

pg_ctl status查看運行情況,pg_ctl stop停止

參考博客:

http://blog.csdn.net/wlwlwlwl015/article/details/53256358

http://blog.csdn.net/u012372092/article/details/70911640

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章