Ad Widget

Collapse

Zabbix Proxy + PostgreSQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daikazahn
    Member
    • Nov 2016
    • 69

    #1

    Zabbix Proxy + PostgreSQL

    Добрый день!
    Подскажите пожалуйста по связке Zabbix Proxy + PostgreSQL:

    Версии ПО
    zabbix-proxy-pgsql.x86_64 3.2.6-1.el7
    postgresql96-server.x86_64 9.6.3-1PGDG.rhel7

    конфиг PG
    Code:
    listen_addresses = '*'		# what IP address(es) to listen on;
    port = 5432				# (change requires restart)
    max_connections = 100			# (change requires restart)
    shared_buffers = 128MB			# min 128kB
    dynamic_shared_memory_type = posix	# the default is the first option
    log_destination = 'stderr'		# Valid values are combinations of
    logging_collector = on			# Enable capturing of stderr and csvlog
    log_directory = 'pg_log'		# directory where log files are written,
    log_filename = 'postgresql-%a.log'	# log file name pattern,
    log_truncate_on_rotation = on		# If on, an existing log file with the
    log_rotation_age = 1d			# Automatic rotation of logfiles will
    log_rotation_size = 0			# Automatic rotation of logfiles will
    log_line_prefix = '< %m > '			# special values:
    log_timezone = 'W-SU'
    autovacuum = off			# Enable autovacuum subprocess?  'on'
    datestyle = 'iso, mdy'
    timezone = 'W-SU'
    lc_messages = 'en_US.UTF-8'			# locale for system error message
    lc_monetary = 'en_US.UTF-8'			# locale for monetary formatting
    lc_numeric = 'en_US.UTF-8'			# locale for number formatting
    lc_time = 'en_US.UTF-8'				# locale for time formatting
    default_text_search_config = 'pg_catalog.english'
    Активность zabbix-proxy в PG
    Code:
    # :activity
     count | datname  | usename  |                                                                          query                                                                          | state  | client_addr 
    -------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------+--------+-------------
        45 | zabbix   | zabbix   | commit;                                                                                                                                                 | idle   | ::1
         5 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10282                                                                                     | idle   | ::1
         3 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10294                                                                                     | idle   | ::1
         3 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10253                                                                                     | idle   | ::1
         3 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10292                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10261                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10254                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10302                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10257                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10248                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10259                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10286                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10288                                                                                     | idle   | ::1
         2 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10289                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10285                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10287                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10290                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10291                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10293                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10301                                                                                     | idle   | ::1
         1 | postgres | postgres | select count(*), datname, usename, query, state, client_addr from pg_stat_activity group by datname, usename, query, state, client_addr order by count .| active | 
           |          |          |.desc;                                                                                                                                                   |        | 
         1 | zabbix   | zabbix   | select min(t.nextcheck) from httptest t,hosts h where t.hostid=h.hostid and mod(t.httptestid,1)=0 and t.status=0 and h.proxy_hostid is null and h.statu.| idle   | ::1
           |          |          |.s=0 and (h.maintenance_status=0 or h.maintenance_type=0)                                                                                                |        | 
         1 | zabbix   | zabbix   | select count(*),min(nextcheck) from drules where status=0 and mod(druleid,1)=0                                                                          | idle   | ::1
         1 | zabbix   | zabbix   | select groupid,name from groups                                                                                                                         | idle   | ::1
         1 | zabbix   | zabbix   | select id,clock,host,listen_ip,listen_dns,listen_port,host_metadata from proxy_autoreg_host where id>145386 order by id limit 1000                      | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10247                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10249                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10251                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10252                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10256                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10260                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10263                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10281                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10283                                                                                     | idle   | ::1
         1 | zabbix   | zabbix   | select itemid from items where type=7 and flags<>2 and hostid=10284                                                                                     | idle   | ::1
    Code:
    # :conninfo
     count | datname  | usename  | state  | client_addr 
    -------+----------+----------+--------+-------------
        97 | zabbix   | zabbix   | idle   | ::1
         1 | postgres | postgres | active |
    Логи zabbix
    Code:
     24642:20170713:093501.604 database is down: reconnecting in 10 seconds
     24626:20170713:093501.604 [Z3001] connection to database 'zabbix' failed: [0] FATAL:  remaining connection slots are reserved for non-replication superuser connections
    Code:
    < 2017-07-13 09:36:19.785 MSK > FATAL:  remaining connection slots are reserved for non-replication superuser connections
    < 2017-07-13 09:36:20.027 MSK > FATAL:  remaining connection slots are reserved for non-replication superuser connections

    Почему zabbix не закрывает соединения? Какую БД вы используете для zabbix-proxy?
  • yukra
    Senior Member
    • Apr 2013
    • 1359

    #2
    Originally posted by Daikazahn
    Почему zabbix не закрывает соединения?
    Он их не "не закрывает", он их "открывает необходимое количество и оставляет на все время работы". Потому что глупо каждые полсекунды открывать новое соединение для одного запроса и сразу закрывать. необходимое колво соединений примерно равно количеству испольщуемых тредов (параметры StartPollers + StartPingers + StartPollersUnreachable + аналогичные в конфиге прокси). Самый простой способ посчитать нужное колво соединений: сделать что-то типа "ps auxf | grep zabbix_proxy | wc -l" на проксе

    Originally posted by Daikazahn
    Какую БД вы используете для zabbix-proxy?
    Ту же, что и для zabbix-server'а (в смысле ту же БД, а не ту же инсталяцию БД), ибо поддерживать 2 инсталяции одной БД проще, чем 2 инсталяции разных БД.

    Comment

    • Daikazahn
      Member
      • Nov 2016
      • 69

      #3
      Стоит ли ставить между zabbix-proxy и PostgreSQL - PgBouncer?

      Comment

      • yukra
        Senior Member
        • Apr 2013
        • 1359

        #4
        Originally posted by Daikazahn
        Стоит ли ставить между zabbix-proxy и PostgreSQL - PgBouncer?
        Я, к своему стыду, очень плохо разбираюсь в postgress и имею мало опыта, но судя по тому, что я вижу в документации режим "Session pooling" не подойдет, потому что на выходе получатся примерно тот же X соединений от заббикса до PGBouncer и тот же X соединений от PGBouncer до самого postgress'а.
        "Transaction pooling" и "Statement pooling" - сильно зависит от внутренней реализации zabbix-proxy (с ней, реализацией, я тоже честно говоря не знаком на уровне разработчика, только администратора). То есть я бы протестировал бы как минимум эти два варианта в вашей среде (ведь помимо архитектуры так же могут вносить свое влияние размер потока данных, имеющиеся мощности и прочие нюансы).

        А собственно какая именно у вас проблема? Почему вообще озадачились этой темой? Может быть стоит попробовать уменьшить колво используемых пуллеров в самой проксе (во первых посмотреть(или создать и посмотреть) на сколько заняты текущие пуллеры, во вторых попробовать поиграть "активным\пассивным" прокси и "активными\пассивными" агентами, которые мониторяться через этот прокси). У меня (правда на mysql) сервер (не прокся) за относитльно старом x3440 (4 ядра по 2,5Ггерца) держит ~350 nvps и судя по графикам еще столько же выдержит прежде чем начнутся проблемы с производительностью.

        Comment

        Working...