[root@localhost postgresql-11.4]# gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) Copyright © 2015 Free Software Foundation, Inc. 本程序是自由軟件;請參看源代碼的版權聲明。本軟件沒有任何擔保; 包括沒有適銷性和某一專用目的下的適用性擔保。
gcc用於編譯源碼
[root@localhost postgresql-11.4]# make --version GNU Make 3.82 Built for x86_64-redhat-linux-gnu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
make用於批量編譯連接源碼,實際幹活的仍是gcc
yum install readline yum -y install -y readline-devel
readline是個坑啊。能夠選擇不安裝readline,後果是在psql裏執行完命令,想用方向鍵再次獲取該命令時就成了亂碼。因此必需要安裝readline。
只yum install readline時,configure的時候任然會報錯,提示找不到readline。解決方法是安裝readline-devel。
yum install zlib //通常狀況下,系統已經默認安裝了zlib yum install zlib-devel
zlib用於數據壓縮
postgresql的官方網站下載:https://www.postgresql.org/
cd /home/software/ tar -xzvf postgresql-11.4.tar.gz
mkdir /home/app/postgresql
./configure --prefix=/home/app/postgresql
make && make install
All of PostgreSQL successfully made. Ready to install.
[1]+ 完成 make
cd /home/software/postgresql-11.4/contrib make && make install
groupadd postgres useradd -g postgres postgres
爲了安全考慮,postgresql不容許使用root用戶操做數據庫,咱們在系統中爲了使用postgresql添加一個用戶postgres:
也能夠是其餘用戶名,可是習慣上你們都是建立postgres用戶做爲數據庫的超級用戶。
初始化數據庫時,就以這個用戶做爲數據庫的超級用戶
chown -R postgres:postgres /home/app/postgresql/data
su postgres vim /home/postgres/.bash_profile
添加環境變量:html
export PGHOME=/home/app/postgresql export PGDATA=/home/app/postgresql/data export PATH=$PGHOME/bin:$PATH export MANPATH=$PGHOME/share/man:$MANPATH export LANG=en_US.utf8 export DATE=`date +"%Y-%m-%d %H:%M:%S"` export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH alias rm='rm -i' alias ll='ls -lh'
而後使環境變量當即生效,不然initdb命令會找不到:linux
source /home/postgres/.bash_profile
initdb -D /home/app/postgresql/data/
Success. You can now start the database server using:
pg_ctl -D /home/app/postgresql/data/ -l logfile start
su postgres cd /home/postgres //logfile須要在postgres的用戶目錄下建立 pg_ctl -D /home/app/postgresql/data/ -l logfile start
查看5432端口是否已經啓動redis
netstat -nltp|grep 5432
cd /home/software/postgresql-11.4/contrib/start-scripts chmod a+x linux. cp linux /etc/init.d/postgresql
此時就可使用 /etc/init.d/postgresql stop 來中止postgresql
也可使用:service postgresql start 來啓動postgresql
修改postgresql腳本中prefix和PGDATA的內容
chkconfig --add postgresql //設置服務開機啓動
#設置監聽整個網絡,查找「listen_addresses 」字符串, vim /home/app/postgresql/data/postgresql.conf #修改成以下: listen_addresses = '*' #配置鏈接方式: vim /home/app/postgresql/data/pg_hba.conf #修改成以下: host all all 192.168.2.0/24 md5