广告
返回顶部
首页 > 资讯 > 操作系统 >Linux上怎么安装PostgreSQL
  • 500
分享到

Linux上怎么安装PostgreSQL

2024-04-02 19:04:59 500人浏览 泡泡鱼
摘要

本篇内容主要讲解“linux上怎么安装postgresql”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux上怎么安装Postgresql”吧!环境此处是

本篇内容主要讲解“linux上怎么安装postgresql”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux上怎么安装Postgresql”吧!

环境

此处是从头学PG,为了适应两年后趋势,所以我选择的都是最新的版本

  • Redhat 7.8

  • PostgreSQL 12.2 源码

下载

  1. 打开 PostgreSQL 官网 https://www.postgresql.org/,点击菜单栏上的 Download。

  2. 可以根据需要点击自己所需要的的版本,此处为了更好的学习PG,不落后其他大咖,我选择下载最新版本的源码

    Linux上怎么安装PostgreSQL

安装

  1. 上传并解压

      [root@node1 soft]# bzip2 -d postgresql-12.2.tar.bz2 
       [root@node1 soft]# tar -xvf postgresql-12.2.tar
       postgresql-12.2/
       postgresql-12.2/.dir-locals.el
       postgresql-12.2/contrib/
       postgresql-12.2/contrib/tcn/
       postgresql-12.2/contrib/tcn/tcn.control
       ... ...(省略输出)
       [root@node1 soft]# ls -lrt 
       total 131200
       drwxrwxrwx 6 1107 1107       273 Feb 10 17:29 postgresql-12.2
       -rw-r--r-- 1 root root 134348800 Apr 30 05:29 postgresql-12.2.ta
  2. 安装 yum 包

    yum -y install readline-devel
    yum -y install readline

    避免 ./configure 时报错
    Linux上怎么安装PostgreSQL

  3. configure

    [root@node1 postgresql-12.2]# ./configure 
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking which template to use... linux
    checking whether NLS is wanted... no
    checking for default port number... 5432
    checking for block size... 8kB
    ... ...(省略输出)
    checking for fop... no
    checking thread safety of required library functions... yes
    checking whether GCc -std=gnu99 supports -Wl,--as-needed... yes
    configure: using compiler=gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
    configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-fORMat-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2
    configure: using CPPFLAGS= -D_GNU_SOURCE 
    configure: using LDFLAGS=  -Wl,--as-needed
    configure: creating ./config.status
    config.status: creating GNUmakefile
    config.status: creating src/Makefile.global
    config.status: creating src/include/pg_config.h
    config.status: creating src/include/pg_config_ext.h
    config.status: creating src/interfaces/ecpg/include/ecpg_config.h
    config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
    config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
    config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
    config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
    config.status: linking src/makefiles/Makefile.linux to src/Makefile.por
  4. make && make install

    [root@node1 postgresql-12.2]# make
    make -C ./src/backend generated-headers
    make[1]: Entering directory `/soft/postgresql-12.2/src/backend'
    make -C catalog distprep generated-header-symlinks
    make[2]: Entering directory `/soft/postgresql-12.2/src/backend/catalog'
    ... ...(省略输出)
    make[2]: Nothing to be done for `all'.
    make[2]: Leaving directory `/soft/postgresql-12.2/src/test/perl'
    make[1]: Leaving directory `/soft/postgresql-12.2/src'
    make -C config all
    make[1]: Entering directory `/soft/postgresql-12.2/config'
    make[1]: Nothing to be done for `all'.
    make[1]: Leaving directory `/soft/postgresql-12.2/config'
    All of PostgreSQL successfully made. Ready to install.
    [root@node1 postgresql-12.2]# make install
    make -C ./src/backend generated-headers
    make[1]: Entering directory `/soft/postgresql-12.2/src/backend'
    make -C catalog distprep generated-header-symlinks
    make[2]: Entering directory `/soft/postgresql-12.2/src/backend/catalog'
    make[2]: Nothing to be done for `distprep'.
    make[2]: Nothing to be done for `generated-header-symlinks'.
    ... ...(省略输出)
    make -C config install
    make[1]: Entering directory `/soft/postgresql-12.2/config'
    /usr/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/config'
    /usr/bin/install -c -m 755 ./install-sh '/usr/local/pgsql/lib/pgxs/config/install-sh'
    /usr/bin/install -c -m 755 ./missing '/usr/local/pgsql/lib/pgxs/config/missing'
    make[1]: Leaving directory `/soft/postgresql-12.2/config'
    PostgreSQL installation complete
  5. 创建用户并配置密码

    [root@node1 postgresql-12.2]# useradd postgres
    [root@node1 postgresql-12.2]# passwd postgres
    Changing passWord for user postgres.
    New password: 
    BAD PASSWORD: The password contains the user name in some form
    Retype new password: 
    passwd: all authentication tokens updated successfully
  6. 创建数据目录并授权

    [root@node1 postgresql-12.2]# mkdir -p /data/pg_data
    [root@node1 postgresql-12.2]# chown postgres:postgres -R /data
    [root@node1 postgresql-12.2]# cd /usr/local
    [root@node1 local]# ll
    total 0
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 bin
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 etc
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 games
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 include
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 lib
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 lib64
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 libexec
    drwxr-xr-x  6 postgres postgres 56 Apr 30 05:53 pgsql
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 sbin
    drwxr-xr-x. 5 root     root     49 Apr 16 12:09 share
    drwxr-xr-x. 2 root     root      6 Dec 14  2017 src
    [root@node1 local]# chown postgres:postgres -R pgsq
  7. 配置 postgres 用户

    [postgres@node1 ~]$ cat .bash_profile 
    export PATH=$PATH:/usr/local/pgsql/bin
    export PGDATA=/data/pg_data
    [postgres@node1 ~]$ source .bash_profile
  8. 初始化数据库

    [postgres@node1 ~]$ initdb -D /data/pg_data/
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    The database cluster will be initialized with locale "en_US.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    The default text search configuration will be set to "english".
    Data page checksums are disabled.
    fixing permissions on existing directory /data/pg_data ... ok
    creating subdirectories ... ok
    selecting dynamic shared memory implementation ... posix
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting default time zone ... America/New_York
    creating configuration files ... ok
    running bootstrap script ... ok
    performing post-bootstrap initialization ... ok
    syncing data to disk ... ok
    initdb: warning: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    Success. You can now start the database server using:
        pg_ctl -D /data/pg_data/ -l logfile star
  9. 启动数据库

    [postgres@node1 ~]$ pg_ctl -D /data/pg_data/ start
    waiting for server to start....2020-04-30 06:34:29.841 EDT [53149] LOG:  starting PostgreSQL 12.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
    2020-04-30 06:34:29.841 EDT [53149] LOG:  listening on IPv6 address "::1", port 5432
    2020-04-30 06:34:29.841 EDT [53149] LOG:  listening on IPv4 address "127.0.0.1", port 5432
    2020-04-30 06:34:29.844 EDT [53149] LOG:  listening on Unix Socket "/tmp/.s.PGSQL.5432"
    2020-04-30 06:34:29.856 EDT [53150] LOG:  database system was shut down at 2020-04-30 06:29:52 EDT
    2020-04-30 06:34:29.858 EDT [53149] LOG:  database system is ready to accept connections
     done
    server starte
  10. 关闭数据库

    [postgres@node1 ~]$ pg_ctl -D /data/pg_data/ stop
    waiting for server to shut down....2020-04-30 06:35:27.573 EDT [53149] LOG:  received fast shutdown request
    2020-04-30 06:35:27.574 EDT [53149] LOG:  aborting any active transactions
    2020-04-30 06:35:27.574 EDT [53149] LOG:  background worker "logical replication launcher" (PID 53156) exited with exit code 1
    2020-04-30 06:35:27.575 EDT [53151] LOG:  shutting down
    2020-04-30 06:35:27.584 EDT [53149] LOG:  database system is shut down
     done
    server stopped

