分类: LINUX
2009-11-02 15:16:04
1.创建ZABBIX的系统账号
为了安全起见建议创建使用zabbix用户运行ZABBIX
groupadd zabbix
useradd zabbix
2.安装环境apache,php,mysql
搭建LAMP环境
mysql-devel
net-snmp-devel
curl-devel
perl-DBI
php-gd
php-mysql
php-bcmath
2.1安装apache
emerge gd
emerge jpeg
emerge zlib
emerge libpng
emerge freetype
tar zxvf httpd-2.2.4.tar.gz
cd httpd-2.2.4
./configure –prefix=/usr/local/apache –enable-so –with-gd –with-jpeg-dir=/usr –with-png-dir=/usr
-with-zlib-dir=/usr –with-freetype-dir=/usr
make
make install
2.2安装mysql
tar -zxvf mysql-5.0.37.tar.gz
cd mysql-5.0.37
groupadd mysql
useradd -g mysql mysql
./configure –prefix=/usr/local/mysql –with-charset=gbk
–with-extra-charsets=gb2312,latin1,utf8 –enable-largefile -
-with-big-tables –
localstatedir=/usr/local/mysql/data –without-debug –with-max-indexes=64 –without-ndbcluster
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cp /root/mysql-5.0.37/support-files/mysql.server /usr/local/mysql/mysql
chmod +x /usr/local/mysql/mysql
cd /usr/local/mysql
bin/mysql_install_db –user=mysql
chown -R root .
chown -R mysql .
chgrp -R mysql .
chown mysql.mysql -R data
2.3安装PHP
emerge dev-libs/libxml
emerge dev-libs/libxml2 //如果没装libxml,则编译会出现configure: error: xml2-config not found.
tar zxvf php-5.2.1.tar.gz
cd php-5.2.1
/configure –with-apxs2=/usr/local/apache/bin/apxs –with-mysql-dir=/usr/local/mysql –with-gd –with-jpeg-dir=/usr
–with-png-dir=/usr -with-zlib-dir=/usr –with-freetype-dir=/usr
make
make install
cp php.ini-dist /usr/local/lib/php.ini
vi /usr/local/httpd/conf/httpd.conf 手动添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps #这两行是让apache知道php的文件类型
DirectoryIndex index.html 修改为DirectoryIndex index.html index.php 让apache支持index.php
echo ‘/usr/local/mysql/lib/mysql’>>/etc/ld.so.conf
保证你的LAMP环境搭建好了后进行下一步操作
3.数据库及其相关表的建立
tar xvzf zabbix-1.6.6.tar.gz
mysql -u root -p
mysql> create database zabbix;
mysql>quit;
cd create/schema/
cat mysql.sql | mysql -u root -p zabbix
cd ../data/
cat data.sql | mysql -u root -p zabbix
cat images_mysql.sql | mysql -u root -p zabbix
4.编译及安装zabbix
4.1服务器端的编译
./configure –with-mysql –with-net-snmp –with-libcurl –enable-server –enable-agent –enable-proxy
–prefix=/usr/local/zabbix
make install
make clean
4.2客户端的编译
./configure –prefix=/usr/local/zabbix –enable-agent
make install
make clean
4.3添加服务 这一步没有必要(建议添加)
vi /etc/services
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
5.创建WEB管理及自启动管理
5.1web
cd frontends/
cp -a php /var/www/html/
cd /var/www/html/
mv php zabbix
chown zabbix:zabbix -R zabbix/
cd /var/www/html/zabbix/include
vi db.inc.php
添加如下内容,同时还要修改/var/www/html/zabbix/include/setup.inc.php同样加入下面的内容
$DB_TYPE=”MYSQL”;
$DB_SERVER=”localhost”;
$DB_DATABASE=”zabbix”;
$DB_USER=”zabbix”;
$DB_PWD=”******”;
vi /etc/php.ini
找到max_execution_time = 30
改成max_execution_time = 300
找到 ;date.timezone =
改成date.timezone = Asia/Shanghai
5.2启动服务及配置
make /etc/zabbix
cp misc/conf/* /etc/zabbix/
修改一下配置文件
服务端配置文件为:zabbix_server.conf
客户端配置文件为:zabbix_agent(d).conf
自己根据需要修改吧
复制启动脚本
cp misc/init.d/redhat/zabbix_server_ctl /etc/init.d/
cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/
chmod 755 zabbix*
mv zabbix_server_ctl zabbix_server
mv zabbix_agentd_ctl zabbix_agentd
vi zabbix_server在#!/bin/sh后添加如下所示内容
#!/bin/sh
#chkconfig:- 95 95 –服务序号
#description:Zabbix Server –添加描述
# control script to stop/start/restart zabbix_server –控制启动服务名
修改zabbix的安装目录如下所示
# base zabbix dir
BASEDIR=/usr/local/zabbix –你的zabbix的安装目录
# pid file (as of 1.0 beta 10)
PIDFILE=/var/tmp/zabbix_server.pid
# binary file
ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_server
vi zabbix_agentd 类似server的修改
修改好了后
chkconfig –add zabbix_sever
chkconfig –level 345 zabbix_server on
config –add zabbix_agentd
chkconfig –level 345 zabbix_agentd on
下次开机就会运行
启动/停止服务就可以用service zabbix_server start|stop
6.登录
启动服务
默认登录用户名admin密码zabbix