RedHat Linux上安裝PostgreSQL

來源:互聯網
上載者:User

1. 作業系統資訊:Red Hat Enterprise Linux 4

2. 下載PostgreSQL源碼:http://www.postgresql.org/ftp/source,現在已經更新到了9.1beta版本了,不過安裝過程基本一致,我之前下載的是8.4.2,所以以8.4.2進行描述。

3.上傳下載到的postgresql-8.4.2.tar.gz到/opt目錄下。

4. 建立postgres使用者及dba組,並切換到postgres使用者。

#useradd -g dba postgres

 5.將postgresql-8.4.2.tar.gz的屬主改為postgres,並解壓。

[root@localhost ~]# cd /opt[root@localhost ~]# #chown postgres postgresql-8.4.2
[root@localhost ~]# #su - postgres
[postgres@localhost opt]$$ cd /opt
[postgres@localhost opt]$$tar -zxvf postgresql-8.4.2.tar.gz[postgres@localhost opt]$$ ll總用量 32drwxr-xr-x  2 root     root 4096  3月 28 19:49 gcc_testdrwxr-xr-x  8 postgres root 4096  7月  9 09:44 postgresqldrwxrwxrwx  6 postgres  258 4096  7月  9 09:40 postgresql-8.4.2drwxr-xr-x  2 root     root 4096  4月  2 19:20 testbool

6. 進入postgresql-8.4.2目錄,進行配置

[postgres@localhost opt]$ cd postgresql-8.4.2/[postgres@localhost postgresql-8.4.2]$./configure --prefix=/opt/postgresql --enable-profiling --with-blocksize=8 --with-wal-blocksize=8

注,各配置項意義見備後文備忘。

7.編譯,大約需要5分鐘,如過程中有失敗,請確認系統上是否有make, gcc等工具,以及目錄許可權問題。

[postgres@localhost postgresql-8.4.2]$make

8.安裝,執行2分鐘左右,螢幕列印“PostgreSQL installation complete”表示安裝完成。

[postgres@localhost postgresql-8.4.2]$make install

9.初始化資料庫。

[postgres@localhost postgresql-8.4.2]$ cd /opt/postgresql/bin/[postgres@localhost bin]$./initdb --encoding=utf8 -D /opt/postgresql/data

 初始化完成後螢幕列印如下資訊:

Success. You can now start the database server using:

    ./postgres -D /opt/postgresql/data
or
    ./pg_ctl -D /opt/postgresql/data -l logfile start

10. 啟動資料庫

[postgres@localhost bin]$./postgres -D /opt/postgresql/data

當然,可以通過日誌重寫向,將啟動資訊寫入日誌,例如:

[postgres@localhost bin]$ ./pg_ctl -D /opt/postgresql/data/ -l /opt/postgresql/log/pg_server.log start

將日誌資訊記錄在檔案/opt/postgresql/log/pg_server.log中,當然,在執行前,請先建立這個檔案,且屬主為postgres。

11.安裝完畢。

 

備忘:編譯配置項各參數說明,可根據實際情況選擇使用:

