postgresql 9源码安装

安装过程:

1、configuration

--prefix=PREFIX

install all files under the directory PREFIX instead of usr/local/psql

--with-pgport=NUMBER

set NUMBER as the default port number for server and clients,the default is 5432.

--with-segsize=SEGSIZE(控制表的大小)

set the segment size,in gigabytes,large tables are divided into multiple operating-system files,each of size equal to the segment size.

--with-blocksize=BLOCKSIZE

set the block size,in kilobytes.this is the unit of starage and i/o within tables.the defaules,8 kilobytes,is susitable for most situnations;but other values may be usefulin special cases,the value must be a power of 2 between 1 and 32(jukobyrtes).

--with-wal-segsize=SEGSIZE

set the wal segment size,in megabytes,this is the size of each individaul file in the wal log.it may be useful to adjust this size to control the granularity of wal log shipping.the default size is 16 megabytes.the value must be a power of 2 between 1 and 64(megabytes).

--with-wal-blocksize=BLOCKSIZE

set the wal block size,in kilobytes.this is the unit of storage and i/o within the wal log,the default,8 kilobytes,is suitable for most situations;but other values may be useful in special cases.the value must be a power of w between 1 and 64(kilobytes).

2、build

gmake

gmake world

3、installing the files

gmake install

gmake install-world

4、add a os user account

#groupadd postgres

#useradd postgres

#passwd postgres

#chown -R postgres:postgres /pgdir

5、creating a database cluster(数据库初始化)

A database cluster is a collection of databases that is managed by a single instance of a running database server.

In file system terms,a database cluster will be a single directory under which all data will be stored.we call this the data direcotry or data area.

as an alternative to the -D option,you can set the environment variable PGDATA

initdb -D /usr/local/pgsql/data/ --locale=C --encoding=UTF8

pg_ctl -D /usr/local/pgsql/data initdb

6、starting the database server

postgres -D /usr/local/pgsql/data   --前台启动方式,退出终端即退出pg

postgres -D /usr/local/pgsql/data >logfile 2>&1 &            --后台启动方式

pg_ctl start -l logfile

安装文档1:

[[email protected] pg952]# tar -jxvf postgresql-9.5.2.tar.bz2

[[email protected] pg952]# cd postgresql-9.5.2

[[email protected] pg952]# cat INSTALL |more

[[email protected] pg952]# mkdir /pg952

[[email protected] pg952]# ./configure --prefix=/pg952/

[[email protected] pg952]# gmake world

[[email protected] pg952]# gmake install-world

[[email protected] pg952]# id postgres

[[email protected] pg952]# chown -R postgres:postgres /pg952/

[[email protected] pg952]# initdb -D /usr/local/pgsql/data/ --locale=C --encoding=UTF8

[[email protected] pg952]# pg_ctl start -l logfile

安装文档2:

linux系统依赖包:

[[email protected] ~]# gcc --version

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

Copyright (C) 2010 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[[email protected] ~]# make --version

GNU Make 3.81

Copyright (C) 2006  Free Software Foundation, Inc.

This is free software; see the source for copying conditions.

There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A

PARTICULAR PURPOSE.

This program built for x86_64-redhat-linux-gnu

[[email protected] ~]# rpm -qa|grep readline

compat-readline5-5.2-17.1.el6.x86_64

readline-devel-6.0-4.el6.x86_64

readline-6.0-4.el6.x86_64

[[email protected] ~]# rpm -qa|grep zlib

zlib-1.2.3-29.el6.x86_64

zlib-devel-1.2.3-29.el6.x86_64

安装postgresql 5.2

[[email protected] mnt]# tar -jxvf postgresql-9.5.2.tar.bz2

[[email protected] mnt]# cd postgresql-9.5.2

[[email protected] postgresql-9.5.2]# ./configure --prefix=/pg952/

[[email protected] postgresql-9.5.2]# make world

[[email protected] postgresql-9.5.2]# make install-world

[[email protected] pg952]# cd /pg952/

[[email protected] pg952]# ll

总计 32

drwxr-xr-x 2 root root 4096 05-26 05:41 bin

drwxr-xr-x 4 root root 4096 05-26 05:40 include

drwxr-xr-x 4 root root 4096 05-26 05:40 lib

drwxr-xr-x 5 root root 4096 05-26 05:40 share

[[email protected] pg952]# id postgres

uid=26(postgres) gid=26(postgres) groups=26(postgres) context=root:system_r:unconfined_t:SystemLow-SystemHigh

[[email protected] pg952]# chown -R postgres:postgres /pg952/

[[email protected] pg952]# ll /pg952/

总计 32

drwxr-xr-x 2 postgres postgres 4096 05-26 05:41 bin

drwxr-xr-x 4 postgres postgres 4096 05-26 05:40 include

drwxr-xr-x 4 postgres postgres 4096 05-26 05:40 lib

drwxr-xr-x 5 postgres postgres 4096 05-26 05:40 share

[[email protected] pg952]# su - postgres

-bash-3.2$ vim .bash_profile    --添加如下环境变量

[ -f /etc/profile ] && source /etc/profile

export PGHOME=/pg952

export PGDATA=/pg952/data

export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH

PATH=$PGHOME/bin:$PATH

-bash-3.2$ pg_ctl init        --初始化数据库

-bash-3.2$ vim postgresql.conf        --修改配置文件

#listen_addresses = ‘localhost‘         # what IP address(es) to listen on;

listen_addresses = ‘*‘

-bash-3.2$ vim pg_hba.conf           --修改配置文件

# IPv4 local connections:

host    all             all             127.0.0.1/32            trust

host    all             all             192.168.72.0/24          md5

