skypaladin 发表于 2019-1-24 11:24:52

centos7.2用rpm包安装zabbix

  centos7.4用rpm包安装zabbix-3.2.11
  #__Author__: Allen_Jol
  #__Date__:2018-06-24
  参考:https://www.abcdocker.com/abcdocker/1402
  查看系统版本
  cat /etc/redhat-release
  CentOS Linux release 7.2.1511 (Core)
  查看内核版本
  uname -r
  3.10.0-693.el7.x86_64
  关闭selinux
  sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
  setenforce 0
  关闭防火墙
  systemctl stop firewalld.service
  systemctl disable firewalld.service
  如果不关闭防火墙需要添加相应的端口,如添加80端口:
  firewall-cmd --permanent --add-port={80/tcp,10051/tcp}添加80端口和10051端口
  firewall-cmd --reload                                 重载防火墙
  更改yum源为阿里源并安装一些所需命令
  yum -y install wget
  cd /etc/yum.repos.d/
  mv CentOS-Base.repo CentOS-Base.repo.bak
  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
  yum clean all && yum makecache
  yum -y install vim unzip net-tools ntpdate psmisc lrzsz
  到zabbix的官网下载相应的rpm包官网地址如下: (我这里没下载直接rpm -ivh安装)
  http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/
  阿里云yum源已经提供了zabbix3.0,因此我们需要使用官方yum源。官方yum源下载会比较慢
  rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
  问题:为什么要下载release版本的zabbix?
  因为下载这个版本会在yum.repos.d下面生成一个zabbix.repo的文件
  ls /etc/yum.repos.d/      会看到一个zabbix.repo
  时间同步
  yum -y install ntp && ntpdate ntp1.aliyun.com
  centos7自带了mariadb-libs需要卸载它
  rpm -qa | grep maraidb
  rpm -e --nodeps mariadb-libs
  安装相关软件包(lamp环境)
  yum -y install zabbix-server zabbix-agent zabbix-web zabbix-server-mysql zabbix-web-mysql mariadb-server mariadb
  注:如果Server端也需要监控则需要安装zabbix-agent
  提示:在Centos7中,mysql改名为mariadb
  修改PHP时区设置
  sed -i 's@# php_value date.timezone Europe/Riga@php_value date.timezone Asia/Shanghai@g' /etc/httpd/conf.d/zabbix.conf
  注意:需要改的配置文件是/etc/httpd/conf.d/zabbix.conf而不是/etc/php.ini
  数据库设置
  systemctl start mariadb
  创建zabbix数据库及用户
  mysql
  create database zabbix character set utf8 collate utf8_bin;
  grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';
  顺便更改下数据库登录密码(mysql-5.7及以后的版本肯能会用别的密码字段 自己百度下吧)
  set password=password('123456');
  flush privileges;
  \q
  导入数据
  cd /usr/share/doc/zabbix-server-mysql-3.2.11/
  zcat create.sql.gz |mysql -uzabbix -p123456 zabbix
  注意:我们使用zcat,专门查看sql.gz包。和cat基本相似
  修改zabbix配置文件
  # vim /etc/zabbix/zabbix_server.conf
  DBHost=localhost          #数据库所在主机
  DBName=zabbix         #数据库名
  DBUser=zabbix             #数据库用户
  DBPassword=zabbix   #数据库密码 ,切记和mysql授权时候的一样,否则web页面显示zabbix_server运行状态为no
  我们用sed方法修改 如下:
  sed -i 's@# DBPassword=@DBPassword=zabbix@g' /etc/zabbix/zabbix_server.conf
  sed -i 's@# DBHost=localhost@DBHost=localhost@g' /etc/zabbix/zabbix_server.conf
  grep -n '^' /etc/zabbix/zabbix_server.conf                        #查看a-Z开头的配置文件
  启动zabbix及apache
  systemctl start zabbix-server
  systemctl start httpd
  注意:如果没有启动成功,要看一下是不是80端口被占用
  Web界面安装zabbix_server
  输入(前面的ip是我zabbix_server服务器ip):
  http://192.168.1.205/zabbix/zabbix.php



页: [1]
查看完整版本: centos7.2用rpm包安装zabbix