postgresql 9源碼安裝

來源:互聯網
上載者:User

標籤:tab   val   collect   restart   library   body   fine   spec   ddr   

安裝過程:

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

postgresql 9源碼安裝

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.