pgpool 简明使用教程
admin
2023-05-21 21:42:34
0

一、系统环境


172.16.3.226(master)

172.16.3.228(slave)

172.16.3.229(pgpool)


# yum install -y gcc-c++ zlib-devel readline-devel


# useradd postgres

# passwd postgres

Changing password for user postgres.

New password: 

BAD PASSWORD: The password contains the user name in some form

Retype new password: 

passwd: all authentication tokens updated successfully.


1.安装postgresql

# vi /etc/profile


export PATH=/opt/pgsql/10.0/bin:$PATH

export LD_LIBRARY_PATH=/opt/pgsql/10.0/lib

export MANPATH=/opt/pgsql/10.0/share/man:$MANPATH

[root@pgpool ~]#



# tar zxvf pgpool-II-3.6.6.tar.gz

# cd pgpool-II-3.6.6

# ./configure --prefix=/opt/pgpool/3.6.6 --sysconfdir=/etc/pgpool/

# make

# make install



# cp src/redhat/pgpool.service /lib/systemd/system/

# chmod +x /lib/systemd/system/pgpool.service

# systemctl enable pgpool.service


# vi /lib/systemd/system/pgpool.service


[Unit]

Description=Pgpool-II

After=syslog.target network.target

Wants=network.target


[Service]

Type=forking


EnvironmentFile=-/etc/sysconfig/pgpool


ExecStart=/opt/pgpool/3.6.6/bin/pgpool -f /etc/pgpool/pgpool.conf $OPTS

ExecStop=/opt/pgpool/3.6.6/bin/pgpool -f /etc/pgpool/pgpool.conf $STOP_OPTS stop

ExecReload=/opt/pgpool/3.6.6/bin/pgpool -f /etc/pgpool/pgpool.conf reload


[Install]

WantedBy=multi-user.target





#####################################################################


# chown postgres -R /opt/pgpool/3.6.6

# chown postgres -R /etc/pgpool/


# su - postgres

[postgres@pgpool ~]$ cd /opt/pgpool/3.6.6/

[postgres@pgpool 3.6.6]$ mkdir log


# su - postgres

Last login: Mon Sep 11 15:08:36 CST 2017 on pts/1

[postgres@pgpool ~]$ 

[postgres@pgpool ~]$ 

[postgres@pgpool ~]$ cd /etc/pgpool/

[postgres@pgpool pgpool]$ mv pgpool.conf.sample-stream pgpool.conf

[postgres@pgpool pgpool]$ vi pgpool.conf



listen_addresses = '*'

port = 5432


# - Backend Connection Settings -


backend_hostname0 = '172.16.3.226'

                                   # Host name or IP address to connect to for backend 0

backend_port0 = 5432

                                   # Port number for backend 0

backend_weight0 = 1

                                   # Weight for backend 0 (only in load balancing mode)

backend_data_directory0 = '/pgdata10'

                                   # Data directory for backend 0

backend_flag0 = 'DISALLOW_TO_FAILOVER'

                                   # Controls various backend behavior

                                   # ALLOW_TO_FAILOVER or DISALLOW_TO_FAILOVER

backend_hostname1 = '172.16.3.228'

backend_port1 = 5432

backend_weight1 = 1

backend_data_directory1 = '/pgdata10'

backend_flag1 = 'DISALLOW_TO_FAILOVER'



#------------------------------------------------------------------------------

# POOLS

#------------------------------------------------------------------------------


# - Concurrent session and pool size -


num_init_children = 25

                                   # Number of concurrent sessions allowed

                                   # (change requires restart)

max_pool = 10

                                   # Number of connection pool caches per connection

                                   # (change requires restart)


# - Life time -



#------------------------------------------------------------------------------

# REPLICATION MODE

#------------------------------------------------------------------------------


replication_mode = off



#------------------------------------------------------------------------------

# LOAD BALANCING MODE

#------------------------------------------------------------------------------


load_balance_mode = on



