源碼安裝postgresql934,源碼postgresql934

來源:互聯網
上載者:User

源碼安裝postgresql934,源碼postgresql934
0
[root@pghost ~]# uname -a
Linux pghost 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@pghost ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m

1
yum -y install readline readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel gcc make flex bison perl perl-devel perl-ExtUtils* 

2
useradd postgres

3
vi /home/postgres/.bash_profile
export PGPORT=5432
export PGDATA=/opt/pgsql9.3.4/pgdata
export LANG=en_US.utf8
export PGHOME=/opt/pgsql
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres
export PGHOST=$PGDATA

4
[root@pghost ~]# cd /root/backup/
[root@pghost backup]# ll
total 21356
-rw-r--r--. 1 root root 21865589 Sep  7 09:21 postgresql-9.3.4.tar.gz

[root@pghost backup]# tar -zxvf postgresql-9.3.4.tar.gz
[root@pghost backup]# ll
total 21360
drwxrwxrwx. 6 1107 1107     4096 Mar 18  2014 postgresql-9.3.4

5
[root@pghost backup]# cd postgresql-9.3.4
[root@pghost postgresql-9.3.4]# ./configure --prefix=/opt/pgsql9.3.4 --with-pgport=5432 --with-perl --with-tcl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=8 --with-blocksize=8 && gmake world
...
...
gmake[2]: Leaving directory `/root/backup/postgresql-9.3.4/contrib/xml2'
gmake[1]: Leaving directory `/root/backup/postgresql-9.3.4/contrib'
PostgreSQL, contrib, and documentation successfully made. Ready to install.
[root@pghost postgresql-9.3.4]# 
[root@pghost postgresql-9.3.4]# ll
total 1448
-rw-r--r--.  1 root root 359981 Sep 19 17:26 config.log
-rwxr-xr-x.  1 root root  39791 Sep 19 17:26 config.status
-rw-r--r--.  1 root root   3618 Sep 19 17:26 GNUmakefile
drwxrwxrwx. 15 1107 1107   4096 Sep 19 17:26 src

6
[root@pghost postgresql-9.3.4]# gmake install-world
...
...
gmake[2]: Leaving directory `/root/backup/postgresql-9.3.4/contrib/xml2'
gmake[1]: Leaving directory `/root/backup/postgresql-9.3.4/contrib'
PostgreSQL, contrib, and documentation installation complete.
[root@pghost postgresql-9.3.4]# 

7
[root@pghost postgresql-9.3.4]# ll /opt/
total 8
drwxr-xr-x. 6 root root 4096 Sep 19 17:31 pgsql9.3.4
drwxr-xr-x. 2 root root 4096 Nov 22  2013 rh

[root@pghost postgresql-9.3.4]# ln -s /opt/pgsql9.3.4 /opt/pgsql

[root@pghost postgresql-9.3.4]# ll /opt/
total 8
lrwxrwxrwx. 1 root root   15 Sep 19 17:33 pgsql -> /opt/pgsql9.3.4
drwxr-xr-x. 6 root root 4096 Sep 19 17:31 pgsql9.3.4
drwxr-xr-x. 2 root root 4096 Nov 22  2013 rh
[root@pghost postgresql-9.3.4]# 

[root@pghost postgresql-9.3.4]# ll /opt/pgsql9.3.4/
total 16
drwxr-xr-x. 2 root root 4096 Sep 19 17:31 bin
drwxr-xr-x. 6 root root 4096 Sep 19 17:31 include
drwxr-xr-x. 4 root root 4096 Sep 19 17:31 lib
drwxr-xr-x. 8 root root 4096 Sep 19 17:31 share

