Zabbix:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Oneleaf留言 | 贡献
无编辑摘要
 
(未显示2个用户的2个中间版本)
第11行: 第11行:
  sudo vim /etc/zabbix/zabbix_server.conf
  sudo vim /etc/zabbix/zabbix_server.conf
修改相关
修改相关
DBHost=localhost
  DBName=zabbix
  DBName=zabbix
  DBUser=zabbix
  DBUser=zabbix
第85行: 第86行:
sudo -Hs
sudo -Hs


#ubuntu 12.04,14.04不需要加
#仅仅用于ubuntu 12.04
#echo "deb http://ppa.launchpad.net/9v-shaun-42/zabbix22/ubuntu precise main" > /etc/apt/sources.list.d/zabbix.list
#echo "deb http://ppa.launchpad.net/9v-shaun-42/zabbix22/ubuntu precise main" > /etc/apt/sources.list.d/zabbix.list
apt-get update
apt-get update
第93行: 第94行:
echo "Server=192.168.3.52,192.168.3.10" > /etc/zabbix/zabbix_agentd.conf.d/server.conf
echo "Server=192.168.3.52,192.168.3.10" > /etc/zabbix/zabbix_agentd.conf.d/server.conf
echo "ServerActive=192.168.3.52" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
echo "ServerActive=192.168.3.52" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
echo "Hostname=`/sbin/ifconfig eth0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'`" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
#echo "Hostname=`/sbin/ifconfig eth0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'`" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
echo "Hostname=`/sbin/ifconfig venet0:0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'`" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
/etc/init.d/zabbix-agent restart
/etc/init.d/zabbix-agent restart
</pre>
</pre>


[[Category:服务器]]
[[Category:服务器]]

2018年10月29日 (一) 14:54的最新版本

在Ubuntu 上安装 Zabbix

安装

安装Apache、Mysql、Php、zabbix

sudo apt-get update 
sudo apt-get install apache2 mysql-server libapache2-mod-php5 php5-gd php5-mysql  php5-common zabbix-server-mysql zabbix-frontend-php


服务端配置

配置数据库连接

sudo vim /etc/zabbix/zabbix_server.conf

修改相关

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
#非必需,但推荐
StartDiscoverers=5

创建mysql账号

mysql -u root -p
mysql> create user 'zabbix'@'localhost' identified by 'zabbix';
mysql> create database zabbix;
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
mysql> flush privileges;
mysql> exit;

导入初始化数据

cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql

修改 PHP 参数

sudo vim /etc/php5/apache2/php.ini

修改项:

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = "Asia/Shanghai"

wwwwww

配置网页

sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php
sudo vim /etc/zabbix/zabbix.conf.php

修改项

$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbix'

配置apache

sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-available/zabbix.conf
sudo a2enconf zabbix.conf
sudo a2enmod alias
sudo service apache2 restart

配置 zabbix server 启动

sudo vim /etc/default/zabbix-server

修改项:

START=yes

启动:

sudo service zabbix-server start

本机监控

sudo apt-get install zabbix-agent
sudo service zabbix-agent restart

访问

http://xxx.xxx.xxx.xxx/zabbix

缺省的账户:

Username = admin
Password = zabbix

客户端配置

sudo apt-get install zabbix-agent

修改配置

sudo vim /etc/zabbix/zabbix_agentd.conf

调整项

Server=127.0.0.1 #修改为 zabbix server 服务器的IP,如果有网关或被监控机为虚拟机也加上母机的IP
ServerActive=127.0.0.1 #修改为 zabbix server 服务器的IP
Hostname=Zabbix server #修改为网页里面添加的Hostname,需要保持一致。

简易脚本:

sudo -Hs

#仅仅用于ubuntu 12.04
#echo "deb http://ppa.launchpad.net/9v-shaun-42/zabbix22/ubuntu precise main" > /etc/apt/sources.list.d/zabbix.list
apt-get update

apt-get install zabbix-agent

echo "Server=192.168.3.52,192.168.3.10" > /etc/zabbix/zabbix_agentd.conf.d/server.conf
echo "ServerActive=192.168.3.52" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
#echo "Hostname=`/sbin/ifconfig eth0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'`" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
echo "Hostname=`/sbin/ifconfig venet0:0|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'`" >> /etc/zabbix/zabbix_agentd.conf.d/server.conf
/etc/init.d/zabbix-agent restart