Postgre SQL   发布时间:2022-05-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了PostgreSQL 9.1.2源码编译大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

刚要入门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@H_675_103@​

#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 ... 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 scheR_779_11845@a ... 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

添加环境变量

#vi /etc/profile

@H_649_197@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

设置启动脚本:

@H_202_262@#@H_944_266@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 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


@H_772_306@#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

大佬总结

以上是大佬教程为你收集整理的PostgreSQL 9.1.2源码编译全部内容,希望文章能够帮你解决PostgreSQL 9.1.2源码编译所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: