centos7系统下postgresql12离线安装
CentOS7系统下PostgreSQL 12离线安装手册
一、PostgreSQL基本信息
官网: https://www.postgresql.org/
下载: https://www.postgresql.org/download/
中文社区: http://www.postgres.cn/index.php/v2/home
中文网: https://postgres.fun/
二、安装规范
Cd / 找到根目录 创建文件夹 约定目录
PostgreSQL 目录安装位置:/usr/pgsql-12
PostgreSQL 数据库保存位置:/data/pgsql/data
PostgreSQL 日志保存位置:/data/pgsql/logs
PostgreSQL 安装包保存位置:/tools/rpm
三、系统及工具
1、系统版本 Centos7.5 CentOS-7-x86_64
2、PostgreSQL: postgresql12
3、辅助工具:SecureCRT、WinSCP、Navicat Premium;
四、安装配置
PostgreSQL数据库的安装方式采用rpm安装方式。
如果数据库服务器网络环境连接不到互联网上,则就需要采用离线安装方式,需要先下载相关的软件包和依赖包,采用手动离线安装的方式来安装。
4.1 关闭防火墙[执行1]
获取root权限:
[iaas@localhost ~]# sudo –s
关闭防火墙:
[root@localhost ~]# systemctl stop firewalld
取消开启防火墙:
[root@localhost ~]# systemctl disable firewalld
查看防火墙的状态
[root@localhost ~]# systemctl status firewalld
4.2 安装[执行2]
进入安装包存放路径
[root@localhost ~]# cd /tools/rpm/
安装依赖
[root@localhost ~]# yum -y install libicu
安装postgres类库
[root@localhost ~]# rpm -ivh postgresql12-libs-12.3-5PGDG.rhel7.x86_64.rpm
安装postgres客户端
[root@localhost ~]# rpm -ivh postgresql12-12.3-5PGDG.rhel7.x86_64.rpm
安装postgres服务端
[root@localhost ~]# rpm -ivh postgresql12-server-12.3-5PGDG.rhel7.x86_64.rpm
安装postgres扩展包
[root@localhost ~]# rpm -ivh postgresql12-contrib-12.3-5PGDG.rhel7.x86_64.rpm
4.3 创建目录 data、logs[执行3]
[root@localhost postgresql]# mkdir -p /data/pgsql/data
[root@localhost postgresql]# mkdir -p /data/pgsql/logs
[root@localhost postgresql]# ls /data/pgsql/
4.4 配置数据库系统环境[执行4]
[root@localhost ~]# vim /etc/profile
在最后写入如下内容(i插入文字, esc后:wq保存退出)
PGHOME=/usr/pgsql-12
export PGHOME
PGDATA=/data/pgsql/data
export PGDATA
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin
export PATH
使配置文件生效
[root@localhost ~]# source /etc/profile
4.5 增加用户 postgres 并赋权[执行4]
postgres用户的密码约定为:postgres
新建用户
[root@localhost ~]# adduser postgres
强制设置密码
[root@localhost ~]# passwd --stdin postgres
修改此用户postgres相关文件夹的归属
[root@localhost ~]# chown -R postgres:postgres /usr/pgsql-12
[root@localhost ~]# chown -R postgres:postgres /data/pgsql
赋予此用户postgres相关文件夹的权限
[root@localhost ~]# chmod -R 777 /usr/pgsql-12
[root@localhost ~]# chmod -R 777 /data/pgsql
4.6 初始化数据库[执行5]
切换用户 postgres
[root@localhost ~]# su postgres
转到postgres安装目录
[postgres@localhost ~]# cd /usr/pgsql-12/bin/
初始化数据库
[postgres@localhost ~]# initdb -D /data/pgsql/data
4.7 编辑配置文件[执行6]
[postgres@localhost ~]$ vim /data/pgsql/data/postgresql.conf
listen_addresses = '*'
port = 5432
[postgres@localhost ~]$ vim /data/pgsql/data/pg_hba.conf
host all all 0.0.0.0/0 trust
说明:
TYPE:pg的连接方式,local:本地unix套接字,host:tcp/ip连接
DATABASE:指定数据库
USER:指定数据库用户
ADDRESS:ip地址,可以定义某台主机或某个网段,32代表检查整个ip地址,相当于固定的ip,24代表只检查前三位,最后一位是0~255之间的任何一个。
METHOD:认证方式,常用的有ident,md5,password,trust,reject。
md5是常用的密码认证方式。
password是以明文密码传送给数据库,建议不要在生产环境中使用。
trust是只要知道数据库用户名就能登录,建议不要在生产环境中使用。
reject是拒绝认证。
4.8启动服务[执行7]
[postgres@localhost ~]$ cd /usr/pgsql-12/bin
[postgres@localhost ~]$ pg_ctl start -l /data/pgsql/logs/pg_server.log
4.14 查看版本[执行13]
[postgres@localhost ~]$ psql -V
psql (PostgreSQL) 12.2
五、登录数据库[执行14]
a) 通过pgsql命令行登录
[postgres@localhost ~]$ psql -U postgres -d postgres
b) 通过第三方工具连接,Navicat Premium
注意:生产环境,一定要修改密码验证方式
至此,Centos7 安装 PostgreSQL 安装部署完毕!
centos7系统下postgresql12离线安装相关推荐
- centos7php自启动,centos7系统下nginx安装并配置开机自启动操作
这篇文章主要介绍了centos7系统下nginx安装并配置开机自启动操作方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下 这篇文章主要介绍了centos7系统下nginx安装并配置开机自启动操作 ...
- Linux下Centos7以rpm方式离线安装MySQL5.7教程以及部分报错解决方案
Linux下Centos7以rpm方式离线安装MySQL5.7教程以及部分报错解决方案 参考文章: (1)Linux下Centos7以rpm方式离线安装MySQL5.7教程以及部分报错解决方案 (2) ...
- Centos7系统下httpd各种方式实现与配置
1. Centos7系统下实现httpd-2.2的安装,并分别实现prefork.worker.event等几种工作方式 Centos 7上若yum安装httpd程序,默认的是2.4的版本,因此无法用 ...
- suse linux 软件包安装,SUSE Linux 11系统rpm包离线安装GCC
SUSE Linux 11系统rpm包离线安装GCC 1.问题显示 编译失败 python2.6环境下编译pycrypto-2.6.1 src/hash_template.c:360: warning ...
- linux环境怎么更新离线rpm包,SUSE Linux 11系统rpm包离线安装GCC
SUSE Linux 11系统rpm包离线安装GCC 1.问题显示 编译失败 python2.6环境下编译pycrypto-2.6.1 src/hash_template.c:360: warning ...
- MinGW-w64在windows下的离线安装
MinGW-w64在windows下的离线安装 如需转载请标明出处:http://blog.csdn.net/itas109 QQ技术交流群:129518033 文章目录 MinGW-w64在wind ...
- linux suse11安装包,SUSE Linux 11系统rpm包离线安装GCC
SUSE Linux 11系统rpm包离线安装GCC 1.问题显示 编译失败 python2.6环境下编译pycrypto-2.6.1 src/hash_template.c:360: warning ...
- centos7系统下使用vimplus配置vim的C++环境
centos7系统下使用vimplus配置vim的C++环境 开源项目请参考:https://gitee.com/chxuan/vimplus 配置好的界面如下: 1. 准备工作: ubuntu 或者 ...
- linux的软件包是独立的,Linux系统下软件包的安装
(以下内容是云课堂Linux课程的笔记,个人纯手工记录,课程以RedHat系列为主) Linux系统下软件包的安装方式包括:源代码安装.本地二进制包安装(rpm命令手工安装).在线二进制包安装(yum ...
- linux系统下源码安装mysql5.6数据库
linux系统下源码安装mysql5.6数据库 下载mysql数据库相关软件包(百度云盘:http://pan.baidu.com/s/1bnL31c7) 从mysql 5.5版本开始,mysql源码 ...
最新文章
- IE8不能正常登录网上银行的解决方法
- Python做数据分析时中文乱码?matplotlib出现中文乱码3行代码解决
- 计算机网络实验(思科模拟器Cisco Packet Tracer)——路由器配置
- java创建读取文件_Java实现文件的创建、读取、写入操作-Fun言
- 前端界面请假管理java_小程序新请假界面
- 大家社区荣获最具影响力品牌
- 绘制神经网络工具汇总(重要)
- 算法实例(2)_遗传算法
- 腾讯云直播开发日记 (二)附近直播-直播礼物-直播回放
- python 编程 安卓脚本_详解基于Android的Appium+Python自动化脚本编写
- 所有程序员都应该知道的 6 个软件开发步骤
- index 0 is out of bounds for axis 0 with size 0
- 陕西计算机中考考试,2018年陕西省中考考试时间及科目安排公布
- 将windows 8安装到U盘随身带!
- 想想搭建个域控文件打印机服务器
- FPGA电子设计系统的资源优化(面积优化)与速度优化
- CMake引入三方库
- 关于滑动时对背景动态高斯模糊的自定义控件
- 如何一键远程开机,远程唤醒功能
- clr(clr a是什么指令)