到此,相信大家对“Linux上怎么安装PostgreSQL”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

--结束END--

本文标题: Linux上怎么安装PostgreSQL

本文链接: https://www.lsjlt.com/news/62934.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Linux上怎么安装PostgreSQL
    本篇内容主要讲解“Linux上怎么安装PostgreSQL”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux上怎么安装PostgreSQL”吧!环境此处是...
    99+
    2022-10-18
  • Linux 上安装 PostgreSQL
    打开 PostgreSQL 官网 https://www.postgresql.org/,点击菜单栏上的 Download ,可以看到这里包含了很多平台的安装包,包括 Linux、Windows、Mac OS等 。 Linux 我们可以看到...
    99+
    2021-01-01
    Linux 上安装 PostgreSQL 数据库入门 数据库基础教程 数据库 mysql
  • 在Linux上如何安装PostgreSQL
    这篇文章主要介绍了在Linux上如何安装PostgreSQL,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。PostgreSQL 的官方下载地址为:ftp://ftp.post...
    99+
    2023-06-13
  • 怎么在Linux系统上安装PostgreSQL数据库
    这篇文章主要讲解了“怎么在Linux系统上安装PostgreSQL数据库”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么在Linux系统上安装PostgreSQL数据库”吧!一、准备工作这...
    99+
    2023-06-29
  • Linux系统怎么安装postgresql
    这篇文章主要介绍了Linux系统怎么安装postgresql的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Linux系统怎么安装postgresql文章都会有所收获,下面我们一起来看看吧。PostgreSQL是...
    99+
    2023-06-28
  • macos上安装 Postgresql
    一、安装环境 主机:MacOS Monterey 版本 12.3(Arm) 数据库版本:postgresql-14.5-1-osx.dmg 二、下载位置 https://www.enterprised...
    99+
    2023-09-13
    postgresql macos 数据库
  • 在Linux系统上安装PostgreSQL数据库
    目录一、准备工作二、安装PostgreSQL2.1、选择版本2.2、安装yum源2.3、安装PostgreSQL三、设置PostgreSQL3.1、初始化数据库3.2、设置数据库自启...
    99+
    2022-11-13
  • 怎么在Ubuntu上安装和配置PostgreSQL
    这篇文章主要为大家展示了“怎么在Ubuntu上安装和配置PostgreSQL”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“怎么在Ubuntu上安装和配置PostgreSQL”这篇文章吧。Post...
    99+
    2023-06-16
  • linux上怎么安装jdk1.6
    在Linux上安装JDK 1.6的步骤如下:1. 打开终端。2. 下载JDK 1.6的安装包。你可以在Oracle官方网站上下载适用...
    99+
    2023-08-23
    linux jdk
  • Linux上怎么安装Zookeeper
    本篇内容介绍了“Linux上怎么安装Zookeeper”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!环境:VMware® Workstati...
    99+
    2023-06-19
  • Linux上怎么安装MongoDB
    本篇内容介绍了“Linux上怎么安装MongoDB”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!环境:CentOS 7MongoDB 3.4...
    99+
    2023-06-19
  • Linux上怎么安装Redis
    这篇文章主要介绍“Linux上怎么安装Redis”,在日常操作中,相信很多人在Linux上怎么安装Redis问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux上怎么安装Redis”的疑惑有所帮助!接下来...
    99+
    2023-06-19
  • Linux上怎么安装Node.js
    本篇内容主要讲解“Linux上怎么安装Node.js”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux上怎么安装Node.js”吧!安装环境本机系统:CentOS Linux releas...
    99+
    2023-06-28
  • linux上怎么安装nodejs
    在Linux上安装Node.js,可以通过以下步骤进行:1. 打开终端窗口。2. 输入以下命令以更新软件包列表:sudo apt u...
    99+
    2023-08-25
    linux nodejs
  • PostgreSQL for Linux 安装方式
    1、环境规划 目录名称 存放位置 Postgres 用户家目录 /home/postgres 软件存放目录 /home/soft 安装目录 /usr/local 数据目录 /hom...
    99+
    2022-10-18
  • 怎么在Linux上安装Python
    本篇内容主要讲解“怎么在Linux上安装Python”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么在Linux上安装Python”吧!在 Linux 上安装最新 Python,替代或与老版本...
    99+
    2023-06-05
  • 怎么在Linux上安装Node.js8
    这篇文章主要介绍“怎么在Linux上安装Node.js8”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“怎么在Linux上安装Node.js8”文章能帮助大家解决问题。Node.js是一种事件驱动、非...
    99+
    2023-07-05
  • 怎么在Linux上安装PuTTY
    怎么在Linux上安装PuTTY,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。Linux发行版在其终端中内置了SSH功能,但是在实际环境中,使用PuTTY代替默认Linux...
    99+
    2023-06-28
  • 怎么在linux上安装phpmyadmin
    小编给大家分享一下怎么在linux上安装phpmyadmin,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!1.安装phpMyAdmin 图形化管理工具      ...
    99+
    2022-10-18
  • Linux系统如何安装PostgreSQL
    这篇文章给大家分享的是有关Linux系统如何安装PostgreSQL的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。PostgreSQL 简介:PostgreSQL是一个功能强大的开源对象关系型数据库系统,他使用和...
    99+
    2023-06-28
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作