ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

centos7下安装postgresql13

2021-07-31 01:02:07  阅读:341  来源: 互联网

标签:00 postgresql postgres postgresql13 centos7 64 安装 x86


PostgreSQL13

install

本机环境

[root@sonarqube02 ~]# cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[root@sonarqube02 ~]# cat /proc/version 
Linux version 3.10.0-1127.19.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Aug 25 17:23:54 UTC 2020

1.通过清华大学源yum安装

Index of /postgresql/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

1.创建repo文件

[root@sonarqube02 ~]# cat /etc/yum.repos.d/postgresql.repo 
[postgresql]
name=postgresql
baseurl=https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/13/redhat/rhel-7-x86_64/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/RPM-GPG-KEY-PGDG-13

报错1:

Downloading packages:
warning: /var/cache/yum/x86_64/7/postgresql/packages/postgresql13-libs-13.3-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY


Public key for postgresql13-libs-13.3-1PGDG.rhel7.x86_64.rpm is not installed

解决1:

指定gpgkey即可

gpgkey=https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/RPM-GPG-KEY-PGDG-13

2.安装postgresql13-server

[root@sonarqube02 ~]# yum list|grep postgresql13
postgresql13.x86_64                        13.3-1PGDG.rhel7           @postgresql
postgresql13-libs.x86_64                   13.3-1PGDG.rhel7           @postgresql
postgresql13-server.x86_64                 13.3-1PGDG.rhel7           @postgresql
postgresql13-contrib.x86_64                13.3-1PGDG.rhel7           postgresql
postgresql13-devel.x86_64                  13.3-1PGDG.rhel7           postgresql
postgresql13-docs.x86_64                   13.3-1PGDG.rhel7           postgresql
postgresql13-llvmjit.x86_64                13.3-1PGDG.rhel7           postgresql
postgresql13-odbc.x86_64                   13.00.0000-1PGDG.rhel7     postgresql
postgresql13-plperl.x86_64                 13.3-1PGDG.rhel7           postgresql
postgresql13-plpython3.x86_64              13.3-1PGDG.rhel7           postgresql
postgresql13-pltcl.x86_64                  13.3-1PGDG.rhel7           postgresql
postgresql13-test.x86_64                   13.3-1PGDG.rhel7           postgresql

yum makecache
yum -y install postgresql13-server.x86_64

3.启动服务

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

systemctl enable postgresql-13
systemctl start postgresql-13

4.验证

[root@sonarqube02 ~]# ps -ef|grep postgres
postgres   2384      1  0 Jul30 ?        00:00:00 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
postgres   2386   2384  0 Jul30 ?        00:00:00 postgres: logger 
postgres   2388   2384  0 Jul30 ?        00:00:00 postgres: checkpointer 
postgres   2389   2384  0 Jul30 ?        00:00:00 postgres: background writer 
postgres   2390   2384  0 Jul30 ?        00:00:00 postgres: walwriter 
postgres   2391   2384  0 Jul30 ?        00:00:00 postgres: autovacuum launcher 
postgres   2392   2384  0 Jul30 ?        00:00:00 postgres: stats collector 
postgres   2393   2384  0 Jul30 ?        00:00:00 postgres: logical replication launcher 

 

2.通过官方二进制包安装

PostgreSQL: Linux downloads (Red Hat family)

1.选择安装包版本

2.Copy, paste and run the relevant parts of the setup script:

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
sudo yum install -y postgresql13-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13

test

安装完毕后,系统会创建一个数据库超级用户 postgres,密码为空

1.切换用户

[root@sonarqube02 ~]# cat /etc/passwd|grep postgres
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash

[root@sonarqube02 ~]# sudo -iu postgres
-bash-4.2$ 

[root@sonarqube02 ~]# sudo --help

sudo - execute a command as another user

Options:

-i, --login run login shell as the target user; a command may also be specified

-u, --user=user run command (or edit file) as specified user name or ID

2.这时使用以下命令进入 postgres,输出以下信息,说明安装成功:

-bash-4.2$ psql 
psql (13.3)
Type "help" for help.

postgres=# 

3.输入以下命令退出 PostgreSQL 提示符:

postgres=# \q

-bash-4.2$ exit
logout
[root@sonarqube02 ~]# 

 

标签:00,postgresql,postgres,postgresql13,centos7,64,安装,x86
来源: https://www.cnblogs.com/omgasw/p/15083049.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有