centos 下源碼安裝postgresql 9.4

來源:互聯網
上載者:User

標籤:

[[email protected] ~]# cd /home
[[email protected] home]# ls
postgresql-9.4.1.tar  test [[email protected] home]# tar xf postgresql-9.4.1.tar  [[email protected] home]# cd postgresql-9.4.1
[[email protected] postgresql-9.4.1]# ls
aclocal.m4  config  configure  configure.in  contrib  COPYRIGHT  doc  GNUmakefile.in  HISTORY  INSTALL  Makefile  README  src
[[email protected] postgresql-9.4.1]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... no
checking whether gcc supports -funroll-loops... yes
checking whether gcc supports -ftree-vectorize... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking whether to build with SELinux support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... /usr/bin/bison
configure: using bison (GNU Bison) 2.4.1
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing shm_open... -lrt
checking for library containing shm_unlink... none required
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn‘t looking in the proper directory.Use --without-readline to disable readline support. #缺少readline library#檢查系統是否安裝readlilne包[[email protected] postgresql-9.4.1]# rpm -qa | grep readlinereadline-6.0-4.el6.x86_64 #通過yum搜尋相關的readline包[[email protected] postgresql-9.4.1]# yun search readline
-bash: yun: command not found
[[email protected] postgresql-9.4.1]# yum search readline
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: mirror.bit.edu.cn
* extras: mirrors.btte.net
* updates: mirror.bit.edu.cn
base                                                                                                     | 3.7 kB     00:00    
extras                                                                                                   | 3.4 kB     00:00    
extras/primary_db                                                                                        |  31 kB     00:00    
updates                                                                                                  | 3.4 kB     00:00    
updates/primary_db                                                                                       | 4.4 MB     00:17    
==================================================== N/S Matched: readline =====================================================
compat-readline5-devel.i686 : Files needed to develop programs which use the readline library
compat-readline5-devel.x86_64 : Files needed to develop programs which use the readline library
compat-readline5-static.x86_64 : Static libraries for the readline library
libreadline-java-javadoc.x86_64 : Javadoc for libreadline-java
readline-devel.i686 : Files needed to develop programs which use the readline library
readline-devel.x86_64 : Files needed to develop programs which use the readline library
readline-static.x86_64 : Static libraries for the readline library
compat-readline5.i686 : A library for editing typed command lines
compat-readline5.x86_64 : A library for editing typed command lines
libreadline-java.x86_64 : Java wrapper for the EditLine library
perl-Term-UI.x86_64 : Term::ReadLine UI made easy
readline.i686 : A library for editing typed command lines
readline.x86_64 : A library for editing typed command lines

  Name and summary matches only, use "search all" for everything. #安裝readline-devel包[[email protected] postgresql-9.4.1]# yum -y install -y readline-devel.x86_64 再次執行configure成功。 --------------------------- [[email protected] postgresql-9.4.1]# adduser postgres[[email protected] postgresql-9.4.1]# mkdir /data/pgsql
[[email protected] postgresql-9.4.1]# mkdir /log
[[email protected] postgresql-9.4.1]# mkdir /data/log
[[email protected] postgresql-9.4.1]# mkdir /data/log/pgsql
[[email protected] postgresql-9.4.1]# chown -R postgres.postgres /data/pgsql
[[email protected] postgresql-9.4.1]# chown -R postgres.postgres /data/log/pgsql
[[email protected] postgresql-9.4.1]# su postgres
[[email protected] postgresql-9.4.1]$ cd /usr/local/pgsql/bin
[[email protected] bin]$ ls
clusterdb   createuser  dropuser  pg_basebackup   pg_ctl      pg_isready      pg_resetxlog  postmaster  vacuumdb
createdb    dropdb      ecpg      pg_config       pg_dump     pg_receivexlog  pg_restore    psql
createlang  droplang    initdb    pg_controldata  pg_dumpall  pg_recvlogical  postgres      reindexdb
[[email protected] bin]$ ./initdb -D /data/pgsql
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data/pgsql ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /data/pgsql/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects‘ descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
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 /data/pgsql
or
    ./pg_ctl -D /data/pgsql -l logfile start

[[email protected] bin]$ ./postgres -D /data/pgsql > /data/log/pgsql/logfile 2>&1 & 服務啟動。接下來設定環境變數。  

每次啟動資料庫服務都要進入PG的bin目錄,再敲一堆命令什麼的也不方便,不如直接將bin下的可執行程式加到使用者環境變數當中。可通過下列方式實現。

 

開啟使用者的環境設定檔,是/home/postgres/下的.profile,通過vim命令開啟(如果沒裝vim可以通過sudo apt-get install vim來安裝)。在末尾處加上:

 

export PGDATA=/data/pgsql

export PATH=$PATH:/usr/local/pgsql/bin

 

PGDATA是postgres –D後面指定的資料庫檔案存放目錄,通過這樣的設定,如果直接運行postgres或pg_ctl start那麼資料庫檔案會預設存放在/data/pgsql目錄中的。

 

至此,PG的安裝結束,使用者在開啟資料庫服務的狀態下,可以使用psql用戶端來串連並訪問資料庫,通過SQL語言來操作。

centos 下源碼安裝postgresql 9.4

相關文章

聯繫我們

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