zoukankan      html  css  js  c++  java
  • centos 下源码安装postgresql 9.4

    [root@localhost ~]# cd /home
    [root@localhost home]# ls
    postgresql-9.4.1.tar  test
    [root@localhost home]# tar xf postgresql-9.4.1.tar 
    [root@localhost home]# cd postgresql-9.4.1
    [root@localhost postgresql-9.4.1]# ls
    aclocal.m4  config  configure  configure.in  contrib  COPYRIGHT  doc  GNUmakefile.in  HISTORY  INSTALL  Makefile  README  src
    [root@localhost 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包
    [root@localhost postgresql-9.4.1]# rpm -qa | grep readline
    readline-6.0-4.el6.x86_64
     
    #通过yum搜索相关的readline包
    [root@localhost postgresql-9.4.1]# yun search readline
    -bash: yun: command not found
    [root@localhost 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包
    [root@localhost postgresql-9.4.1]# yum -y install -y readline-devel.x86_64
     
    再次执行configure成功。
     
    ---------------------------
     
    [root@localhost postgresql-9.4.1]# adduser postgres
    [root@localhost postgresql-9.4.1]# mkdir /data/pgsql
    [root@localhost postgresql-9.4.1]# mkdir /log
    [root@localhost postgresql-9.4.1]# mkdir /data/log
    [root@localhost postgresql-9.4.1]# mkdir /data/log/pgsql
    [root@localhost postgresql-9.4.1]# chown -R postgres.postgres /data/pgsql
    [root@localhost postgresql-9.4.1]# chown -R postgres.postgres /data/log/pgsql
    [root@localhost postgresql-9.4.1]# su postgres
    [postgres@localhost postgresql-9.4.1]$ cd /usr/local/pgsql/bin
    [postgres@localhost 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
    [postgres@localhost 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

    [postgres@localhost 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语言来操作。
  • 相关阅读:
    vue项目中引入tinymce4
    `elementui`表格实现无限滚动
    `index.html`与`App.vue`中有相同`id`的`div`,`main.js`绑定的是哪一个?
    IDEA下新建SpringMVC项目的配置文件
    IDEA中-------Tomcat启动提示404
    一、代理模式:静态代理与动态代理
    Java发送QQ邮件-附jar包下载链接
    Git使用教程(下)
    Git使用教程(中)
    python菜鸟教程学习13:文件操作
  • 原文地址:https://www.cnblogs.com/yingtaowz/p/4680664.html
Copyright © 2011-2022 走看看