PostgreSQL 9.1.2 source code compilation

Source: Internet
Author: User
Tags getting started with php stop script

Just getting started with PHP, and then start compiling the environment, starting with PostgreSQL...

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

| System | centos 5.7.

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

If you encounter the dependency issue for compiling PostgreSQL, please post it in a text box.

Yum-y install Readline-devel

Reference: http://blog.92cto.com/blog/339.html

PostgreSQL Download Page

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

Extract

# Tar-zxvf postgresql-9.1.2.tar.gz

# Su--c "useradd-M Postgres"

# Chown-r Postgres: Postgres postgresql-9.1.2


Configure Compilation
#./Configure -- Help

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

# Mkdir/opt/pgsql/Data

# Chown Postgres: Postgres/opt/pgsql/Data

Initialization

# Su ipvs

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 ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in / opt / pgsql / data / base / 1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL / pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

/ opt / pgsql / bin / postgres -D / opt / pgsql / data
or
/ opt / pgsql / bin / pg_ctl -D / opt / pgsql / data -l logfile start
Add environment variables

#vi / etc / profile

PATH = / opt / pgsql / bin: $ PATH

export PATH

#source / etc / profile

Start:

#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

Set the startup script:

#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

Modify PostgreSQL script

#! / 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 prefix
prefix = / opt / pgsql

# Data directory
PGDATA = "/ opt / pgsql / data"

# Who to run the postmaster as, usually "postgres". (NOT "root")
PGUSER = postgres

# Where to keep a log file
PGLOG = "$ 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 script
PATH = / 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 postmaster
PGCTL = "$ 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 0
else exit 5
fi
}


# Parse command line parameters.
case $ 1 in
  start)
echo -n "Starting PostgreSQL:"
test x "$ OOM_ADJ"! = x && echo "$ OOM_ADJ"> / proc / self / oom_adj
su $ PGUSER -c "$ DAEMON -D '$ PGDATA' &" >> $ PGLOG 2> & 1
echo "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_adj
su $ PGUSER -c "$ DAEMON -D '$ PGDATA' &" >> $ PGLOG 2> & 1
echo "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 help
echo "Usage: $ 0 {start | stop | restart | reload | status}" 1> & 2
exit 1
;;
esac

exit 0
#service postgresql-9.1.2 restart

PS: The compiling environment on my machine was already done, so there might be something missing,Such as gcc, make, etc., you can directly yum

The following is the installation of the dependency package that I see from lnmp (but I have not tested it myself):

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 gettextcurvel-devel -devel gmp-devel pspell-devel unzip
Reference:
<< Beginning PHP and PostgreSQL 8 from Novice to Professional >>

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.