飞道的博客

ubuntu 安装 zabbix+mysql+nginx 及卸载

256人阅读  评论(0)

环境


  
  1. ubuntu 16. 04
  2. zabbix4. 0
  3. mysql5. 7
  4. nginx

安装服务+客户端

被监控主机安装

可视化web GUI

安装nginx


  
  1. wget http: //nginx.org/keys/nginx_signing.key
  2. sudo apt-key add nginx_signing.key
  3. echo "deb http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources. list
  4. echo "deb-src http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources. list
  5. apt update
  6. apt install nginx

安装php7.0


  
  1. add-apt-repository ppa:ondrej/php
  2. apt install php 7. 0

安装php插件

apt install -y php7.0-fpm php7.0-curl php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip php7.0-dev php7.0-bcmath php7.0-ldap

安装mysql5.7

apt install mysql-server

创建数据库、用户并授权


  
  1. mysql -uroot -p
  2. create database zabbix character set utf8 collate utf8_bin;
  3. grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
  4. flush privileges;
  5. exit;

安装zabbix4.0


  
  1. wget https://mirrors.aliyun.com/zabbix/zabbix/ 4. 0/ubuntu/pool/main/z/zabbix-release/zabbix-release_ 4. 0- 2% 2bbionic_all.deb
  2. dpkg -i zabbix-release_ 4. 0- 2+bionic_all.deb
  3. apt update

安装插件

apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

数据导入数据库

zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix

配置zabbix

vim /etc/zabbix/zabbix_server.conf,


  
  1. DBHost=localhost
  2. DBName=zabbix
  3. DBUser=zabbix
  4. DBPassword= 123456

配置zabbix前端代码(没有nginx可忽略)

vim /etc/nginx/conf.d/zabbix.conf


  
  1. server {
  2.     listen   80;
  3.     server_name 127.0.0.1;
  4.     root /var/www/zabbix/;
  5.     access_log      /var/log/nginx/zabbix_access.log;
  6.     error_log       /var/log/nginx/zabbix_error.log;
  7.     index index.php;
  8.     location ~ \.php$ {
  9.           fastcgi_pass   unix:/var/run/php/php7.0-fpm.sock;
  10.           fastcgi_index  index.php;
  11.           fastcgi_buffer_size 128k;
  12.           fastcgi_buffers 64 256k;
  13.           fastcgi_param  SCRIPT_FILENAME  /var/www/zabbix $fastcgi_script_name;
  14.           include        fastcgi_params;
  15.       }
  16. }

修改nginx的user为有访问/var/www/权限的用户

vim /etc/nginx/nginx.conf

user root;

启动相关程序 (nginx加入服务参考https://blog.csdn.net/weixin_43789195/article/details/113740161


  
  1. systemctl start nginx
  2. /etc/init.d/php7 .0-fpm start
  3. systemctl restart zabbix- server zabbix- agent

设置开机启动

systemctl enable zabbix-server zabbix-agent nginx

浏览器访问zabbix

127.0.0.1/setup.php

apache版 和 具体配置参考:https://www.cnblogs.com/yjlch1016/p/8371049.html

 

根据报错信息提示修改php的参数

vim /etc/php/7.0/fpm/php.ini


  
  1. post_max_size = 16M
  2. max_execution_time = 300
  3. max_input_time = 300
  4. date.timezone = Asia/Shanghai

重启php7.0-fpm

/etc/init.d/php7.0-fpm restart

安装客户端(被监控主机)

安装zabbix-agent

apt install zabbix-agent

配置zabbix-agent

vim /etc/zabbix/zabbix_agentd.conf


  
  1. PidFile=/var/run/zabbix/zabbix_agentd.pid
  2. LogFile=/var/log/zabbix/zabbix_agentd.log
  3. LogFileSize= 0
  4. # 服务端ip
  5. Server= 192.168. 206.131
  6. ListenPort= 10050
  7. ListenIP= 0.0. 0.0
  8. StartAgents= 3
  9. # 服务端ip
  10. ServerActive= 192.168. 206.131
  11. HostnameItem=system.hostname
  12. Include=/etc/zabbix/zabbix_agentd.d/*.conf

启动zabbix-agent

systemctl start zabbix-agent

提示:请确保10050正常监听并能够和zabbix正常通信;

服务端添加新主机参考:https://www.cnblogs.com/qiuhom-1874/p/14007342.html

卸载zabbix


  
  1. sudo apt- get --purge remove zabbix-server-mysql
  2. sudo apt- get autoremove zabbix-server-mysql
  3. sudo apt- get --purge remove zabbix-frontend-php
  4. sudo apt- get autoremove zabbix-frontend-php
  5. sudo apt- get --purge remove abbix-apache-conf
  6. sudo apt- get autoremove abbix-apache-conf
  7. sudo apt- get --purge remove zabbix-agent
  8. sudo apt- get autoremove zabbix-agent

清理数据

sudo dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

删除以上apt-get卸载的软件包

sudo apt-get autoclean

删除缓存的所有软件包

sudo apt-get clean

删除其他软件依赖的但现在已不用的软件包(保留配置文件)

sudo apt-get autoremove

OK.


转载:https://blog.csdn.net/weixin_43789195/article/details/116665105
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场