5290589 发表于 2018-1-1 13:49:13

CentOS Linux release 7.3源码安装zabbix

  CentOS Linux>  作者:尹正杰
  版权声明:原创作品,谢绝转载!否则将追究法律责任。
  前言:
  我去年用用centos6的环境搭建了一下 zabbix3.0版本的,新到的公司用的都是centos7的操作系统,没法,之前的搭建的我就没有直接照搬过来,就用centos7研究了一下搭建的方法,也是百度出来的,也才过不少坑,不过终究还是搭建起来了,其实你在看搭建的步骤其实就跟之前的一篇博客的步骤是类似的,只不过是更换了操作系统,以及欢乐一下数据库而已,那么下面我们就一起来用centos7的操作系统来搭建一下zabbix吧,你会发现其实真的很简单。
  一.实验环境

  二.安装依赖工具
# yum -y install gcc* make php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmpnet-snmp-devel perl-DBI httpd mariadb* mysql-devel libxml2-devel curl-devel unixODBC-devel net-snmp-devel OpenIPMI-devel vim   #这个可能需要等待一会时间,因为一次性安装包太多,记住你的服务器要联网在执行这条命令哟~除非你制作的有本地源。
  三.关闭防火漆和selinux
  注意:我这里是因为在局域网,没有做NAT访问工位,如果你给您的服务器配置了一个固定的IP地址的话,建议开启必要的端口,我这里为了试验方便就没有开启了.因为我现在也是一个centos7的新手。以后有时间了可以研究一下如何在开启selinux的情况下使得服务正常运行。建议在内网做监控哟!如果贵公司向用您的zabbix监控您全国各地的服务器的话建议开启防火墙和selinux,避免不法分子的入侵!
#systemctl stop firewalld.service#关闭防火强,重启后有会恢复上一次的配置情况。
# systemctl disable firewalld.service#禁止防火墙开机自启,即重启后,防火墙就不会自动启动了。
# firewall-cmd --state #查看防火墙是否是启动状态
  not running
#
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config#禁用selinux,需重启
# setenforce 0 #临时关闭,不需要重启就关闭了
  四.源码安装zabbix3.2
  1.下载zabbix3.2包,我是在网上download的,大家可以自行下载,以下是我实验环境的安装包:
  链接:http://pan.baidu.com/s/1c25qjpY 密码:ktyw
  2.将安装包上传到服务器上,并解压安装
# mkdir -pv /yinzhengjie/tools/zabbix&& /yinzhengjie/tools/zabbix/ #创建一个存放软件包的目录
# yum -y install lrzsz#安装上传工具,将zabbix安装包上传上来
# tar -xf zabbix-3.2.4.tar.gz
# cd zabbix-3.2.4
# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc
# make -j 4 && make install
  3.严重是否安装成
# echo $? #如果返回值非"0"说明你安装失败了!需要先拍错哪里出了问题~
  0
#
  五.数据库授权
  1.创建管理zabbix的用户
# groupadd zabbix
# useradd zabbix -s /sbin/nologin -M -g zabbix
#
  2.启动数据库
# systemctl start mariadb.service
# echo $?
  0
#
  3.给数据库设置管理密码
# mysqladmin -u root -p password yinzhengjie#设置root的密码为yinzhengjie
  Enter password:#直接回车就好~因为咱们是第一次启动数据库,默认密码为空
# mysql -pyinzhengjie#验证数据库是否能正常登陆,出现以下信息说明配置的就没有问题。
  Welcome to the MariaDB monitor.Commands end with ; or \g.

  Your MariaDB connection>  Server version: 5.5.52-MariaDB MariaDB Server
  Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  MariaDB [(none)]>
  4.数据库授权zabbix用户
