PostgreSQL 9.6.1源码安装

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介:

RHEL7.2+PostgreSQL9.6.1


Requirements softwares

1.GNU make version 3.80 or newer is required

[root@rhel7 ~]# make --version

GNU Make 3.82

Built for x86_64-redhat-linux-gnu

2.You need an ISO/ANSI C compiler (at least C89-compliant). Recent versions of GCC are recommended

[root@rhel7 ~]# gcc --version

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)

3. tar is required to unpack the source distribution, in addition to either gzip or bzip2.

4.The GNU Readline library is used by default.

readline

readline-devel

libedit

Optional

perl 5.8 or later

python

Kerberos

OpenSSL

OpenLDAP

and/or PAM

Flex 2.5.31 or later

Bison 1.875 or later


useradd pguser

su - pguser

tar -zxvf postgresql-9.6.1.tar.gz


Install

  cd postgresql-9.6.1

  ./configure

    默认安装目录/usr/local/pgsql,可以使用--prefix=path进行修改,./configure --help

 make

    The last line displayed should be:
    All of PostgreSQL successfully made. Ready to install.

 su (使用root安装)

 make install

    PostgreSQL installation complete.

Set the environment variables for pguser

 mkdir /usr/local/pgsql/data #PostgreSQL数据存储目录

 chown pguser:pguser /usr/local/pgsql/data

 export LD_LIBRARY_PATH=/usr/local/pgsql/lib

 export PG_HOME=/usr/local/pgsql

 export PATH=$PG_HOME/bin/:$PATH

 export PGDATA=/usr/local/pgsql/data

Initilize the DBServer

  (使用pguser)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[pguser@rhel7 ~]$ initdb -D  /usr/local/pgsql/data
The files belonging to this database system will be owned by user  "pguser" .
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  /usr/local/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
running bootstrap script ... ok
performing post-bootstrap initialization ... 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  /usr/local/pgsql/data  -l logfile start

Start the DBServer 

1
2
3
4
5
6
7
8
9
10
[pguser@rhel7 ~]$ postgres -D /usr/ local /pgsql/data >logfile 2>&1 &
[1] 13799
[pguser@rhel7 ~]$ ps -ef |grep postgre
pguser   13799  4377  0 12:37 pts/0    00:00:00 postgres -D /usr/ local /pgsql/data
pguser   13801 13799  0 12:37 ?        00:00:00 postgres: checkpointer process   
pguser   13802 13799  0 12:37 ?        00:00:00 postgres: writer process   
pguser   13803 13799  0 12:37 ?        00:00:00 postgres: wal writer process   
pguser   13804 13799  0 12:37 ?        00:00:00 postgres: autovacuum launcher process  
pguser   13805 13799  0 12:37 ?        00:00:00 postgres: stats collector process  
pguser   13807  4377  0 12:37 pts/0    00:00:00 grep  --color=auto postgre

连接测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[pguser@rhel7 ~]$ psql  --list
                                List  of  databases
    Name     | Owner  | Encoding |    Collate    |    Ctype    | Access  privileges 
-----------+--------+----------+-------------+-------------+-------------------
  postgres  | pguser | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
  template0 | pguser | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pguser        +
            |        |          |             |             | pguser=CTc/pguser
  template1 | pguser | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pguser        +
            |        |          |             |             | pguser=CTc/pguser
(3  rows )
 
[pguser@rhel7 ~]$ psql postgres
psql (9.6.1)
Type  "help"  for  help.
 
postgres=#  select  version();
                                                  version                                                 
---------------------------------------------------------------------------------------------------------
  PostgreSQL 9.6.1  on  x86_64-pc-linux-gnu, compiled  by  gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4), 64- bit
(1 row)
 
postgres=#  select  current_date ;
     date    
------------
  2016-12-01
(1 row)
 
postgres=# \q

官方文档:https://www.postgresql.org/docs/9.6/static/installation.html





     本文转自hbxztc 51CTO博客,原文链接:http://blog.51cto.com/hbxztc/1878425,如需转载请自行联系原作者


相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
7月前
|
SQL 关系型数据库 编译器
PostgreSQL 16源码安装
PostgreSQL 16源码编译,涵盖gcc、clang、pg jit
294 0
|
关系型数据库 Linux 数据库
|
关系型数据库 数据库 开发工具
PostgreSQL 10.0 源码安装
源码安装 tar zxvf postgresql-10.0.tar.gz mv postgresql-10.0 /usr/local/pgsql cd /usr/local/pgsql/ root用户下安装依赖包 yum -y install gcc gcc-c++ automake auto...
1676 0
|
JavaScript 关系型数据库 Linux
PostgreSQL 11源码安装
PostgreSQL 11源码安装 测试环境:RedHat 7.0 Linux 64bit PostgreSQL 11源码安装包下载地址link 系统环境准备 RedHat 7.0默认会安装相关系统包,还需要增加PostgreSQL编译时必须包,如下: gcc, bison, gcc-c++, r.
7470 0
|
关系型数据库 数据库 PostgreSQL
|
关系型数据库 数据库 PostgreSQL
|
运维 关系型数据库 数据库
PostgreSQL运维实战精讲之“postgresql源码安装”
一、下载地址 wget https://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.gz 二、安装: #安装依赖包 yum install -y perl-...
881 0
|
关系型数据库 PostgreSQL 数据库
|
9月前
|
SQL Cloud Native 关系型数据库
ADBPG(AnalyticDB for PostgreSQL)是阿里云提供的一种云原生的大数据分析型数据库
ADBPG(AnalyticDB for PostgreSQL)是阿里云提供的一种云原生的大数据分析型数据库
739 1