源代碼安裝pg 9.4

chkconfig iptables off
service iptables off
修改系統時間
1、下載源碼解壓
tar jxvf postgresql-9.4.4.tar.bz2  或者tar zxvf postgresql-9.4.4.tar.gz
將安裝包傳到系統中,目錄最好是/opt
2、創建安裝的目錄
mkdir /opt/pgsql-9.4.4
3、進入解壓後的目錄
cd postgresql-9.4.4  
4、進行安裝  編譯源碼
./configure --prefix=/opt/pgsql-9.4.4
……
checking for gcc... no
checking for cc... no
configure: error: in `/tmp/postgresql-9.4.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

要掛載好映像。配置好yum。
將操作系統盤放入光驅並掛載mount /dev/sr0 /mnt
或者可上傳系統ISO,並掛載鏡像mount -o loop xxx.iso /mnt
 
配置yum安裝程序 
vi /etc/yum.repos.d/rhel.repo
輸入如下內容:
[rhel]
name=rhel
baseurl=file:///mnt/Server/
enabled=1
gpgcheck=0

yum install gcc readline-devel zlib-devel -y
./configure --prefix=/opt/pgsql-9.4.4
5、make
6、make install
安裝完成
7、useradd postgres
8、passwd postgres
9、環境變量的設置
可以把下面的內容添加到linux用戶的~/.bash_profile或~/.profile文件中, 
[root@highgo postgresql-9.4.0]# su - postgres
[postgres@highgo ~]$ vi .bash_profile
直接將下面粘貼到最後,然後保存
#postgres
PGDATA=/opt/pgsql-9.4.4/data
PATH=/opt/pgsql-9.4.4/bin:$PATH
export PGDATA PATH
[postgres@highgo ~]$ source .bash_profile 運行一下.bash_profile,使其生效。
環境變量設置方法二:(最好別用,後續問題很多)
vi /etc/profile
export PATH=/opt/pgsql-9.4.4/bin:$PATH
export LD_LIBRARY_PATH=/opt/pgsql-9.4.4/lib:$LD_LIBRARY_PATH
source /etc/profile
chown postgres:postgres /opt -R
su - postgres
vi .bash_profile
export PGDATA=/opt/pgsql-9.4.4/data

10、initdb
11、pg_ctl start
12、psql
成功。


源碼安裝開機服務:
設置PostgreSQL開機自啓動
PostgreSQL的開機自啓動腳本位於PostgreSQL源碼目錄的contrib/start-scripts路徑下
linux文件即爲linux系統上的啓動腳本
1)修改linux文件屬性,添加X屬性
exit
切換到root目錄
#cd /opt/postgresql-9.4.4/contrib/start-scripts/
#chmod a+x linux
2) 複製linux文件到/etc/init.d目錄下,更名爲postgresql
#cp linux /etc/init.d/postgresql
3)修改/etc/init.d/postgresql文件的兩個變量
#vi /etc/init.d/postgresql
prefix設置爲postgresql的安裝路徑:prefix=/opt/pgsql-9.4.4
PGDATA設置爲postgresql的數據目錄路徑:PGDATA="/opt/pgsql-9.4.4/data"
4) 執行service postgresql start,就可以啓動PostgreSQL服務
#service postgresql start
 
5)設置postgresql服務開機自啓動
#chkconfig --add postgresql
執行上面的命令,就可以實現postgresql服務的開機自啓動。
reboot
方法二:
PostgreSQL數據庫Linux系統開機啓動
chmod a+x /opt/postgresql-8.4.3/contrib/start-scripts/linux
cp /opt/postgresql-8.4.3/contrib/start-scripts/linux /etc/init.d/postgresql
chkconfig --add postgresql
vi /ect/init.d/postgresql
修改start部分代碼
su - $PGUSER -c "$DAEMON -i -D '$PGDATA' &" >>$PGLOG 2>&1加上-i參數以支持JAVA程序調取的處理
reboot


收尾工作

開啓日誌收集功能
vi $PGDATA/postgresql.conf
logging_collector = on
log_directory = 'pg_log'
log_rotation_age = 1d

發佈了18 篇原創文章 · 獲贊 8 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章