zabbix install

zabbix install

  1. zabbix yum source

    1
    2
    3
    4
    5
    [root@localhost ~]# hostname zabbixserver
    [root@localhost ~]# echo zabbixserver| tee /etc/hostname
    [root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

    [root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm
  2. zabbix-server mysql install

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    [root@zabbixserver ~]# yum -y install mariadb-server mariadb
    [root@zabbixserver ~]# cat > /etc/my.cnf <<EOF
    > [mysqld]
    > character-set-server=utf8
    > datadir=/mnt/data/mysql
    > socket=/mnt/data/mysql/mysql.sock
    > symbolic-links=0
    > [mysqld_safe]
    > log-error=/var/log/mariadb/mariadb.log
    > pid-file=/var/run/mariadb/mariadb.pid
    > !includedir /etc/my.cnf.d
    > [mysql]
    > socket=/mnt/data/mysql/mysql.sock
    > [client]
    > default-character-set=utf8
    > socket=/mnt/data/mysql/mysql.sock
    > EOF

    [root@101 ~]# mkdir -p /mnt/data/mysql
    [root@101 ~]# chown -R mysql.mysql /mnt/data/mysql

    [root@101 ~]# systemctl start mariadb
    [root@101 ~]# systemctl enable mariadb
  3. zabbix-server install

    1
    2
    [root@101 ~]# yum -y install zabbix-server-mysql zabbix-web-mysql httpd
    [root@101 ~]# yum -y install zabbix-java-gateway zabbix-sender zabbix-get
  4. zabbix-server mysql set

    1
    2
    3
    4
    [root@101 ~]# mysql
    MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
    MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@10.0.1.89 identified by 'UPCLfTHSj72a';
    [root@101 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.3/create.sql.gz | mysql -uzabbix -pUPCLfTHSj72a -h10.0.1.89 -B zabbix
  5. zabbix-server configuration

    1
    2
    3
    4
    5
    [root@101 ~]# vim /etc/zabbix/zabbix_server.conf
    DBHost=10.0.1.89
    DBName=zabbix
    DBUser=zabbix
    DBPassword=UPCLfTHSj72a
  6. zabbix-server start

    1
    2
    [root@101 ~]# systemctl start zabbix-server
    [root@101 ~]# systemctl enable zabbix-server
  7. httpd zabbix.conf configuration

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    [root@101 ~]# vim /etc/httpd/conf.d/zabbix.conf
    Alias /zabbix /usr/share/zabbix

    <Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted

    <IfModule mod_php5.c>
    php_value max_execution_time 300
    php_value memory_limit 1024M
    php_value post_max_size 32M
    php_value upload_max_filesize 20M
    php_value max_input_time 300
    php_value always_populate_raw_post_data -1
    php_value date.timezone Asia/Shanghai
    </IfModule>
    </Directory>

    <Directory "/usr/share/zabbix/conf">
    Require all denied
    </Directory>

    <Directory "/usr/share/zabbix/app">
    Require all denied
    </Directory>

    <Directory "/usr/share/zabbix/include">
    Require all denied
    </Directory>

    <Directory "/usr/share/zabbix/local">
    Require all denied
    </Directory>
  8. httpd start

    1
    [root@101 ~]# systemctl restart httpd
  9. 打开浏览器,配置zabbix-server

    1
    http://{IP}:80/zabbix  用户名/密码: Admin/zabbix
  10. zabbix-server nginx反向代理

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    [root@192 vhost]# cat zabbix.conf
    # zabbix
    server {
    listen 80;
    server_name zabbix.domain.cn;

    location / {
    rewrite ^/ http://zabbix.domain.cn/zabbix/;
    }

    location /zabbix {
    proxy_pass http://192.168.13.202;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    access_log /mnt/log/nginx/zabbix.domain.cn.log main;
    }
  11. zabbix-agent install

    1
    [root@59 ~]# yum -y install zabbix-agent zabbix-sender
  12. zabbix-agent configuration

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    [root@59 ~]# cp /etc/zabbix/{zabbix_agentd.conf,abbix_agentd.conf.bak}
    [root@59 ~]# cat > /etc/zabbix/zabbix_agentd.conf <<EOF
    PidFile=/var/run/zabbix/zabbix_agentd.pid
    LogFile=/var/log/zabbix/zabbix_agentd.log
    LogFileSize=20
    DebugLevel=3
    SourceIP=10.0.1.90
    EnableRemoteCommands=1
    LogRemoteCommands=1
    Server=10.0.1.89
    ListenPort=10050
    StartAgents=5
    ServerActive=10.0.1.89
    Hostname=10.0.1.90
    HostMetadataItem=system.uname
    RefreshActiveChecks=120
    BufferSend=5
    BufferSize=200
    MaxLinesPerSecond=100
    Timeout=10
    AllowRoot=0
    Include=/etc/zabbix/zabbix_agentd.d/*.conf
    UnsafeUserParameters=1
    EOF
  13. zabbix-agent start

    1
    2
    [root@59 ~]# systemctl start zabbix-agent
    [root@59 ~]# systemctl enable zabbix-agent
  14. zabbix-aget iptables

    1
    2
    3
    4
    5
    6
    7
    [root@59 ~]# iptables -I INPUT -p tcp -m tcp --dport 10050 -m comment --comment "zabbix_agentd listen " -j ACCEPT
    or:
    [root@59 ~]# /etc/init.d/iptables status
    [root@59 ~]# iptables -I INPUT 3 -s 192.168.13.204/32 -j ACCEPT
    [root@59 ~]# iptables -I INPUT 5 -s 192.168.13.204/32 -p tcp -m tcp --dport 22 -j ACCEPT
    [root@59 ~]# iptables -I INPUT 5 -s 192.168.13.204/32 -p tcp -m tcp --dport 10050 -j ACCEPT
    [root@59 ~]# /etc/init.d/iptables save