• db PostgreSQL 10


    postgresql 基本命令

    https://www.cnblogs.com/my-blogs-for-everone/p/10226473.html

    下载安装PostgreSQL 10

    https://www.postgresql.org/download/linux/redhat/

    [root@centos8 yum.repos.d]#  yum install postgresql

    [root@centos8 yum.repos.d]# yum install postgresql-server
    Package postgresql-server-10.15-1.module_el8.3.0+619+dbc95fbc.x86_64 is already installed.
    [root@centos8 yum.repos.d]# dnf install postgresql-server
    Package postgresql-server-10.15-1.module_el8.3.0+619+dbc95fbc.x86_64 is already installed.
    [root@centos8 yum.repos.d]# systemctl restart postgresql.service

    查看postgresql 版本

    [postgres@centos8 ~]$ psql --version
    psql: /lib/libpq.so.5: no version information available (required by psql)
    psql (PostgreSQL) 10.15

    设置postgresql 10 允许外部连接

    https://blog.csdn.net/u014698745/article/details/86612511

    https://blog.csdn.net/a964921988/article/details/80618661

    1,修改文件 /var/lib/pgsql/data/pg_hba.conf

    [root@centos8 data]# vim /var/lib/pgsql/data/pg_hba.conf

    host    all       all         192.168.1.1/32      md5 --/32代表只允许192.168.1.1访问
    host    all       all         192.168.1.0/24     md5 --/24代表192.168.1.1~192.168.1.255都允许访问
    host    all       all         192.168.0.0/16      md5 --/16代表192.168.1.1~192.168.255.255都允许访问
    host    all       all         192.0.0.0/8          md5 --/8代表192.1.1.1~192.255.255.255都允许访问
    host    all       all         0.0.0.0/0          md5 --/0代表所有ip地址都允许访问
    找到“# IPv4 local connections:“后,新加一行内容如下:
    host    all       all         0.0.0.0/0          trust
    2,修改文件 /var/lib/pgsql/data/postgresql.conf
    修改内容 listen_addresses = '*'
    3,重启postgres服务
    [root@centos8 data]# systemctl restart postgresql.service
    [root@centos8 data]# systemctl status postgresql.service
    4,防火墙打开端口,以CentOS8为例
    [root@centos8 data]# sudo firewall-cmd --permanent --zone=public --add-port=5432/tcp
    [root@centos8 data]# sudo firewall-cmd --reload

    [root@centos8 pgsql]# vim /var/lib/pgsql/initdb_postgresql.log 

    [root@centos8 pgsql]# vim initdb_postgresql.log
    
    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 /var/lib/pgsql/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting default timezone ... Asia/Shanghai
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    running bootstrap script ... ok
    performing post-bootstrap initialization ... ok
    syncing data to disk ... ok
    
    Success. You can now start the database server using:
    
        /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

    https://www.postgresql.org/download/linux/redhat/

    [root@centos8 yum.repos.d]# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    [root@centos8 yum.repos.d]# sudo dnf -qy module disable postgresql
    [root@centos8 yum.repos.d]# sudo dnf install -y postgresql10-server
    [root@centos8 yum.repos.d]# sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
    [root@centos8 yum.repos.d]# sudo systemctl enable postgresql-10
    [root@centos8 yum.repos.d]# sudo systemctl start postgresql-10

    [root@centos8 yum.repos.d]# vim /etc/yum.repos.d/pgdg-redhat-all.repo

    #######################################################
    # PGDG Red Hat Enterprise Linux / CentOS repositories #
    #######################################################
    
    # PGDG Red Hat Enterprise Linux / CentOS stable common repository for all PostgreSQL versions
    
    [pgdg-common]
    name=PostgreSQL common RPMs for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # Red Hat recently breaks compatibility between 8.n and 8.n+1. PGDG repo is
    # affected with the LLVM repo. This is a band aid repo for the llvmjit users
    # whose installations cannot be updated.
    
    [pgdg-centos8-sysupdates]
    name=PostgreSQL Supplementary ucommon RPMs for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/common/pgdg-centos8-sysupdates/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # PGDG Red Hat Enterprise Linux / CentOS stable repositories:
    
    [pgdg13]
    name=PostgreSQL 13 for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg12]
    name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg11]
    name=PostgreSQL 11 for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg10]
    name=PostgreSQL 10 for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg96]
    name=PostgreSQL 9.6 for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg95]
    name=PostgreSQL 9.5 for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # PGDG RHEL/CentOS Updates Testing common repositories.
    
    [pgdg-common-testing]
    name=PostgreSQL common testing RPMs for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/common/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # PGDG RHEL/CentOS Updates Testing repositories. (These packages should not be used in production)
    # Available for 11 and above.
    
    [pgdg14-updates-testing]
    name=PostgreSQL 14 for RHEL/CentOS $releasever - $basearch - Updates testing
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/14/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg13-updates-testing]
    name=PostgreSQL 13 for RHEL/CentOS $releasever - $basearch - Updates testing
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/13/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg12-updates-testing]
    name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch - Updates testing
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/12/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg11-updates-testing]
    name=PostgreSQL 11 for RHEL/CentOS $releasever - $basearch - Updates testing
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/11/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # PGDG Red Hat Enterprise Linux / CentOS SRPM testing common repository
    
    [pgdg-source-common]
    name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch - Source
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/common/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # PGDG RHEL / CentOS testing common SRPM repository for all PostgreSQL versions
    
    [pgdg-common-srpm-testing]
    name=PostgreSQL common testing SRPMs for RHEL/CentOS $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/common/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # PGDG Source RPMs (SRPM), and their testing repositories:
    
    [pgdg14-source-updates-testing]
    name=PostgreSQL 14 for RHEL/CentOS $releasever - $basearch - Source updates testing
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/14/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg13-source-updates-testing]
    name=PostgreSQL 13 for RHEL/CentOS $releasever - $basearch - Source updates testing
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/13/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg12-source]
    name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/12/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg12-source-updates-testing]
    name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch - Source update testing
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/12/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg11-source]
    name=PostgreSQL 11 for RHEL/CentOS $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/11/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg11-source-updates-testing]
    name=PostgreSQL 11 for RHEL/CentOS $releasever - $basearch - Source update testing
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/11/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg10-source]
    name=PostgreSQL 10 for RHEL/CentOS $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/10/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg96-source]
    name=PostgreSQL 9.6 for RHEL/CentOS $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/9.6/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg95-source]
    name=PostgreSQL 9.5 for RHEL/CentOS $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/9.5/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # Debuginfo/debugsource packages for stable repos
    
    [pgdg13-updates-debuginfo]
    name=PostgreSQL 13 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/debug/13/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg12-updates-debuginfo]
    name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/debug/12/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg11-updates-debuginfo]
    name=PostgreSQL 11 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/debug/11/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg10-updates-debuginfo]
    name=PostgreSQL 10 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/debug/10/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg96-updates-debuginfo]
    name=PostgreSQL 9.6 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/debug/9.6/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg95-updates-debuginfo]
    name=PostgreSQL 9.5 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/debug/9.5/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    # Debuginfo/debugsource packages for testing repos
    # Available for 11 and above.
    
    [pgdg14-updates-testing-debuginfo]
    name=PostgreSQL 14 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/14/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg13-updates-testing-debuginfo]
    name=PostgreSQL 13 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/13/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg12-updates-testing-debuginfo]
    name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/12/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
    
    [pgdg11-updates-testing-debuginfo]
    name=PostgreSQL 11 for RHEL/CentOS $releasever - $basearch - Debuginfo
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/11/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG

    end

    https://www.postgresql.org/download/linux/redhat/

  • 相关阅读:
    jquery实现瀑布文字
    文本域、bootstrap-table显示以及MySQL三者间的换行符问题
    Mybatis框架的搭建和基本使用方法
    解决ajax多次绑定问题
    浅析JSONP与CROS技术解决跨域问题
    使用Ajax+nodejs实现页面头像上传功能
    自写滚屏组件
    express框架的ejs模板引擎渲染html页面
    自写轮播组件
    mousewheel事件细节
  • 原文地址:https://www.cnblogs.com/lindows/p/14463871.html
Copyright © 2020-2023  润新知