当前位置:Gxlcms > 数据库问题 > centos 下源码安装postgresql 9.4

centos 下源码安装postgresql 9.4

时间:2021-07-01 10:21:17 帮助过:2人阅读


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语言来操作。

centos 下源码安装postgresql 9.4

标签:

人气教程排行