在CentOS 7 / RHEL 7安装PostgreSQL 10

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

原文地址:https://www.cnblogs.com/Paul-watermelon/p/10401015.html

时间: 2024-08-29 09:37:47

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

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

在 CentOS 7.2 上安装 ODOO 10 更新系统 yum update 安装 EPEL 源 1 yum install -y epel-release 安装依赖组件 yum install fontconfig libpng libX11 libXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi wkhtmltopdf yum-utils 安装 PostgreSQL Server # 安装 yum install post

centos和redhat下安装postgreSQL

1.确定你要下载的版本:下载地址 2.进入你存放下载文件的目录运行wget http://yum.postgresql.org/9.2/redhat/rhel-5-i386/pgdg-centos92-9.2-6.noarch.rpm,我的是32bit的centos5,其他版本可以在上面的路径中找到相关的链接 3.运行命令 rpm -ivh pgdg-centos92-9.2-6.noarch.rpm 安装 4.运行命令 yum install postgresql92-server 安装ser

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.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2.安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/iptables #编辑

CentOS 7 64位 安装 PostgreSQL 9.2整理

centos版本 LSB Version: :core-4.1-amd64:core-4.1-noarchDistributor ID: CentOSDescription: CentOS Linux release 7.0.1406 (Core)Release: 7.0.1406Codename: Core 注意:centos用yum安装postgresql的 数据库程序路径为:/usr/pgsql-9.2 数据库存储文件路径为: /var/lib/pgsql/ 1.运行:yum instal

CentOS 6.9下安装PostgreSQL

操作系统:CentOS6.9_x64 安装数据库 使用如下命令: yum install postgresql-server -y 设置开机启动: chkconfig postgresql on 启动数据库: service postgresql start 安装后,默认生成一个名为postgres的数据库和一个名为postgres的数据库用户.这里需要注意的是,同时还生成了一个名为postgres的Linux系统用户. 配置数据库 初始化数据库 service postgresql initd

CentOS或RHEL使用安装光盘镜像制作本地yum源

平时自己在家学习的时候,有时候会用到一些虚拟机环境.最初安装的时候为了节省本地的磁盘空间,选择最小安装模式,后期使用的时候,如果用到什么其他的软件包,再去另外安装.但是使用网络上的yum源,可能会因为种种原因,不能访问,或者速度收到限制,影响效率,因此我们可以使用安装OS时使用的光盘镜像,来搭建一个本地yum源. 方法如下: 1. 在虚拟机设置中,挂载光盘镜像文件: 2. 使用下面的方法配置: # mount /dev/cdrom /mnt # cd /etc/yum.repos.d/ # ta

centos 下源码安装postgresql 9.4

[[email protected] ~]# cd /home [[email protected] home]# ls postgresql-9.4.1.tar  test [[email protected] home]# tar xf postgresql-9.4.1.tar  [[email protected] home]# cd postgresql-9.4.1 [[email protected] postgresql-9.4.1]# lsaclocal.m4  config  c

Redhat 7.2 编译安装PostgreSQL 10

1.环境说明 CentOS7.2 postgresql10.4 2.下载 postgresql的官方地址 https://www.postgresql.org/ftp/source/ 在下载列表中根据需求选择版本10.4,如下图: 进入子目录后,可以看到文件列表: 选择postgresql-10.4.tar.gz,下载完成后上传至RedHat服务器的指定目录即可. 3.配置编译安装 tar -zxvf postgresql-10.4.tar.gz cd postgresql-10.4 ./con

Linux CentOS 7 安装PostgreSQL 9.3(发行版本)

前言 如题,本篇blog记录一下在Linux CentOS 7中安装PostgresSQL的整个过程以及数据库配置等,在Linux系统中,PostgreSQL的安装方式分两种,分别是: 二进制安装包安装 源码编译安装 由于我们没有什么特殊需求所在在此选择较为简单的方式--二进制安装包安装,二进制包安装的方法一般都是通过不同发行版本的Linux下的包管理器进行的,例如Debian和Ubuntu下是使用apt-get命令或aptitude命令来安装,命令如下: sudo apt-get instal