標籤:
下載源碼並解壓
[[email protected] ~]# wget https://ftp.postgresql.org/pub/source/v9.4.0/postgresql-9.4.0.tar.bz2[[email protected] ~]# tar -xjvf postgresql-9.4.0.tar.bz2 [[email protected] ~]# 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...
繼續
[[email protected] postgresql-9.4.0]# ./configure[[email protected] postgresql-9.4.0]# make……All of PostgreSQL successfully made. Ready to install.[[email protected] postgresql-9.4.0]# make install……PostgreSQL installation complete.
添加使用者
[[email protected] postgresql-9.4.0]# useradd postgres[[email protected] 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目標檔案夾
[[email protected] postgresql-9.4.0]# mkdir /var/lib/pgsql/data -p[[email protected] postgresql-9.4.0]# chown -R postgres /var/lib/pgsql
環境變數設定
[[email protected] ~]$ vi .bash_profile …# postgresPGDATA=/var/lib/pgsql/dataPATH=/usr/local/pgsql/bin:$PATHexport PGDATA PATH[[email protected] ~]$ . .bash_profile
建立database cluster
loading PL/pgSQL server-side language ... okThe files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /var/lib/pgsql/data ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okcreating template1 database in /var/lib/pgsql/data/base/1 ... okinitializing pg_authid ... okinitializing dependencies ... okcreating system views ... okloading system objects‘ descriptions ... okcreating collations ... okcreating conversions ... okcreating dictionaries ... oksetting privileges on built-in objects ... okcreating information schema ... okloading PL/pgSQL server-side language ... okvacuuming database template1 ... okcopying template1 to template0 ... okcopying template1 to postgres ... oksyncing data to disk ... okWARNING: 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上的源碼安裝