码迷,mamicode.com
首页 > 数据库 > 详细

postgresql 在linux上的源码安装

时间:2015-02-04 16:59:21      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

下载源码并解压

[root@fnddb ~]# wget https://ftp.postgresql.org/pub/source/v9.4.0/postgresql-9.4.0.tar.bz2
[root@fnddb ~]# tar -xjvf postgresql-9.4.0.tar.bz2 
[root@fnddb ~]# cd postgresql-9.4.0

开始编译安装

[root@fnddb postgresql-9.4.0]# ./configure 
……
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.

按照错误提示依次安装依赖包

[root@fnddb postgresql-9.4.0]# yum install readline-devel
[root@fnddb postgresql-9.4.0]# yum install zlib-devel
...

继续

[root@fnddb postgresql-9.4.0]# ./configure
[root@fnddb postgresql-9.4.0]# make
……
All of PostgreSQL successfully made. Ready to install.
[root@fnddb postgresql-9.4.0]# make install
……
PostgreSQL installation complete.

添加用户

[root@fnddb postgresql-9.4.0]# useradd postgres
[root@fnddb postgresql-9.4.0]# passwd postgres
Changing password for user postgres.
New password: 
BAD PASSWORD: it is based on a dictionary word
Retype new password: 
passwd: all authentication tokens updated successfully.

建立好database cluster目标文件夹

[root@fnddb postgresql-9.4.0]# mkdir /var/lib/pgsql/data -p
[root@fnddb postgresql-9.4.0]# chown -R postgres /var/lib/pgsql

环境变量设置

[postgres@fnddb ~]$ vi .bash_profile 
…
# postgres
PGDATA=/var/lib/pgsql/data
PATH=/usr/local/pgsql/bin:$PATH
export PGDATA PATH

[postgres@fnddb ~]$ . .bash_profile 

创建database cluster

loading PL/pgSQL server-side language ... ok
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 /var/lib/pgsql/data ... 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 /var/lib/pgsql/data/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:

    /usr/local/pgsql/bin/postgres -D /var/lib/pgsql/data
or
    /usr/local/pgsql/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

启动数据库实例

设置好PGDATA环境变量后,可以不带-D选项

[postgres@fnddb ~]$ pg_ctl start -l /var/lib/pgsql/pgsql.log
server starting

关闭数据库实例

[postgres@fnddb ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped

开机自动启动设置

[root@fnddb postgresql-9.4.0]# vi /etc/rc.local
…
su - c ‘/usr/local/pgsql/bin/pg_ctl start -D /var/lib/pgsql/data -l /var/lib/pgsql/pgsql.log‘

postgresql 在linux上的源码安装

标签:

原文地址:http://my.oschina.net/hippora/blog/375292

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!