| >然后运行命令:
#/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] 下一页
|