本文由编程笔记#小编为大家整理,主要介绍了Zabbix实战部署相关的知识,希望对你有一定的参考价值。Zabbix实战部署Zabiix是一个高度集成的企业级开源网络监控
本文由编程笔记#小编为大家整理,主要介绍了Zabbix实战部署相关的知识,希望对你有一定的参考价值。
Zabbix实战部署
Zabiix是一个高度集成的企业级开源网络监控解决方案 ,提供分布式监控及集中的web管理界面。
部署准备:
关闭防火墙和安全linux
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# setenforce 0
Zabbix通过c/s模式采集数据,通过b/s模式在web端展示和配置,需要使用LAMP平台来承载数据库和web界面。
部署:
1.本地仓库yum安装LAMP平台
[[email protected] ~]# yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
[[email protected] ~]# vi /etc/httpd/conf/httpd.conf
[[email protected] ~]# vi /etc/php.ini //时区修改为中国PRC
开启httpd服务与数据库:
[[email protected] ~]# systemctl start httpd
[[email protected] ~]# systemctl start mariadb
查看httpd服务与数据库是否开启
[[email protected] ~]# netstat -anpt | grep 80
tcp6 0 0 :::80 ::: LISTEN 1102/httpd
[[email protected] ~]# netstat -anpt | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 1355/mysqld
[[email protected] ~]# mysql_secure_installation //初始化数据库,系统自带命令
设置密码,后面(y/n):选y。
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> GRANT all ON zabbix. TO ‘zabbix‘@‘%‘ IDENTIFIED BY ‘admin123‘;
MariaDB [(none)]> flush privileges; //创建zabbix数据库,开启权限及远程登陆账号及密码,刷新权限
MariaDB [(none)]> exit //退出
[[email protected] ~]# vi /var/www/html/index.php
$link=mysql_connect(‘192.168.100.20‘,‘zabbix‘,‘admin123‘);
if($link) echo "
Success!!
";
else echo "Fail!!";
mysql_close();
?> //http:192.168.100.20验证php连接数据库是否正常
测试成功!!!搭建LAMP平台成功
2.部署zabbix-server服务器(192.168.100.20上操作)
[[email protected] ~]# vi /etc/yum.repos.d/CentOS-Base.repo //添加阿里云源区域
[Ali]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[[email protected] ~]# systemctl restart network //重启网卡,添加一张桥接模式网卡
[[email protected] ~]# ping www.baidu.com //确保网络畅通
PING www.a.shifen.com (119.75.217.26) 56(84) bytes of data.
64 bytes from 119.75.217.26 (119.75.217.26): icmp_seq=1 ttl=50 time=25.2 ms
64 bytes from 119.75.217.26 (119.75.217.26): icmp_seq=2 ttl=50 time=26.4 ms
[[email protected] ~]# yum makecache //加载元数据缓存
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm //自动生成yum源文件,需保证系统可以上网
[[email protected] ~]# yum install -y php-mbstring php-bcmath //安装必备插件
[[email protected] ~]# yum install zabbix-server-mysql zabbix-web-mysql –y //安装zabbix服务器和web页面支持
[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -p zabbix //导入zabbix监控数据库
Enter password: //输入admin123 ,上面授权的密码
[[email protected] ~]# grep -n ‘^‘[a-Z] /etc/zabbix/zabbix_server.conf //查看未注释行
[[email protected] ~]# vi /etc/zabbix/zabbix_server.conf
DBPassword=admin123 //125行去掉注释添加密码,只需要修改这一行
[[email protected] ~]# vi /etc/httpd/conf.d/zabbix.conf //修改时区
php_value date.timezone Asia/Shanghai //去掉前面注释,改成上海
[[email protected] ~]# systemctl enable zabbix-server //设置zabbix自启
[[email protected] ~]# systemctl start zabbix-server //启动zabbix服务器
[[email protected] ~]# netstat -anpt | grep zabbix //工作在10051端口上
[[email protected] ~]# systemctl restart httpd.service //重启httpd服务
http:192.168.100.20/zabbix/ //安装后登陆,用户名及密码默认Admin:zabbix
点Next step安装
密码还是admin123
成功进入zabbix服务器监控页面
3.部署zabbix-agent客户机(192.168.100.60上操作)
[[email protected] ~]# vi /etc/yum.repos.d/CentOS-Base.repo //添加阿里云源区域
[Ali]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[[email protected] ~]# systemctl restart network //重启网卡,添加一张桥接模式网卡
[[email protected] ~]# ping www.baidu.com //确保网络畅通
PING www.a.shifen.com (119.75.217.26) 56(84) bytes of data.
64 bytes from 119.75.217.26 (119.75.217.26): icmp_seq=1 ttl=50 time=25.2 ms
64 bytes from 119.75.217.26 (119.75.217.26): icmp_seq=2 ttl=50 time=26.4 ms
[[email protected] ~]# yum makecache //加载元数据缓存
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm //自动生成yum源文件,需保证系统可以上网
[[email protected] ~]# yum install -y zabbix-agent //下载zabbix客户端
[[email protected] ~]# systemctl enable zabbix-agent.service //开机自启
[[email protected] ~]# systemctl restart zabbix-agent.service //重启zabbix客户端
[[email protected] ~]# netstat -anpt | grep zabbix //默认工作在10050端口上
到这192.168.100.60zabbix客户机就配置好了我们到web界面监控
***注意先选小“加”在添加蓝色的“加”才算添加成功
成功添加被监控主机
下面我们在zabbix-agent客户机安装好httpd服务
[[email protected] ~]# yum install -y httpd
[[email protected] ~]# systemctl start httpd
开启成功
我们到zabbix-server Web界面看是否警告解除
明显没有警告了,,警告解除。到此我们的zabbix监控部署就完成了,还有细节方面各种监控都可以自己探索