PostgreSQL 9.1.2源碼編譯

來源:互聯網
上載者:User

剛要入門php,然後開始編譯環境,先從PostgreSQL開始...

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

| System | CentOS 5.7

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

遇到的編譯postgresql的依賴問題,請轉文後補充.

yum -y install readline-devel

參考: http://blog.92cto.com/blog/339.html

PostgreSQL 下載頁面

http://www.postgresql.org/ftp/source/

#mkdir /usr/local/src/postgresql &&cd
/usr/local/src/postgresql 

#wget http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.gz

解壓縮

#tar -zxvf postgresql-9.1.2.tar.gz

#su - -c "useradd -M postgres"

#chown -R postgres:postgres postgresql-9.1.2


配置編譯
#./configure --help

#./configure --prefix=/opt/pgsql--sysconfdir=/opt/pgsql/etc

#mkdir/opt/pgsql/data

#chown postgres:postgres /opt/pgsql/data

初始化

# su postgres

bash-3.2$ /opt/pgsql/bin/initdb -D /opt/pgsql/data

The 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".fixing permissions on existing directory /opt/pgsql/data ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 32MBcreating configuration files ... okcreating template1 database in /opt/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 ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the -A option thenext time you run initdb.Success. You can now start the database server using:/opt/pgsql/bin/postgres -D /opt/pgsql/dataor/opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile start

添加環境變數

#vi /etc/profile

PATH=/opt/pgsql/bin:$PATH

export PATH

#source /etc/profile

啟動:

#mkdir /opt/pgsql/logs/

#chown postgres:postgres /opt/pgsql/logs/

#su postgres

bash-3.2$ /opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l /opt/pgsql/logs/pgsql.log start

設定啟動指令碼:

#su -c "cp /usr/local/src/postgresql/postgresql-9.1.2/contrib/start-scripts/linux
/etc/rc.d/init.d/postgresql-9.1.2"

#su -c "chmod a+x /etc/rc.d/init.d/postgresql-9.1.2"

#vi /etc/rc.d/init.d/postgresql-9.1.2

修改PostgreSQL指令碼

#! /bin/sh# chkconfig: 2345 98 02# description: PostgreSQL RDBMS# This is an example of a start/stop script for SysV-style init, such# as is used on Linux systems.  You should edit some of the variables# and maybe the 'echo' commands.## Place this file at /etc/init.d/postgresql (or# /etc/rc.d/init.d/postgresql) and make symlinks to#   /etc/rc.d/rc0.d/K02postgresql#   /etc/rc.d/rc1.d/K02postgresql#   /etc/rc.d/rc2.d/K02postgresql#   /etc/rc.d/rc3.d/S98postgresql#   /etc/rc.d/rc4.d/S98postgresql#   /etc/rc.d/rc5.d/S98postgresql# Or, if you have chkconfig, simply:# chkconfig --add postgresql## Proper init scripts on Linux systems normally require setting lock# and pid files under /var/run as well as reacting to network# settings, so you should treat this with care.# Original author:  Ryan Kirkpatrick <pgsql@rkirkpat.net># contrib/start-scripts/linux## EDIT FROM HERE# Installation prefixprefix=/opt/pgsql# Data directoryPGDATA="/opt/pgsql/data"# Who to run the postmaster as, usually "postgres".  (NOT "root")PGUSER=postgres# Where to keep a log filePGLOG="$prefix/logs/pgsql.log"# It's often a good idea to protect the postmaster from being killed by the# OOM killer (which will tend to preferentially kill the postmaster because# of the way it accounts for shared memory).  Setting the OOM_ADJ value to# -17 will disable OOM kill altogether.  If you enable this, you probably want# to compile PostgreSQL with "-DLINUX_OOM_ADJ=0", so that individual backends# can still be killed by the OOM killer.#OOM_ADJ=-17## STOP EDITING HERE# The path that is to be used for the scriptPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# What to use to start up the postmaster.  (If you want the script to wait# until the server has started, you could use "pg_ctl start -w" here.# But without -w, pg_ctl adds no value.)DAEMON="$prefix/bin/postmaster"# What to use to shut down the postmasterPGCTL="$prefix/bin/pg_ctl"set -e# Only start if we can find the postmaster.test -x $DAEMON ||{echo "$DAEMON not found"if [ "$1" = "stop" ]then exit 0else exit 5fi}# Parse command line parameters.case $1 in  start)echo -n "Starting PostgreSQL: "test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adjsu  $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1echo "ok";;  stop)echo -n "Stopping PostgreSQL: "#su -  $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"su  $PGUSER -c "$PGCTL stop -D '$PGDATA' -m fast"echo "ok";;  restart)echo -n "Restarting PostgreSQL: "su  $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adjsu  $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1echo "ok";;  reload)        echo -n "Reload PostgreSQL: "        su  $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"        echo "ok"        ;;  status)su  $PGUSER -c "$PGCTL status -D '$PGDATA'";;  *)# Print helpecho "Usage: $0 {start|stop|restart|reload|status}" 1>&2exit 1;;esacexit 0

#service postgresql-9.1.2 restart

PS: 我機子上本來編譯環境已經弄好了,所以可能會有些東西缺了,比如gcc ,make 等,可以直接yum

以下是我從lnmp那裡看來的依賴包安裝(但我自己並沒有測試):

yum -y install patch make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip

Reference :
<<Beginning PHP and PostgreSQL 8 from Novice to Professional>>

https://writer.zoho.com/public/6b6a49b6dcbb8205336873dd09e1b3517a451cd1e1176acb29ac6183f6c6c0976db04614eed231e5

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.