CentOS 到了7.x版本, PostgreSQL也来到了10.x版本. 前些天MySQL都直接跨到了8.0版本.

本文是一篇在CentOS 7.4上安装安装PostgreSQL 10.3 的教程. 本文发布于2018-04-28.

1. 切换到root用户:
sudo su
2. 把最新的rpm包添加到系统库:

PostgreSQL会为所有的Linux平台发布rpm包, 而且会比其他的的库更新的更快.
可以试试在浏览器输入 https://download.postgresql.org/pub 看会发现什么.

### CentOS 7 ###

# rpm -Uvh https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

### RHEL 7 ###

# rpm -Uvh https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm
3. 用 yum 安装PostgreSQL:
# yum install -y postgresql10-server postgresql10
4. 安装完成后, 初次使用前先进行初始化:
# /usr/pgsql-10/bin/postgresql-10-setup initdb

PostgreSQL文件默认放在路径: /var/lib/pgsql/10/data/

5. 启动PostgreSQL:
# systemctl start postgresql-10
6. 设置PostgreSQL自启动:
# systemctl enable postgresql-10
7. 查询PostgreSQL运行状态:
# systemctl status postgresql-10

会输出类似的信息:

● postgresql-10.service - PostgreSQL 10 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-10.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-04-27 18:03:08 CST; 21h ago
Docs: https://www.postgresql.org/docs/10/static/
Main PID: 14916 (postmaster)
CGroup: /system.slice/postgresql-10.service
├─14916 /usr/pgsql-10/bin/postmaster -D /var/lib/pgsql/10/data/
├─14920 postgres: logger process
├─14922 postgres: checkpointer process
├─14923 postgres: writer process
├─14924 postgres: wal writer process
├─14925 postgres: autovacuum launcher process
├─14926 postgres: stats collector process
└─14927 postgres: bgworker: logical replication launcher Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ systemd[1]: Starting PostgreSQL 10 database server...
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.762 CST [14916] LOG: listening on IPv4 address "127.0.0.1...t 5432
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.762 CST [14916] LOG: could not bind IPv6 address "::1": C...ddress
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.762 CST [14916] HINT: Is another postmaster already runni...retry.
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.764 CST [14916] LOG: listening on Unix socket "/var/run/p....5432"
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.767 CST [14916] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.777 CST [14916] LOG: redirecting log output to logging co...rocess
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.777 CST [14916] HINT: Future log output will appear in di..."log".
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ systemd[1]: Started PostgreSQL 10 database server.
Hint: Some lines were ellipsized, use -l to show in full.

8. 再确认看看PostgreSQL是否运行在5432端口:

# netstat -antup | grep 5432

会有类似输出:

tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      14916/postmaster
9. 连接PostgreSQL服务器:

PostgreSQL会自动创建postgres用户, 创建数据库之前, 要用postgres用户或root用户登录并重置postgres用户密码.

# su -l postgres
10. 连接数据库, psql命令会激活PostgreSQL数据库终端:
$ psql

会输出下列说明连接进入了PostgreSQL数据库:

psql (10.3)
Type "help" for help. postgres=#
11. 重置postgres用户密码:
postgres=# \password

密码:postgresql

