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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
|
'\" t
.\" Title: pgbouncer
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.74.3 <http://docbook.sf.net/>
.\" Date: 01/15/2010
.\" Manual: [FIXME: manual]
.\" Source: [FIXME: source]
.\" Language: English
.\"
.TH "PGBOUNCER" "1" "01/15/2010" "[FIXME: source]" "[FIXME: manual]"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
pgbouncer \- Lightweight connection pooler for PostgreSQL\&.
.SH "SYNOPSIS"
.sp
.nf
pgbouncer [\-d][\-R][\-v][\-u user] <pgbouncer\&.ini>
pgbouncer \-V|\-h
.fi
.sp
.sp
On Windows computers, the options are:
.sp
.nf
pgbouncer\&.exe [\-v][\-u user] <pgbouncer\&.ini>
pgbouncer\&.exe \-V|\-h
.fi
.sp
.sp
Additional options for setting up a Windows service:
.sp
.nf
pgbouncer\&.exe \-regservice <pgbouncer\&.ini>
pgbouncer\&.exe \-unregservice <pgbouncer\&.ini>
.fi
.SH "DESCRIPTION"
.sp
pgbouncer is a PostgreSQL connection pooler\&. Any target application can be connected to pgbouncer as if it were a PostgreSQL server, and pgbouncer will create a connection to the actual server, or it will reuse one of its existing connections\&.
.sp
The aim of pgbouncer is to lower the performance impact of opening new connections to PostgreSQL\&.
.sp
In order not to compromise transaction semantics for connection pooling, pgbouncer supports several types of pooling when rotating connections:
.PP
Session pooling
.RS 4
Most polite method\&. When client connects, a server connection will be assigned to it for the whole duration the client stays connected\&. When the client disconnects, the server connection will be put back into the pool\&. This is the default method\&.
.RE
.PP
Transaction pooling
.RS 4
A server connection is assigned to client only during a transaction\&. When PgBouncer notices that transaction is over, the server connection will be put back into the pool\&.
.RE
.PP
Statement pooling
.RS 4
Most aggressive method\&. The server connection will be put back into pool immediately after a query completes\&. Multi\-statement transactions are disallowed in this mode as they would break\&.
.RE
.sp
The administration interface of pgbouncer consists of some new SHOW commands available when connected to a special \fIvirtual\fR database pgbouncer\&.
.SH "QUICK-START"
.sp
Basic setup and usage as following\&.
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
Create a pgbouncer\&.ini file\&. Details in
pgbouncer(5)\&. Simple example:
.sp
.if n \{\
.RS 4
.\}
.nf
[databases]
template1 = host=127\&.0\&.0\&.1 port=5432 dbname=template1
.fi
.if n \{\
.RE
.\}
.sp
.if n \{\
.RS 4
.\}
.nf
[pgbouncer]
listen_port = 6543
listen_addr = 127\&.0\&.0\&.1
auth_type = md5
auth_file = users\&.txt
logfile = pgbouncer\&.log
pidfile = pgbouncer\&.pid
admin_users = someuser
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 2." 4.2
.\}
Create a users\&.txt file:
.sp
.if n \{\
.RS 4
.\}
.nf
"someuser" "same_password_as_in_server"
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 3." 4.2
.\}
Launch
pgbouncer:
.sp
.if n \{\
.RS 4
.\}
.nf
$ pgbouncer \-d pgbouncer\&.ini
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 4.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 4." 4.2
.\}
Have your application (or the
psql
client) connect to
pgbouncer
instead of directly to PostgreSQL server\&.
.sp
.if n \{\
.RS 4
.\}
.nf
$ psql \-p 6543 \-U someuser template1
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 5.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 5." 4.2
.\}
Manage
pgbouncer
by connecting to the special administration database
pgbouncer
and issuing
show help;
to begin:
.sp
.if n \{\
.RS 4
.\}
.nf
$ psql \-p 6543 \-U someuser pgbouncer
pgbouncer=# show help;
NOTICE: Console usage
DETAIL:
SHOW [HELP|CONFIG|DATABASES|FDS|POOLS|CLIENTS|SERVERS|SOCKETS|LISTS|VERSION]
SET key = arg
RELOAD
PAUSE
SUSPEND
RESUME
SHUTDOWN
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 6.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 6." 4.2
.\}
If you made changes to the pgbouncer\&.ini file, you can reload it with:
.sp
.if n \{\
.RS 4
.\}
.nf
pgbouncer=# RELOAD;
.fi
.if n \{\
.RE
.\}
.RE
.SH "COMMAND LINE SWITCHES"
.PP
\-d
.RS 4
Run in background\&. Without it the process will run in foreground\&. Note: Does not work on Windows,
pgbouncer
need to run as service there\&.
.RE
.PP
\-R
.RS 4
Do an online restart\&. That means connecting to the running process, loading the open sockets from it, and then using them\&. If there is no active process, boot normally\&. Note: Does not work on Windows machines\&.
.RE
.PP
\-u user
.RS 4
Switch to the given user on startup\&.
.RE
.PP
\-v
.RS 4
Increase verbosity\&. Can be used multiple times\&.
.RE
.PP
\-q
.RS 4
Be quiet \- do not log to stdout\&. Note this does not affect logging verbosity, only that stdout is not to be used\&. For use in init\&.d scripts\&.
.RE
.PP
\-V
.RS 4
Show version\&.
.RE
.PP
\-h
.RS 4
Show short help\&.
.RE
.PP
\-regservice
.RS 4
Win32: Register pgbouncer to run as Windows service\&. The
service_name
config parameter value is used as name to register under\&.
.RE
.PP
\-unregservice
.RS 4
Win32: Unregister Windows service\&.
.RE
.SH "ADMIN CONSOLE"
.sp
The console is available by connecting as normal to the database pgbouncer
.sp
.if n \{\
.RS 4
.\}
.nf
$ psql \-p 6543 pgbouncer
.fi
.if n \{\
.RE
.\}
.sp
.sp
Only users listed in configuration parameters admin_users or stats_users are allowed to login to the console\&. (Except when auth_mode=any, then any user is allowed in as an admin\&.)
.sp
Additionally, the username pgbouncer is allowed to log in without password, if the login comes via Unix socket and the client has same Unix user uid as the running process\&.
.SS "SHOW COMMANDS"
.sp
The SHOW commands output information\&. Each command is described below\&.
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW STATS;\fR
.RS 4
.sp
Shows statistics\&.
.PP
database
.RS 4
Statistics are presented per database\&.
.RE
.PP
total_requests
.RS 4
Total number of
SQL
requests pooled by
pgbouncer\&.
.RE
.PP
total_received
.RS 4
Total volume in bytes of network traffic received by
pgbouncer\&.
.RE
.PP
total_sent
.RS 4
Total volume in bytes of network traffic sent by
pgbouncer\&.
.RE
.PP
total_query_time
.RS 4
Total number of microseconds spent by
pgbouncer
when actively connected to PostgreSQL\&.
.RE
.PP
avg_req
.RS 4
Average requests per second in last stat period\&.
.RE
.PP
avg_recv
.RS 4
Average received (from clients) bytes per second\&.
.RE
.PP
avg_sent
.RS 4
Average sent (to clients) bytes per second\&.
.RE
.PP
avg_query
.RS 4
Average query duration in microseconds\&.
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW SERVERS;\fR
.RS 4
.PP
type
.RS 4
S, for server\&.
.RE
.PP
user
.RS 4
Username
pgbouncer
uses to connect to server\&.
.RE
.PP
database
.RS 4
Database name\&.
.RE
.PP
state
.RS 4
State of the pgbouncer server connection, one of
active,
used
or
idle\&.
.RE
.PP
addr
.RS 4
IP address of PostgreSQL server\&.
.RE
.PP
port
.RS 4
Port of PostgreSQL server\&.
.RE
.PP
local_addr
.RS 4
Connection start address on local machine\&.
.RE
.PP
local_port
.RS 4
Connection start port on local machine\&.
.RE
.PP
connect_time
.RS 4
When the connection was made\&.
.RE
.PP
request_time
.RS 4
When last request was issued\&.
.RE
.PP
ptr
.RS 4
Address of internal object for this connection\&. Used as unique ID\&.
.RE
.PP
link
.RS 4
Address of client connection the server is paired with\&.
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW CLIENTS;\fR
.RS 4
.PP
type
.RS 4
C, for client\&.
.RE
.PP
user
.RS 4
Client connected user\&.
.RE
.PP
database
.RS 4
Database name\&.
.RE
.PP
state
.RS 4
State of the client connection, one of
active,
used,
waiting
or
idle\&.
.RE
.PP
addr
.RS 4
IP address of client\&.
.RE
.PP
port
.RS 4
Port client is connected to\&.
.RE
.PP
local_addr
.RS 4
Connection end address on local machine\&.
.RE
.PP
local_port
.RS 4
Connection end port on local machine\&.
.RE
.PP
connect_time
.RS 4
Timestamp of connect time\&.
.RE
.PP
request_time
.RS 4
Timestamp of latest client request\&.
.RE
.PP
ptr
.RS 4
Address of internal object for this connection\&. Used as unique ID\&.
.RE
.PP
link
.RS 4
Address of server connection the client is paired with\&.
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW POOLS;\fR
.RS 4
.sp
A new pool entry is made for each couple of (database, user)\&.
.PP
database
.RS 4
Database name\&.
.RE
.PP
user
.RS 4
Username\&.
.RE
.PP
cl_active
.RS 4
Count of currently
active
client connections\&.
.RE
.PP
cl_waiting
.RS 4
Count of currently
waiting
client connections\&.
.RE
.PP
sv_active
.RS 4
Count of currently
active
server connections\&.
.RE
.PP
sv_idle
.RS 4
Count of currently
idle
server connections\&.
.RE
.PP
sv_used
.RS 4
Count of currently
used
server connections\&.
.RE
.PP
sv_tested
.RS 4
Count of currently
tested
server connections\&.
.RE
.PP
sv_login
.RS 4
Count of server connections currently
logged in
to PostgreSQL\&.
.RE
.PP
maxwait
.RS 4
How long the first (oldest) client in queue has waited, in seconds\&. If this starts increasing, then the current pool of servers does not handle requests quick enough\&. Reason may be either overloaded server or just too small of a
pool_size
setting\&.
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW LISTS;\fR
.RS 4
.sp
Show following internal information, in columns (not rows):
.PP
databases
.RS 4
Count of databases\&.
.RE
.PP
users
.RS 4
Count of users\&.
.RE
.PP
pools
.RS 4
Count of pools\&.
.RE
.PP
free_clients
.RS 4
Count of free clients\&.
.RE
.PP
used_clients
.RS 4
Count of used clients\&.
.RE
.PP
login_clients
.RS 4
Count of clients in
login
state\&.
.RE
.PP
free_servers
.RS 4
Count of free servers\&.
.RE
.PP
used_servers
.RS 4
Count of used servers\&.
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW USERS;\fR
.RS 4
.sp
Shows one line per user, under the name column name\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW DATABASES;\fR
.RS 4
.PP
name
.RS 4
Name of configured database entry\&.
.RE
.PP
host
.RS 4
Host pgbouncer connects to\&.
.RE
.PP
port
.RS 4
Port pgbouncer connects to\&.
.RE
.PP
database
.RS 4
Actual database name pgbouncer connects to\&.
.RE
.PP
force_user
.RS 4
When user is part of the connection string, the connection between pgbouncer and PostgreSQL is forced to the given user, whatever the client user\&.
.RE
.PP
pool_size
.RS 4
Maximum number of server connections\&.
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW FDS;\fR
.RS 4
.sp
Shows list of fds in use\&. When the connected user has username "pgbouncer", connects through Unix socket and has same UID as running process, the actual fds are passed over the connection\&. This mechanism is used to do an online restart\&. Note: This does not work on Windows machines\&.
.PP
fd
.RS 4
File descriptor numeric value\&.
.RE
.PP
task
.RS 4
One of
pooler,
client
or
server\&.
.RE
.PP
user
.RS 4
User of the connection using the FD\&.
.RE
.PP
database
.RS 4
Database of the connection using the FD\&.
.RE
.PP
addr
.RS 4
IP address of the connection using the FD,
unix
if a unix socket is used\&.
.RE
.PP
port
.RS 4
Port used by the connection using the FD\&.
.RE
.PP
cancel
.RS 4
Cancel key for this connection\&.
.RE
.PP
link
.RS 4
fd for corresponding server/client\&. NULL if idle\&.
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHOW CONFIG;\fR
.RS 4
.sp
Show the current configuration settings, one per row, with following columns:
.PP
key
.RS 4
Configuration variable name
.RE
.PP
value
.RS 4
Configuration value
.RE
.PP
changeable
.RS 4
Either
yes
or
no, shows if the variable can be changed while running\&. If
no, the variable can be changed only boot\-time\&.
.RE
.RE
.SS "PROCESS CONTROLLING COMMANDS"
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBPAUSE;\fR
.RS 4
.sp
PgBouncer tries to disconnect from all servers, first waiting for all queries to complete\&. The command will not return before all queries are finished\&. To be used at the time of database restart\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSUSPEND;\fR
.RS 4
.sp
All socket buffers are flushed and PgBouncer stops listening for data on them\&. The command will not return before all buffers are empty\&. To be used at the time of PgBouncer online reboot\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBRESUME;\fR
.RS 4
.sp
Resume work from previous PAUSE or SUSPEND command\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSHUTDOWN;\fR
.RS 4
.sp
The PgBouncer process will exit\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBRELOAD;\fR
.RS 4
.sp
The PgBouncer process will reload its configuration file and update changeable settings\&.
.RE
.SS "SIGNALS"
.PP
SIGHUP
.RS 4
Reload config\&. Same as issuing command
RELOAD;
on console\&.
.RE
.PP
SIGINT
.RS 4
Safe shutdown\&. Same as issuing
PAUSE;
and
SHUTDOWN;
on console\&.
.RE
.PP
SIGTERM
.RS 4
Immediate shutdown\&. Same as issuing
SHUTDOWN;
on console\&.
.RE
.SS "LIBEVENT SETTINGS"
.sp
From libevent docs:
.sp
.if n \{\
.RS 4
.\}
.nf
It is possible to disable support for epoll, kqueue, devpoll, poll
or select by setting the environment variable EVENT_NOEPOLL,
EVENT_NOKQUEUE, EVENT_NODEVPOLL, EVENT_NOPOLL or EVENT_NOSELECT,
respectively\&.
.fi
.if n \{\
.RE
.\}
.sp
.if n \{\
.RS 4
.\}
.nf
By setting the environment variable EVENT_SHOW_METHOD, libevent
displays the kernel notification method that it uses\&.
.fi
.if n \{\
.RE
.\}
.SH "SEE ALSO"
.sp
pgbouncer(5) \- manpage of configuration settings descriptions\&.
.sp
\m[blue]\fBhttp://pgbouncer\&.projects\&.postgresql\&.org/doc/\fR\m[]
.sp
\m[blue]\fBhttps://developer\&.skype\&.com/SkypeGarage/DbProjects/PgBouncer\fR\m[]
|