• Centos7-pgsql 11.6 安装


    环境: 银河麒麟v10(yum源更换为华为 centos 7.9)
    pgsql 11.16

    一、主库安装配置:
    1.安装依赖包

    [root @kylin ]$ yum -y install readline  gcc  -y readline-devel zlib-devel
    
    • 1

    2.编译安装

    
    [root @kylin ]$ tar -xvf postgresql-11.6.tar.gz
    
    [root @kylin ]$ mkdir -p /opt/postgresql-11.6
    
    [root @kylin ]$  cd /opt/postgresql-11.6
    
    [root @kylin ]$ ./configure --prefix=/opt/postgresql-11.6 --with-blocksize=32  && make && make install
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    3.创建相应的用户

     [root @kylin ]$ groupadd postgres
    
     [root @kylin ]$ useradd -g postgres postgres
    
    创建数据及日志目录,并做相应授权
    
    [root @kylin ]$ mkdir -p /opt/postgresql-11.6/{data,log}
    
    [root @kylin ]$ chown -R postgres:postgres /opt/postgresql-11.6
    
     
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    4.初始化数据库

    [root @kylin ]$ su - postgres
    
    [postgres@kylin bin]$ cd /opt/postgresql-11.6/bin
    
    [postgres@kylin bin]$ ./initdb -D /opt/postgresql-11.6/data/
    
    [postgres@kylin bin]$ ./pg_ctl -D /opt/postgresql-11.6/data/ -l /opt/postgresql-11.6/log/postgres.log  start
    waiting for server to start.... done
    server started
    [postgres@kylin bin]$ cd ~
    [postgres@kylin ~]$ ls
    [postgres@kylin ~]$ pwd
    /home/postgres
    [postgres@kylin ~]$ vim .bash_profile 
    
    # Source /root/.bashrc if user has one
    [ -f ~/.bashrc ] && . ~/.bashrc
    
    PATH=$PATH:$HOME/.local/bin:$HOME/bin:/opt/postgresql-11.6/bin
    
    export PATH
    ~
    
    ".bash_profile" 6L, 149C written       
    [postgres@kylin ~]$ source ~/.bash_profile 
    
    [postgres@kylin ~]$ cd  /opt/postgresql-11.6/
    [postgres@kylin postgresql-11.6]$ ls
    bin  data  include  lib  log  share
    [postgres@kylin postgresql-11.6]$ cd bin
    [postgres@kylin bin]$ ./pg_ctl -D /opt/postgresql-11.6/data/ -l /opt/postgresql-11.6/log/postgres.log  restart
    waiting for server to shut down.... done
    server stopped
    waiting for server to start.... done
    server started
    
    [postgres@kylin bin]$ ./psql -p 5555
    psql (11.6)
    Type "help" for help.
    
    postgres=# ALTER USER postgres WITH PASSWORD 'postgres';
    ALTER ROLE
    postgres=# select * from pg_shadow ;
     usename  | usesysid | usecreatedb | usesuper | userepl | usebypass
    rls |               passwd                | valuntil | useconfig 
    ----------+----------+-------------+----------+---------+----------
    ----+-------------------------------------+----------+-----------
     postgres |       10 | t           | t        | t       | t        
        | md53175bce1d3201d16594cebf9d7eb3f9d |          | 
    (1 row)
    
    postgres=# \l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Ac
    cess privileges   
    -----------+----------+----------+-------------+-------------+-----
    ------------------
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/p
    ostgres          +
               |          |          |             |             | post
    gres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/p
    ostgres          +
               |          |          |             |             | post
    gres=CTc/postgres
    (3 rows)
    
    postgres=# \q
                 
    [postgres@kylin bin]$ ./pg_ctl -D /opt/postgresql-11.6/data/ -l /opt/postgresql-11.6/log/postgres.log  restart
    waiting for server to shut down.... done
    server stopped
    waiting for server to start.... done
    server started
    
    [postgres@kylin bin]$ vim /opt/postgresql-11.6/data/postgresql.conf
    # with the "SET" SQL command.
    #
    # Memory units:  kB = kilobytes        Time units:  ms  = milliseconds
    #                MB = megabytes                     s   = seconds
    #                GB = gigabytes                     min = minutes
    #                TB = terabytes                     h   = hours
    #                                                   d   = days
    
    
    #------------------------------------------------------------------------------
    # FILE LOCATIONS
    #------------------------------------------------------------------------------
    
    # The default values of these variables are driven from the -D command-line
    # option or PGDATA environment variable, represented here as ConfigDir.
    
    #data_directory = 'ConfigDir'           # use data in another directory
                                            # (change requires restart)
    #hba_file = 'ConfigDir/pg_hba.conf'     # host-based authentication file
                                            # (change requires restart)
    #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
                                            # (change requires restart)
    
    # If external_pid_file is not explicitly set, no extra PID file is written.
    #external_pid_file = ''                 # write an extra PID file
                                            # (change requires restart)
    
    
    #------------------------------------------------------------------------------
    # CONNECTIONS AND AUTHENTICATION
    #------------------------------------------------------------------------------
    
    # - Connection Settings -
    
    #listen_addresses = 'localhost'         # what IP address(es) to listen on;
    listen_addresses = '*'
                                            # comma-separated list of addresses;
                                            # defaults to 'localhost'; use '*' for all
                                            # (change requires restart)
    #port = 5432                            # (change requires restart)
    port=5555
    
    wal_level = replica
    archive_mode = on
    archive_command = 'cp %p /opt/postgresql-11.6/data/pg_archive/%f'
    ##%p = path of file to archive
    ##%f = file name only
    max_wal_senders = 6
    wal_keep_segments = 10240
    wal_sender_timeout = 60s
    
    [postgres@kylin bin]$ vim   ../data/pg_hba.conf 
    # Database and user names containing spaces, commas, quotes and other
    # special characters must be quoted.  Quoting one of the keywords
    # "all", "sameuser", "samerole" or "replication" makes the name lose
    # its special character, and just match a database or username with
    # that name.
    #
    # This file is read on server startup and when the server receives a
    # SIGHUP signal.  If you edit the file on a running system, you have to
    # SIGHUP the server for the changes to take effect, run "pg_ctl reload",
    # or execute "SELECT pg_reload_conf()".
    #
    # Put your actual configuration here
    # ----------------------------------
    #
    # If you want to allow non-local connections, you need to add more
    # "host" records.  In that case you will also need to make PostgreSQL
    # listen on a non-local interface via the listen_addresses
    # configuration parameter, or via the -i or -h command line switches.
    
    # CAUTION: Configuring the system for local "trust" authentication
    # allows any local user to connect as any PostgreSQL user, including
    # the database superuser.  If you do not trust all your local users,
    # use another authentication method.
    
    
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # "local" is for Unix domain socket connections only
    local   all             all                                     trust
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    host    all             all             0.0.0.0/0            md5
    # IPv6 local connections:
    host    all             all             ::1/128                 trust
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    local   replication     all                                     trust
    host    replication     all             127.0.0.1/32            trust
    host    replication     all             ::1/128                 trust
    host    replication     repl             192.168.1.6/24         md5
    host    all             repl             192.168.1.6/24         trust
    
    [postgres@kylin bin]$ ./pg_ctl -D /opt/postgresql-11.6/data reload
    [postgres@kylin bin]$ ./pg_ctl -D /opt/postgresql-11.6/data/ -l /opt/postgresql-11.6/log/postgres.log  restart
    waiting for server to shut down.... done
    server stopped
    waiting for ser
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176

    参看: https://www.cnblogs.com/likecoke/p/15715095.html

    https://www.postgresql.org/ftp/source/v10.20/

  • 相关阅读:
    mySQL相关操作(不看是你的损失)
    【Web前端基础进阶学习】HTML详解(下篇)
    springboot基于web的摩托车销售系统的设计与实现毕业设计源码031706
    【Vue3从零开始-实战】S10:Toast弹窗组件开发
    因为一条DDL,差点搞挂整个系统,这次真的长了教训
    基于低代码平台打造高度灵活性的OA系统
    vue-router的编程式导航有哪些方法?
    仿`gRPC`功能实现像调用本地方法一样调用其他服务器方法
    童装CPC认证检测哪些内容?童装上架亚马逊美国站CPC认证办理
    c++-基本数据类型
  • 原文地址:https://blog.csdn.net/weixin_38504735/article/details/126123598