[postgres@localhost postgresql-8.4.2]$ ./configure -help`configure' configures PostgreSQL 8.4.2 to adapt to many kinds of systems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them asVAR=VALUE.  See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:  -h, --help              display this help and exit      --help=short        display options specific to this package      --help=recursive    display the short help of all the included packages  -V, --version           display version information and exit  -q, --quiet, --silent   do not print `checking...' messages      --cache-file=FILE   cache test results in FILE [disabled]  -C, --config-cache      alias for `--cache-file=config.cache'  -n, --no-create         do not create output files      --srcdir=DIR        find the sources in DIR [configure dir or `..']Installation directories:  --prefix=PREFIX         install architecture-independent files in PREFIX                          [/usr/local/pgsql]  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX                          [PREFIX]By default, `make install' will install all the files in`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc.  You can specifyan installation prefix other than `/usr/local/pgsql' using `--prefix',for instance `--prefix=$HOME'.For better control, use the options below.Fine tuning of the installation directories:  --bindir=DIR           user executables [EPREFIX/bin]  --sbindir=DIR          system admin executables [EPREFIX/sbin]  --libexecdir=DIR       program executables [EPREFIX/libexec]  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]  --libdir=DIR           object code libraries [EPREFIX/lib]  --includedir=DIR       C header files [PREFIX/include]  --oldincludedir=DIR    C header files for non-gcc [/usr/include]  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]  --infodir=DIR          info documentation [DATAROOTDIR/info]  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]  --mandir=DIR           man documentation [DATAROOTDIR/man]  --docdir=DIR           documentation root [DATAROOTDIR/doc/postgresql]  --htmldir=DIR          html documentation [DOCDIR]  --dvidir=DIR           dvi documentation [DOCDIR]  --pdfdir=DIR           pdf documentation [DOCDIR]  --psdir=DIR            ps documentation [DOCDIR]System types:  --build=BUILD     configure for building on BUILD [guessed]  --host=HOST       cross-compile to build programs to run on HOST [BUILD]Optional Features:  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]  --disable-integer-datetimes                          disable 64-bit integer date/time support  --enable-nls[=LANGUAGES]                          enable Native Language Support  --disable-shared        do not build shared libraries  --disable-rpath         do not embed shared library search path in                          executables  --disable-spinlocks     do not use spinlocks  --enable-debug          build with debugging symbols (-g)  --enable-profiling      build with profiling enabled  --enable-coverage       build with coverage testing instrumentation  --enable-dtrace         build with DTrace support  --enable-depend         turn on automatic dependency tracking  --enable-cassert        enable assertion checks (for debugging)  --enable-thread-safety  make client libraries thread-safe  --enable-thread-safety-force                          force thread-safety despite thread test failure  --disable-float4-byval  disable float4 passed by value  --disable-float8-byval  disable float8 passed by value  --disable-largefile     omit support for large filesOptional Packages:  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)  --with-template=NAME    override operating system template  --with-includes=DIRS    look for additional header files in DIRS  --with-libraries=DIRS   look for additional libraries in DIRS  --with-libs=DIRS        alternative spelling of --with-libraries  --with-pgport=PORTNUM   set default port number [5432]  --with-blocksize=BLOCKSIZE                          set table block size in kB [8]  --with-segsize=SEGSIZE  set table segment size in GB [1]  --with-wal-blocksize=BLOCKSIZE                          set WAL block size in kB [8]  --with-wal-segsize=SEGSIZE                          set WAL segment size in MB [16]  --with-CC=CMD           set compiler (deprecated)  --with-tcl              build Tcl modules (PL/Tcl)  --with-tclconfig=DIR    tclConfig.sh is in DIR  --with-perl             build Perl modules (PL/Perl)  --with-python           build Python modules (PL/Python)  --with-gssapi           build with GSSAPI support  --with-krb5             build with Kerberos 5 support  --with-krb-srvnam=NAME  default service principal name in Kerberos                          [postgres]  --with-pam              build with PAM support  --with-ldap             build with LDAP support  --with-bonjour          build with Bonjour support  --with-openssl          build with OpenSSL support  --without-readline      do not use GNU Readline nor BSD Libedit for editing  --with-libedit-preferred                          prefer BSD Libedit over GNU Readline  --with-ossp-uuid        use OSSP UUID library when building                          contrib/uuid-ossp  --with-libxml           build with XML support  --with-libxslt          use XSLT support when building contrib/xml2  --with-system-tzdata=DIR                          use system time zone data in DIR  --without-zlib          do not use Zlib  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]Some influential environment variables:  CC          C compiler command  CFLAGS      C compiler flags  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a              nonstandard directory <lib dir>  LIBS        libraries to pass to the linker, e.g. -l<library>  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if              you have headers in a nonstandard directory <include dir>  CPP         C preprocessor  LDFLAGS_SL  linker flags for shared library linking  DOCBOOKSTYLE              location of DocBook stylesheetsUse these variables to override the choices made by `configure' or to helpit to find libraries and programs with nonstandard names/locations.Report bugs to <pgsql-bugs@postgresql.org>.[postgres@localhost postgresql-8.4.2]$

 

 

 

 

相關文章

聯繫我們

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