ZABBIX - 구축(H/A·zabbix-agent(active)에 의한 감시 노드 자동 등록)-

목적


  • AZ를 가로 지르는 중복 구성 (Active-Standby)
  • 부동 ip에서의 운용이 아닌 ELB의 헬스 체크에 의존한다
  • 최근 업데이트된 기능으로 운영 가능
  • Register or De-Register EC2 Instances for Your Load Balancer


  • 자동 검색을 비활성화하고 Zabbix-agent (활성)에 Internal-ELB를 작성하고 노드를 자동으로 등록합니다.

    이미지





    환경


  • t2-micro (운영하기 위해서는 C4 이상이 바람직하다)
  • Active/Standby 구성 (Standby는 서버가 시작되었지만 F/O를 트리거하는 프로세스를 중지합니다)
  • F/O 트리거는 zabbix-server 중지
  • 클러스터 제어에는 Corosync, 리소스 제어에는 Pacemaker를 사용
  • Rundeck - 구축(H/A)-


  • 건설



    설치


    $ sudo rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
    $ sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-agent
    

    설정



    MySQL



    깨지지 않도록 사전에 파라미터 그룹을 만들고 character_set_client와 character_set_server의 값을 utf-8로 둔다.

    $ mysql -h <rds-endpoint> -u <user> -p
    mysql> grant all privileges on <dbname>.* to <user>@localhost identified by '<password>';
    
    #初期スキーマとデータをインポート
    $ cd /usr/share/doc/zabbix-server-mysql-2.4.7/create
    $ mysql -h <rds-endpoint> <db> -u <user> -p < schema.sql
    $ mysql -h <rds-endpoint> <db> -u <user> -p < images.sql
    $ mysql -h <rds-endpoint> <db> -u <user> -p < data.sql
    

    zabbix-server



    zabbix_server.conf
    ### Option: ListenPort
    #       Listen port for trapper.
    #
    # Mandatory: no
    # Range: 1024-32767
    # Default
    # ListenPort=10051
    
    ### Option: DBHost
    #       Database host name.
    #       If set to localhost, socket is used for MySQL.
    #       If set to empty string, socket is used for PostgreSQL.
    #
    # Mandatory: no
    # Default:
    # DBHost=localhost
    DBHost=<rds-endpoint>
    ### Option: DBName
    #       Database name.
    #       For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
    #
    # Mandatory: yes
    # Default:
    # DBName=
    
    DBName=<DBName>
    
    ### Option: DBSchema
    #       Schema name. Used for IBM DB2 and PostgreSQL.
    #
    # Mandatory: no
    # Default:
    # DBSchema=
    
    ### Option: DBUser
    #       Database user. Ignored for SQLite.
    #
    # Mandatory: no
    # Default:
    # DBUser=
    
    DBUser=<user>
    
    ### Option: DBPassword
    #       Database password. Ignored for SQLite.
    #       Comment this line if no password is used.
    #
    # Mandatory: no
    # Default:
    # DBPassword=
    DBPassword=********
    ### Option: DBSocket
    #       Path to MySQL socket.
    #
    # Mandatory: no
    # Default:
    # DBSocket=/tmp/mysql.sock
    
    DBSocket=/var/lib/mysql/mysql.sock
    

    zabbix_agent.conf
    ### Option: Server
    #       List of comma delimited IP addresses (or hostnames) of Zabbix servers.
    #       Incoming connections will be accepted only from the hosts listed here.
    #       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
    #
    # Mandatory: no
    # Default:
    # Server=
    
    Server=10.0.1.23,10.0.3.60
    
    ### Option: ListenPort
    #       Agent will listen on this port for connections from the server.
    #
    # Mandatory: no
    # Range: 1024-32767
    # Default:
    ListenPort=10050
    
    ### Option: ServerActive
    #       List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks.
    #       If port is not specified, default port is used.
    #       IPv6 addresses must be enclosed in square brackets if port for that host is specified.
    #       If port is not specified, square brackets for IPv6 addresses are optional.
    #       If this parameter is not specified, active checks are disabled.
    #       Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
    #
    # Mandatory: no
    # Default:
    # ServerActive=
    
    ServerActive=<internal ELB Aレコード>or<internal ELB CNAME>
    
    ### Option: Hostname
    #       Unique, case sensitive hostname.
    #       Required for active checks and must match hostname as configured on the server.
    #       Value is acquired from HostnameItem if undefined.
    #
    # Mandatory: no
    # Default:
    # Hostname=
    
    #Hostname=Zabbix server
    
    ### Option: HostnameItem
    #       Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.
    #       Does not support UserParameters or aliases.
    #
    # Mandatory: no
    # Default:
    HostnameItem=system.hostname
    

    Apache/PHP



    httpd.conf
    $ sudo vim /etc/httpd/conf/httpd.conf
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    #
    DocumentRoot "/var/www/zabbix"
    
    $ cd /var/www
    $ sudo ln -s /usr/share/zabbix zabbix
    
    $ sudo vim /etc/php.ini
    post_max_size = 16M
    max_execution_time = 300
    max_input_time = 300
    date.timezone = Asia/Tokyo
    always_populate_raw_post_data = -1
    

    프런트 엔드


    $ sudo service httpd start&&sudo chkconfig httpd on
    $ sudo service zabbix-server start&&sudo chkconfig zabbix-server on
    $ sudo service zabbix-agent start&&sudo chkconfig zabbix-agent on
    







    자동 등록 동작


  • Action에만 표시하는 호스트 정보를 기술
  • Conditions 설명 필요 없음. Operations는 "호스트 추가", "템플릿 및 링크".







  • zabbix-agent


  • 모니터링 대상 노드로 설정

  • 설치


    $ sudo rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
    $ sudo yum -y install zabbix-agent
    

    zabbix_agent.conf
    ### Option: SourceIP
    #   Source IP address for outgoing connections.
    #
    # Mandatory: no
    # Default:
    # SourceIP=
    SourceIP=10.0.3.6
    
    ### Option: Server
    #       List of comma delimited IP addresses (or hostnames) of Zabbix servers.
    #       Incoming connections will be accepted only from the hosts listed here.
    #       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
    #
    # Mandatory: no
    # Default:
    # Server=
    
    Server=10.0.1.23,10.0.3.60
    
    ### Option: ListenPort
    #       Agent will listen on this port for connections from the server.
    #
    # Mandatory: no
    # Range: 1024-32767
    # Default:
    ListenPort=10050
    
    ### Option: ServerActive
    #       List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks.
    #       If port is not specified, default port is used.
    #       IPv6 addresses must be enclosed in square brackets if port for that host is specified.
    #       If port is not specified, square brackets for IPv6 addresses are optional.
    #       If this parameter is not specified, active checks are disabled.
    #       Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
    #
    # Mandatory: no
    # Default:
    # ServerActive=
    
    ServerActive=<internal ELB Aレコード>or<internal ELB CNAME>
    
    ### Option: Hostname
    #       Unique, case sensitive hostname.
    #       Required for active checks and must match hostname as configured on the server.
    #       Value is acquired from HostnameItem if undefined.
    #
    # Mandatory: no
    # Default:
    # Hostname=
    
    #Hostname=Zabbix server
    
    ### Option: HostnameItem
    #       Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.
    #       Does not support UserParameters or aliases.
    #
    # Mandatory: no
    # Default:
    HostnameItem=system.hostname
    

    오류
    $ sudo service zabbix-agent start
    Starting Zabbix agent:                                     [  OK  ]
    $ sudo tail -f /var/log/zabbix/zabbix_agentd.log
      2709:20151228:150932.183 Starting Zabbix Agent [ip-10-0-3-6]. Zabbix 2.4.7 (revision 56694).
      2709:20151228:150932.183 using configuration file: /etc/zabbix/zabbix_agentd.conf
      2709:20151228:150932.183 agent #0 started [main process]
      2714:20151228:150932.183 agent #5 started [active checks #1]
      2713:20151228:150932.183 agent #4 started [listener #3]
      2712:20151228:150932.184 agent #3 started [listener #2]
      2711:20151228:150932.184 agent #2 started [listener #1]
      2710:20151228:150932.184 agent #1 started [collector]
      2714:20151228:150932.217 no active checks on server [******.elb.amazonaws.com:10051]: host [ip-10-0-3-6] not found
    
  • 프런트 엔드에서는 노드의 자동 등록이 성공한 것처럼 보이지만, Zabbix-server와 Zabbix-agent와의 통신이 실패하고 있다.

  • Agent interfaces에서 취득한 IP를 알 수 없음
  • Internal-ELB의 IP였습니다
  • $ dig internal-******.elb.amazonaws.com
    
    ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.42.amzn1 <<>> internal-******.elb.amazonaws.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38512
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;internal-******.elb.amazonaws.com. IN A
    
    ;; ANSWER SECTION:
    internal-******.elb.amazonaws.com. 60 IN A 10.0.2.62
    internal-******.elb.amazonaws.com. 60 IN A 10.0.2.58
    
    ;; Query time: 5 msec
    ;; SERVER: 10.0.0.2#53(10.0.0.2)
    ;; WHEN: Mon Dec 28 15:13:25 2015
    ;; MSG SIZE  rcvd: 116
    
  • 대책으로서는, zabbix-agent.conf의 ListenIP에 자신의 IP를 기술하는 것으로, Agent interfaces로 취득할 수 있게 된다.
  • ### Option: ListenIP
    #       List of comma delimited IP addresses that the agent should listen on.
    #       First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks.
    #
    # Mandatory: no
    # Default:
    ListenIP=10.0.3.6
    

    좋은 웹페이지 즐겨찾기