PostgreSQL 9.6.1源码安装
admin
2023-05-30 04:21:35
0

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)

[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 

[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

连接测试

[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

相关内容

热门资讯

我国首座抗17级台风高技术难度... 本文转自【新华网】; 新华社北京8月6日电(记者王悦阳、梁姊)中国海油8月6日宣布,我国自主设计建造...
山西省灵丘县科技馆里“热度”飙... 央广网大同8月6日消息(记者张洁 通讯员马明清)8月5日,山西省大同市灵丘县科技馆展厅内人头攒动、氛...
校地协同 聚力科研攻关 8月3日,在市沙漠综合治理中心主任张雁平的陪同下,青岛农业大学教授刘建龙、内蒙古自治区林科院研究员杨...
唐波、崔洪芝获颁2025年度山... 8月6日下午,全省科技大会在济南召开。会上,宣读《中共山东省委山东省人民政府关于2025年度山东省科...
台风“白海豚”逐渐逼近华东沿海... 据中央气象台消息,今年第13号台风“白海豚”的中心8月6日14时位于距离浙江省温州市偏东方向约120...
阿联酋、土耳其、沙特等8国外长... 【环球网报道 记者 索炎琦】据《以色列时报》等媒体报道,阿联酋、卡塔尔、约旦、印度尼西亚、巴基斯坦、...
字节CEO梁汝波承认大语言模型... 8月6日,字节跳动召开2026年度年中全员会,公司CEO梁汝波、新成立的“创造力服务平台”(Crea...
知名经济学家、教育家、出版人高... 澎湃新闻记者 蒋子文 岳怀让据台湾《远见》杂志网站消息,知名经济学家、教育家、出版人,远见‧天下文化...
“女生洗澡,大叔帮搓背”,苏泊... 国民级厨房小家电品牌苏泊尔,最近因几段AI生成的短视频,被指内容低俗,引发关注。而就在不久前,苏泊尔...
网红,被罚10万欧元? 在法国,一个中等收入消费者,打开手机上的跨境电商平台,花几欧元就能买到一件不错的T恤,而同样的产品在...