环境
-
ubuntu
16.
04
-
zabbix4.
0
-
mysql5.
7
-
nginx
安装服务+客户端
被监控主机安装
可视化web GUI
安装nginx
-
wget http:
//nginx.org/keys/nginx_signing.key
-
-
sudo apt-key add nginx_signing.key
-
-
echo
"deb http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.
list
-
-
echo
"deb-src http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.
list
-
-
apt update
-
-
apt install nginx
安装php7.0
-
add-apt-repository ppa:ondrej/php
-
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
创建数据库、用户并授权
-
mysql -uroot -p
-
-
create
database zabbix
character
set utf8
collate utf8_bin;
-
-
grant
all
privileges
on zabbix.*
to zabbix@localhost
identified
by
'123456';
-
-
flush
privileges;
-
-
exit;
安装zabbix4.0
-
wget https://mirrors.aliyun.com/zabbix/zabbix/
4.
0/ubuntu/pool/main/z/zabbix-release/zabbix-release_
4.
0-
2%
2bbionic_all.deb
-
-
dpkg -i zabbix-release_
4.
0-
2+bionic_all.deb
-
-
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,
-
DBHost=localhost
-
-
DBName=zabbix
-
-
DBUser=zabbix
-
-
DBPassword=
123456
配置zabbix前端代码(没有nginx可忽略)
vim /etc/nginx/conf.d/zabbix.conf
-
server {
-
listen
80;
-
server_name
127.0.0.1;
-
root /var/www/zabbix/;
-
access_log /var/log/nginx/zabbix_access.log;
-
error_log /var/log/nginx/zabbix_error.log;
-
index index.php;
-
-
location
~ \.php$ {
-
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
-
fastcgi_index index.php;
-
fastcgi_buffer_size
128k;
-
fastcgi_buffers
64
256k;
-
fastcgi_param SCRIPT_FILENAME /var/www/zabbix
$fastcgi_script_name;
-
include fastcgi_params;
-
}
-
}
修改nginx的user为有访问/var/www/权限的用户
vim /etc/nginx/nginx.conf
user root;
启动相关程序 (nginx加入服务参考https://blog.csdn.net/weixin_43789195/article/details/113740161)
-
systemctl
start nginx
-
-
/etc/init.d/php7
.0-fpm
start
-
-
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
-
post_max_size =
16M
-
-
max_execution_time =
300
-
-
max_input_time =
300
-
-
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
-
PidFile=/var/run/zabbix/zabbix_agentd.pid
-
LogFile=/var/log/zabbix/zabbix_agentd.log
-
LogFileSize=
0
-
# 服务端ip
-
Server=
192.168.
206.131
-
ListenPort=
10050
-
ListenIP=
0.0.
0.0
-
StartAgents=
3
-
# 服务端ip
-
ServerActive=
192.168.
206.131
-
HostnameItem=system.hostname
-
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
-
sudo apt-
get --purge
remove zabbix-server-mysql
-
sudo apt-
get autoremove zabbix-server-mysql
-
-
sudo apt-
get --purge
remove zabbix-frontend-php
-
sudo apt-
get autoremove zabbix-frontend-php
-
-
sudo apt-
get --purge
remove abbix-apache-conf
-
sudo apt-
get autoremove abbix-apache-conf
-
-
sudo apt-
get --purge
remove zabbix-agent
-
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