zabbix 也是一个用的比较多的监控工具,同样需要apache+php的支持,但它比nagios多一个mysql,因为它有数据需要存储。所以,安装zabbix必须安装mysql。
安装epel扩展源
[[email protected] ~]# yum install -y epel-release
安装rpm包的lamp环境
[[email protected] ~]# yum install -y httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring
安装zabbix服务端
[[email protected] ~]# yum install -y zabbix20 zabbix20-agent zabbix20-server zabbix20-server-mysql zabbix20-web zabbix20-web-mysql net-snmp-devel
启动服务
[[email protected] ~]# /etc/init.d/zabbix-server start Starting Zabbix server: [确定] [[email protected] ~]# /etc/init.d/zabbix-agent start Starting Zabbix agent: [确定] [[email protected] ~]# /etc/init.d/httpd start 正在启动 httpd:httpd: Could not reliably determine the server‘s fully qualified domain name, using 0.0.0.133 for ServerName [确定]
修改mysql配置文件
[[email protected] ~]# vim /etc/my.cnf
修改或增加如下内容
[mysql] default-character-set=utf8 [mysqld] character_set_server=utf8
启动mysql
[[email protected] ~]# /etc/init.d/mysqld start Please report any problems with the /usr/bin/mysqlbug script! [确定] 正在启动 mysqld: [确定]
创建数据库,导入数据
[[email protected] ~]# mysql -uroot -e "create database zabbix" [[email protected] ~]# mysql -uroot --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/schema.sql [[email protected] ~]# mysql -uroot --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/images.sql [[email protected] ~]# mysql -uroot --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/data.sql [[email protected] ~]# mysql -uroot -e "grant all on *.* to ‘zabbix‘@‘localhost‘ identified by ‘zabbix‘;"
编辑zabbix-server配置文件,配置DBUser,DBPassword,然后重启zabbix-server。
[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf DBUser=zabbix DBPassword=zabbix [[email protected] ~]# /etc/init.d/zabbix-server restart Shutting down Zabbix server: [失败] Starting Zabbix server: [确定] [[email protected] ~]# netstat -lnp|grep zabbix tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1691/zabbix_agentd tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2078/zabbix_server tcp 0 0 :::10050 :::* LISTEN 1691/zabbix_agentd tcp 0 0 :::10051 :::* LISTEN 2078/zabbix_server
网页安装zabbix
浏览器访问 http://ip/zabbix,默认会有“It is not safe to rely on the system‘s timezone settings”这样的警告信息,根据其中提示,需要 vim /etc/php.ini 设置 date.timezone="Asia/Shanghai",重启apache后刷新就没有了,点next。
它会提示一些参数不合适:
编辑配置文件 /etc/php.ini,解决相关的报错信息,然后点击retry。
[[email protected] ~]# vim /etc/php.ini post_max_size = 16M max_execution_time = 300 max_input_time = 300 [[email protected] ~]# service httpd restart 停止 httpd: [确定] 正在启动 httpd:httpd: Could not reliably determine the server‘s fully qualified domain name, using 0.0.0.133 for ServerName [确定]
然后接着输入mysql的信息,首先测试一下,不通过则需要调试,通过则下一步。
前两项保持默认,其中zabbix-server的port可以用netstat -lnp|grep zabbix查看,Name是可以自定义的,我写为 127.0.0.1 ,下面就是一路next到finish。
下面即进入登录界面,默认管理员账号为 admin,密码为 zabbix。
时间: 2024-10-03 01:27:55