岁月联盟 · 中国技术网 本站主页 | 安全认证 | 用户服务 | 技术论坛
新闻快报 | 新手学堂 | 黑客特区 | 程序语言 | 数 据 库 | 防 火 墙 | 路由交换 | 系统集成 | 服 务 器 | 存储备份 | 考试认证
Windows | Linux | Java | 协议分析 | 问题解答 | 进程大全 | 网页设计 | 多 媒 体 | 图库资料 | 软件下载 | 站内下载
  您现在的位置: 岁月联盟 >> 数据库 >> POSTGRE >> 数据库正文
PostgreSql服务器的配置
作者:未知 文章来源:本站整理 点击数: 更新时间:2007-12-18 18:30:04
>然后运行命令:

#/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: "

上一页  [1] [2] [3] [4] 下一页


  • 上一个数据库:
  • 下一个数据库:
  •  
    热门文章
    推荐文章
    关于我们 | 发展历程 | 网站地图 | 广告服务 | 招贤纳士 | 战略合作 | 友情链接 | 著作声明 | 联系我们
    Copyright © 2002-2007 SYUE All rights reserved.
    E_mail:WebSyue@163.Com 皖ICP备05004589号
    未经授权禁止转载、摘编、复制或建立镜像.如有违反,追究法律责任.
    热血江湖私服 天龙八部私服 bet365 传奇服务端 魔域私服 劲舞私服 传奇世界私服 bet365 传世私服 传奇世界私服