zoukankan      html  css  js  c++  java
  • 源码编译安装pg13

    源码下载地址:https://www.postgresql.org/ftp/source/

    [root@muze1 data]# wget https://ftp.postgresql.org/pub/source/v13.2/postgresql-13.2.tar.gz
    -- 创建用户
    groupadd -g 60000 dba
    useradd -u 60000 -g dba postgres
    echo "lhr" | passwd --stdin postgres
    -- 创建目录
    [root@muze1 data]# mkdir -p /data/postgresql/{pgdata,archive,scripts,backup,pg13,soft}
    chown -R postgres:dba /data/postgresql
    chmod -R 775 /data/postgresql
    -- 编译
    su -  postgres
    cd /data/postgresql/soft
    tar zxvf postgresql-13.2.tar.gz
    cd postgresql-13.2
    ./configure --prefix=/data/postgresql/pg13 --without-readline
    make -j 8 && make install

    -- 配置环境变量
    cat >> ~/.bash_profile <<"EOF"
    export LANG=en_US.UTF-8
    export PS1="[u@h W]$ "
    export PGPORT=5432
    export PGDATA=/data/postgresql/pgdata
    export PGHOME=/data/postgresql/pg13
    export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
    export PATH=$PGHOME/bin:$PATH:.
    export DATE=`date +"%Y%m%d%H%M"`
    export MANPATH=$PGHOME/share/man:$MANPATH
    export PGHOST=$PGDATA
    export PGUSER=postgres
    export PGDATABASE=postgres

    alias psql='rlwrap psql'
    EOF

    source ~/.bash_profile
    -- 初始化
    [postgres@muze1 postgresql]$ /data/postgresql/pg13/bin/initdb -D /data/postgresql/pgdata -E UTF8 --locale=en_US.utf8 -U postgres
    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.utf8".
    The default text search configuration will be set to "english".

    Data page checksums are disabled.

    fixing permissions on existing directory /data/postgresql/pgdata ... ok
    creating subdirectories ... ok
    selecting dynamic shared memory implementation ... posix
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting default time zone ... Asia/Shanghai
    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:

    /data/postgresql/pg13/bin/pg_ctl -D /data/postgresql/pgdata -l logfile start

    [postgres@muze1 postgresql]$

    -- 修改参数
    cat >> /data/postgresql/pgdata/postgresql.conf <<"EOF"
    listen_addresses = '*'
    port=5432
    unix_socket_directories='/data/postgresql/pgdata'
    logging_collector = on
    log_directory = 'pg_log'
    log_filename = 'postgresql-%a.log'
    log_truncate_on_rotation = on
    EOF

    cat > /data/postgresql/pgdata/pg_hba.conf << EOF
    # TYPE DATABASE USER ADDRESS METHOD
    local all all trust
    host all all 127.0.0.1/32 trust
    host all all 0.0.0.0/0 md5
    host replication all 0.0.0.0/0 md5
    EOF

    [postgres@muze1 ~]$ pg_ctl start
    waiting for server to start....2021-06-08 17:10:13.281 CST [87275] LOG: redirecting log output to logging collector process
    2021-06-08 17:10:13.281 CST [87275] HINT: Future log output will appear in directory "pg_log".
    done
    server started
    [postgres@muze1 ~]$ ps -ef|grep pg
    postgres 87275 1 0 17:10 ? 00:00:00 /data/postgresql/pg13/bin/postgres

    postgres 87292 87178 0 17:10 pts/0 00:00:00 grep --color=auto pg

     [postgres@muze1 bin]$ ./psql

    psql (13.2)
    Type "help" for help.

    postgres=# select version() ;
    version
    ---------------------------------------------------------------------------------------------------------
    PostgreSQL 13.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
    (1 row)

  • 相关阅读:
    day7随笔
    day6随笔
    day5笔记
    uniapp 全屏蒙版下的其他view禁止滑动
    uniapp scroll-view 组件右侧的滚动条
    uni 组件 头部
    根据两点的经纬度查询两点间的距离
    仅供学习使用的一些 相关vue类
    仅供学习使用的一些样式+行为
    百度地图简单调用
  • 原文地址:https://www.cnblogs.com/vzhangxk/p/14863710.html
Copyright © 2011-2022 走看看