標籤:
http://my.oschina.net/hippora/blog/375292下載源碼並解壓
[root@fnddb ~]# wget https://ftp.postgresql.org/pub/source/v9.4.0/postgresql-9.4.0.tar.bz2[root@fnddb ~]# tar -xjvf postgresql-9.4.0.tar.bz2 [root@fnddb ~]# cd postgresql-9.4.0
開始編譯安裝
[[email protected] postgresql-9.4.0]# ./configure ……checking for library containing shmget... none requiredchecking for library containing readline... noconfigure: error: readline library not foundIf you have readline already installed, see config.log for details on thefailure. It is possible the compiler isn‘t looking in the proper directory.Use --without-readline to disable readline support.
按照錯誤提示依次安裝依賴包
[[email protected] postgresql-9.4.0]# yum install readline-devel[[email protected] postgresql-9.4.0]# yum install zlib-devel...
繼續
[root@fnddb postgresql-9.4.0]# ./configure[root@fnddb postgresql-9.4.0]# make……All of PostgreSQL successfully made. Ready to install.[root@fnddb postgresql-9.4.0]# make install……PostgreSQL installation complete.
添加使用者
[root@fnddb postgresql-9.4.0]# useradd postgres[root@fnddb postgresql-9.4.0]# passwd postgresChanging password for user postgres.New password: BAD PASSWORD: it is based on a dictionary wordRetype new password: passwd: all authentication tokens updated successfully.
建立好database cluster目標檔案夾
[root@fnddb postgresql-9.4.0]# mkdir /var/lib/pgsql/data -p[root@fnddb postgresql-9.4.0]# chown -R postgres /var/lib/pgsql
環境變數設定
[root@fnddb postgresql-9.4.0]# su - postgres[postgres@fnddb ~]$ vi .bash_profile …# postgresPGDATA=/var/lib/pgsql/dataPATH=/usr/local/pgsql/bin:$PATHexport PGDATA PATH[postgres@fnddb ~]$ . .bash_profile
建立database cluster
[[email protected] ~]$ pg_ctl initdb......WARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success. You can now start the database server using: /usr/local/pgsql/bin/postgres -D /var/lib/pgsql/dataor /usr/local/pgsql/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start
啟動資料庫執行個體
設定好PGDATA環境變數後,可以不帶-D選項
[[email protected] ~]$ pg_ctl start -l /var/lib/pgsql/pgsql.logserver starting
關閉資料庫執行個體
[[email protected] ~]$ pg_ctl stopwaiting for server to shut down.... doneserver stopped
開機自動啟動設定
[[email protected] postgresql-9.4.0]# vi /etc/rc.local…su - c ‘/usr/local/pgsql/bin/pg_ctl start -D /var/lib/pgsql/data -l /var/lib/pgsql/pgsql.log‘
postgresql 在linux上的源碼安裝