# mysql -pyinzhengjie
  Welcome to the MariaDB monitor.Commands end with ; or \g.

  Your MariaDB connection>  Server version: 5.5.52-MariaDB MariaDB Server
  Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
  Query OK, 1 row affected (0.00 sec)
  MariaDB [(none)]> insert into mysql.user(Host,User,Password) values('localhost','zabbix',password('zabbix'));
  Query OK, 1 row affected, 4 warnings (0.00 sec)
  MariaDB [(none)]> flush privileges; #这里要把上面2台语句刷新以下哟~不然直接敲击下一行命令是会报错的,因为数据库此时还没有更新上面两天的数据~
  Query OK, 0 rows affected (0.00 sec)

  MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'localhost'>  Query OK, 0 rows affected (0.00 sec)
  MariaDB [(none)]> flush privileges;
  Query OK, 0 rows affected (0.00 sec)
  MariaDB [(none)]> quit
  Bye
#
  5.导入Sql语句
# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
#
  六.修改PHP的配置参数
# vim /etc/php.ini
  date.timezone= Asia/Shanghai
  max_execution_time = 300
  post_max_size = 32M
  memory_limit = 128M
  mbstring.func_overload = 1
  max_input_time = 300
  七.移动zabbix项目到httpd目录中去
# cp -r ./frontends/php//var/www/html/zabbix
# ll /var/www/html/
  总用量 4
  drwxr-xr-x. 13 root root 4096 4月24 12:22 zabbix
# chown -R apache.apache /var/www/html/zabbix/
# ll /var/www/html/
  总用量 4
  drwxr-xr-x. 13 apache apache 4096 4月24 12:22 zabbix
#
  八.配置开机启动
# cp misc/init.d/fedora/core/zabbix_*   /etc/init.d/
# chkconfig --add zabbix_server
# chkconfig --add zabbix_agentd
# chkconfigzabbix_server on
# chkconfigzabbix_agentd on
#
  九.编译安装Zabbix Agent并配置
  1.安装zabbbix Agent
# pwd
  /yinzhengjie/tools/zabbix/zabbix-3.2.4
#./configure --enable-agent
# make -j 4 && make install
  2.配置zabbix Agent
# more /usr/local/etc/zabbix_agentd.conf | grep -v ^$ | grep -v ^#
  LogFile=/tmp/zabbix_agentd.log
  Server=172.16.96.210,127.0.0.1
  ServerActive=172.16.96.210,127.0.0.1
  Hostname=Zabbix server
# more /usr/local/etc/zabbix_server.conf| grep -v ^# | grep -v ^$
  LogFile=/tmp/zabbix_server.log
  DBHost=localhost
  DBName=zabbix
  DBUser=zabbix
  DBPassword=zabbix
  Timeout=4
  LogSlowQueries=3000
#
  十.启动服务器,web安装zabbix
  1.启动服务
# systemctl enable httpd.service
# systemctl enable mariadb.service
# systemctl start httpd.service
# echo $?
  0
# ps -ef | grep http#检查服务是否启动成功
  root      9968   11 13:04 ?      00:00:00 /usr/sbin/httpd -DFOREGROUND
  apache    997099680 13:04 ?      00:00:00 /usr/sbin/httpd -DFOREGROUND
  apache    997199680 13:04 ?      00:00:00 /usr/sbin/httpd -DFOREGROUND
  apache    997299680 13:04 ?      00:00:00 /usr/sbin/httpd -DFOREGROUND
  apache    997399680 13:04 ?      00:00:00 /usr/sbin/httpd -DFOREGROUND
  apache    997499680 13:04 ?      00:00:00 /usr/sbin/httpd -DFOREGROUND
  root      997623610 13:04 pts/0    00:00:00 grep --color=auto http
#
  2.web登录
  输入服务器IP地址+项目名称

  点击下一步

  输入密码zabbix点击下一步

  点击下一步

  继续点击下一步,别克制

  点击完成

  输入用户名和密码:注意用户名第一个字母是大写哟~

  打完收工,如果想看如何将页面配置成中文的话请参考:http://www.cnblogs.com/yinzhengjie/p/6126943.html
页: [1]
查看完整版本: CentOS Linux release 7.3源码安装zabbix