8
[root@pghost ~]# chown -R root:daemon /opt/pgsql9.3.4/
[root@pghost ~]# ll /opt/
total 8
lrwxrwxrwx. 1 root root     15 Sep 19 17:33 pgsql -> /opt/pgsql9.3.4
drwxr-xr-x. 6 root daemon 4096 Sep 19 17:31 pgsql9.3.4
drwxr-xr-x. 2 root root   4096 Nov 22  2013 rh
[root@pghost ~]# ll /opt/pgsql9.3.4/
total 16
drwxr-xr-x. 2 root daemon 4096 Sep 19 17:31 bin
drwxr-xr-x. 6 root daemon 4096 Sep 19 17:31 include
drwxr-xr-x. 4 root daemon 4096 Sep 19 17:31 lib
drwxr-xr-x. 8 root daemon 4096 Sep 19 17:31 share

9
[root@pghost pgsql9.3.4]# mkdir pgdata
[root@pghost pgsql9.3.4]# chown postgres:postgres pgdata/
[root@pghost pgsql9.3.4]# ll
total 20
drwxr-xr-x. 2 root     daemon   4096 Sep 19 17:31 bin
drwxr-xr-x. 6 root     daemon   4096 Sep 19 17:31 include
drwxr-xr-x. 4 root     daemon   4096 Sep 19 17:31 lib
drwxr-xr-x. 2 postgres postgres 4096 Sep 19 17:48 pgdata
drwxr-xr-x. 8 root     daemon   4096 Sep 19 17:31 share

10
[root@pghost postgresql-9.3.4]# su - postgres
[postgres@pghost ~]$ initdb -D $PGDATA -E UTF8 --locale=C -U postgres -W
...
...
syncing data to disk ... ok


WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.


Success. You can now start the database server using:


    postgres -D /opt/pgsql9.3.4/pgdata
or
    pg_ctl -D /opt/pgsql9.3.4/pgdata -l logfile start


[postgres@pghost ~]$

11
[root@pghost opt]# ll pgsql9.3.4/
total 20
drwxr-xr-x.  2 root     daemon   4096 Sep 19 17:31 bin
drwxr-xr-x.  6 root     daemon   4096 Sep 19 17:31 include
drwxr-xr-x.  4 root     daemon   4096 Sep 19 17:31 lib
drwx------. 15 postgres postgres 4096 Sep 22 11:51 pgdata
drwxr-xr-x.  8 root     daemon   4096 Sep 19 17:31 share


12
[root@pghost opt]# vi pgsql9.3.4/pgdata/pg_hba.conf 
# IPv4 local connections:
host    all             all             0.0.0.0/0               md5


13
[root@pghost opt]# vi pgsql9.3.4/pgdata/postgresql.conf
listen_addresses = '*' 
#listen_addresses = 'localhost' 

unix_socket_directories = '.'
#unix_socket_directories = '/tmp'

unix_socket_permissions = 0700
#unix_socket_permissions = 0777

14
[postgres@pghost ~]$ pg_ctl -D /opt/pgsql9.3.4/pgdata/ -l /opt/pgsql9.3.4/pgdata/pg_log/startup.log  start
server starting
[postgres@pghost ~]$ 

[postgres@pghost ~]$ ps -ef | grep postgres
postgres 33829     1  0 15:26 pts/1    00:00:00 /opt/pgsql9.3.4/bin/postgres -D /opt/pgsql9.3.4/pgdata
postgres 33831 33829  0 15:26 ?        00:00:00 postgres: checkpointer process                        
postgres 33832 33829  0 15:26 ?        00:00:00 postgres: writer process                              
postgres 33833 33829  0 15:26 ?        00:00:00 postgres: wal writer process                          
postgres 33834 33829  0 15:26 ?        00:00:00 postgres: autovacuum launcher process                 
postgres 33835 33829  0 15:26 ?        00:00:00 postgres: stats collector process                     
[postgres@pghost ~]$ 

15
[root@pghost ~]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
[root@pghost ~]# /etc/init.d/iptables restart


