zoukankan      html  css  js  c++  java
  • centos7编译安装pgbouncer

    1、下载pgbouncer程序包和libevent依赖包

    wget https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz  //pgbouncer需要用到libevent依赖包
    wget http://www.pgbouncer.org/downloads/files/1.12.0/pgbouncer-1.12.0.tar.gz

    2、安装编译所需的环境依赖

     yum install gcc gcc-c++ make openssl-devel
    

    3、解压并编译安装

    tar -xf libevent-2.1.11-stable.tar.gz
    tar -xf pgbouncer-1.12.0.tar.gz
    

    4、编译安装libevent

     ./configure --prefix=/usr/local/libevent
    make -j 2
    make install
    

    5、配置环境变量

    echo "export PKG_CONFIG_PATH=/usr/local/libevent/lib/pkgconfig" >> ~/.bashrc
    cat ~/.bashrc
    source ~/.bashrc
    

     9、授权postgres用户访问libevent-2.1.so.7权限

    setfacl -Rm u:postgres:rwx /usr/
    

     10、创建软连接

    ln -s /usr/local/libevent/lib/libevent-2.1.so.7 /usr/lib64/libevent-2.1.so.7
    

    11、编译安装pgbouncer

    ./configure --prefix=/usr/local/pgbouncer/
    make -j 2
    make install
    

     12、创建pgbouncer.ini配置文件

    cat /etc/pgbouncer/pgbouncer.ini
    [databases]
    postgres = host=127.0.0.1 port=5432 dbname=postgres
     
    [pgbouncer]
    logfile = /var/log/pgbouncer/pgbouncer.log
    pidfile = /var/run/pgbouncer/pgbouncer.pid
    listen_addr = 10.15.150.41
    listen_port = 6432
    unix_socket_dir = /var/run/postgresql
    auth_type = md5
    auth_file = /etc/pgbouncer/userlist.txt
    admin_users = postgres
    ignore_startup_parameters = extra_float_digits,geqo
      
    pool_mode = session
    server_reset_query = DISCARD ALL
    max_client_conn = 10000
    default_pool_size = 1000
    reserve_pool_size = 30
    reserve_pool_timeout = 5
    max_db_connections = 5000
    pkt_buf = 8192
    

     13、创建用户名及密码认证文件,确保仅postgres用户可以访问,权限600

    cat /etc/pgbouncer/userlist.txt
    "postgres" "P2poRLYZ8"
    

     14、配置开机自启服务,由systemctl管理,创建pgbouncer.service文件

    cat /etc/systemd/system/pgbouncer.service
    [Unit]
    Description=pgBouncer connection pooling for PostgreSQL
    After=syslog.target network.target
     
    [Service]
    Type=forking
     
    User=postgres
    Group=postgres
     
    PermissionsStartOnly=true
    ExecStartPre=-/bin/mkdir -p /var/run/pgbouncer /var/log/pgbouncer
    ExecStartPre=/bin/chown -R postgres:postgres /var/run/pgbouncer /var/log/pgbouncer
    ExecStart=/usr/local/pgbouncer/bin/pgbouncer -d /etc/pgbouncer/pgbouncer.ini
    ExecReload=/bin/kill -SIGHUP $MAINPID
    PIDFile=/var/run/pgbouncer/pgbouncer.pid
     
    LimitNOFILE=100000
     
    [Install]
    WantedBy=multi-user.target
    

     15、填写可执行权限

    chmod +x /etc/systemd/system/pgbouncer.service
    

     16、启动服务

    systemctl start pgbouncer
    

     17、查询启动状态systemctl status pgbouncer

     18、加入开机启动项

    systemctl enable pgbouncer
    

      

      

  • 相关阅读:
    (八)DVWA之SQL Injection--SQLMap&Burp测试(Medium)
    (五)SQLMap工具检测SQL注入漏洞、获取数据库中的数据
    (四)SQLMap之Tamper篡改脚本的类型、作用、适用场景
    (七)DVWA之SQL Injection--SQLMap测试(Low)
    (三)SQLMap工具-使用选项的操作命令&功能
    20190923-13Linux企业真实面试题 000 021
    20190923-12Linux软件包管理 000 020
    20190923-11Linux crond 系统定时任务 000 019
    20190923-10Linux进程线程类 000 018
    20190923-09Linux磁盘分区类 000 017
  • 原文地址:https://www.cnblogs.com/caidingyu/p/12073454.html
Copyright © 2011-2022 走看看