CentOS 7 源码编译安装 PostgreSQL 11.2

本文涉及的产品
云原生数据库 PolarDB MySQL 版,通用型 2核4GB 50GB
云原生数据库 PolarDB PostgreSQL 版,标准版 2核4GB 50GB
简介: CentOS 7 源码编译安装 PostgreSQL 11.2

环境

系统版本 Centos7.6


工具:xshell6


PostgreSql: postgresql-11.2.tar.gz


安装部署

安装前准备

官网下载PostgreSQL 11.2源码地址:https://www.postgresql.org/ftp/source/v11.2/


选择postgresql-11.2.tar.gz

image.png

编译安装

tar -zxvf postgresql-11.2.tar.gz
cd postgresql-11.2
./configure --prefix=/usr/local/postgresql --without-readline
make && make install

进入安装后的目录,查看目录结构

cd /usr/local/postgresql/

image.png

安装服务器端包

yum -y install postgresql11

创建目录 data、log

mkdir /usr/local/postgresql/data
mkdir /usr/local/postgresql/log
chmod -R 775 /usr/local/postgresql/data

配置环境变量

vim /etc/profile

PGHOME=/usr/local/postgresql
export PGHOME
PGDATA=/usr/local/postgresql/data
export PGDATA
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin
export PATHPGHOME=/usr/local/postgresql
export PGHOME
PGDATA=/usr/local/postgresql/data
export PGDATA
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin
export PATH

使配置文件生效

source /etc/profile

创建用户

useradd postgres

将pg的数据目录全部赋给postgres用户,执行以下命令:

chown -R postgres:postgres /usr/local/postgresql/

初始化数据库

切换到postgres用户,执行如下命令:

su - postgres
/usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data/su - postgres
/usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data/

image.png

启动数据库

/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data/ -l logfile start

查看数据库版本

psql -V

psql (PostgreSQL) 11.2

 

连接数据库

psql -U postgres -d postgres

配置文件

目录/usr/local/postgresql/data/下,pg_hba.conf和postgresql.conf两个文件。

vi /usr/local/postgresql/data/pg_hba.conf

image.png

vi /usr/local/postgresql/data/postgresql.conf

修改listen_addresses = ‘*’;

image.png

登录数据库

psql -U postgres -d postgres

image.png

设置防火墙规则

firewall-cmd --zone=public --add-port=8432/tcp --permanent
firewall-cmd --reload

初始化 database

/usr/pgsql-11/bin/postgresql-11-setup initdb

重启数据库

systemctl restart postgresql-11

设置开机启动

自动启动
systemctl enable postgresql-11.service
启动
systemctl start postgresql-11.service
停止某服务
systemctl stop postgresql-11.service
不自动启动
systemctl disable postgresql-11.service
检查服务状态(服务详细信息)
systemctl status postgresql-11.service
检查服务状态(仅显示是否Active)
systemctl is-active postgresql-11.service
显示所有已启动的服务
systemctl list-units --type=service



相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
22天前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
20天前
|
弹性计算 关系型数据库 MySQL
centos7 mysql安装及配置
本文详细介绍了在阿里云服务器ECS上通过yum源安装MySQL 8.0.12的过程,包括更新yum源、下载并安装MySQL源、解决安装过程中可能遇到的问题等步骤。此外,还介绍了如何启动MySQL服务、设置开机自启、配置登录密码、添加远程登录用户以及处理远程连接异常等问题。适合初学者参考,帮助快速搭建MySQL环境。
107 8
centos7 mysql安装及配置
|
17天前
|
存储 Linux Docker
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
关于如何在CentOS 7.6上安装Docker、介绍Docker存储引擎以及服务进程关系的实战案例。
62 3
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
|
22天前
|
Linux 开发工具 C语言
centos7编译安装python3
centos7编译安装python3
|
22天前
|
分布式计算 资源调度 Hadoop
centos7二进制安装Hadoop3
centos7二进制安装Hadoop3
|
22天前
|
分布式计算 Java Hadoop
centos7编译安装Hadoop3
centos7编译安装Hadoop3
|
25天前
|
缓存 运维 Linux
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
|
22天前
|
Linux Python
Centos7安装Python虚拟环境之virtualenv
Centos7安装Python虚拟环境之virtualenv
|
22天前
|
存储 缓存 Linux
LDAP学习笔记之一:Centos7安装389-DS(RHDS)
LDAP学习笔记之一:Centos7安装389-DS(RHDS)
|
23天前
|
前端开发 小程序 Unix
Centos安装前端开发常用软件
Centos安装前端开发常用软件