CentOS下安装zabbix服务端并且附录监控windows步骤
准备工作:(yum源最好用网易速度快)
关闭防火墙 :# systemctl stop firewalld
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。1、安装apache mysql*php*(用yum)
# yum -y install httpd mariadb mariadb-server php php-gd php-mysql
# yum -y install php php-gd php-mysql php-bcmath php-mbstring
接下来我们做Apache和php的整合,打开Apache的配置文件
# vim /etc/httpd/conf/httpd.conf
默认首页设置成php
增加php应用的支持(在httpd.conf中添加)
AddType application/x-httpd-php .php
重启httpd和mariadb
# systemctl restart httpd mariadb
安装EPEL repository
# yum install epel-release
2、配置ZabbixZone package repository and GPG key
# rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
# rpm -Uv http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
3、安装Zabbix server and agent(agent是可选的)
安装Zabbix server and agent:(配置自己监控自己,所以安装了zabbix-agent之后会附上监控windows)
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway
编辑 file /etc/httpd/conf.d/zabbix:
# vi /etc/httpd/conf.d/zabbix.conf
更新时区(修改):
php_value date.timezone Asia/Shanghai
重启httpd
# systemctl restart httpd
设置mysql密码
# mysqladmin -uroot password 123
4、创建MySQL 数据库和用户
登录MariaDB:
mysql –u root –p
创建一个数据库‘zabbixdb’和数据库用户‘zabbix’并且赋予权限
MariaDB [(none)]> create database zabbix character set utf8;
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
MariaDB [(none)]> flush privileges;
5、数据库导入zabbix template
查看要导入数据库
ls /usr/share/doc/zabbix-server-mysql-2.4.8/create/
使用数据库用户zabbix登录数据库
# mysql –uzabbix –p
切换到zabbix数据库
MariaDB [(none)]> use zabbix
导入模板数据
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
6、配置Zabbix server
编辑文件/etc/zabbix/zabbix_server.conf,
# vi /etc/zabbix/zabbix_server.conf
配置下面的三个参数
[...]
DBName=zabbix
[...]
DBUser=zabbix
[...]
DBPassword=zabbix
[...]
7、配置zabbix-agent(可以自己在另外的服务器配置,方法一样)
# vi /etc/zabbix/zabbix_agentd.conf
配置zabbix server 的ip
[...]
## Line 85 - Specify Zabbix server ##
Server=127.0.0.1
[...]
## Line 126 - Specify Zabbix server ##
ServerActive=127.0.0.1
[...]
## Line 137 - Specify Zabbix server Hostname or IP address ##
Hostname=127.0.0.1
[...]
8、修改PHP 设置
修改php.ini为zabbix 建议的设置
编辑文件 php.ini,
# vi /etc/php.ini
设置下面的参数.
max_execution_time = 600
max_input_time = 600
memory_limit = 256
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Shanghai
9、修改Firewall 和SELinux 设置
开放zabbix端口10050 and 10051.
# firewall-cmd --permanent --add-port=10050/tcp
# firewall-cmd --permanent --add-port=10051/tcp
重启firewall(测试阶段关闭防火墙)
# systemctl restart firewalld (停止是stop经常用的命令要重点记一下)
以下标红可忽略
如果使用 SELinux, 运行以下命令使 Apache 可以和 Zabbix通信
setsebool -P httpd_can_connect_zabbix=1
[root@mygod ~]# vi /etc/selinux/config
[root@mygod ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
启动zabbix-server 和zabbix-agent。重启httpd,,并设置zabbix-server和zabbix-agent开机自动启动
# systemctl start zabbix-server
# systemctl start zabbix-agent
# systemctl restart httpd
# systemctl restart mariadb
# systemctl enable zabbix-server
# systemctl enable zabbix-agent ---- (可选)
11、通过控制台配置Zabbix
浏览器访问http://本机IP/zabbix
有一个不OK都不能下一步,如果出现请看上面步骤有没有漏掉的没修改的配置
密码123然后点击Test Connection
设置模板自行百度一下,监控Windows写在下一个里面了,有点多有点啰嗦了已经。