在CentOS 7 / RHEL 7安装PostgreSQL 10的更多相关文章

  1. 在 CentOS 7.2 上安装 ODOO 10 (2018-10-09 持续更新)

    在 CentOS 7.2 上安装 ODOO 10 更新系统 yum update 安装 EPEL 源 1 yum install -y epel-release 安装依赖组件 yum install ...

  2. 在CentOS或RHEL上安装Nux Dextop仓库

    介绍 Nux Dextop是类似CentOS.RHEL.ScientificLinux的第三方RPM仓库(比如:Ardour,Shutter等等).目前,Nux Dextop对CentOS/RHEL ...

  3. centos 6.4下安装postgresql 9.2

    我的linux版本是centos 6.4 ,准备安装postgresql 9.2 根据官方说明: http://www.postgresql.org/download/linux/redhat/ 缺省 ...

  4. CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境

    准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...

  5. CentOS 7.4 如何安装 MariaDB 10.3.9 Stable 数据库

    CentOS 7.4 如何安装 MariaDB 10.3.9 Stable 数据库 一.CentOS 7.4上卸载 Mariadb 数据库 1.查询所安装的MariaDB组件 [libin@VM_0_ ...

  6. CentOS 7.4 下面安装 jdk 10 的一点总结

    CentOS 7.4 下面安装 jdk 10 的一点总结 一.前期工作 1.检验系统原版本 [root@zck ~]# java -version java version "1.7.0_& ...

  7. Ubuntu下编译安装postgreSQL 10.5

    Ubuntu下编译安装postgreSQL 10.5 ubuntu 16.04 LTS系统postgreSQL 10.5 安装包准备 1.从PostgreSQL官网下载PostgreSQL的安装包 安 ...

  8. CentOS 7 64位 安装 PostgreSQL 9.2整理

    centos版本 LSB Version: :core-4.1-amd64:core-4.1-noarchDistributor ID: CentOSDescription: CentOS Linux ...

  9. CentOS 6.9下安装PostgreSQL

    操作系统:CentOS6.9_x64 PostgreSQL官方网址: https://www.postgresql.org/ 安装数据库 使用如下命令: yum install postgresql- ...

随机推荐

  1. Spring Cloud学习(一):Eureka服务注册与发现

    1.Eureka是什么 Eureka是Netflix开发的服务发现框架,本身是一个基于REST的服务,主要用于定位运行在AWS域中的中间层服务,以达到负载均衡和中间层服务故障转移的目的. Eureka ...

  2. 个人永久性免费-Excel催化剂功能第46波-区域集合函数,超乎所求所想

    在常规自定义函数的世界中,一般情况下,仅会输入一堆的参数,最终输出一个结果值,在以往Excel催化剂的自定义函数,已经大量出现输入一堆参数返回多个结果值并自动输出到多个单元格区域内.此项技术可运用的场 ...

  3. 艺赛旗RPA-处理无表头表格

    今天写一个demo,要求是对表格数据用价格为key进行排序 样本数据有两种格式: 一.第一行是一个大单元格 处理步骤: 在不变参数的情况下读取表格数据: 结果如下: 可以看见表头: Unnamed: ...

  4. Python学习3——Python的简单推导

    列表推导是一种从其他列表创建列表的方式,类似于数学中的集合推导,列表推导的工作原理非常简单,类似于for循环.(以下代码均在IDLE实现) 最简单的列表推导: >>>[x*x for ...

  5. 描述符\get/set/delete,init/new/call,元类

    6.23 自我总结 1.描述符__get__,__set__,__delete__ 描述符是什么:描述符本质就是一个新式类,在这个新式类中,至少实现了____get__(),__set__(),__d ...

  6. 2017day2

    系统模块: # Author: sonny# -*- coding:utf-8 -*-import sys; #print(sys.path);print(sys.argv);print(sys.ar ...

  7. Linux系统安装jdk——.tar.gz版

    1.rpm.deb.tar.gz的区别: rpm格式的软件包适用于基于Red Hat发行版的系统,例如Red Hat Linux.SUSE.Fedora. deb格式的软件包则是适用于基于Debian ...

  8. 探究netty的观察者设计模式

    javadoc笔记点 观察者的核心思想就是,在适当的时机回调观察者的指定动作函数 我们知道,在使用netty创建channel时,一般都是把这个channel设置成非阻塞的模式,这意味着什么呢? 意味 ...

  9. vue教程(一)-html使用vue

    前后端分离.微服务框架是当下比较流行的词汇,而vue就是前端框架的佼佼者.下面重点介绍一下vue的用法: vue起步:1.引包    2.启动new Vue({el:目的地,template:模板内容 ...

  10. @GetMapping、@PostMapping和@RequestMapping的区别

    @GetMapping 用于将Http Get 请求映射到特定处理程序方法的注释.具体来说就是:@GetMapping是一个作为快捷方式的组合注释 @RequestMapping(method = R ...