#------------------------------------------------------------------------------

# MASTER/SLAVE MODE

#------------------------------------------------------------------------------


master_slave_mode = on

                                   # Activate master/slave mode

                                   # (change requires restart)

master_slave_sub_mode = 'stream'

                                   # Master/slave sub mode

                                   # Valid values are combinations slony or

                                   # stream. Default is slony.

                                   # (change requires restart)

                                   

                                   

# - Streaming -


sr_check_period = 10

                                   # Streaming replication check period

                                   # Disabled (0) by default

sr_check_user = 'postgres'



#------------------------------------------------------------------------------

# HEALTH CHECK

#------------------------------------------------------------------------------


health_check_period = 0

                                   # Health check period

                                   # Disabled (0) by default

health_check_timeout = 20

                                   # Health check timeout

                                   # 0 means no timeout

health_check_user = 'postgres'





# -- query mode --


wd_life_point = 3

                                    # lifecheck retry times

                                    # (change requires restart)

wd_lifecheck_query = 'SELECT 1'

                                    # lifecheck query to pgpool from watchdog

                                    # (change requires restart)

wd_lifecheck_dbname = 'template1'

                                    # Database name connected for lifecheck

                                    # (change requires restart)

wd_lifecheck_user = 'postgres'

                                   

                                   

#------------------------------------------------------------------------------

# FILE LOCATIONS

#------------------------------------------------------------------------------


pid_file_name = '/opt/pgpool/3.6.6/pgpool.pid'




# - What to log -


log_line_prefix = '%t [%p]: [%l-1] db=%d,user=%u,app=%a,client=%h '   # printf-style string to output at beginning of each log line.


log_connections = on

                                   # Log connections

log_hostname = on

                                   # Hostname will be shown in ps status

                                   # and in logs if connections are logged

log_statement = on

                                   # Log all statements

log_per_node_statement = on

                           

                                   

                                   


                                   


# systemctl start pgpool.service

# systemctl status pgpool.service


相关内容

热门资讯

美国罕见缩减全球外交规模,涉日... 据凤凰卫视援引外媒8月4日报道,美国国务院已通知国会,计划关闭5个驻外使团。报道称,这是美国罕见地缩...
强震后遇“烤验”,日本熊本出现... 据凤凰卫视报道,一周前发生7.1级地震的日本熊本县,救灾仍在进行当中,现又遭遇酷热威胁,县府所在地熊...
红十字国际委员会代表与昂山素季... 昂山素季3日罕见公开露面。缅甸总统办公室表示,红十字国际委员会代表探视了昂山素季,并与她私下交谈。联...
普京回答小男孩什么是胜利 据凤凰卫视报道,8月3日,俄罗斯总统普京与全俄“大变革”竞赛总决赛选手交谈时,13岁的年轻选手卡泽金...
菲尔兹奖与定点爆破 【文/观察者网专栏作者 边芹】近日舆论场一片喜庆,中国数学家得了菲尔兹奖。自1978年后,这类新闻便...
“救”在身边!4天2场“急”时... ▲红十字少年叶子豪与护士马莉开展紧急救援。台海网8月4日讯(导报记者 石程罗纳 通讯员 苏映红 陈雅...
Claude仅用8分钟,5年未... 新智元报道 25分钟,500个钱包被洗劫一空! 这几天,知名硬件钱包Coldcard暴雷,而引发这...
低价流量卡一夜消失!三大运营商... 最近几天,关于流量卡的讨论热度越来越高,原因很简单——流量卡没了。 最开始,只是有网友突然上传了一份...
薪火传家 执“戟”报国——王戟... 新华社长沙8月3日电 题:薪火传家 执“戟”报国——国防科技大学研究员王戟的家风故事新华社记者黄明、...
夏季战役第二阶段打响,乌方称俄... 据凤凰卫视报道,俄乌夏季战役第二阶段已经打响,顿巴斯中线多地陷入持续激战,俄军拿下了别列茨克定居点,...