-bash-3.2$ pg_ctl start -l $PGHOME/logfile 2>&1 >/dev/null   --启动数据库

注意:pg_ctl start|status|stop|restart进行数据库启动

-bash-3.2$ ps -ef|grep post                   --查看数据库状态

-bash-3.2$ cat logfile

-bash-3.2$ ps -f -U postgres

连接数据库:

-bash-3.2$ psql                  --本地连接

psql (9.5.2)

Type "help" for help.

postgres=# \l

..........

postgres-# \password            --修改pg口令

Enter new password:

Enter it again:

C:\Users\wangwc>psql -h 192.168.72.130 -U postgres -d oracle    --远程连接


Postgresql shared memory usage:

Usage


Approximate shared memory bytes required(as of 8.3)


commections


(1800+270*max_locks_per_transaction)*max_connections


Autovacuum workers


(1800+270*max_locks_per_transaction)*autovacuum_max_workers


Prepared transactions


(770+270*max_locks_per_transaction)*max_prepared_transcctions


Shared disk buffers


(blocks_size+208)*shared_buffers


Wal buffers


(wal_blocks_size+208)*wal_buffers


Fixd space requiremenrs


770kb

时间: 2024-11-05 20:44:52

postgresql 9源码安装的相关文章

CentOS7 源码安装 PostgreSQL 12

PostgreSQL 12 源码安装 Table of Contents 1. 下载 2. 准备环境 3. 编译安装 4. 设置环境变量 5. 初始化数据库 6. 配置参数文件 6.1. postgresql.conf 6.2. pg_hba.conf 7. 数据库启动与关闭 7.1. 手动 7.2. 开机自动启动 1 下载 官网提供了源码和预安装的版本. 源码需要编译安装,解决依赖包等问题,而预安装的版本要简单很多.只需下载解压, 初始化数据库即可. 本例以源码安装为例:请至官网 下载源码.

Postgresql源码安装

以在64位CentOS6.5操作系统上源码安装postgresql-9.6beta1为例 一.进入官网下载代码(postgresql-9.6beta1.tar.gz) https://www.postgresql.org 二.将源码上传到服务器/home/alian目录下 可以在windows安装ssh或xftp工具,也可以在CentOS安装lrzsz的rpm包(使用rz,sz命令)上传或下载文件. 三.将源码在当前目录下解压 [[email protected] alian]# tar xzv

ubuntu14.04源码安装postgresql 9.1

项目需要使用gisgraphy,怎奈gisgraphy3.0只支持postgis1.5.因此只能安装老版本的posgresql和postgis了,从postgis的support matrix图可以看到postgis不同版本支持的postgresql, 我安装的是postgresql9.1.14. 1.下载postgresql9.1版本的源码,http://www.postgresql.org/docs/9.1/static/install-short.html 2.解压缩,然后切换到解压缩后的

centos环境源码安装postgresql9.4

源码安装简要步骤 下载PostgreSQL 源码包  下载根目录地址:http://ftp.postgresql.org/  本人选择的是当前最新版本v9.4.1:http://ftp.postgresql.org/pub/source/v9.4.1/  本人下载的源码压缩包地址如下: $ /usr/local/postgresql 1 解压源码包 $ tar -zxvf postgresql-9.4.1.tar.gz 1 进入解压后的目录 $ cd postgresql-9.4.1 1 开始编

pgrouting源码安装说明

1.前提条件: CentOS Linux release 7.2.1511 (Core) X64 postgresql-9.6.1 源码安装 postgis-2.3.0 源码安装 修改环境变量文件 vi /etc/profile export LD_LIBRARY_PATH=/opt/pgsql/9.6.1/lib:/usr/local/lib:/usr/local/lib64 export PATH=/opt/pgsql/9.6.1/bin:$PATH export MANPATH=/opt/

centos7.2源码安装openssl1.0.2

centos7.2默认是安装了opensll软件包的,但是部署个别服务时,由于版本太低.会影响服务的正常部署.只能使用源码安装提高openssl软件版本. 因为之前有openssl软件包,所以要先移除之前版本: 删除旧版本: yum remove -y openssl openssl-devel 源码安装openssl需要perl环境编译,如果没有perl环境还是需要安装: yum -y install perl perl-devel 现在新版本openssl: wget https://www

centos6.5 64 源码安装redis服务,建立可远程连接的redis数据库

安装环境:centos6.5 64位 使用的包:redis-2.8.19.tar.gz  tcl8.6.3-src.tar.gz 包的下载链接:http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz http://download.redis.io/releases/redis-2.8.19.tar.gz 本次安装的目录/home/hadoop/redis为任意目录 代码实现: 1,安装需要的支持环境 su root cd /home/h

ubuntu php5.6源码安装

今天又花了一天时间装了php,感觉php的源码安装也挺麻烦的,整个过程各种报错. 下篇文章准备整合所有查找到的报错和解决方法. php和nginx一样,在安装前需要装一堆的依赖.有libmcrypt.mcrypt.mhash.其实远不止这三个包,在后面的configure和make中还会陆陆续续安装一些依赖. 1.安装libmcrypt.mcrypt.mhash(整个过程都在/usr/local/src/php目录下) #创建/usr/local/src/php目录并进入mkdir /usr/l

LinuxMint下的Orionode源码安装

1. Orionode介绍 Eclipse-orion是Eclipse项目下面的一个子项目,orion是一个在在线版的代码编辑环境.其介绍参考http://wiki.eclipse.org/Orion. Eclipse-orion是使用Java语言开发的, Orionode则是使用Node.js开发的一个简易版orion.关于orionode跟orion的特性差异请查考http://wiki.eclipse.org/Orion/Node/Getting_started. 2. Node.js和n