centos7編譯安裝pgbouncer

2022-06-12 23:12:09 字數 2818 閱讀 8455

wget   //pgbouncer需要用到libevent依賴包

wget

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

centos7編譯安裝gcc

centos7 的yum 只能將 gcc公升級到 4.9 的版本 但是從gcc官網看 已經到 7.2 的版本了,因為想自己編譯乙個最新版的linux核心,所以對gcc要求有點高,於是自己動手編譯gcc。gcc v 檢視原來的版本 直接來乾貨 1 需要明白的 2 明白.configure 後面的引數配...

centos7 編譯安裝memcached

安裝memcached之前首先需要安裝libevent,我這裡用的版本是 首先將這兩個安裝檔案上傳至linux伺服器,在解壓安裝之前最好先檢查一下是否已安裝,從libevent開始 rpm q libevent發現系統已經安裝了乙個版本的libevent 既然已經安裝了乙個版本的libevent,那...

Centos7 編譯安裝Nginx

nginx版本分開發版和穩定版,生產環境使用穩定版,實驗新功能,新特性可以使用開發版。安裝nginx編譯需要依賴的包 yum install gcc gcc c wget yum install pcre devel zlib devel openssl devel說明 zlib nginx提供gz...