PostgreSQL_配置pgbouncer连接池

下载地址 PgBouncer Downloads

上传解压

[postgres@localhost ~]$ cd ~
[postgres@localhost ~]$ cd resoruce/
[postgres@localhost resoruce]$ ll
-rw-r--r--. 1 postgres postgres    598294 Jul  9 08:15 pgbouncer-1.17.0.tar.gz
[postgres@localhost resoruce]$ tar -zxvf pgbouncer-1.17.0.tar.gz 

编译安装

[postgres@localhost ~]$ su root
[root@localhost ~]# yum install -y libevent-devel

[postgres@localhost resoruce]$ cd pgbouncer-1.17.0
[postgres@localhost pgbouncer-1.17.0]$ mkdir ~/pgbouncer
[postgres@localhost pgbouncer-1.17.0]$ ./configure --prefix=/home/postgres/pgbouncer/
[postgres@localhost pgbouncer-1.17.0]$ make
[postgres@localhost pgbouncer-1.17.0]$ make install

修改配置文件

[postgres@localhost pgbouncer]$ cd ~/pgbouncer/
[postgres@localhost pgbouncer]$ egrep -v '^\;|^$' /home/postgres/pgbouncer/share/doc/pgbouncer/pgbouncer.ini > pgbouncer.ini
[postgres@localhost pgbouncer]$ vi pgbouncer.ini
[databases]
appdb = host = 192.168.144.140 dbname=appdb port=5666
[pgbouncer]
logfile = /home/postgres/pgbouncer/pgbouncer.log
pidfile = /home/postgres/pgbouncer.pid
listen_addr = *
listen_port = 5766
auth_type = trust
auth_file = /home/postgres/pgbouncer/userlist.txt

修改登录用户列表

[postgres@localhost pgbouncer]$ cp share/doc/pgbouncer/userlist.txt ./
[postgres@localhost pgbouncer]$ vi userlist.txt
"appuser" "1qaz@WSX"

修改环境变量

[postgres@localhost pgbouncer]$ vi ~/.bashrc
[postgres@localhost pgbouncer]$ source ~/.bashrc 
export PATH=${PGHOME}/bin:/home/postgres/pgbouncer/bin:${PATH}

修改pg_hba配置文件 保证appdb可以连接

[postgres@localhost pgbouncer]$ vi $PGDATA/pg_hba.conf

启动pgbouncer

[postgres@localhost pgbouncer]$ pgbouncer -d -v /home/postgres/pgbouncer/pgbouncer.ini

使用pgbouncer连接数据库

[postgres@localhost pgbouncer]$ psql -U appuser -d appdb -p 5766
psql (12.0)
Type "help" for help.

appdb=> show port;
 port 
------
 5666
(1 row)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PostgreSQL是以加州大学伯克利分校计算机系开发的POSTGRES,现在已经更名为PostgreSQL. PostgreSQL支持大部分SQL标准并且提供了许多其它现代特性:复杂查询、外键、触发器、视图、事务完整性等。 PostgreSQL 是一个免费的对象-关系数据库服务器(数据库管理系统),它在灵活的 BSD-风格许可证下发行。它提供了相对其他开放源代码数据库系统(比如 MySQL 和 Firebird),和专有系统(比如 Oracle、Sybase、IBM 的 DB2 和 Microsoft SQL Server)之外的另一种选择。 事实上, PostgreSQL 的特性覆盖了 SQL-2/SQL-92 和 SQL-3/SQL-99,首先,它包括了可以说是目前世界上最丰富的数据类型的支持,其中有些数据类型可以说连商业数据库都不具备, 比如 IP 类型和几何类型等;其次,PostgreSQL 是全功能的自由软件数据库,很长时间以来,PostgreSQL 是唯一支持事务、子查询、多版本并行控制系统(MVCC)、数据完整性检查等特性的唯一的一种自由软件的数据库管理系统。 Inprise 的 InterBase 以及SAP等厂商将其原先专有软件开放为自由软件之后才打破了这个唯一。最后,PostgreSQL拥有一支非常活跃的开发队伍,而且在许多黑客的努力下,PostgreSQL 的质量日益提高。从技术角度来讲,PostgreSQL 采用的是比较经典的C/S(client/server)结构,也就是一个客户端对应一个服务器端守护进程的模式,这个守护进程分析客户端来的查询请求,生成规划树,进行数据检索并最终把结果格式化输出后返回给客户端。为了便于客户端的程序的编写,由数据库服务器提供了统一的客户端 C 接口。而不同的客户端接口都是源自这个 C 接口,比如ODBC,JDBC,Python,Perl,Tcl,C/C++,ESQL等, 同时也要指出的是,PostgreSQL 对接口的支持也是非常丰富的,几乎支持所有类型的数据库客户端接口。这一点也可以说是 PostgreSQL 一大优点。 本课程作为PostgreSQL数据库管理一,主要讲解以下内容:1.     PostgreSQL安装和环境准备2.     PostgreSQL数据查询3.     PostgreSQL 数据过滤4.     PostgreSQL 多表的联接5.     PostgreSQL数据的分组6.     PostgreSQL合集的操作7.   PostgreSQL 合集的分组

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值