热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Debian6.04系统下安装PostgreSQL-9.1.3数据库

前言:本人机器:AMD64x24400++1G内存第一阶段-编译安装:1,从postgresql官网下载postgresql-9.1.3.tar.bz2这个我想大家都知道的2,把源代码复制到/usr/src/postgresql-9.1.3.tar.bz2且cd/usr/src3,解压:tarxjvfpostgresq

前言:本人机器:AMD64x2 4400++ 1G 内存
第一阶段-编译安装:
1,从postgresql官网下载postgresql-9.1.3.tar.bz2这个我想大家都知道的
2,把源代码复制到/usr/src/postgresql-9.1.3.tar.bz2 且 cd /usr/src
3,解压: tar xjvf postgresql-9.1.3.tar.bz2
4,进入源码目录: cd postgresql-9.1.3
5,建立pgsql安装目录。这里我选择 :mkdir /usr/pgsql-9.1.3
6,安装必须的工具执行:aptitude install build-essential zlib1g-dev libpam0g-dev libssl-dev libperl-dev kernel-package libncurses5-dev flex bison gawk chkconfig系统会自动安装所以来的软件
7,在源码目录里面执行下面命令:
./configure   CFLAGS='-DLINUX_OOM_ADJ=0 -O2 -pipe -march=athlon64 -fomit-frame-pointer -fstack-protector' --prefix=/usr/pgsql-9.1.3 --with-perl --with-openssl --with-pam --enable-nls --disable-debug
8,开始编译 :make -j 4
9,变成成功后,执行 make install 安装
10,建立postgresql数据库专用普通权限用户 :adduser psqlroot
11,切换到安装目录: cd /usr/pgsql-9.1.3建立初始化数据库集群文件夹:mkdir date
12,改变date所有权限 chown psqlroot:psqlroot date
13,执行数据库初始化(必须使用psqlroot用户):su - psqlroot -c './initdb /usr/pgsql-9.1.3/date'
14,好了,进入date目录可以看到初始化后的文件,比如conf配置文件等等。

第二阶段-制作启动脚本:
1,从源代码目录里面复制出原始的开机脚本:
cp /usr/src/postgresql-9.1.3/contrib/start-scripts/linux    /etc/init.d/postgresql
2,给予执行权限:chmod 700 /etc/init.d/postgresql
3,建立s 2 3 4 5 6各个级别启动连接在(/etc/rcS.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d)
   使用:chkconfig /etc/init.d/postgresql自动建立 呵呵很方便哦!
4,修改/etc/init.d/postgresql文件,这个文件是用/bin/sh基础的,改成/bin/bash的:

#! /bin/bash

# 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

# contrib/start-scripts/linux

## EDIT FROM HERE

# Installation PREFIX
PREFIX=/usr/pgsql-9.1.3

# Data directory
PGDATA=$PREFIX/date

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

# Where to keep a log file
PGLOG=/var/log/serverlog

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

5,注意上文提到的OOM_ADJ=-17 是为了逃避OOM自动封杀,OK!执行/etc/init.d/postgresql start stop restart 等等命令试试,大工告成!!
6,把安装目录中的conf配置文件复制到/etc/postgresql下面去,方便以后更改配置
  mkdir /etc/postgresql
  mv /usr/pgsql-9.1.3/date/*conf /etc/postgresql/
  cd /usr/pgsql-9.1.3/date
  su - psqlroot -c 'ln -s /etc/postgresql/pg_hba.conf pg_hba.conf'
  su - psqlroot -c 'ln -s /etc/postgresql/pg_ident.conf pg_ident.conf'
  su - psqlroot -c 'ln -s /etc/postgresql/postgresql.conf postgresql.conf'

第三阶段-优化


推荐阅读
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • PHP组合工具以及开发所需的工具
    本文介绍了PHP开发中常用的组合工具和开发所需的工具。对于数据分析软件,包括Excel、hihidata、SPSS、SAS、MARLAB、Eview以及各种BI与报表工具等。同时还介绍了PHP开发所需的PHP MySQL Apache集成环境,包括推荐的AppServ等版本。 ... [详细]
  • 环境配置tips
    一、MySQL在Linux下数据库名、表名、列名、别名大小写规则是这样的:  1、数据库名与表名是严格区分大小写的;  2、表的别名是严格区分大小写的& ... [详细]
  • 本文介绍了在Linux下安装Perl的步骤,并提供了一个简单的Perl程序示例。同时,还展示了运行该程序的结果。 ... [详细]
  • Linux如何安装Mongodb的详细步骤和注意事项
    本文介绍了Linux如何安装Mongodb的详细步骤和注意事项,同时介绍了Mongodb的特点和优势。Mongodb是一个开源的数据库,适用于各种规模的企业和各类应用程序。它具有灵活的数据模式和高性能的数据读写操作,能够提高企业的敏捷性和可扩展性。文章还提供了Mongodb的下载安装包地址。 ... [详细]
  • 欢乐的票圈重构之旅——RecyclerView的头尾布局增加
    项目重构的Git地址:https:github.comrazerdpFriendCircletreemain-dev项目同步更新的文集:http:www.jianshu.comno ... [详细]
  • 腾讯安全平台部招聘安全工程师和数据分析工程师
    腾讯安全平台部正在招聘安全工程师和数据分析工程师。安全工程师负责安全问题和安全事件的跟踪和分析,提供安全测试技术支持;数据分析工程师负责安全产品相关系统数据统计和分析挖掘,通过用户行为数据建模为业务决策提供参考。招聘要求包括熟悉渗透测试和常见安全工具原理,精通Web漏洞,熟练使用多门编程语言等。有相关工作经验和在安全站点发表作品的候选人优先考虑。 ... [详细]
  • Introduction(简介)Forbeingapowerfulobject-orientedprogramminglanguage,Cisuseda ... [详细]
  • 对于一般的扩展包,我们一般直接pipinstallxxx即可安装,但是unrar直接安装后,发现并不能通过Python程序实现解压的功能& ... [详细]
  • MySQL5.6.40在CentOS764下安装过程 ... [详细]
  • 这篇文章给大家介绍怎么从源码启动和编译IoTSharp ,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。IoTSharp项目是 ... [详细]
  • Docker安装Rabbitmq(配合宝塔)
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Docker安装Rabbitmq(配合宝塔)相关的知识,希望对你有一定的参考价值。一、事前准备 ... [详细]
  • Ihavethisfollowinginputfile:我有以下输入文件:test.csvdone_cfg,,,,port<0>,clk_in,subcktA,ins ... [详细]
author-avatar
youyiyang
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有