设为首页 收藏本站
查看: 1093|回复: 0

[经验分享] CentOS7 企业级分布式监控系统Zabbix(01)

[复制链接]

尚未签到

发表于 2019-1-24 09:41:10 | 显示全部楼层 |阅读模式
  本次以CentOS 7.2 x64系统为例
  

  系统环境
[root@centos72-node1 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@centos72-node1 ~]# uname -r
3.10.0-327.el7.x86_64
[root@centos72-node1 ~]# uname -m
x86_64
[root@centos72-node1 ~]# hostname
centos72-node1.wangdong.com
[root@centos72-node1 ~]# ifconfig | grep -w "inet" | awk '{print $2}'
192.168.56.51
127.0.0.1
  

  设置yum源和epel源为阿里
[root@centos72-node1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
......
[root@centos72-node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
......
  

  安装Apache
[root@centos72-node1 ~]# yum install httpd -y
......
  

  启动Apache
[root@centos72-node1 ~]# systemctl start httpd
  

  设置开机启动
[root@centos72-node1 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
  

  设置防火墙策略(若不启用防火墙,此步骤跳过)
[root@centos72-node1 ~]# firewall-cmd --permanent --add-service=http
success
[root@centos72-node1 ~]# systemctl restart firewalld
  

  测试Apache(Apache默认使用TCP/80端口,确保没有其他程序占用此端口)

  

  安装MariaDB(即MySQL)
[root@centos72-node1 ~]# yum install mariadb-server mariadb -y
......
  

  启动MariaDB
[root@centos72-node1 ~]# systemctl start mariadb
  

  设置开机启动
[root@centos72-node1 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
  

  初始化MariaDB
[root@centos72-node1 ~]# mysql_secure_installation
......
Enter current password for root (enter for none):    # 输入MySQL的root原密码,密码为空,直接回车
......
Set root password? [Y/n] Y         # 是否设置root密码,是
New password:            # 输入新密码,我设置123456
Re-enter new password:    # 输入新密码,我设置123456
......
Remove anonymous users? [Y/n] Y
......
Disallow root login remotely? [Y/n] n
......
Remove test database and access to it? [Y/n] Y
......
Reload privilege tables now? [Y/n] Y
......
  

  安装PHP
[root@centos72-node1 ~]# yum install php php-mysql php-gd php-pear -y
......
  

  测试PHP
[root@centos72-node1 ~]# vim /var/www/html/testphp.php    # 创建php测试文件,将下面3行内容写入文件保存

[root@centos72-node1 ~]# systemctl restart httpd
  

  使用浏览器访问服务器地址的/testphp.php

  

  配置zabbix源
[root@centos72-node1 ~]# yum install epel-release -y
......
[root@centos72-node1 ~]# rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
[root@centos72-node1 ~]# rpm -Uv http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
Preparing packages...
zabbix-release-2.4-1.el7.noarch
  

  安装zabbix和相关
[root@centos72-node1 ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y
......
  

  设置zabbix
[root@centos72-node1 ~]# vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix

    Options FollowSymLinks
    AllowOverride None
    Require all granted
   
        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 date.timezone Asia/Shanghai    # 设置时区为上海
        # php_value date.timezone Europe/Riga
   


    Require all denied


    Require all denied

[root@centos72-node1 ~]# systemctl restart httpd
  

  MariaDB创建zabbix库
[root@centos72-node1 ~]# mysql -u root -p123456
......
MariaDB [(none)]> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit;
Bye
[root@centos72-node1 ~]#
  

  MariaDB导入zabbix模板
[root@centos72-node1 ~]# mysql -u zabbix -pzabbix
......
MariaDB [(none)]> use zabbix;
Database changed
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.7/create/schema.sql
......
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.7/create/images.sql
......
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.7/create/data.sql
......
MariaDB [zabbix]> exit;
Bye
  

  配置zabbix server
[root@centos72-node1 ~]# vim /etc/zabbix/zabbix_server.conf
......
DBName=zabbix
......
DBUser=zabbix
......
DBPassword=zabbix
......
  

  配置zabbix agent
[root@centos72-node1 ~]# vim /etc/zabbix/zabbix_agentd.conf
......
Server=127.0.0.1        # 约在85行
......
ServerActive=127.0.0.1    # 约在126行
......
Hostname=127.0.0.1    # 约在137行
......
  

  修改PHP配置
[root@centos72-node1 ~]# vim /etc/php.ini
......
max_execution_time = 600        # 约384行
......
max_input_time = 600        # 约394行
......
memory_limit = 256        # 约405行
......
post_max_size = 32M        # 约672行
......
upload_max_filesize = 16M    # 约800行
......
[date]
......
date.timezone = Asia/Shanghai        # 此项默认没有配置,需要添加,约880行
......
  

  修改防火墙配置(若没有开启防火墙,则忽略)
[root@centos72-node1 ~]# firewall-cmd --permanent --add-port=10050/tcp
success
[root@centos72-node1 ~]# firewall-cmd --permanent --add-port=10051/tcp
success
[root@centos72-node1 ~]# systemctl restart firewalld
  

  重启服务
[root@centos72-node1 ~]# systemctl start zabbix-server
[root@centos72-node1 ~]# systemctl start zabbix-agent
[root@centos72-node1 ~]# systemctl restart httpd
[root@centos72-node1 ~]# systemctl restart mariadb
[root@centos72-node1 ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@centos72-node1 ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
  

  配置zabbix,访问服务器地址的/zabbix/
  点击“Next”按钮

  

  检查各种测试,应全部显示OK,点击“Next”
  
  

  选择数据库类型为MySQL,库名为zabbix,用户名zabbix,密码我使用的zabbix,点击“Test connection”,显示OK后点击“Next”
  
  

  输入Server Name(可选)
  
  

  检查信息是否有误,点击“Next”按钮
  
  

  配置完成,点击“Finish”按钮
  
  

  进入Zabbix的管理界面,默认用户名为admin,默认密码为zabbix
  
  

  进入界面后,如果想要使用中文,可以点击进入Profile
  




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-666892-1-1.html 上篇帖子: 为zabbix增加服务器信息统计(服务器品牌、型号、SN号等) 下篇帖子: 自动化运维工具之Zabbix分布式监控应用(五)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表