├── haproxy.cfg ├── pg_hba.conf ├── pg_hba.conf.orig ├── postgresql.conf ├── postgresql.conf.orig ├── postgresql.conf.repli ├── repli-config-add-replica.sh ├── repli-config-start-haproxy.sh ├── repli-config-start-master.sh ├── rpmbuild ├── RPMS │ └── x86_64 │ │ ├── haproxy-1.5.11-1.el6.x86_64.rpm │ │ └── haproxy-debuginfo-1.5.11-1.el6.x86_64.rpm ├── SPECS │ └── haproxy.spec └── SRPMS │ └── haproxy-1.5.11-1.el6.src.rpm ├── ut-stat-replication └── ut-stat-xact /haproxy.cfg: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------- 2 | # Example configuration for a possible web application. See the 3 | # full configuration options online. 4 | # 5 | # http://haproxy.1wt.eu/download/1.4/doc/configuration.txt 6 | # 7 | #--------------------------------------------------------------------- 8 | 9 | #--------------------------------------------------------------------- 10 | # Global settings 11 | #--------------------------------------------------------------------- 12 | global 13 | # to have these messages end up in /var/log/haproxy.log you will 14 | # need to: 15 | # 16 | # 1) configure syslog to accept network log events. This is done 17 | # by adding the '-r' option to the SYSLOGD_OPTIONS in 18 | # /etc/sysconfig/syslog 19 | # 20 | # 2) configure local2 events to go to the /var/log/haproxy.log 21 | # file. A line like the following can be added to 22 | # /etc/sysconfig/syslog 23 | # 24 | # local2.* /var/log/haproxy.log 25 | # 26 | log 127.0.0.1 local2 27 | 28 | chroot /var/lib/haproxy 29 | pidfile /var/run/haproxy.pid 30 | maxconn 4000 31 | user haproxy 32 | group haproxy 33 | daemon 34 | 35 | # turn on stats unix socket 36 | stats socket /var/lib/haproxy/stats 37 | 38 | #--------------------------------------------------------------------- 39 | # common defaults that all the 'listen' and 'backend' sections will 40 | # use if not designated in their block 41 | #--------------------------------------------------------------------- 42 | defaults 43 | mode tcp 44 | # mode http 45 | log global 46 | # option httplog 47 | # option dontlognull 48 | # option http-server-close 49 | # option forwardfor except 127.0.0.0/8 50 | # option redispatch 51 | retries 3 52 | # timeout http-request 10s 53 | timeout queue 1m 54 | timeout connect 10s 55 | timeout client 1m 56 | timeout server 1m 57 | # timeout http-keep-alive 10s 58 | timeout check 5s 59 | maxconn 3000 60 | 61 | #--------------------------------------------------------------------- 62 | # main frontend which proxys to the backends 63 | #--------------------------------------------------------------------- 64 | #frontend main *:5000 65 | # acl url_static path_beg -i /static /images /javascript /stylesheets 66 | # acl url_static path_end -i .jpg .gif .png .css .js 67 | 68 | # use_backend static if url_static 69 | # default_backend app 70 | 71 | listen pgsql 0.0.0.0:15432 72 | mode tcp 73 | balance roundrobin 74 | 75 | # Add PostgreSQL replica here. 76 | option pgsql-check user snaga 77 | server replica1 127.0.0.1:5433 check inter 10000 78 | server replica2 127.0.0.1:5434 check inter 10000 79 | server replica3 127.0.0.1:5435 check inter 10000 80 | 81 | #listen stats 127.0.0.1:6080 82 | listen stats *:6080 83 | mode http 84 | log global 85 | 86 | maxconn 10 87 | 88 | timeout client 100s 89 | timeout server 100s 90 | timeout connect 100s 91 | timeout queue 100s 92 | 93 | stats enable 94 | stats hide-version 95 | stats refresh 30s 96 | stats show-node 97 | # stats auth admin:password 98 | stats uri /stats 99 | 100 | #--------------------------------------------------------------------- 101 | # static backend for serving up images, stylesheets and such 102 | #--------------------------------------------------------------------- 103 | #backend static 104 | # balance roundrobin 105 | # server static 127.0.0.1:4331 check 106 | 107 | #--------------------------------------------------------------------- 108 | # round robin balancing between the various backends 109 | #--------------------------------------------------------------------- 110 | #backend app 111 | # balance roundrobin 112 | # server app1 127.0.0.1:5001 check 113 | # server app2 127.0.0.1:5002 check 114 | # server app3 127.0.0.1:5003 check 115 | # server app4 127.0.0.1:5004 check 116 | -------------------------------------------------------------------------------- /pg_hba.conf: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the PostgreSQL 5 | # documentation for a complete description of this file. A short 6 | # synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTIONS] 13 | # host DATABASE USER ADDRESS METHOD [OPTIONS] 14 | # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] 15 | # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] 16 | # 17 | # (The uppercase items must be replaced by actual values.) 18 | # 19 | # The first field is the connection type: "local" is a Unix-domain 20 | # socket, "host" is either a plain or SSL-encrypted TCP/IP socket, 21 | # "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a 22 | # plain TCP/IP socket. 23 | # 24 | # DATABASE can be "all", "sameuser", "samerole", "replication", a 25 | # database name, or a comma-separated list thereof. The "all" 26 | # keyword does not match "replication". Access to replication 27 | # must be enabled in a separate record (see example below). 28 | # 29 | # USER can be "all", a user name, a group name prefixed with "+", or a 30 | # comma-separated list thereof. In both the DATABASE and USER fields 31 | # you can also write a file name prefixed with "@" to include names 32 | # from a separate file. 33 | # 34 | # ADDRESS specifies the set of hosts the record matches. It can be a 35 | # host name, or it is made up of an IP address and a CIDR mask that is 36 | # an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that 37 | # specifies the number of significant bits in the mask. A host name 38 | # that starts with a dot (.) matches a suffix of the actual host name. 39 | # Alternatively, you can write an IP address and netmask in separate 40 | # columns to specify the set of hosts. Instead of a CIDR-address, you 41 | # can write "samehost" to match any of the server's own IP addresses, 42 | # or "samenet" to match any address in any subnet that the server is 43 | # directly connected to. 44 | # 45 | # METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", 46 | # "ident", "peer", "pam", "ldap", "radius" or "cert". Note that 47 | # "password" sends passwords in clear text; "md5" is preferred since 48 | # it sends encrypted passwords. 49 | # 50 | # OPTIONS are a set of options for the authentication in the format 51 | # NAME=VALUE. The available options depend on the different 52 | # authentication methods -- refer to the "Client Authentication" 53 | # section in the documentation for a list of which options are 54 | # available for which authentication methods. 55 | # 56 | # Database and user names containing spaces, commas, quotes and other 57 | # special characters must be quoted. Quoting one of the keywords 58 | # "all", "sameuser", "samerole" or "replication" makes the name lose 59 | # its special character, and just match a database or username with 60 | # that name. 61 | # 62 | # This file is read on server startup and when the postmaster receives 63 | # a SIGHUP signal. If you edit the file on a running system, you have 64 | # to SIGHUP the postmaster for the changes to take effect. You can 65 | # use "pg_ctl reload" to do that. 66 | 67 | # Put your actual configuration here 68 | # ---------------------------------- 69 | # 70 | # If you want to allow non-local connections, you need to add more 71 | # "host" records. In that case you will also need to make PostgreSQL 72 | # listen on a non-local interface via the listen_addresses 73 | # configuration parameter, or via the -i or -h command line switches. 74 | 75 | # CAUTION: Configuring the system for local "trust" authentication 76 | # allows any local user to connect as any PostgreSQL user, including 77 | # the database superuser. If you do not trust all your local users, 78 | # use another authentication method. 79 | 80 | 81 | # TYPE DATABASE USER ADDRESS METHOD 82 | 83 | # "local" is for Unix domain socket connections only 84 | local all all trust 85 | # IPv4 local connections: 86 | host all all 127.0.0.1/32 trust 87 | # IPv6 local connections: 88 | host all all ::1/128 trust 89 | # Allow replication connections from localhost, by a user with the 90 | # replication privilege. 91 | #local replication snaga trust 92 | host replication snaga 127.0.0.1/32 trust 93 | #host replication snaga ::1/128 trust 94 | -------------------------------------------------------------------------------- /pg_hba.conf.orig: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the PostgreSQL 5 | # documentation for a complete description of this file. A short 6 | # synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTIONS] 13 | # host DATABASE USER ADDRESS METHOD [OPTIONS] 14 | # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] 15 | # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] 16 | # 17 | # (The uppercase items must be replaced by actual values.) 18 | # 19 | # The first field is the connection type: "local" is a Unix-domain 20 | # socket, "host" is either a plain or SSL-encrypted TCP/IP socket, 21 | # "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a 22 | # plain TCP/IP socket. 23 | # 24 | # DATABASE can be "all", "sameuser", "samerole", "replication", a 25 | # database name, or a comma-separated list thereof. The "all" 26 | # keyword does not match "replication". Access to replication 27 | # must be enabled in a separate record (see example below). 28 | # 29 | # USER can be "all", a user name, a group name prefixed with "+", or a 30 | # comma-separated list thereof. In both the DATABASE and USER fields 31 | # you can also write a file name prefixed with "@" to include names 32 | # from a separate file. 33 | # 34 | # ADDRESS specifies the set of hosts the record matches. It can be a 35 | # host name, or it is made up of an IP address and a CIDR mask that is 36 | # an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that 37 | # specifies the number of significant bits in the mask. A host name 38 | # that starts with a dot (.) matches a suffix of the actual host name. 39 | # Alternatively, you can write an IP address and netmask in separate 40 | # columns to specify the set of hosts. Instead of a CIDR-address, you 41 | # can write "samehost" to match any of the server's own IP addresses, 42 | # or "samenet" to match any address in any subnet that the server is 43 | # directly connected to. 44 | # 45 | # METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", 46 | # "ident", "peer", "pam", "ldap", "radius" or "cert". Note that 47 | # "password" sends passwords in clear text; "md5" is preferred since 48 | # it sends encrypted passwords. 49 | # 50 | # OPTIONS are a set of options for the authentication in the format 51 | # NAME=VALUE. The available options depend on the different 52 | # authentication methods -- refer to the "Client Authentication" 53 | # section in the documentation for a list of which options are 54 | # available for which authentication methods. 55 | # 56 | # Database and user names containing spaces, commas, quotes and other 57 | # special characters must be quoted. Quoting one of the keywords 58 | # "all", "sameuser", "samerole" or "replication" makes the name lose 59 | # its special character, and just match a database or username with 60 | # that name. 61 | # 62 | # This file is read on server startup and when the postmaster receives 63 | # a SIGHUP signal. If you edit the file on a running system, you have 64 | # to SIGHUP the postmaster for the changes to take effect. You can 65 | # use "pg_ctl reload" to do that. 66 | 67 | # Put your actual configuration here 68 | # ---------------------------------- 69 | # 70 | # If you want to allow non-local connections, you need to add more 71 | # "host" records. In that case you will also need to make PostgreSQL 72 | # listen on a non-local interface via the listen_addresses 73 | # configuration parameter, or via the -i or -h command line switches. 74 | 75 | # CAUTION: Configuring the system for local "trust" authentication 76 | # allows any local user to connect as any PostgreSQL user, including 77 | # the database superuser. If you do not trust all your local users, 78 | # use another authentication method. 79 | 80 | 81 | # TYPE DATABASE USER ADDRESS METHOD 82 | 83 | # "local" is for Unix domain socket connections only 84 | local all all trust 85 | # IPv4 local connections: 86 | host all all 127.0.0.1/32 trust 87 | # IPv6 local connections: 88 | host all all ::1/128 trust 89 | # Allow replication connections from localhost, by a user with the 90 | # replication privilege. 91 | #local replication snaga trust 92 | #host replication snaga 127.0.0.1/32 trust 93 | #host replication snaga ::1/128 trust 94 | -------------------------------------------------------------------------------- /postgresql.conf: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # TB = terabytes h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | #data_directory = 'ConfigDir' # use data in another directory 42 | # (change requires restart) 43 | #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | #external_pid_file = '' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | listen_addresses = '*' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost'; use '*' for all 62 | # (change requires restart) 63 | port = 5432 # (change requires restart) 64 | max_connections = 100 # (change requires restart) 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 66 | # connection slot, plus lock space (see max_locks_per_transaction). 67 | #superuser_reserved_connections = 3 # (change requires restart) 68 | #unix_socket_directories = '/tmp' # comma-separated list of directories 69 | # (change requires restart) 70 | #unix_socket_group = '' # (change requires restart) 71 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 72 | # (change requires restart) 73 | #bonjour = off # advertise server via Bonjour 74 | # (change requires restart) 75 | #bonjour_name = '' # defaults to the computer name 76 | # (change requires restart) 77 | 78 | # - Security and Authentication - 79 | 80 | #authentication_timeout = 1min # 1s-600s 81 | #ssl = off # (change requires restart) 82 | #ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers 83 | # (change requires restart) 84 | #ssl_prefer_server_ciphers = on # (change requires restart) 85 | #ssl_ecdh_curve = 'prime256v1' # (change requires restart) 86 | #ssl_renegotiation_limit = 512MB # amount of data between renegotiations 87 | #ssl_cert_file = 'server.crt' # (change requires restart) 88 | #ssl_key_file = 'server.key' # (change requires restart) 89 | #ssl_ca_file = '' # (change requires restart) 90 | #ssl_crl_file = '' # (change requires restart) 91 | #password_encryption = on 92 | #db_user_namespace = off 93 | 94 | # GSSAPI using Kerberos 95 | #krb_server_keyfile = '' 96 | #krb_caseins_users = off 97 | 98 | # - TCP Keepalives - 99 | # see "man 7 tcp" for details 100 | 101 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 102 | # 0 selects the system default 103 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 104 | # 0 selects the system default 105 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 106 | # 0 selects the system default 107 | 108 | 109 | #------------------------------------------------------------------------------ 110 | # RESOURCE USAGE (except WAL) 111 | #------------------------------------------------------------------------------ 112 | 113 | # - Memory - 114 | 115 | shared_buffers = 128MB # min 128kB 116 | # (change requires restart) 117 | #huge_pages = try # on, off, or try 118 | # (change requires restart) 119 | #temp_buffers = 8MB # min 800kB 120 | #max_prepared_transactions = 0 # zero disables the feature 121 | # (change requires restart) 122 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 123 | # per transaction slot, plus lock space (see max_locks_per_transaction). 124 | # It is not advisable to set max_prepared_transactions nonzero unless you 125 | # actively intend to use prepared transactions. 126 | #work_mem = 4MB # min 64kB 127 | #maintenance_work_mem = 64MB # min 1MB 128 | #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem 129 | #max_stack_depth = 2MB # min 100kB 130 | dynamic_shared_memory_type = posix # the default is the first option 131 | # supported by the operating system: 132 | # posix 133 | # sysv 134 | # windows 135 | # mmap 136 | # use none to disable dynamic shared memory 137 | 138 | # - Disk - 139 | 140 | #temp_file_limit = -1 # limits per-session temp file space 141 | # in kB, or -1 for no limit 142 | 143 | # - Kernel Resource Usage - 144 | 145 | #max_files_per_process = 1000 # min 25 146 | # (change requires restart) 147 | #shared_preload_libraries = '' # (change requires restart) 148 | 149 | # - Cost-Based Vacuum Delay - 150 | 151 | #vacuum_cost_delay = 0 # 0-100 milliseconds 152 | #vacuum_cost_page_hit = 1 # 0-10000 credits 153 | #vacuum_cost_page_miss = 10 # 0-10000 credits 154 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 155 | #vacuum_cost_limit = 200 # 1-10000 credits 156 | 157 | # - Background Writer - 158 | 159 | #bgwriter_delay = 200ms # 10-10000ms between rounds 160 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 161 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 162 | 163 | # - Asynchronous Behavior - 164 | 165 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 166 | #max_worker_processes = 8 167 | 168 | 169 | #------------------------------------------------------------------------------ 170 | # WRITE AHEAD LOG 171 | #------------------------------------------------------------------------------ 172 | 173 | # - Settings - 174 | 175 | wal_level = hot_standby # minimal, archive, hot_standby, or logical 176 | # (change requires restart) 177 | #fsync = on # turns forced synchronization on or off 178 | #synchronous_commit = on # synchronization level; 179 | # off, local, remote_write, or on 180 | #wal_sync_method = fsync # the default is the first option 181 | # supported by the operating system: 182 | # open_datasync 183 | # fdatasync (default on Linux) 184 | # fsync 185 | # fsync_writethrough 186 | # open_sync 187 | #full_page_writes = on # recover from partial page writes 188 | #wal_log_hints = off # also do full page writes of non-critical updates 189 | # (change requires restart) 190 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 191 | # (change requires restart) 192 | #wal_writer_delay = 200ms # 1-10000 milliseconds 193 | 194 | #commit_delay = 0 # range 0-100000, in microseconds 195 | #commit_siblings = 5 # range 1-1000 196 | 197 | # - Checkpoints - 198 | 199 | checkpoint_segments = 32 # in logfile segments, min 1, 16MB each 200 | checkpoint_timeout = 60min # range 30s-1h 201 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 202 | #checkpoint_warning = 30s # 0 disables 203 | 204 | # - Archiving - 205 | 206 | #archive_mode = off # allows archiving to be done 207 | # (change requires restart) 208 | #archive_command = '' # command to use to archive a logfile segment 209 | # placeholders: %p = path of file to archive 210 | # %f = file name only 211 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 212 | #archive_timeout = 0 # force a logfile segment switch after this 213 | # number of seconds; 0 disables 214 | 215 | 216 | #------------------------------------------------------------------------------ 217 | # REPLICATION 218 | #------------------------------------------------------------------------------ 219 | 220 | # - Sending Server(s) - 221 | 222 | # Set these on the master and on any standby that will send replication data. 223 | 224 | max_wal_senders = 10 # max number of walsender processes 225 | # (change requires restart) 226 | wal_keep_segments = 8 # in logfile segments, 16MB each; 0 disables 227 | wal_sender_timeout = 60s # in milliseconds; 0 disables 228 | 229 | #max_replication_slots = 0 # max number of replication slots 230 | # (change requires restart) 231 | 232 | # - Master Server - 233 | 234 | # These settings are ignored on a standby server. 235 | 236 | #synchronous_standby_names = 'prod1,prod2' # standby servers that provide sync rep 237 | # comma-separated list of application_name 238 | # from standby(s); '*' = all 239 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 240 | 241 | # - Standby Servers - 242 | 243 | # These settings are ignored on a master server. 244 | 245 | hot_standby = on # "on" allows queries during recovery 246 | # (change requires restart) 247 | max_standby_archive_delay = 30s # max delay before canceling queries 248 | # when reading WAL from archive; 249 | # -1 allows indefinite delay 250 | max_standby_streaming_delay = 30s # max delay before canceling queries 251 | # when reading streaming WAL; 252 | # -1 allows indefinite delay 253 | wal_receiver_status_interval = 10s # send replies at least this often 254 | # 0 disables 255 | hot_standby_feedback = off # send info from standby to prevent 256 | # query conflicts 257 | wal_receiver_timeout = 60s # time that receiver waits for 258 | # communication from master 259 | # in milliseconds; 0 disables 260 | 261 | 262 | #------------------------------------------------------------------------------ 263 | # QUERY TUNING 264 | #------------------------------------------------------------------------------ 265 | 266 | # - Planner Method Configuration - 267 | 268 | #enable_bitmapscan = on 269 | #enable_hashagg = on 270 | #enable_hashjoin = on 271 | #enable_indexscan = on 272 | #enable_indexonlyscan = on 273 | #enable_material = on 274 | #enable_mergejoin = on 275 | #enable_nestloop = on 276 | #enable_seqscan = on 277 | #enable_sort = on 278 | #enable_tidscan = on 279 | 280 | # - Planner Cost Constants - 281 | 282 | #seq_page_cost = 1.0 # measured on an arbitrary scale 283 | #random_page_cost = 4.0 # same scale as above 284 | #cpu_tuple_cost = 0.01 # same scale as above 285 | #cpu_index_tuple_cost = 0.005 # same scale as above 286 | #cpu_operator_cost = 0.0025 # same scale as above 287 | #effective_cache_size = 4GB 288 | 289 | # - Genetic Query Optimizer - 290 | 291 | #geqo = on 292 | #geqo_threshold = 12 293 | #geqo_effort = 5 # range 1-10 294 | #geqo_pool_size = 0 # selects default based on effort 295 | #geqo_generations = 0 # selects default based on effort 296 | #geqo_selection_bias = 2.0 # range 1.5-2.0 297 | #geqo_seed = 0.0 # range 0.0-1.0 298 | 299 | # - Other Planner Options - 300 | 301 | #default_statistics_target = 100 # range 1-10000 302 | #constraint_exclusion = partition # on, off, or partition 303 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 304 | #from_collapse_limit = 8 305 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 306 | # JOIN clauses 307 | 308 | 309 | #------------------------------------------------------------------------------ 310 | # ERROR REPORTING AND LOGGING 311 | #------------------------------------------------------------------------------ 312 | 313 | # - Where to Log - 314 | 315 | log_destination = 'stderr' # Valid values are combinations of 316 | # stderr, csvlog, syslog, and eventlog, 317 | # depending on platform. csvlog 318 | # requires logging_collector to be on. 319 | 320 | # This is used when logging to stderr: 321 | logging_collector = on # Enable capturing of stderr and csvlog 322 | # into log files. Required to be on for 323 | # csvlogs. 324 | # (change requires restart) 325 | 326 | # These are only used if logging_collector is on: 327 | log_directory = 'pg_log' # directory where log files are written, 328 | # can be absolute or relative to PGDATA 329 | log_filename = 'postgresql-%d.log' # log file name pattern, 330 | # can include strftime() escapes 331 | #log_file_mode = 0600 # creation mode for log files, 332 | # begin with 0 to use octal notation 333 | log_truncate_on_rotation = on # If on, an existing log file with the 334 | # same name as the new log file will be 335 | # truncated rather than appended to. 336 | # But such truncation only occurs on 337 | # time-driven rotation, not on restarts 338 | # or size-driven rotation. Default is 339 | # off, meaning append to existing files 340 | # in all cases. 341 | log_rotation_age = 1d # Automatic rotation of logfiles will 342 | # happen after that time. 0 disables. 343 | log_rotation_size = 0 # Automatic rotation of logfiles will 344 | # happen after that much log output. 345 | # 0 disables. 346 | 347 | # These are relevant when logging to syslog: 348 | #syslog_facility = 'LOCAL0' 349 | #syslog_ident = 'postgres' 350 | 351 | # This is only relevant when logging to eventlog (win32): 352 | #event_source = 'PostgreSQL' 353 | 354 | # - When to Log - 355 | 356 | #client_min_messages = notice # values in order of decreasing detail: 357 | # debug5 358 | # debug4 359 | # debug3 360 | # debug2 361 | # debug1 362 | # log 363 | # notice 364 | # warning 365 | # error 366 | 367 | #log_min_messages = warning # values in order of decreasing detail: 368 | # debug5 369 | # debug4 370 | # debug3 371 | # debug2 372 | # debug1 373 | # info 374 | # notice 375 | # warning 376 | # error 377 | # log 378 | # fatal 379 | # panic 380 | 381 | #log_min_error_statement = error # values in order of decreasing detail: 382 | # debug5 383 | # debug4 384 | # debug3 385 | # debug2 386 | # debug1 387 | # info 388 | # notice 389 | # warning 390 | # error 391 | # log 392 | # fatal 393 | # panic (effectively off) 394 | 395 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 396 | # and their durations, > 0 logs only 397 | # statements running at least this number 398 | # of milliseconds 399 | 400 | 401 | # - What to Log - 402 | 403 | #debug_print_parse = off 404 | #debug_print_rewritten = off 405 | #debug_print_plan = off 406 | #debug_pretty_print = on 407 | #log_checkpoints = off 408 | #log_connections = off 409 | #log_disconnections = off 410 | #log_duration = off 411 | #log_error_verbosity = default # terse, default, or verbose messages 412 | #log_hostname = off 413 | log_line_prefix = '[%t] %p: %u/%d ' # special values: 414 | # %a = application name 415 | # %u = user name 416 | # %d = database name 417 | # %r = remote host and port 418 | # %h = remote host 419 | # %p = process ID 420 | # %t = timestamp without milliseconds 421 | # %m = timestamp with milliseconds 422 | # %i = command tag 423 | # %e = SQL state 424 | # %c = session ID 425 | # %l = session line number 426 | # %s = session start timestamp 427 | # %v = virtual transaction ID 428 | # %x = transaction ID (0 if none) 429 | # %q = stop here in non-session 430 | # processes 431 | # %% = '%' 432 | # e.g. '<%u%%%d> ' 433 | #log_lock_waits = off # log lock waits >= deadlock_timeout 434 | #log_statement = 'none' # none, ddl, mod, all 435 | #log_temp_files = -1 # log temporary files equal or larger 436 | # than the specified size in kilobytes; 437 | # -1 disables, 0 logs all temp files 438 | log_timezone = 'Asia/Tokyo' 439 | 440 | 441 | #------------------------------------------------------------------------------ 442 | # RUNTIME STATISTICS 443 | #------------------------------------------------------------------------------ 444 | 445 | # - Query/Index Statistics Collector - 446 | 447 | #track_activities = on 448 | #track_counts = on 449 | #track_io_timing = off 450 | #track_functions = none # none, pl, all 451 | #track_activity_query_size = 1024 # (change requires restart) 452 | #update_process_title = on 453 | #stats_temp_directory = 'pg_stat_tmp' 454 | 455 | 456 | # - Statistics Monitoring - 457 | 458 | #log_parser_stats = off 459 | #log_planner_stats = off 460 | #log_executor_stats = off 461 | #log_statement_stats = off 462 | 463 | 464 | #------------------------------------------------------------------------------ 465 | # AUTOVACUUM PARAMETERS 466 | #------------------------------------------------------------------------------ 467 | 468 | #autovacuum = on # Enable autovacuum subprocess? 'on' 469 | # requires track_counts to also be on. 470 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 471 | # their durations, > 0 logs only 472 | # actions running at least this number 473 | # of milliseconds. 474 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 475 | # (change requires restart) 476 | #autovacuum_naptime = 1min # time between autovacuum runs 477 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 478 | # vacuum 479 | #autovacuum_analyze_threshold = 50 # min number of row updates before 480 | # analyze 481 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 482 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 483 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 484 | # (change requires restart) 485 | #autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age 486 | # before forced vacuum 487 | # (change requires restart) 488 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 489 | # autovacuum, in milliseconds; 490 | # -1 means use vacuum_cost_delay 491 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 492 | # autovacuum, -1 means use 493 | # vacuum_cost_limit 494 | 495 | 496 | #------------------------------------------------------------------------------ 497 | # CLIENT CONNECTION DEFAULTS 498 | #------------------------------------------------------------------------------ 499 | 500 | # - Statement Behavior - 501 | 502 | #search_path = '"$user",public' # schema names 503 | #default_tablespace = '' # a tablespace name, '' uses the default 504 | #temp_tablespaces = '' # a list of tablespace names, '' uses 505 | # only default tablespace 506 | #check_function_bodies = on 507 | #default_transaction_isolation = 'read committed' 508 | #default_transaction_read_only = off 509 | #default_transaction_deferrable = off 510 | #session_replication_role = 'origin' 511 | #statement_timeout = 0 # in milliseconds, 0 is disabled 512 | #lock_timeout = 0 # in milliseconds, 0 is disabled 513 | #vacuum_freeze_min_age = 50000000 514 | #vacuum_freeze_table_age = 150000000 515 | #vacuum_multixact_freeze_min_age = 5000000 516 | #vacuum_multixact_freeze_table_age = 150000000 517 | #bytea_output = 'hex' # hex, escape 518 | #xmlbinary = 'base64' 519 | #xmloption = 'content' 520 | 521 | # - Locale and Formatting - 522 | 523 | datestyle = 'iso, mdy' 524 | #intervalstyle = 'postgres' 525 | timezone = 'Asia/Tokyo' 526 | #timezone_abbreviations = 'Default' # Select the set of available time zone 527 | # abbreviations. Currently, there are 528 | # Default 529 | # Australia (historical usage) 530 | # India 531 | # You can create your own file in 532 | # share/timezonesets/. 533 | #extra_float_digits = 0 # min -15, max 3 534 | #client_encoding = sql_ascii # actually, defaults to database 535 | # encoding 536 | 537 | # These settings are initialized by initdb, but they can be changed. 538 | lc_messages = 'C' # locale for system error message 539 | # strings 540 | lc_monetary = 'C' # locale for monetary formatting 541 | lc_numeric = 'C' # locale for number formatting 542 | lc_time = 'C' # locale for time formatting 543 | 544 | # default configuration for text search 545 | default_text_search_config = 'pg_catalog.english' 546 | 547 | # - Other Defaults - 548 | 549 | #dynamic_library_path = '$libdir' 550 | #local_preload_libraries = '' 551 | #session_preload_libraries = '' 552 | 553 | 554 | #------------------------------------------------------------------------------ 555 | # LOCK MANAGEMENT 556 | #------------------------------------------------------------------------------ 557 | 558 | #deadlock_timeout = 1s 559 | #max_locks_per_transaction = 64 # min 10 560 | # (change requires restart) 561 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 562 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 563 | # lock table slots. 564 | #max_pred_locks_per_transaction = 64 # min 10 565 | # (change requires restart) 566 | 567 | 568 | #------------------------------------------------------------------------------ 569 | # VERSION/PLATFORM COMPATIBILITY 570 | #------------------------------------------------------------------------------ 571 | 572 | # - Previous PostgreSQL Versions - 573 | 574 | #array_nulls = on 575 | #backslash_quote = safe_encoding # on, off, or safe_encoding 576 | #default_with_oids = off 577 | #escape_string_warning = on 578 | #lo_compat_privileges = off 579 | #quote_all_identifiers = off 580 | #sql_inheritance = on 581 | #standard_conforming_strings = on 582 | #synchronize_seqscans = on 583 | 584 | # - Other Platforms and Clients - 585 | 586 | #transform_null_equals = off 587 | 588 | 589 | #------------------------------------------------------------------------------ 590 | # ERROR HANDLING 591 | #------------------------------------------------------------------------------ 592 | 593 | #exit_on_error = off # terminate session on any error? 594 | #restart_after_crash = on # reinitialize after backend crash? 595 | 596 | 597 | #------------------------------------------------------------------------------ 598 | # CONFIG FILE INCLUDES 599 | #------------------------------------------------------------------------------ 600 | 601 | # These options allow settings to be loaded from files other than the 602 | # default postgresql.conf. 603 | 604 | #include_dir = 'conf.d' # include files ending in '.conf' from 605 | # directory 'conf.d' 606 | #include_if_exists = 'exists.conf' # include file only if it exists 607 | #include = 'special.conf' # include file 608 | 609 | 610 | #------------------------------------------------------------------------------ 611 | # CUSTOMIZED OPTIONS 612 | #------------------------------------------------------------------------------ 613 | 614 | # Add settings for extensions here 615 | -------------------------------------------------------------------------------- /postgresql.conf.orig: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # TB = terabytes h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | #data_directory = 'ConfigDir' # use data in another directory 42 | # (change requires restart) 43 | #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | #external_pid_file = '' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | #listen_addresses = 'localhost' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost'; use '*' for all 62 | # (change requires restart) 63 | #port = 5432 # (change requires restart) 64 | max_connections = 100 # (change requires restart) 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 66 | # connection slot, plus lock space (see max_locks_per_transaction). 67 | #superuser_reserved_connections = 3 # (change requires restart) 68 | #unix_socket_directories = '/tmp' # comma-separated list of directories 69 | # (change requires restart) 70 | #unix_socket_group = '' # (change requires restart) 71 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 72 | # (change requires restart) 73 | #bonjour = off # advertise server via Bonjour 74 | # (change requires restart) 75 | #bonjour_name = '' # defaults to the computer name 76 | # (change requires restart) 77 | 78 | # - Security and Authentication - 79 | 80 | #authentication_timeout = 1min # 1s-600s 81 | #ssl = off # (change requires restart) 82 | #ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers 83 | # (change requires restart) 84 | #ssl_prefer_server_ciphers = on # (change requires restart) 85 | #ssl_ecdh_curve = 'prime256v1' # (change requires restart) 86 | #ssl_renegotiation_limit = 512MB # amount of data between renegotiations 87 | #ssl_cert_file = 'server.crt' # (change requires restart) 88 | #ssl_key_file = 'server.key' # (change requires restart) 89 | #ssl_ca_file = '' # (change requires restart) 90 | #ssl_crl_file = '' # (change requires restart) 91 | #password_encryption = on 92 | #db_user_namespace = off 93 | 94 | # GSSAPI using Kerberos 95 | #krb_server_keyfile = '' 96 | #krb_caseins_users = off 97 | 98 | # - TCP Keepalives - 99 | # see "man 7 tcp" for details 100 | 101 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 102 | # 0 selects the system default 103 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 104 | # 0 selects the system default 105 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 106 | # 0 selects the system default 107 | 108 | 109 | #------------------------------------------------------------------------------ 110 | # RESOURCE USAGE (except WAL) 111 | #------------------------------------------------------------------------------ 112 | 113 | # - Memory - 114 | 115 | shared_buffers = 128MB # min 128kB 116 | # (change requires restart) 117 | #huge_pages = try # on, off, or try 118 | # (change requires restart) 119 | #temp_buffers = 8MB # min 800kB 120 | #max_prepared_transactions = 0 # zero disables the feature 121 | # (change requires restart) 122 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 123 | # per transaction slot, plus lock space (see max_locks_per_transaction). 124 | # It is not advisable to set max_prepared_transactions nonzero unless you 125 | # actively intend to use prepared transactions. 126 | #work_mem = 4MB # min 64kB 127 | #maintenance_work_mem = 64MB # min 1MB 128 | #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem 129 | #max_stack_depth = 2MB # min 100kB 130 | dynamic_shared_memory_type = posix # the default is the first option 131 | # supported by the operating system: 132 | # posix 133 | # sysv 134 | # windows 135 | # mmap 136 | # use none to disable dynamic shared memory 137 | 138 | # - Disk - 139 | 140 | #temp_file_limit = -1 # limits per-session temp file space 141 | # in kB, or -1 for no limit 142 | 143 | # - Kernel Resource Usage - 144 | 145 | #max_files_per_process = 1000 # min 25 146 | # (change requires restart) 147 | #shared_preload_libraries = '' # (change requires restart) 148 | 149 | # - Cost-Based Vacuum Delay - 150 | 151 | #vacuum_cost_delay = 0 # 0-100 milliseconds 152 | #vacuum_cost_page_hit = 1 # 0-10000 credits 153 | #vacuum_cost_page_miss = 10 # 0-10000 credits 154 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 155 | #vacuum_cost_limit = 200 # 1-10000 credits 156 | 157 | # - Background Writer - 158 | 159 | #bgwriter_delay = 200ms # 10-10000ms between rounds 160 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 161 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 162 | 163 | # - Asynchronous Behavior - 164 | 165 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 166 | #max_worker_processes = 8 167 | 168 | 169 | #------------------------------------------------------------------------------ 170 | # WRITE AHEAD LOG 171 | #------------------------------------------------------------------------------ 172 | 173 | # - Settings - 174 | 175 | #wal_level = minimal # minimal, archive, hot_standby, or logical 176 | # (change requires restart) 177 | #fsync = on # turns forced synchronization on or off 178 | #synchronous_commit = on # synchronization level; 179 | # off, local, remote_write, or on 180 | #wal_sync_method = fsync # the default is the first option 181 | # supported by the operating system: 182 | # open_datasync 183 | # fdatasync (default on Linux) 184 | # fsync 185 | # fsync_writethrough 186 | # open_sync 187 | #full_page_writes = on # recover from partial page writes 188 | #wal_log_hints = off # also do full page writes of non-critical updates 189 | # (change requires restart) 190 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 191 | # (change requires restart) 192 | #wal_writer_delay = 200ms # 1-10000 milliseconds 193 | 194 | #commit_delay = 0 # range 0-100000, in microseconds 195 | #commit_siblings = 5 # range 1-1000 196 | 197 | # - Checkpoints - 198 | 199 | #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each 200 | #checkpoint_timeout = 5min # range 30s-1h 201 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 202 | #checkpoint_warning = 30s # 0 disables 203 | 204 | # - Archiving - 205 | 206 | #archive_mode = off # allows archiving to be done 207 | # (change requires restart) 208 | #archive_command = '' # command to use to archive a logfile segment 209 | # placeholders: %p = path of file to archive 210 | # %f = file name only 211 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 212 | #archive_timeout = 0 # force a logfile segment switch after this 213 | # number of seconds; 0 disables 214 | 215 | 216 | #------------------------------------------------------------------------------ 217 | # REPLICATION 218 | #------------------------------------------------------------------------------ 219 | 220 | # - Sending Server(s) - 221 | 222 | # Set these on the master and on any standby that will send replication data. 223 | 224 | #max_wal_senders = 0 # max number of walsender processes 225 | # (change requires restart) 226 | #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables 227 | #wal_sender_timeout = 60s # in milliseconds; 0 disables 228 | 229 | #max_replication_slots = 0 # max number of replication slots 230 | # (change requires restart) 231 | 232 | # - Master Server - 233 | 234 | # These settings are ignored on a standby server. 235 | 236 | #synchronous_standby_names = '' # standby servers that provide sync rep 237 | # comma-separated list of application_name 238 | # from standby(s); '*' = all 239 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 240 | 241 | # - Standby Servers - 242 | 243 | # These settings are ignored on a master server. 244 | 245 | #hot_standby = off # "on" allows queries during recovery 246 | # (change requires restart) 247 | #max_standby_archive_delay = 30s # max delay before canceling queries 248 | # when reading WAL from archive; 249 | # -1 allows indefinite delay 250 | #max_standby_streaming_delay = 30s # max delay before canceling queries 251 | # when reading streaming WAL; 252 | # -1 allows indefinite delay 253 | #wal_receiver_status_interval = 10s # send replies at least this often 254 | # 0 disables 255 | #hot_standby_feedback = off # send info from standby to prevent 256 | # query conflicts 257 | #wal_receiver_timeout = 60s # time that receiver waits for 258 | # communication from master 259 | # in milliseconds; 0 disables 260 | 261 | 262 | #------------------------------------------------------------------------------ 263 | # QUERY TUNING 264 | #------------------------------------------------------------------------------ 265 | 266 | # - Planner Method Configuration - 267 | 268 | #enable_bitmapscan = on 269 | #enable_hashagg = on 270 | #enable_hashjoin = on 271 | #enable_indexscan = on 272 | #enable_indexonlyscan = on 273 | #enable_material = on 274 | #enable_mergejoin = on 275 | #enable_nestloop = on 276 | #enable_seqscan = on 277 | #enable_sort = on 278 | #enable_tidscan = on 279 | 280 | # - Planner Cost Constants - 281 | 282 | #seq_page_cost = 1.0 # measured on an arbitrary scale 283 | #random_page_cost = 4.0 # same scale as above 284 | #cpu_tuple_cost = 0.01 # same scale as above 285 | #cpu_index_tuple_cost = 0.005 # same scale as above 286 | #cpu_operator_cost = 0.0025 # same scale as above 287 | #effective_cache_size = 4GB 288 | 289 | # - Genetic Query Optimizer - 290 | 291 | #geqo = on 292 | #geqo_threshold = 12 293 | #geqo_effort = 5 # range 1-10 294 | #geqo_pool_size = 0 # selects default based on effort 295 | #geqo_generations = 0 # selects default based on effort 296 | #geqo_selection_bias = 2.0 # range 1.5-2.0 297 | #geqo_seed = 0.0 # range 0.0-1.0 298 | 299 | # - Other Planner Options - 300 | 301 | #default_statistics_target = 100 # range 1-10000 302 | #constraint_exclusion = partition # on, off, or partition 303 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 304 | #from_collapse_limit = 8 305 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 306 | # JOIN clauses 307 | 308 | 309 | #------------------------------------------------------------------------------ 310 | # ERROR REPORTING AND LOGGING 311 | #------------------------------------------------------------------------------ 312 | 313 | # - Where to Log - 314 | 315 | log_destination = 'stderr' # Valid values are combinations of 316 | # stderr, csvlog, syslog, and eventlog, 317 | # depending on platform. csvlog 318 | # requires logging_collector to be on. 319 | 320 | # This is used when logging to stderr: 321 | logging_collector = on # Enable capturing of stderr and csvlog 322 | # into log files. Required to be on for 323 | # csvlogs. 324 | # (change requires restart) 325 | 326 | # These are only used if logging_collector is on: 327 | log_directory = 'pg_log' # directory where log files are written, 328 | # can be absolute or relative to PGDATA 329 | log_filename = 'postgresql-%a.log' # log file name pattern, 330 | # can include strftime() escapes 331 | #log_file_mode = 0600 # creation mode for log files, 332 | # begin with 0 to use octal notation 333 | log_truncate_on_rotation = on # If on, an existing log file with the 334 | # same name as the new log file will be 335 | # truncated rather than appended to. 336 | # But such truncation only occurs on 337 | # time-driven rotation, not on restarts 338 | # or size-driven rotation. Default is 339 | # off, meaning append to existing files 340 | # in all cases. 341 | log_rotation_age = 1d # Automatic rotation of logfiles will 342 | # happen after that time. 0 disables. 343 | log_rotation_size = 0 # Automatic rotation of logfiles will 344 | # happen after that much log output. 345 | # 0 disables. 346 | 347 | # These are relevant when logging to syslog: 348 | #syslog_facility = 'LOCAL0' 349 | #syslog_ident = 'postgres' 350 | 351 | # This is only relevant when logging to eventlog (win32): 352 | #event_source = 'PostgreSQL' 353 | 354 | # - When to Log - 355 | 356 | #client_min_messages = notice # values in order of decreasing detail: 357 | # debug5 358 | # debug4 359 | # debug3 360 | # debug2 361 | # debug1 362 | # log 363 | # notice 364 | # warning 365 | # error 366 | 367 | #log_min_messages = warning # values in order of decreasing detail: 368 | # debug5 369 | # debug4 370 | # debug3 371 | # debug2 372 | # debug1 373 | # info 374 | # notice 375 | # warning 376 | # error 377 | # log 378 | # fatal 379 | # panic 380 | 381 | #log_min_error_statement = error # values in order of decreasing detail: 382 | # debug5 383 | # debug4 384 | # debug3 385 | # debug2 386 | # debug1 387 | # info 388 | # notice 389 | # warning 390 | # error 391 | # log 392 | # fatal 393 | # panic (effectively off) 394 | 395 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 396 | # and their durations, > 0 logs only 397 | # statements running at least this number 398 | # of milliseconds 399 | 400 | 401 | # - What to Log - 402 | 403 | #debug_print_parse = off 404 | #debug_print_rewritten = off 405 | #debug_print_plan = off 406 | #debug_pretty_print = on 407 | #log_checkpoints = off 408 | #log_connections = off 409 | #log_disconnections = off 410 | #log_duration = off 411 | #log_error_verbosity = default # terse, default, or verbose messages 412 | #log_hostname = off 413 | log_line_prefix = '< %m >' # special values: 414 | # %a = application name 415 | # %u = user name 416 | # %d = database name 417 | # %r = remote host and port 418 | # %h = remote host 419 | # %p = process ID 420 | # %t = timestamp without milliseconds 421 | # %m = timestamp with milliseconds 422 | # %i = command tag 423 | # %e = SQL state 424 | # %c = session ID 425 | # %l = session line number 426 | # %s = session start timestamp 427 | # %v = virtual transaction ID 428 | # %x = transaction ID (0 if none) 429 | # %q = stop here in non-session 430 | # processes 431 | # %% = '%' 432 | # e.g. '<%u%%%d> ' 433 | #log_lock_waits = off # log lock waits >= deadlock_timeout 434 | #log_statement = 'none' # none, ddl, mod, all 435 | #log_temp_files = -1 # log temporary files equal or larger 436 | # than the specified size in kilobytes; 437 | # -1 disables, 0 logs all temp files 438 | log_timezone = 'UTC' 439 | 440 | 441 | #------------------------------------------------------------------------------ 442 | # RUNTIME STATISTICS 443 | #------------------------------------------------------------------------------ 444 | 445 | # - Query/Index Statistics Collector - 446 | 447 | #track_activities = on 448 | #track_counts = on 449 | #track_io_timing = off 450 | #track_functions = none # none, pl, all 451 | #track_activity_query_size = 1024 # (change requires restart) 452 | #update_process_title = on 453 | #stats_temp_directory = 'pg_stat_tmp' 454 | 455 | 456 | # - Statistics Monitoring - 457 | 458 | #log_parser_stats = off 459 | #log_planner_stats = off 460 | #log_executor_stats = off 461 | #log_statement_stats = off 462 | 463 | 464 | #------------------------------------------------------------------------------ 465 | # AUTOVACUUM PARAMETERS 466 | #------------------------------------------------------------------------------ 467 | 468 | #autovacuum = on # Enable autovacuum subprocess? 'on' 469 | # requires track_counts to also be on. 470 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 471 | # their durations, > 0 logs only 472 | # actions running at least this number 473 | # of milliseconds. 474 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 475 | # (change requires restart) 476 | #autovacuum_naptime = 1min # time between autovacuum runs 477 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 478 | # vacuum 479 | #autovacuum_analyze_threshold = 50 # min number of row updates before 480 | # analyze 481 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 482 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 483 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 484 | # (change requires restart) 485 | #autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age 486 | # before forced vacuum 487 | # (change requires restart) 488 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 489 | # autovacuum, in milliseconds; 490 | # -1 means use vacuum_cost_delay 491 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 492 | # autovacuum, -1 means use 493 | # vacuum_cost_limit 494 | 495 | 496 | #------------------------------------------------------------------------------ 497 | # CLIENT CONNECTION DEFAULTS 498 | #------------------------------------------------------------------------------ 499 | 500 | # - Statement Behavior - 501 | 502 | #search_path = '"$user",public' # schema names 503 | #default_tablespace = '' # a tablespace name, '' uses the default 504 | #temp_tablespaces = '' # a list of tablespace names, '' uses 505 | # only default tablespace 506 | #check_function_bodies = on 507 | #default_transaction_isolation = 'read committed' 508 | #default_transaction_read_only = off 509 | #default_transaction_deferrable = off 510 | #session_replication_role = 'origin' 511 | #statement_timeout = 0 # in milliseconds, 0 is disabled 512 | #lock_timeout = 0 # in milliseconds, 0 is disabled 513 | #vacuum_freeze_min_age = 50000000 514 | #vacuum_freeze_table_age = 150000000 515 | #vacuum_multixact_freeze_min_age = 5000000 516 | #vacuum_multixact_freeze_table_age = 150000000 517 | #bytea_output = 'hex' # hex, escape 518 | #xmlbinary = 'base64' 519 | #xmloption = 'content' 520 | 521 | # - Locale and Formatting - 522 | 523 | datestyle = 'iso, mdy' 524 | #intervalstyle = 'postgres' 525 | timezone = 'UTC' 526 | #timezone_abbreviations = 'Default' # Select the set of available time zone 527 | # abbreviations. Currently, there are 528 | # Default 529 | # Australia (historical usage) 530 | # India 531 | # You can create your own file in 532 | # share/timezonesets/. 533 | #extra_float_digits = 0 # min -15, max 3 534 | #client_encoding = sql_ascii # actually, defaults to database 535 | # encoding 536 | 537 | # These settings are initialized by initdb, but they can be changed. 538 | lc_messages = 'C' # locale for system error message 539 | # strings 540 | lc_monetary = 'C' # locale for monetary formatting 541 | lc_numeric = 'C' # locale for number formatting 542 | lc_time = 'C' # locale for time formatting 543 | 544 | # default configuration for text search 545 | default_text_search_config = 'pg_catalog.english' 546 | 547 | # - Other Defaults - 548 | 549 | #dynamic_library_path = '$libdir' 550 | #local_preload_libraries = '' 551 | #session_preload_libraries = '' 552 | 553 | 554 | #------------------------------------------------------------------------------ 555 | # LOCK MANAGEMENT 556 | #------------------------------------------------------------------------------ 557 | 558 | #deadlock_timeout = 1s 559 | #max_locks_per_transaction = 64 # min 10 560 | # (change requires restart) 561 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 562 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 563 | # lock table slots. 564 | #max_pred_locks_per_transaction = 64 # min 10 565 | # (change requires restart) 566 | 567 | 568 | #------------------------------------------------------------------------------ 569 | # VERSION/PLATFORM COMPATIBILITY 570 | #------------------------------------------------------------------------------ 571 | 572 | # - Previous PostgreSQL Versions - 573 | 574 | #array_nulls = on 575 | #backslash_quote = safe_encoding # on, off, or safe_encoding 576 | #default_with_oids = off 577 | #escape_string_warning = on 578 | #lo_compat_privileges = off 579 | #quote_all_identifiers = off 580 | #sql_inheritance = on 581 | #standard_conforming_strings = on 582 | #synchronize_seqscans = on 583 | 584 | # - Other Platforms and Clients - 585 | 586 | #transform_null_equals = off 587 | 588 | 589 | #------------------------------------------------------------------------------ 590 | # ERROR HANDLING 591 | #------------------------------------------------------------------------------ 592 | 593 | #exit_on_error = off # terminate session on any error? 594 | #restart_after_crash = on # reinitialize after backend crash? 595 | 596 | 597 | #------------------------------------------------------------------------------ 598 | # CONFIG FILE INCLUDES 599 | #------------------------------------------------------------------------------ 600 | 601 | # These options allow settings to be loaded from files other than the 602 | # default postgresql.conf. 603 | 604 | #include_dir = 'conf.d' # include files ending in '.conf' from 605 | # directory 'conf.d' 606 | #include_if_exists = 'exists.conf' # include file only if it exists 607 | #include = 'special.conf' # include file 608 | 609 | 610 | #------------------------------------------------------------------------------ 611 | # CUSTOMIZED OPTIONS 612 | #------------------------------------------------------------------------------ 613 | 614 | # Add settings for extensions here 615 | -------------------------------------------------------------------------------- /postgresql.conf.repli: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # TB = terabytes h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | #data_directory = 'ConfigDir' # use data in another directory 42 | # (change requires restart) 43 | #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file 44 | # (change requires restart) 45 | #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file 46 | # (change requires restart) 47 | 48 | # If external_pid_file is not explicitly set, no extra PID file is written. 49 | #external_pid_file = '' # write an extra PID file 50 | # (change requires restart) 51 | 52 | 53 | #------------------------------------------------------------------------------ 54 | # CONNECTIONS AND AUTHENTICATION 55 | #------------------------------------------------------------------------------ 56 | 57 | # - Connection Settings - 58 | 59 | listen_addresses = '*' # what IP address(es) to listen on; 60 | # comma-separated list of addresses; 61 | # defaults to 'localhost'; use '*' for all 62 | # (change requires restart) 63 | port = 5432 # (change requires restart) 64 | max_connections = 100 # (change requires restart) 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 66 | # connection slot, plus lock space (see max_locks_per_transaction). 67 | #superuser_reserved_connections = 3 # (change requires restart) 68 | #unix_socket_directories = '/tmp' # comma-separated list of directories 69 | # (change requires restart) 70 | #unix_socket_group = '' # (change requires restart) 71 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 72 | # (change requires restart) 73 | #bonjour = off # advertise server via Bonjour 74 | # (change requires restart) 75 | #bonjour_name = '' # defaults to the computer name 76 | # (change requires restart) 77 | 78 | # - Security and Authentication - 79 | 80 | #authentication_timeout = 1min # 1s-600s 81 | #ssl = off # (change requires restart) 82 | #ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers 83 | # (change requires restart) 84 | #ssl_prefer_server_ciphers = on # (change requires restart) 85 | #ssl_ecdh_curve = 'prime256v1' # (change requires restart) 86 | #ssl_renegotiation_limit = 512MB # amount of data between renegotiations 87 | #ssl_cert_file = 'server.crt' # (change requires restart) 88 | #ssl_key_file = 'server.key' # (change requires restart) 89 | #ssl_ca_file = '' # (change requires restart) 90 | #ssl_crl_file = '' # (change requires restart) 91 | #password_encryption = on 92 | #db_user_namespace = off 93 | 94 | # GSSAPI using Kerberos 95 | #krb_server_keyfile = '' 96 | #krb_caseins_users = off 97 | 98 | # - TCP Keepalives - 99 | # see "man 7 tcp" for details 100 | 101 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 102 | # 0 selects the system default 103 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 104 | # 0 selects the system default 105 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 106 | # 0 selects the system default 107 | 108 | 109 | #------------------------------------------------------------------------------ 110 | # RESOURCE USAGE (except WAL) 111 | #------------------------------------------------------------------------------ 112 | 113 | # - Memory - 114 | 115 | shared_buffers = 128MB # min 128kB 116 | # (change requires restart) 117 | #huge_pages = try # on, off, or try 118 | # (change requires restart) 119 | #temp_buffers = 8MB # min 800kB 120 | #max_prepared_transactions = 0 # zero disables the feature 121 | # (change requires restart) 122 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 123 | # per transaction slot, plus lock space (see max_locks_per_transaction). 124 | # It is not advisable to set max_prepared_transactions nonzero unless you 125 | # actively intend to use prepared transactions. 126 | #work_mem = 4MB # min 64kB 127 | #maintenance_work_mem = 64MB # min 1MB 128 | #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem 129 | #max_stack_depth = 2MB # min 100kB 130 | dynamic_shared_memory_type = posix # the default is the first option 131 | # supported by the operating system: 132 | # posix 133 | # sysv 134 | # windows 135 | # mmap 136 | # use none to disable dynamic shared memory 137 | 138 | # - Disk - 139 | 140 | #temp_file_limit = -1 # limits per-session temp file space 141 | # in kB, or -1 for no limit 142 | 143 | # - Kernel Resource Usage - 144 | 145 | #max_files_per_process = 1000 # min 25 146 | # (change requires restart) 147 | #shared_preload_libraries = '' # (change requires restart) 148 | 149 | # - Cost-Based Vacuum Delay - 150 | 151 | #vacuum_cost_delay = 0 # 0-100 milliseconds 152 | #vacuum_cost_page_hit = 1 # 0-10000 credits 153 | #vacuum_cost_page_miss = 10 # 0-10000 credits 154 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 155 | #vacuum_cost_limit = 200 # 1-10000 credits 156 | 157 | # - Background Writer - 158 | 159 | #bgwriter_delay = 200ms # 10-10000ms between rounds 160 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 161 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 162 | 163 | # - Asynchronous Behavior - 164 | 165 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 166 | #max_worker_processes = 8 167 | 168 | 169 | #------------------------------------------------------------------------------ 170 | # WRITE AHEAD LOG 171 | #------------------------------------------------------------------------------ 172 | 173 | # - Settings - 174 | 175 | wal_level = hot_standby # minimal, archive, hot_standby, or logical 176 | # (change requires restart) 177 | #fsync = on # turns forced synchronization on or off 178 | #synchronous_commit = on # synchronization level; 179 | # off, local, remote_write, or on 180 | #wal_sync_method = fsync # the default is the first option 181 | # supported by the operating system: 182 | # open_datasync 183 | # fdatasync (default on Linux) 184 | # fsync 185 | # fsync_writethrough 186 | # open_sync 187 | #full_page_writes = on # recover from partial page writes 188 | #wal_log_hints = off # also do full page writes of non-critical updates 189 | # (change requires restart) 190 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 191 | # (change requires restart) 192 | #wal_writer_delay = 200ms # 1-10000 milliseconds 193 | 194 | #commit_delay = 0 # range 0-100000, in microseconds 195 | #commit_siblings = 5 # range 1-1000 196 | 197 | # - Checkpoints - 198 | 199 | checkpoint_segments = 32 # in logfile segments, min 1, 16MB each 200 | checkpoint_timeout = 60min # range 30s-1h 201 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 202 | #checkpoint_warning = 30s # 0 disables 203 | 204 | # - Archiving - 205 | 206 | #archive_mode = off # allows archiving to be done 207 | # (change requires restart) 208 | #archive_command = '' # command to use to archive a logfile segment 209 | # placeholders: %p = path of file to archive 210 | # %f = file name only 211 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 212 | #archive_timeout = 0 # force a logfile segment switch after this 213 | # number of seconds; 0 disables 214 | 215 | 216 | #------------------------------------------------------------------------------ 217 | # REPLICATION 218 | #------------------------------------------------------------------------------ 219 | 220 | # - Sending Server(s) - 221 | 222 | # Set these on the master and on any standby that will send replication data. 223 | 224 | max_wal_senders = 5 # max number of walsender processes 225 | # (change requires restart) 226 | wal_keep_segments = 8 # in logfile segments, 16MB each; 0 disables 227 | wal_sender_timeout = 60s # in milliseconds; 0 disables 228 | 229 | #max_replication_slots = 0 # max number of replication slots 230 | # (change requires restart) 231 | 232 | # - Master Server - 233 | 234 | # These settings are ignored on a standby server. 235 | 236 | #synchronous_standby_names = 'prod1,prod2' # standby servers that provide sync rep 237 | # comma-separated list of application_name 238 | # from standby(s); '*' = all 239 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 240 | 241 | # - Standby Servers - 242 | 243 | # These settings are ignored on a master server. 244 | 245 | hot_standby = on # "on" allows queries during recovery 246 | # (change requires restart) 247 | max_standby_archive_delay = 30s # max delay before canceling queries 248 | # when reading WAL from archive; 249 | # -1 allows indefinite delay 250 | max_standby_streaming_delay = 30s # max delay before canceling queries 251 | # when reading streaming WAL; 252 | # -1 allows indefinite delay 253 | wal_receiver_status_interval = 10s # send replies at least this often 254 | # 0 disables 255 | hot_standby_feedback = off # send info from standby to prevent 256 | # query conflicts 257 | wal_receiver_timeout = 60s # time that receiver waits for 258 | # communication from master 259 | # in milliseconds; 0 disables 260 | 261 | 262 | #------------------------------------------------------------------------------ 263 | # QUERY TUNING 264 | #------------------------------------------------------------------------------ 265 | 266 | # - Planner Method Configuration - 267 | 268 | #enable_bitmapscan = on 269 | #enable_hashagg = on 270 | #enable_hashjoin = on 271 | #enable_indexscan = on 272 | #enable_indexonlyscan = on 273 | #enable_material = on 274 | #enable_mergejoin = on 275 | #enable_nestloop = on 276 | #enable_seqscan = on 277 | #enable_sort = on 278 | #enable_tidscan = on 279 | 280 | # - Planner Cost Constants - 281 | 282 | #seq_page_cost = 1.0 # measured on an arbitrary scale 283 | #random_page_cost = 4.0 # same scale as above 284 | #cpu_tuple_cost = 0.01 # same scale as above 285 | #cpu_index_tuple_cost = 0.005 # same scale as above 286 | #cpu_operator_cost = 0.0025 # same scale as above 287 | #effective_cache_size = 4GB 288 | 289 | # - Genetic Query Optimizer - 290 | 291 | #geqo = on 292 | #geqo_threshold = 12 293 | #geqo_effort = 5 # range 1-10 294 | #geqo_pool_size = 0 # selects default based on effort 295 | #geqo_generations = 0 # selects default based on effort 296 | #geqo_selection_bias = 2.0 # range 1.5-2.0 297 | #geqo_seed = 0.0 # range 0.0-1.0 298 | 299 | # - Other Planner Options - 300 | 301 | #default_statistics_target = 100 # range 1-10000 302 | #constraint_exclusion = partition # on, off, or partition 303 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 304 | #from_collapse_limit = 8 305 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 306 | # JOIN clauses 307 | 308 | 309 | #------------------------------------------------------------------------------ 310 | # ERROR REPORTING AND LOGGING 311 | #------------------------------------------------------------------------------ 312 | 313 | # - Where to Log - 314 | 315 | log_destination = 'stderr' # Valid values are combinations of 316 | # stderr, csvlog, syslog, and eventlog, 317 | # depending on platform. csvlog 318 | # requires logging_collector to be on. 319 | 320 | # This is used when logging to stderr: 321 | logging_collector = on # Enable capturing of stderr and csvlog 322 | # into log files. Required to be on for 323 | # csvlogs. 324 | # (change requires restart) 325 | 326 | # These are only used if logging_collector is on: 327 | log_directory = 'pg_log' # directory where log files are written, 328 | # can be absolute or relative to PGDATA 329 | log_filename = 'postgresql-%d.log' # log file name pattern, 330 | # can include strftime() escapes 331 | #log_file_mode = 0600 # creation mode for log files, 332 | # begin with 0 to use octal notation 333 | log_truncate_on_rotation = on # If on, an existing log file with the 334 | # same name as the new log file will be 335 | # truncated rather than appended to. 336 | # But such truncation only occurs on 337 | # time-driven rotation, not on restarts 338 | # or size-driven rotation. Default is 339 | # off, meaning append to existing files 340 | # in all cases. 341 | log_rotation_age = 1d # Automatic rotation of logfiles will 342 | # happen after that time. 0 disables. 343 | log_rotation_size = 0 # Automatic rotation of logfiles will 344 | # happen after that much log output. 345 | # 0 disables. 346 | 347 | # These are relevant when logging to syslog: 348 | #syslog_facility = 'LOCAL0' 349 | #syslog_ident = 'postgres' 350 | 351 | # This is only relevant when logging to eventlog (win32): 352 | #event_source = 'PostgreSQL' 353 | 354 | # - When to Log - 355 | 356 | #client_min_messages = notice # values in order of decreasing detail: 357 | # debug5 358 | # debug4 359 | # debug3 360 | # debug2 361 | # debug1 362 | # log 363 | # notice 364 | # warning 365 | # error 366 | 367 | #log_min_messages = warning # values in order of decreasing detail: 368 | # debug5 369 | # debug4 370 | # debug3 371 | # debug2 372 | # debug1 373 | # info 374 | # notice 375 | # warning 376 | # error 377 | # log 378 | # fatal 379 | # panic 380 | 381 | #log_min_error_statement = error # values in order of decreasing detail: 382 | # debug5 383 | # debug4 384 | # debug3 385 | # debug2 386 | # debug1 387 | # info 388 | # notice 389 | # warning 390 | # error 391 | # log 392 | # fatal 393 | # panic (effectively off) 394 | 395 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 396 | # and their durations, > 0 logs only 397 | # statements running at least this number 398 | # of milliseconds 399 | 400 | 401 | # - What to Log - 402 | 403 | #debug_print_parse = off 404 | #debug_print_rewritten = off 405 | #debug_print_plan = off 406 | #debug_pretty_print = on 407 | #log_checkpoints = off 408 | #log_connections = off 409 | #log_disconnections = off 410 | #log_duration = off 411 | #log_error_verbosity = default # terse, default, or verbose messages 412 | #log_hostname = off 413 | log_line_prefix = '[%t] %p: %u/%d ' # special values: 414 | # %a = application name 415 | # %u = user name 416 | # %d = database name 417 | # %r = remote host and port 418 | # %h = remote host 419 | # %p = process ID 420 | # %t = timestamp without milliseconds 421 | # %m = timestamp with milliseconds 422 | # %i = command tag 423 | # %e = SQL state 424 | # %c = session ID 425 | # %l = session line number 426 | # %s = session start timestamp 427 | # %v = virtual transaction ID 428 | # %x = transaction ID (0 if none) 429 | # %q = stop here in non-session 430 | # processes 431 | # %% = '%' 432 | # e.g. '<%u%%%d> ' 433 | #log_lock_waits = off # log lock waits >= deadlock_timeout 434 | #log_statement = 'none' # none, ddl, mod, all 435 | #log_temp_files = -1 # log temporary files equal or larger 436 | # than the specified size in kilobytes; 437 | # -1 disables, 0 logs all temp files 438 | log_timezone = 'Asia/Tokyo' 439 | 440 | 441 | #------------------------------------------------------------------------------ 442 | # RUNTIME STATISTICS 443 | #------------------------------------------------------------------------------ 444 | 445 | # - Query/Index Statistics Collector - 446 | 447 | #track_activities = on 448 | #track_counts = on 449 | #track_io_timing = off 450 | #track_functions = none # none, pl, all 451 | #track_activity_query_size = 1024 # (change requires restart) 452 | #update_process_title = on 453 | #stats_temp_directory = 'pg_stat_tmp' 454 | 455 | 456 | # - Statistics Monitoring - 457 | 458 | #log_parser_stats = off 459 | #log_planner_stats = off 460 | #log_executor_stats = off 461 | #log_statement_stats = off 462 | 463 | 464 | #------------------------------------------------------------------------------ 465 | # AUTOVACUUM PARAMETERS 466 | #------------------------------------------------------------------------------ 467 | 468 | #autovacuum = on # Enable autovacuum subprocess? 'on' 469 | # requires track_counts to also be on. 470 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 471 | # their durations, > 0 logs only 472 | # actions running at least this number 473 | # of milliseconds. 474 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 475 | # (change requires restart) 476 | #autovacuum_naptime = 1min # time between autovacuum runs 477 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 478 | # vacuum 479 | #autovacuum_analyze_threshold = 50 # min number of row updates before 480 | # analyze 481 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 482 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 483 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 484 | # (change requires restart) 485 | #autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age 486 | # before forced vacuum 487 | # (change requires restart) 488 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 489 | # autovacuum, in milliseconds; 490 | # -1 means use vacuum_cost_delay 491 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 492 | # autovacuum, -1 means use 493 | # vacuum_cost_limit 494 | 495 | 496 | #------------------------------------------------------------------------------ 497 | # CLIENT CONNECTION DEFAULTS 498 | #------------------------------------------------------------------------------ 499 | 500 | # - Statement Behavior - 501 | 502 | #search_path = '"$user",public' # schema names 503 | #default_tablespace = '' # a tablespace name, '' uses the default 504 | #temp_tablespaces = '' # a list of tablespace names, '' uses 505 | # only default tablespace 506 | #check_function_bodies = on 507 | #default_transaction_isolation = 'read committed' 508 | #default_transaction_read_only = off 509 | #default_transaction_deferrable = off 510 | #session_replication_role = 'origin' 511 | #statement_timeout = 0 # in milliseconds, 0 is disabled 512 | #lock_timeout = 0 # in milliseconds, 0 is disabled 513 | #vacuum_freeze_min_age = 50000000 514 | #vacuum_freeze_table_age = 150000000 515 | #vacuum_multixact_freeze_min_age = 5000000 516 | #vacuum_multixact_freeze_table_age = 150000000 517 | #bytea_output = 'hex' # hex, escape 518 | #xmlbinary = 'base64' 519 | #xmloption = 'content' 520 | 521 | # - Locale and Formatting - 522 | 523 | datestyle = 'iso, mdy' 524 | #intervalstyle = 'postgres' 525 | timezone = 'Asia/Tokyo' 526 | #timezone_abbreviations = 'Default' # Select the set of available time zone 527 | # abbreviations. Currently, there are 528 | # Default 529 | # Australia (historical usage) 530 | # India 531 | # You can create your own file in 532 | # share/timezonesets/. 533 | #extra_float_digits = 0 # min -15, max 3 534 | #client_encoding = sql_ascii # actually, defaults to database 535 | # encoding 536 | 537 | # These settings are initialized by initdb, but they can be changed. 538 | lc_messages = 'C' # locale for system error message 539 | # strings 540 | lc_monetary = 'C' # locale for monetary formatting 541 | lc_numeric = 'C' # locale for number formatting 542 | lc_time = 'C' # locale for time formatting 543 | 544 | # default configuration for text search 545 | default_text_search_config = 'pg_catalog.english' 546 | 547 | # - Other Defaults - 548 | 549 | #dynamic_library_path = '$libdir' 550 | #local_preload_libraries = '' 551 | #session_preload_libraries = '' 552 | 553 | 554 | #------------------------------------------------------------------------------ 555 | # LOCK MANAGEMENT 556 | #------------------------------------------------------------------------------ 557 | 558 | #deadlock_timeout = 1s 559 | #max_locks_per_transaction = 64 # min 10 560 | # (change requires restart) 561 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 562 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 563 | # lock table slots. 564 | #max_pred_locks_per_transaction = 64 # min 10 565 | # (change requires restart) 566 | 567 | 568 | #------------------------------------------------------------------------------ 569 | # VERSION/PLATFORM COMPATIBILITY 570 | #------------------------------------------------------------------------------ 571 | 572 | # - Previous PostgreSQL Versions - 573 | 574 | #array_nulls = on 575 | #backslash_quote = safe_encoding # on, off, or safe_encoding 576 | #default_with_oids = off 577 | #escape_string_warning = on 578 | #lo_compat_privileges = off 579 | #quote_all_identifiers = off 580 | #sql_inheritance = on 581 | #standard_conforming_strings = on 582 | #synchronize_seqscans = on 583 | 584 | # - Other Platforms and Clients - 585 | 586 | #transform_null_equals = off 587 | 588 | 589 | #------------------------------------------------------------------------------ 590 | # ERROR HANDLING 591 | #------------------------------------------------------------------------------ 592 | 593 | #exit_on_error = off # terminate session on any error? 594 | #restart_after_crash = on # reinitialize after backend crash? 595 | 596 | 597 | #------------------------------------------------------------------------------ 598 | # CONFIG FILE INCLUDES 599 | #------------------------------------------------------------------------------ 600 | 601 | # These options allow settings to be loaded from files other than the 602 | # default postgresql.conf. 603 | 604 | #include_dir = 'conf.d' # include files ending in '.conf' from 605 | # directory 'conf.d' 606 | #include_if_exists = 'exists.conf' # include file only if it exists 607 | #include = 'special.conf' # include file 608 | 609 | 610 | #------------------------------------------------------------------------------ 611 | # CUSTOMIZED OPTIONS 612 | #------------------------------------------------------------------------------ 613 | 614 | # Add settings for extensions here 615 | -------------------------------------------------------------------------------- /repli-config-add-replica.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | _PGNAME=$1 4 | _PGDATA=$2 5 | _PGPORT=$3 6 | 7 | if [ -s $_PGPORT ]; then 8 | echo "Usage: $0 " 9 | exit 0 10 | fi 11 | 12 | # input parameters: 13 | # - Slave PGDATA 14 | # - Master Hostname/IP 15 | # - Master Port 16 | # - Master Username 17 | # - Slave (App)Name 18 | # - Slave Port 19 | 20 | PATH=/usr/pgsql-9.4/bin:$PATH 21 | export PATH 22 | 23 | _PID=`ps auxx | grep $_PGDATA | grep -v grep | grep -v $0 | awk '{ print $2 }'` 24 | 25 | if [ "$_PID"x != "x" ]; then 26 | echo kill $_PID 27 | kill $_PID 28 | fi 29 | 30 | echo rm -rf $_PGDATA 31 | rm -rf $_PGDATA 32 | 33 | # initdb -D /tmp/pgdata2 --no-locale -E utf-8 34 | # cp -v postgresql.conf pg_hba.conf /tmp/pgdata2 35 | 36 | psql -h 127.0.0.1 -c 'checkpoint' postgres 37 | 38 | echo pg_basebackup -h 127.0.0.1 -U snaga -D $_PGDATA --xlog --progress --verbose 39 | pg_basebackup -h 127.0.0.1 -U snaga -D $_PGDATA --xlog --progress --verbose 40 | 41 | cat < recovery.conf 42 | standby_mode = 'on' 43 | primary_conninfo = 'host=127.0.0.1 port=5432 user=snaga application_name=${_PGNAME}' 44 | EOF 45 | 46 | cat recovery.conf 47 | mv -v recovery.conf $_PGDATA 48 | 49 | pg_ctl -w -D $_PGDATA start -o "-p $_PGPORT" 50 | -------------------------------------------------------------------------------- /repli-config-start-haproxy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo cp haproxy.cfg /etc/haproxy/ 4 | 5 | sudo service haproxy restart 6 | -------------------------------------------------------------------------------- /repli-config-start-master.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PATH=/usr/pgsql-9.4/bin:$PATH 4 | export PATH 5 | 6 | PGDATA=/tmp/pgdata/master1 7 | 8 | ps auxx | grep $PGDATA |grep -v grep | awk '{ print $2 }' | xargs kill 9 | 10 | rm -rf $PGDATA 11 | 12 | initdb -D $PGDATA --no-locale -E utf-8 13 | 14 | cp -v postgresql.conf pg_hba.conf $PGDATA 15 | 16 | pg_ctl -w -D $PGDATA start -o "-p 5432" 17 | -------------------------------------------------------------------------------- /rpmbuild/RPMS/x86_64/haproxy-1.5.11-1.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snaga/postgres-haproxy/f03b656fc4eafd31cdc41e8d955129ab75dcf017/rpmbuild/RPMS/x86_64/haproxy-1.5.11-1.el6.x86_64.rpm -------------------------------------------------------------------------------- /rpmbuild/RPMS/x86_64/haproxy-debuginfo-1.5.11-1.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snaga/postgres-haproxy/f03b656fc4eafd31cdc41e8d955129ab75dcf017/rpmbuild/RPMS/x86_64/haproxy-debuginfo-1.5.11-1.el6.x86_64.rpm -------------------------------------------------------------------------------- /rpmbuild/SPECS/haproxy.spec: -------------------------------------------------------------------------------- 1 | %define haproxy_user haproxy 2 | %define haproxy_uid 188 3 | %define haproxy_group haproxy 4 | %define haproxy_gid 188 5 | %define haproxy_home %{_localstatedir}/lib/haproxy 6 | %define haproxy_confdir %{_sysconfdir}/haproxy 7 | %define haproxy_datadir %{_datadir}/haproxy 8 | 9 | Name: haproxy 10 | Summary: HAProxy is a TCP/HTTP reverse proxy for high availability environments 11 | Version: 1.5.11 12 | Release: 1%{?dist} 13 | 14 | Group: System Environment/Daemons 15 | License: GPLv2+ 16 | 17 | URL: http://www.haproxy.org/ 18 | Source0: http://www.haproxy.org/download/1.5/src/haproxy-%{version}.tar.gz 19 | Source1: haproxy.init 20 | Source2: haproxy.cfg 21 | Source3: haproxy.logrotate 22 | Source4: halog.1 23 | 24 | Patch0: halog-unused-variables.patch 25 | 26 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 27 | 28 | BuildRequires: pcre-devel 29 | BuildRequires: zlib-devel 30 | BuildRequires: openssl-devel 31 | 32 | Requires: pcre 33 | Requires: openssl 34 | Requires: setup >= 2.8.14-14 35 | 36 | Requires(pre): %{_sbindir}/groupadd 37 | Requires(pre): %{_sbindir}/useradd 38 | Requires(post): /sbin/chkconfig 39 | Requires(preun): /sbin/chkconfig 40 | Requires(preun): /sbin/service 41 | Requires(postun): /sbin/service 42 | 43 | %description 44 | HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high 45 | availability environments. Indeed, it can: 46 | - route HTTP requests depending on statically assigned cookies 47 | - spread load among several servers while assuring server persistence 48 | through the use of HTTP cookies 49 | - switch to backup servers in the event a main one fails 50 | - accept connections to special ports dedicated to service monitoring 51 | - stop accepting connections without breaking existing ones 52 | - add, modify, and delete HTTP headers in both directions 53 | - block requests matching particular patterns 54 | - persists clients to the correct application server depending on 55 | application cookies 56 | - report detailed status as HTML pages to authenticated users from a URI 57 | intercepted from the application 58 | 59 | %prep 60 | %setup -q 61 | %patch0 -p0 62 | 63 | %build 64 | %ifarch %ix86 x86_64 65 | use_regparm="USE_REGPARM=1" 66 | %endif 67 | 68 | %{__make} %{?_smp_mflags} CPU="generic" TARGET="linux2628" USE_PCRE=1 USE_ZLIB=1 USE_OPENSSL=1 ${use_regparm} ADDINC="%{optflags}" USE_LINUX_TPROXY=1 69 | 70 | pushd contrib/halog 71 | %{__make} halog OPTIMIZE="%{optflags}" 72 | popd 73 | 74 | pushd contrib/iprange 75 | %{__make} iprange OPTIMIZE="%{optflags}" 76 | popd 77 | 78 | %install 79 | %{__rm} -rf %{buildroot} 80 | 81 | %{__make} install-bin DESTDIR=%{buildroot} PREFIX=%{_prefix} 82 | %{__make} install-man DESTDIR=%{buildroot} PREFIX=%{_prefix} 83 | 84 | %{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name} 85 | %{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{haproxy_confdir}/%{name}.cfg 86 | %{__install} -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} 87 | %{__install} -p -D -m 0644 %{SOURCE4} %{buildroot}%{_mandir}/man1/halog.1 88 | %{__install} -d -m 0755 %{buildroot}%{haproxy_home} 89 | %{__install} -d -m 0755 %{buildroot}%{haproxy_datadir} 90 | %{__install} -d -m 0755 %{buildroot}%{_bindir} 91 | %{__install} -p -m 0755 ./contrib/halog/halog %{buildroot}%{_bindir}/halog 92 | %{__install} -p -m 0755 ./contrib/iprange/iprange %{buildroot}%{_bindir}/iprange 93 | %{__install} -p -m 0644 ./examples/errorfiles/* %{buildroot}%{haproxy_datadir} 94 | 95 | %{__rm} -f %{buildroot}%{_sbindir}/haproxy-systemd-wrapper 96 | 97 | for httpfile in $(find ./examples/errorfiles/ -type f) 98 | do 99 | %{__install} -p -m 0644 $httpfile %{buildroot}%{haproxy_datadir} 100 | done 101 | 102 | for textfile in $(find ./ -type f -name '*.txt' -o -name README) 103 | do 104 | %{__mv} $textfile $textfile.old 105 | iconv --from-code ISO8859-1 --to-code UTF-8 --output $textfile $textfile.old 106 | %{__rm} -f $textfile.old 107 | done 108 | 109 | %clean 110 | %{__rm} -rf %{buildroot} 111 | 112 | %pre 113 | %{_sbindir}/groupadd -g %{haproxy_gid} -r %{haproxy_group} 2>/dev/null || : 114 | %{_sbindir}/useradd -u %{haproxy_uid} -g %{haproxy_group} -d %{haproxy_home} -s /sbin/nologin -r %{haproxy_user} 2>/dev/null || : 115 | 116 | %post 117 | /sbin/chkconfig --add haproxy 118 | 119 | %preun 120 | if [ "$1" -eq 0 ]; then 121 | /sbin/service haproxy stop >/dev/null 2>&1 122 | /sbin/chkconfig --del haproxy 123 | fi 124 | 125 | %postun 126 | if [ "$1" -ge 1 ]; then 127 | /sbin/service haproxy condrestart >/dev/null 2>&1 || : 128 | fi 129 | 130 | %files 131 | %defattr(-,root,root,-) 132 | %doc doc/* 133 | %doc examples/url-switching.cfg 134 | %doc examples/acl-content-sw.cfg 135 | %doc examples/content-sw-sample.cfg 136 | %doc examples/cttproxy-src.cfg 137 | %doc examples/haproxy.cfg 138 | %doc examples/tarpit.cfg 139 | %doc CHANGELOG LICENSE README 140 | %dir %{haproxy_confdir} 141 | %dir %{haproxy_datadir} 142 | %{haproxy_datadir}/* 143 | %config(noreplace) %{haproxy_confdir}/%{name}.cfg 144 | %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} 145 | %{_initrddir}/%{name} 146 | %{_sbindir}/%{name} 147 | %{_bindir}/halog 148 | %{_bindir}/iprange 149 | %{_mandir}/man1/* 150 | %attr(-,%{haproxy_user},%{haproxy_group}) %dir %{haproxy_home} 151 | 152 | %changelog 153 | * Wed Feb 11 2015 Satoshi Nagayasu - 1.5.11-1 154 | - Rebase to upstream version 1.5.11 155 | 156 | * Wed Sep 03 2014 Ryan O'Hara - 1.5.2-2 157 | - Fix emote client denial of service vulnerability 158 | Resolves: rhbz#1136698 159 | 160 | * Tue Jul 15 2014 Ryan O'Hara - 1.5.2-1 161 | - Rebase to upstream version 1.5.2 162 | Resolves: rhbz#1081727 163 | 164 | * Tue Jun 24 2014 Ryan O'Hara - 1.5.1-1 165 | - Rebase to upstream version 1.5.1 166 | Resolves: rhbz#1081727 167 | 168 | * Fri Jun 20 2014 Ryan O'Hara - 1.5.0-1 169 | - Rebase to upstream version 1.5.0 170 | Resolves: rhbz#1081727 171 | 172 | * Fri May 30 2014 Ryan O'Hara - 1.5-0.1.dev26 173 | - Rebase to upstream version 1.5-dev26 174 | Resolves: rhbz#1081727 175 | 176 | * Wed Jul 10 2013 Ryan O'Hara - 1.4.24-2 177 | - Drop supplementary groups after setuid/setgid calls. 178 | Resolves: rhbz#903303 179 | 180 | * Wed Jul 10 2013 Ryan O'Hara - 1.4.24-1 181 | - Rebase to upstream version 1.4.24. 182 | Resolves: rhbz#947987 183 | - Rewrite rules flaw can lead to arbitrary code execution (CVE-2013-1912). 184 | Resolves: rhbz#947701 185 | - Fix possible crash when using negative header occurrences (CVE-2013-2175). 186 | Resolves: rhbz#974263 187 | - Enable TPROXY support. 188 | Resolves: rhbz#921064 189 | 190 | * Tue Oct 02 2012 Ryan O'Hara - 1.4.22-3 191 | - Use static uid/gid. 192 | Resolves: rhbz#846067 193 | 194 | * Fri Sep 21 2012 Ryan O'Hara - 1.4.22-2 195 | - Bump release number. 196 | Resolves: rhbz#846067 197 | 198 | * Thu Sep 20 2012 Ryan O'Hara - 1.4.22-1 199 | - Initial build. 200 | Resolves: rhbz#846067 201 | -------------------------------------------------------------------------------- /rpmbuild/SRPMS/haproxy-1.5.11-1.el6.src.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snaga/postgres-haproxy/f03b656fc4eafd31cdc41e8d955129ab75dcf017/rpmbuild/SRPMS/haproxy-1.5.11-1.el6.src.rpm -------------------------------------------------------------------------------- /ut-stat-replication: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PORT=5432 4 | 5 | # pid | 22133 6 | # usesysid | 10 7 | # usename | snaga 8 | # application_name | prod2 9 | # client_addr | 127.0.0.1 10 | # client_hostname | 11 | # client_port | 40214 12 | # backend_start | 2015-02-11 17:15:44.459425+09 13 | # backend_xmin | 14 | # state | streaming 15 | # sent_location | 0/5000060 16 | # write_location | 0/5000060 17 | # flush_location | 0/5000060 18 | # replay_location | 0/5000060 19 | # sync_priority | 2 20 | # sync_state | sync 21 | 22 | while [ 1 ]; do 23 | D=`date` 24 | echo "****** $D ******"; 25 | psql -p $PORT -c "select null as pid,null as name,null as addr,null as port,'local' as state,pg_current_xlog_insert_location() as sent,pg_current_xlog_location() as write,null as flush,null as replay,null as pri,'master' as mode union all select pid,application_name as name,client_addr as addr,client_port as port,state,sent_location as sent,write_location as write,flush_location as flush,replay_location as reply,sync_priority as pri,sync_state as mode from pg_stat_replication" postgres | grep -v rows\); 26 | sleep 3; 27 | done 28 | 29 | -------------------------------------------------------------------------------- /ut-stat-xact: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PORTS="5432 5433 5434 5435" 4 | DBNAME=postgres 5 | 6 | while [ 1 ]; do 7 | D=`date` 8 | echo "****** $D ******"; 9 | header=0 10 | for p in $PORTS; do 11 | if [ $header -eq 0 ]; then 12 | psql -p $p -c "select '$p' as port,datname,numbackends,xact_commit,xact_rollback from pg_stat_database where datname = current_database()" $DBNAME | grep '|\|-'; 13 | if [ $? -ne 0 ]; then 14 | continue; 15 | fi 16 | header=1 17 | else 18 | psql -p $p -c "select '$p' as port,datname,numbackends,xact_commit,xact_rollback from pg_stat_database where datname = current_database()" $DBNAME | grep $DBNAME; 19 | fi 20 | done; 21 | echo 22 | sleep 3; 23 | done 24 | 25 | --------------------------------------------------------------------------------