16
[root@hostalonetest ~]# /opt/PostgreSQL/9.3/bin/psql -h 192.168.19.77 -Upostgres
Password for user postgres: 
psql.bin (9.3.5, server 9.3.4)
Type "help" for help.


postgres=# 


參考:http://www.postgresql.org/docs/9.3/interactive/tutorial-install.html



----------------- 

轉載請著明出處:
blog.csdn.net/beiigang

跪postgreSQL資料庫安裝程式

這裡有下載,各個版本都有
www.postgresql.org/
安裝的說明:我學生以前整理的,不知道是否適用現在版本

/************************************************
這是一個介紹安裝postgresql的說明文檔,win 下的話寫字板開啟linux下直接開啟。
以postgresql-8.4.6為例,PS;安裝過程中一但提示許可權不夠,就到root使用者下,重新執行命令即可,屢試不爽。
**************************************************/
最開始我們需要建立一個postgres使用者,首先點擊左下角(或者左上方,看你的在那裡了)的那個紅帽(相當於win的開始),
管理-->使用者和組群
添加使用者->對話方塊裡面填寫,使用者名稱:postgres
全稱 :PostgreSQL Server
密碼:(自己輸入一個)
主目錄:/var/lib/pgsql
登入: /bin/bash

1.在這裡我們利用原始碼進行安裝,首先我們獲得原始碼,如果沒有可以到www.postgresql.org/download/下載。

2.在這裡我介紹壓縮包後副檔名字為tar.bz2的解壓方式,
首先在當前壓縮包所在目錄下,開啟終端,輸入命令,
bzip2 -d postgresql-8.4.6.tar.bz2
tar -xvf postgresql-8.4.6.tar

3.經過上面的命令我們獲得了PG的原始碼檔案夾,預設命名為postgresql-8.4.6,進入這個檔案夾,我們看到有一些檔案和檔案夾,開啟終端(右鍵滑鼠選擇打來,或者快速鍵F4都可以開啟),下面是一些通用的在Linux上面安裝原代碼過程,以後也可能用到。注意這三個命令
./configure
make
make install
在make install 需要到root使用者下面安裝。
所以應該會需要命令,su root並且輸入密碼。
安裝完成後,我們重啟電腦,用postgres登入進去系統。

4.所有命令執行完畢後我們就會安裝完成PG 的安裝,我們可以到預設安裝目錄下面查看一下,
預設的目錄為/usr/local/pgsql,
在這裡我們需要建立一個資料庫存放的檔案夾,開啟終端,到root使用者下執行命令,也就是先su root然後在執行下面命令。
mkdir data
chmod 777 data
chown postgres data

5.執行命令
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
完成資料庫的初始......餘下全文>>
 
為何linux不可以安裝最新版本的postgresql (postgresql-912targz)

可選擇源碼編譯安裝:
一、在root使用者下使用源碼編譯方式安裝PostgreSQL
1. 解壓
tar jxvf postgresql-9.1.2.tar.bz2

2. 檢查依賴軟體包
rpm -qa | grep readline
rpm -qa | grep zlib
rpm -qa | grep gcc
rpm -qa | grep make

3. 如果缺少依賴軟體包,安裝以下軟體包
gcc
make
zlib-devel
readline-devel

4. 配置PostgreSQL
cd postgresql-9.1.2
./configure --prefix=/usr/local/pgsql

5. 編譯並安裝PostgreSQL
make
make install

6. 建立組和使用者
groupadd postgres
useradd -g postgres postgres
passwd postgres

7. 建立資料庫庫檔案儲存體目錄、給postgres賦予許可權:
mkdir /usr/local/pgsql/data
cd /usr/local/pgsql
chown postgres.postgres data
touch /var/log/pgsql.log
chown postgres.postgres /var/log/pgsql.log

8. 初始化資料庫目錄(在postgres使用者下執行命令)
cd /usr/local/pgsql/
./bin/initdb -E UTF-8 -D /usr/local/pgsql/data --locale=zh_CN.UTF-8
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.