编译安装 ZABBIX-2.4.7
#Zabbix-2.4.7 笔记#2016.01.17v1.2
#Author wood_man
1.测试环境
VMware 10.0 CentOS release 6.6 (Final) i386kernel 2.6.32-504.el6.i686
2.准备工作
(1) yum 源(epel + cqu.edu)
#rpm -ivhhttp://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
#rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
可选操作:epel.repo中注释所有的"#mirrorlist"使用"baseurl"并且"enabled=1"。
yum install http://mirror.iprimus.com.au/epel/6/i386/epel-release-6-8.noarch.rpm ;(wiki) #wget http://mirrors.cqu.edu.cn/distri/CentOS/6/CentOS-Base.repo(重大源)
#yum clean all
#yum makecache
慎用 缓存到本地安装速度快,但占用带宽和磁盘。缓存位置看/etc/yum.conf
#yum repolist
(2)安全关闭,去掉两座山。
#setenforce 0 ;临时关闭selinux。
#service iptables stop;关闭iptable。
3.安装开发工具包 和 依赖包
#yum -y groupinstall "Development Tools"http://qqadapt.qpic.cn/adapt/0/efc311e8-1539-60a4-c484-c67a552abbd8/800?pt=0&ek=1&kp=1&sce=0-12-12
#yum -y install httpd mysql mysql-server php php-mysql php-common php-mbstring php-gd php-odbc php-pear curl curl-devel net-snmp net-snmp-devel perl-DBI php-xml ntpdatephp-bcmath httpd-manual mod_ssl mod_perl mod_auth_mysql mysql-devel libdbi-dbd-mysql mysql-connector-odbc
4.系统时间
#date 0116231416.10
#hwclock -w
5.创建zabbix服务运行所需的用户和组(500以内)
#groupadd -g 116zabbix
#useradd-g zabbix-u 116 -m zabbix
6.初始化mysql服务器
#/etc/init.d/mysqld start
7.创建zabbix所需要的数据库及用户权限
mysqladmin -uroot -h127.0.0.1password "test"
mysql -uroot-p
>Create Database zabbix character Set utf8;
>Show Databases;
>use zabbix;
>Grant All Privileges ON zabbix.* TO myzabbix@'%' Identified BY 'zabbixpassword';
>flush privileges;
8.下载解压zabbix sources
#cd /usr/src
#wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.4.7/zabbix-2.4.7.tar.gz
#tar -zxf zabbix-2.4.7.tar.gz
9.将zabbix初始数据导入数据库
#cd zabbix-2.4.7
#mysql -u myzabbix-p zabbix < database/mysql/schema.sql
#mysql -u myzabbix-p zabbix < database/mysql/images.sql
#mysql -u myzabbix-p zabbix < database/mysql/data.sql
10.编译安装zabbix,没有"sysconfdir"则默认在/usr/local/etc下
#./configure -sysconfdir=/etc/zabbix/ -enable-server -enable-agent -with-net-snmp -with-libcurl -with-mysql
#make
#make install
11.复制 zabbix server端和agent端的启动脚本,并设置执行权限
#cp misc/init.d/tru64/zabbix_* /etc/init.d/
chmod +x /etc/init.d/zabbix_*
12.将zabbix的页面文件复制到指定目录(apache默认在/var/www/html)
mkdir -p /var/www/html/zabbix
cp -afrontends/php/*/var/www/html/zabbix/
chown -Rapache.apache /var/www/html/zabbix/
chown -R zabbix.zabbix /etc/zabbix
chown zabbix /etc/zabbix/zabbix_server.conf
13.配置php文件,适应zabbix安装所需的参数(一下是X64参数)
vim /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
memory_limit = 128M
mbstring.func_overload = 0
14.配置apache文件,定义虚拟主机并禁止ip访问;注意修改hosts文件。
vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1:80
#DocumentRoot "/var/www/html" (注释line=292)
NameVirtualHost *:80
---------------- 可以忽略
ErrorDocument 403 "Please enter a valid domain name."
ErrorDocument 404 "http://www.tshare365.com"
ErrorDocument 500 "Sorry can't allow you access today"
<virtualHost *:80>
ServerName 192.168.10.*
<Location />
order allow,deny
deny from all
</Location>
</VirtualHost>
-------------
<VirtualHost *:80>
DocumentRoot"/var/www/html"
ServerName www.myzabbix.com
#做些安全控制
<Directory "/var/www/html">
Options SymLinksifOwnerMatch
AllowOverride None
order allow,deny
allow from all
</Directory>
</VirtualHost>
15.配置zabbix 优化参数则需自行研究手册。
(1)server端的文件
#vim /etc/zabbix/zabbix_server.conf
DBHost=127.0.0.1
DBName=zabbix
DBUser=myzabbix
DBPassword=zabbixpassword
AlertScriptsPath=/etc/zabbix/alertscripts
(2)agent端的文件
#vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
UnsafeUserParameters=0 默认不启用自定义脚本,设置为1开启自定义key功能。
Include=/etc/zabbix/zabbix_agentd.conf.d/ 自定义的 agentd 配置文件可以写在这个目录下面
16.启动apache服务跟zabbix服务
(1) 启动相关服务service httpd restart/etc/init.d/zabbix_server restart(2) 设置开机启动编辑/etc/init.d/zabbix*在#!/bin/bash下加一行"#chkconfig: 2345 08 92“chkconfig --add zabbix_serverchkconfig --add zabbix_agentd 17.进入WEB安装
http://www.myzabbix.com/zabbix
18.导入Windows Template
(1)下载模版:Template_OS_Windows-2.4.7.xml
http://www.zabbix.org/wiki/Zabbix_Templates/Official_Templates#Zabbix_2.4.7
(2)修改xml文件内容
替换所有“Template_OS_Windows ”避免跟默认的冲突。
(3)导入模版
Configuration --> Templates --> import (右上方)
19.开启安全功能
(1)开启Selinux,1 = on ; 0 = off
#setenforce 1
If you want to allow zabbix to connect to unreserved ports, you must turn on the zabbix_can_network boolean.
#setsebool -P zabbix_can_network 1
If you want to allow http daemon to connect to zabbix, you must turn on the httpd_can_connect_zabbix boolean.
#setsebool -P httpd_can_connect_zabbix 1
(2)因为设置的zabbix为系统用户所以需用修改
#chcon --reference=/var/www/html -R /var/www/html/zabbix
#restorecon -R -v /var/www/html/zabbix/
(3)Iptables放开必要端口80,10050,10051
#iptables -I INPUT -p tcp --dport 80 -j ACCEPT
#iptables -L -n
#service iptables save
END#参考文档https://www.zabbix.com/documentation/2.4/manual/https://www.zabbix.org/wiki/InstallOnCentOS_6.x_RHEL_6.xhttps://mgrepl.fedorapeople.org/man_selinux/Fedora18/zabbix.htmlhttp://httpd.apache.org/docs/2.2/#源码包http://www.zabbix.com/download.php
页:
[1]