gfdxy3322 发表于 2018-6-20 13:38:06

zabbix的安装监控windows,linux操作流程

  CentOS默认源里没有nginx软件 :wget http://www.atomicorp.com/installers/atomic
  sh ./atomic #安装YUM源
  yum check-update #更新yum软件包
  一、安装nginx
  yum install nginx
  service nginx start
  chkconfig nginx on
  二、安装mysql
  yum install mysql mysql-server mysql-devel
  service mysqld start
  chkconfig mysqld on
  三、安装php
  #安装PHP及组件,使PHP支持 MySQL、PHP支持FastCGI模式
  yum install php php-mysql php-gd libjpeg* php-pear php-xml php-mbstring
  php-mcrypt php-mhash libmcrypt libmcrypt-devel php-imap php-ldap php-odbc php-bcmath php-xmlrpc php-fpm
  service mysqld restart
  service nginx restart
  service php-fpm start
  四、配置nginx支持php
  vi /etc/nginx/nginx.conf#修改运行用户
  user nginx;
  vi /etc/nginx/conf.d/default.conf #开启php支持
  index index.php index.html index.htm;
  location ~ \.php$ {
  root html; #取消FastCGI server部分location的注释
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; #$document_root设置为网站根目录
  include fastcgi_params;
  }
  改成这样:
  location ~ \.php$ {
  root         /usr/share/nginx/html;
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_indexindex.php;
  fastcgi_paramSCRIPT_FILENAME/$document_root$fastcgi_script_name;
  include      fastcgi_params;
  }
  并找到 index index.php index.html index.htm; 添加index.php
  1、配置php
  date.timezone = Asia/Shanghai #设置时区
  expose_php = OFF #禁止显示版本信息
  2、配置php-fpm
  vi /etc/php-fpm.d/www.conf
  user = nginx
  group = nginx
  3、测试
  chown -R nginx.nginx /usr/share/nginx/html/ #设置目录所有者
  chmod 774 -R /usr/share/nginx/html/ #设置目录权限
  service mysqld restart
  service nginx restart
  service php-fpm restart
  cd /usr/share/nginx/html/
  vi index.php
  <?Php phpinfo();?>
  http://127.0.0.1 #可以看到相关的配置信息!
  编辑安装zabbix
  1、修改php.ini,以达到zabbixserver的要求
  # vim/etc/php.ini
  date.timezone = Asia/Shanghai
  max_input_time = 300
  post_max_size = 32M
  max_execution_time = 300
  memory_limit = 128M
  mbstring.func_overload = 2
  2、创建zabbix用户
  3、创建zabbix库,并且给库创建用户设置密码。
  set password =password('你的密码');

  grant all on zabbix.* to zabbix@localhost>  flush privileges;
  4、编译zabbix(确定安装mysql mysql-devel mysql-server) (需要安装依赖库yum -y install net-snmp-devel curl-devel)
  ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl
  5、在/etc/services中添加
  zabbix-agent    10050/tcp               # Zabbix Agent
  zabbix-agent    10050/udp               # Zabbix Agent
  zabbix-server   10051/tcp               # zabbix Trapper
  zabbix-server   10051/udp               # zabbix Trapper
  6、导入数据库并授权
  ls database/mysql/
  data.sqlimages.sqlschema.sql
  mysql -uzabbix -pzabbix zabbix < schema.sql
  mysql -uzabbix -pzabbix zabbix < images.sql
  mysql -uzabbix -pzabbix zabbix < data.sql
  7、创建相关的目录和连接
  # mkdir /var/log/zabbix
  # chown zabbix.zabbix /var/log/zabbix
  # ln -s /usr/local/zabbix/etc/ /etc/zabbix
  # ln -s /usr/local/zabbix/bin/* /usr/bin/
  # ln -s /usr/local/zabbix/sbin/* /usr/sbin/
  8、把zabbix server加入到系统服务
  # cp zabbix-2.4.2/misc/init.d/fedora/core/zabbix_* /etc/init.d
  # vim /etc/init.d/zabbix_server
  BASEDIR=/usr/local/zabbix
  # vim /etc/init.d/zabbix_agentd
  BASEDIR=/usr/local/zabbix
  9、修改配置文件
  # vim /etc/zabbix/etc/zabbix_server.conf
  DBName=zabbix
  DBUser=zabbix
  DBPassword=zabbix
  LogFile=/var/log/zabbix/zabbix_server.log ----自己搜索后再确定
  10、设置zabbix监控自己
  # vim /etc/zabbix/etc/zabbix_agentd.conf
  LogFile=/var/log/zabbix/zabbix_agentd.log
  Server=127.0.0.1,x.x.x.x    被动模式
  ServerActive=x.x.x.x:10051   主动模式
  Hostname=主机名
  UnsafeUserParameters=1
  11、拷贝网页文件到nginx网站目录
  # cp -r zabbix-2.4.2/frontends/php/ /www
  # chown -R nginx.nginx /www
  12、启动zabbix_server和zabbix_agentd并设置开机自启动
  # service zabbix_server start
  # chkconfig zabbix_server on
  # service zabbix_agentd start
  # chkconfig zabbix_agentd on
  另外一种启动方式:
  /usr/local/zabbix/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agent.conf /usr/local/zabbix/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
  监控windows主机
  直接解压放置到C:\磁盘目录中
  安装启动:
  zabbix_agent.exe的路径 -czabbix_agentd.win.conf -i安装
  zabbix_agent.exe的路径 -czabbix_agentd.win.conf -s 启动 -d 卸载
  监控linux服务器:
  关闭selinux
  groupadd zabbix -g 201
  useradd -g zabbix -u 201 -m zabbix
  ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix --enable-agent
  修改/etc/zabbix/zabbix_agentd.conf文件
  zabbix_agent.conf是用超级服务(xinetd)的方式来启动的,
  zabbix_agentd.conf是以独立进程的方式来启动的.
  注释:
  server是被动模式,不要127也行,
  serverActive是主动模式
  启动:
  /usr/local/zabbix/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agent.conf
  添加:
  在server端可以用命令:/usr/local/zabbix/bin/zabbix_get -s 192.168.5.138 -p 10050 -k system.uname进行测试zabbix是否能获取服务端上的数据。
  如果打开了防火墙防火墙需要打开的端口:
  agent 客户端打开:10050
  server 打开:10050 10051 3306 80 9000
页: [1]
查看完整版本: zabbix的安装监控windows,linux操作流程