源码安装Postgresql9.5

Postgresql简介:

PostgreSQL是一个功能强大,开源对象关系型数据库系统。它拥有超过15年的持续开发和经验证的体系结构,赢得了良好的声誉:可靠性,数据完整性和正确性

官方号称:

PostgreSQL: The world‘s most advanced open source database

官网下载地址:https://www.postgresql.org/download/

Postgresql部署:

环境:

[[email protected] ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

下载包:

[[email protected] ~]# wget https://ftp.postgresql.org/pub/source/v9.5.4/postgresql-9.5.4.tar.gz

安装依赖包:

[[email protected] ~]# yum install gcc gcc-c++ automake autoconf libtool make readline-devel zlib-devel  -y
[[email protected] ~]# yum install -y perl-ExtUtils-Embed  perl-ExtUtils-MakeMake perl-ExtUtils-MakeMaker-Coverage readline readline-devel pam pam-devel libxml2 libxml-devel libxml2-python libxml2-static  libxslt libxslt-devel  tcl tcl-devel python-devel openssl openssl-devel

创建postgresql用户及设置密码(postgresql默认不允许root用户启动):

[[email protected]de-01 ~]# useradd -u 6233 -p 123456 postgres    
[[email protected] ~]# id postgres
uid=6233(postgres) gid=6233(postgres) groups=6233(postgres)

编译安装postgresql:

[[email protected] ~]# tar -xf postgresql-9.5.4.tar.gz 
[[email protected] ~]# cd postgresql-9.5.4
[[email protected] postgresql-9.5.4]# ./configure --prefix=/usr/local/postgresql  --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam  --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=16 --with-blocksize=16
编译安装有两种方式:make和gmake,这里推荐gmake
方法1:gmake world &&  gmake install-world
方法2:make -j 4 && make install 
[[email protected] postgresql-9.5.4]# gmake world &&  gmake install-world
[[email protected] postgresql-9.5.4]# ls /usr/local/postgresql/
bin  include  lib  share

设置数据库目录及权限:

[[email protected] ~]# mkdir -p /data/postgresql
[[email protected] ~]# chown -R postgres.postgres /data/postgresql/

添加系统环境变量:

[[email protected] ~]# echo ‘export PATH=$PATH:/usr/local/postgresql/bin/‘ >> /etc/profile
[[email protected] ~]# psql -V
psql (PostgreSQL) 9.5.4

初始化数据库:

[[email protected] ~]# su - postgres
[[email protected] ~]$ initdb -D /data/postgresql/ -U postgres -E UTF8 --locale=C -W
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 "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data/postgresql ... 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/postgresql/base/1 ... ok
initializing pg_authid ... ok
Enter new superuser password:      设置超级用户的密码
Enter it again: 
setting password ... 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:

    pg_ctl -D /data/postgresql/ -l logfile start

参数:
-U postgres:指定的数据库超级管理员,自定义
-W :设置密码
-D :数据存放目录
-E :设置编译

修改验证方式简单的配置:

[[email protected] ~]$ vim /data/postgresql/pg_hba.conf
host    all             all             127.0.0.1/32            md5    MD5验证方式需要输入用户密码
[[email protected] ~]$ vim /data/postgresql/postgresql.conf
port = 1236                            # (change requires restart)
max_connections = 100 
unix_socket_directories = ‘/dev/shm/‘

添加服务管理脚本:

[[email protected] ~]# cd postgresql-9.5.4
[[email protected] postgresql-9.5.4]# cp contrib/start-scripts/linux /etc/init.d/postgresql
[[email protected] postgresql-9.5.4]# chmod +x /etc/init.d/postgresql
[[email protected] postgresql-9.5.4]# chkconfig postgresql on
[[email protected] postgresql-9.5.4]# vim /etc/init.d/postgresql 
prefix=/usr/local/postgresql
PGDATA="/data/postgresql"
PGUSER=postgres
PGLOG="$PGDATA/serverlog"

启动postgresql:

[[email protected] postgresql-9.5.4]# /etc/init.d/postgresql start
[[email protected] postgresql-9.5.4]#  lsof -i :1236              
COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postmaste 16232 postgres    3u  IPv6  53256      0t0  TCP localhost:bvcontrol (LISTEN)
postmaste 16232 postgres    4u  IPv4  53257      0t0  TCP localhost:bvcontrol (LISTEN)

登陆postgresql:

[[email protected] ~]# psql -h 127.0.0.1 -p 1236 -U postgres -d postgres
Password for user postgres: 
psql (9.5.4)
Type "help" for help.

postgres=#

安装所有的扩展包:

[[email protected] ~]# cd postgresql-9.5.4/contrib/  
[[email protected] contrib]# ls -d */ | xargs -n 1 -P 0 sh -c ‘cd {}; make ; make install;‘c


时间: 2024-08-07 03:04:14

源码安装Postgresql9.5的相关文章

centos环境源码安装postgresql9.4

源码安装简要步骤 下载PostgreSQL 源码包  下载根目录地址:http://ftp.postgresql.org/  本人选择的是当前最新版本v9.4.1:http://ftp.postgresql.org/pub/source/v9.4.1/  本人下载的源码压缩包地址如下: $ /usr/local/postgresql 1 解压源码包 $ tar -zxvf postgresql-9.4.1.tar.gz 1 进入解压后的目录 $ cd postgresql-9.4.1 1 开始编

CentOS6.5 64位下源码安装PostgreSQL9.5.1

1.官方下载源码文件 http://www.postgresql.org/ftp/source/v9.5.1/ 2.添加用户 [[email protected] ~]#  useradd postgres [[email protected] ~]#  passwd postgres Changing password for user postgres. New password: Retype new password: passwd: all authentication tokens

源码安装Postgresql9.4.1

1.先到官网下载http://www.postgresql.org/ftp/source/v9.4.1/ tar包 2.解压后执行: sudo apt-get install zlib1g-dev sudo apt-get install libreadline-dev 3. ./configure make su make install 4.安装完成后程序目录在/usr/local/pgsql/ 5.切换到postgres用户编辑~/.bash_profile文件,将数据库执行命令的目录加入

Postgresql源码安装

以在64位CentOS6.5操作系统上源码安装postgresql-9.6beta1为例 一.进入官网下载代码(postgresql-9.6beta1.tar.gz) https://www.postgresql.org 二.将源码上传到服务器/home/alian目录下 可以在windows安装ssh或xftp工具,也可以在CentOS安装lrzsz的rpm包(使用rz,sz命令)上传或下载文件. 三.将源码在当前目录下解压 [[email protected] alian]# tar xzv

pgrouting源码安装说明

1.前提条件: CentOS Linux release 7.2.1511 (Core) X64 postgresql-9.6.1 源码安装 postgis-2.3.0 源码安装 修改环境变量文件 vi /etc/profile export LD_LIBRARY_PATH=/opt/pgsql/9.6.1/lib:/usr/local/lib:/usr/local/lib64 export PATH=/opt/pgsql/9.6.1/bin:$PATH export MANPATH=/opt/

ubuntu14.04源码安装postgresql 9.1

项目需要使用gisgraphy,怎奈gisgraphy3.0只支持postgis1.5.因此只能安装老版本的posgresql和postgis了,从postgis的support matrix图可以看到postgis不同版本支持的postgresql, 我安装的是postgresql9.1.14. 1.下载postgresql9.1版本的源码,http://www.postgresql.org/docs/9.1/static/install-short.html 2.解压缩,然后切换到解压缩后的

centos7.2源码安装openssl1.0.2

centos7.2默认是安装了opensll软件包的,但是部署个别服务时,由于版本太低.会影响服务的正常部署.只能使用源码安装提高openssl软件版本. 因为之前有openssl软件包,所以要先移除之前版本: 删除旧版本: yum remove -y openssl openssl-devel 源码安装openssl需要perl环境编译,如果没有perl环境还是需要安装: yum -y install perl perl-devel 现在新版本openssl: wget https://www

centos6.5 64 源码安装redis服务,建立可远程连接的redis数据库

安装环境:centos6.5 64位 使用的包:redis-2.8.19.tar.gz  tcl8.6.3-src.tar.gz 包的下载链接:http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz http://download.redis.io/releases/redis-2.8.19.tar.gz 本次安装的目录/home/hadoop/redis为任意目录 代码实现: 1,安装需要的支持环境 su root cd /home/h

ubuntu php5.6源码安装

今天又花了一天时间装了php,感觉php的源码安装也挺麻烦的,整个过程各种报错. 下篇文章准备整合所有查找到的报错和解决方法. php和nginx一样,在安装前需要装一堆的依赖.有libmcrypt.mcrypt.mhash.其实远不止这三个包,在后面的configure和make中还会陆陆续续安装一些依赖. 1.安装libmcrypt.mcrypt.mhash(整个过程都在/usr/local/src/php目录下) #创建/usr/local/src/php目录并进入mkdir /usr/l