Zabbix的安装
服务器信息:centos7 zabbix-server(192.168.111.132)zabbix-agent(192.168.111.131),Mariadb,apache
官方下载资料:官方下载资料
安装步骤
- 下载epel源
yum install epel-release -y
- 下载zabbix相关rpm包 zabbix-rpm包下载
- 上传zabbix rpm包到服务器上 (rz或者xftp上传)
- 进入上传到linux服务器的目录,在zabbix-server端安装zabbix相关软件,在zabbix-agent端安装zabbix-agent软件 ,centos7 的系统需要安装epel-release软件,获得epel源的地址
yum install zabbix-* -y #服务端
yum install zabbix-agent -y #客户端
- 提前安装好mariadb =>在服务端
- 启动Mariadb服务
yum install mariadb mariadb-server -y
service mariadb start
systemctl enable mariadb
ps aux|grep mysql # 查看mysqld进程
- 关闭防火墙,selinux
systemctl disable firewalld
setenforce 0 # 临时禁用修改selinux
vim /etc/sysconfig/selinux
SELINUX = disabled 永久禁用selinux
- mariadb的使用
mysql -uroot -p # mariadb第一次默认没有密码
create database zabbix character set utf8 collate utf8_bin; #建库zabbix,指定字符集为utf8
show databases;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123'; #新建一个用户zabbix@localhost 密码为zabbix123 可以有所有的权限在zabbix这个库里的所有的表上
- 导入数据到MySQL数据库里的zabbix库
[root@zabbix ~]# cd /usr/share/doc/zabbix-server-mysql-4.4.6/
[root@zabbix zabbix-server-mysql-4.4.6]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@zabbix-server-1 zabbix-server-mysql]# gunzip create.sql.gz
[root@zabbix-server-1 zabbix-server-mysql]# mysql -uzabbix -p'zabbix123' zabbix < create.sql
- 启动Zabbix Server进程
在zabbix_server.conf中编辑数据库配置
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix123
DBSocket=/data/mysql/mysql.sock # 使用mysql的需要填写这个
DBPort=3306
启动Zabbix Server进程
service zabbix-server start
ps aux|grep zabbix # 查看zabbix服务是否起来
zabbix 48631 0.0 0.1 257624 3384 ? S 15:26 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
root 48634 0.0 0.0 112724 988 pts/0 S+ 15:26 0:00 grep --color=auto zabbix
netstat -anplut # 查看zabbix-server占用的端口号10051
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 961/sshd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 6139/zabbix_server
systemctl enable zabbix-serve 设置开机启动
- Zabbix前端配置,编辑Zabbix前端的PHP设置
zabbix前端的Apache配置文件位于 /etc/php-fpm.d/zabbix.conf 。一些PHP设置已经完成了配置。
timedatectl #查看时区
[root@zabbix-server-1 php-fpm.d]#pwd
/etc/php-fpm.
[root@zabbix-server-1 php-fpm.d]# ls
www.conf zabbix.conf
[root@zabbix-server-1 php-fpm.d]# vim zabbix.conf
php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Shanghai **修改为Asia/Shanghai**
- 启动Zabbix server和agent进程
使用apache---》LAMP环境
# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fpm
使用nginx --》LNMP环境
# systemctl restart zabbix-server zabbix-agent nginx php-fpm
# systemctl enable zabbix-server zabbix-agent nginx php-fpm
- 在客户机上安装agent
yum install zabbix-agent -y
service zabbix-agent start # 启动agent程序
ps aux|grep zabbix
zabbix 17017 0.0 0.1 80828 1276 ? S 15:36 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 17018 0.0 0.1 80828 1316 ? S 15:36 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 17019 0.0 0.1 80828 1832 ? S 15:36 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 17020 0.0 0.1 80828 1832 ? S 15:36 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 17021 0.0 0.1 80828 1832 ? S 15:36 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 17022 0.0 0.2 80960 2212 ? S 15:36 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 17026 0.0 0.0 112724 988 pts/0 R+ 15:37 0:00 grep --color=auto zabbix
systemctl enable zabbix-agent #设置开机启动
修改客户端上的agent的配置文件
[root@zabbix zabbix]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.111.132 #修改为允许来采集数据的服务器ip,不然下面的zabbix_get命令不能去采集数据
ServerActive=192.168.111.132
刷新agent服务
service zabbix-agent restart
- 在服务器端使用zabbix_get命令测试
zabbix_get -s 192.168.111.131 -p 10050 -k "system.cpu.load[all,avg1]"
- web页面安装zabbix
- Zabbix默认账户:Admin ,默认密码:zabbix