频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

PostgreSql服务器的配置

来源: 作者: 出处:巧巧读书 2007-10-01 进入讨论组

 

4、编译源码:

$make

5、按照ocnfigure的配置按照程序:

#su
#make install

在这里我们架设postgresql安装在默认的位置/usr/local/

6、配置共享库:

告诉你的系统如何找到共享库。如何实现这些因平台而异。看起来可以在任何地方生效的方法是设置环境变量 LD_LIBRARY_PATH:
# LD_LIBRARY_PATH=/usr/local/pgsql/lib
# export LD_LIBRARY_PATH

你可能把这些放到一个 shell 启动文件里,象 ~/.bash_profile。
在一些系统里,下面的方法是最好的方法,但是你必须有 root 权限。编辑文件 /etc/ld.so.conf,增加一行

/usr/local/pgsql/lib

然后运行命令:

#/sbin/ldconfig

7、用postgres数据库超级用户完成数据库的安装:

你必须用 PostgreSQL 超级用户帐号登录执行这一步。以 root 是不能进行这一步的;

# mkdir /usr/local/pgsql/data
# chown postgres /usr/local/pgsql/data
#su postgres
$ /usr/local/pgsql/initdb -D /usr/local/pgsql/data
We are initializing the database system with username postgres (uid=40).
This user will own all the files and must also own the server process.
Creating Postgres database system directory /var/lib/pgsql/base
Creating template database in /var/lib/pgsql/base/template1
Creating global classes in /var/lib/pgsql/base
Adding template1 database to pg_database...
Vacuuming template1
Creating public pg_user view
Creating view pg_rules
Creating view pg_views
Creating view pg_tables
Creating view pg_indexes
Loading pg_description

-D 选项声明数据存储的位置。你可以使用任何你想用的路径,它不必在安装目录里。在运行 initdb 前只要确保数据库超级用户帐户可以写(或者创建)那个目录就行了。

8、启动postgresql服务;

前面的步骤应该已经告诉你如何启动数据库服务器。现在就做。
$ /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
这样将在前台启动数据库服务器。要把它放到后台,使用 -S。

4.配置Postgresql的脚本文件

配置“/etc/rc.d/ini.d/postgresql”脚本文件,用来启动和停止PostgreSQL服务器。

创建“postgresql”脚本文件(touch /etc/rc.d/init.d/postgresql)并加入:

#! /bin/sh
# postgresql This is the init script for starting up the PostgreSQL
# server
# chkconfig: 345 85 15
# description: Starts and stops the PostgreSQL backend daemon that handles
# all database requests.
# processname: postmaster
# pidfile: /var/run/postmaster.pid
#
# Source function library.
. /etc/rc.d/init.d/functions
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
# Pretty much need it for postmaster.
[ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/bin/postmaster ]@# @#exit 0
# This script is slightly unusual in that the name of the daemon (postmaster)
# is not the same as the name of the subsystem (postgresql)
# See how we were called.
case "$1" in
start)
echo -n "Checking postgresql installation: "
# Check for the PGDATA structure
if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d /var/lib/pgsql/base/template1 ]
then
# Check version of existing PGDATA
if [ `cat /var/lib/pgsql/PG_VERSION` != 6.5 ]
then
echo "old version. Need to Upgrade."
echo "See /usr/doc/postgresql-6.5.2/README.rpm for more information."
exit 1
else
echo "looks good!"
fi
# No existing PGDATA! Initdb it.
else
echo "no database files found."
if [ ! -d /var/lib/pgsql ]
then
mkdir -p /var/lib/pgsql
chown postgres.postgres /var/lib/pgsql
fi
su -l postgres -c /usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=/var/lib/pgsql
fi
# Check for postmaster already running...
pid=`pidof postmaster`
if [ $pid ]
then
echo "Postmaster already running."
else
#all systems go -- remove any stale lock files
rm -f /tmp/.s.PGSQL.* > /dev/null
echo -n "Starting postgresql service: "
su -l postgres -c /usr/bin/postmaster -i -S -D/var/lib/pgsql
sleep 1
pid=`pidof postmaster`
if [ $pid ]
then
echo -n "postmaster [$pid]"
touch /var/lock/subsys/postgresql
echo $pid > /var/run/postmaster.pid
echo
else
echo "failed."
fi
fi
;;
stop)
echo -n "Stopping postgresql service: "
killproc postmaster
sleep 2
rm -f /var/run/postmaster.pid
rm -f /var/lock/subsys/postgresql
echo
;;
status)
status postmaster
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: postgresql {start|stop|status|restart}"
exit 1
esac
exit 0

本文:http://www.qqread.com/other-database/c215502.html 更多文章 更多内容请看FTP服务器双核服务器技术网站服务器的选型专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
讨论组问题推荐
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章