一、在zabbix主机上需要安装的步骤
1、在已有的LAMP或者LNMP的基础上安装zabbix,安装一些依赖包:
1 |
yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel \ bzip2 bzip2-devel ncurses curl openssl-devel db4-devel libXpm-devel libX11-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c libcurl libcurl-devel |
2、添加用户:
1 2 | groupadd zabbix useradd zabbix -g zabbix |
3、创建数据库,添加授权账号
1 2 | create database zabbix character set utf8; grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix' ; |
4、编译安装zabbix
下载地址:wgethttp://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.0/zabbix-2.2.0.tar.gz
1 2 3 4 5 | tar zxf zabbix- 2.2 . 0 .tar.gz cd zabbix- 2.2 . 0 ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent \ -- with -mysql -- with -net-snmp -- with -libcurl make install |
5、导入数据库
1 2 3 | mysql -uzabbix -pzabbix -hlocalhost zabbix < database/mysql/schema.sql mysql -uzabbix -pzabbix -hlocalhost zabbix < database/mysql/images.sql mysql -uzabbix -pzabbix -hlocalhost zabbix < database/mysql/data.sql |
6、修改配置文件
1 2 3 4 5 6 7 | cp misc/init.d/fedora/core/zabbix_server /etc/init.d/ cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/ cp -R frontends/php / var /www/html/zabbix sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's/^.*DBPassword=.*$/DBPassword=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd |
7、添加服务端口:
1 2 3 4 5 6 | cat >>/etc/services <<EOF zabbix-agent 10050 /tcp Zabbix Agent zabbix-agent 10050 /udp Zabbix Agent zabbix-trapper 10051 /tcp Zabbix Trapper zabbix-trapper 10051 /udp Zabbix Trapper EOF |
8、启动服务
1 2 3 4 | /etc/init.d/zabbix_server start /etc/init.d/zabbix_agentd start echo "/etc/init.d/zabbix_server start" >> /etc/rc.local
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 21314/zabbix_server Installing the Web frontend This is where Apache and PHP come into play. We will need to install some extra php packages for full functionality yum install php-mysql php-gd php-bcmath php-mbstring php-xml Once installed its time to copy the web files to the correct folder, with CentOS and Apache this would be /var/www/html/. cp -r frontends/php/ /var/www/html/ To make the page accessable through http://localhost/zabbix we will have to to rename the folder to zabbix. # mv /var/www/html/php/ /var/www/html/zabbix Apache configuration file for Zabbix frontend is located in /etc/httpd/conf.d/zabbix.conf. Some PHP settings are already configured. php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 # php_value date.timezone Europe/Riga php: /etc/php.ini and change following: max_execution_time = 600 memory_limit = 256M post_max_size = 32M date.timezone = Europe/Zurich mbstring.func_overload = 2 |
9、web页面配置,配置http访问好了后web登陆:http://ip/zabbix
10,如果是nginx做反向代理,使用域名访问,执行以下操作、
server {
listen 80;
server_name zabbix.xxx.com;
index index.html index.php index.html;
root /var/www/html/zabbix;
location ~ ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
参考文章:http://bguncle.blog.51cto.com/3184079/1330247
二、在被监控机器上安装:
1.下载
http://cdnetworks-kr-2.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.0.1/zabbix-2.0.1.tar.gz
2.安装
2)创建用户
添加Zabbix用户和组。
groupadd zabbix useradd zabbix -g zabbix -s /sbin/nologin mkdir /usr/local/zabbix_agentd
2.
tar -zxvf zabbix-2.0.1.tar.gz -C /usr/local/zabbix_agent
3.
cd zabbix-2.0.1
./configure --prefix=/usr/local/zabbix_agent --enable-agent
make install
4.
安装服
cat >>/etc/services<<EOF
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
EOF
5.修改配置文件
vi /usr/local/zabbix_agent/etc/zabbix_agent.conf
修改Zabbix server的ip
Server=127.0.0.1 #若本机不是server,则修改为服务器端的ip
6. cd /usr/local/zabbix_agentdconf 假如没有zabbix_agentd.conf,则从zabbix服务器考一份过来即可,修改内容就ok
vim zabbix_agentd.conf
Server=zabbix ip
Hostname=被监控机器的ip
4.启动
/usr/local/zabbix_agentd/sbin/zabbix_agentd -c /usr/local/zabbix_agentd/conf/zabbix_agentd.conf & --建议使用这个
或者
/usr/local/zabbix_agentd/sbin/zabbix_agentd
5 检查端口是否启动
netstat -tnlp
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 13407/zabbix_agentd