Debain系统上部署zabbix

来源:互联网 发布:sublime text js 补全 编辑:程序博客网 时间:2024/06/02 06:00

在安装前

1、sudo apt-get install apache2

2、sudo apt-get install php5

3、sudo apt-get install libapache2-mod-php5

4、sudo /etc/init.d/apache2 restart // 重启apache,此时php5已经可用了

5、sudo apt-get install MySQL-server//数据库账号:root密码:root

6、sudo apt-get install libapache2-mod-auth-mysql

7、sudo apt-get install php5-mysql

   apt-get -y install php5-gd

8、sudo /etc/init.d/apache2 restart // 再次重启apache,使新服务正常激活

启用PHP模块,然后重启apache即可。

OK,apache、php5、mysql都已经可用了。

9、sudo /etc/init.d/apache2 restart

 

这里还需要配置下sudo vi /etc/php5/apache2/php.ini

1、; date.timezone ===>去掉注释在=后添加 Asia/Shanghai

2、max_input_time = 600

3、max_execution_time = 600

4、post_max_size = 32M

5、sudo /etc/init.d/apache2 restart

1. 去zabbix官网下载zabbix2.2.9的tar包,放到服务器上。

2.tar cvf解压缩后,进入解压后的目录

2.1 安装gcc apt-get install gcc

3. 在解压后的zabbix目录下执行安装命令  ./configure --enable-server --enable-agent --with-mysql --with-libxml2 --with-net-snmp --with-openipmi --with-libcurl --with-unixodbc --prefix=/app/zabbix

结果提示错误: configure:error: mysql library not found

这个错误是因为mysql-devel未安装,在debian中不叫mysql-devel,而是叫libmysqld-dev  安装之:apt-get -y install libmysqld-dev 即可解决这个问题 (如果过程中出现找不到源的情况,请更新源 apt-get update)

编译时提示需要安装的包
1)configure: error: no acceptable C compiler found in $PATH
需要安装apt-get -y install gcc
2)configure: error: MySQL library not found
需要安装apt-get -y install libghc6-hsql-mysql-dev
3)configure: error: LIBXML2 library not found
需要安装apt-get -y install libxml2-dev
4)configure: error: unixODBC library not found
需要安装apt-get -y install unixodbc-dev
5)configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
需要安装apt-get -y install libsnmp-dev
6)configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
需要安装apt-get -y install libopenipmi-dev
7)configure: error: Curl library not found
需要安装apt-get -y libcurl4-openssl-dev
8)make命令
需要安装apt-get -y install make

4. 继续执行安装命令,再次提示错误

需要安装: apt-get -y install libxml2-dev unixODBC-dev snmp libsnmp-dev libopenipmi-dev  libcurl4-openssl-dev

装完后继续执行安装命令,应该可以OK通过,如果还不行,则继续看错误,根据错误安装。

5. 根据安装好的提示,接下来要执行make install 命令了,看下本机是否有make命令,没有则apt-get -y install make

然后执行make   make install

6.  做软连接

ln -s /app/zabbix/bin/* /usr/local/bin/
ln -s /app/zabbix/sbin/* /usr/local/sbin/

创建zabbix组和用户

groupadd zabbix

useradd -s /bin/false -g zabbix zabbix

7. 安装mysql,然后创建用户及赋予权限

apt-get install mysql-server mysql-client然后初始化mysql_install_db --user=mysql --datadir=/app/mysql

shell> mysql -uroot -p<password>mysql> create database zabbix character set utf8 collate utf8_bin;mysql> 

  例如: 你想myuser使用mypassword(密码)从任何主机连接到mysql服务器的话。

  mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

mysql> quit;shell> mysql -uzabbix -p<password> zabbix < /root/zabbix-2.4.8/database/mysql/schema.sql# stop here if you are creating database for Zabbix proxyshell> mysql -uzabbix -p<password> zabbix < /root/zabbix-2.4.8/database/mysql/images.sqlshell> mysql -uzabbix -p<password> zabbix < /root/zabbix-2.4.8/database/mysql/data.sql8.先备份配置文件cp /app/zabbix/etc/zabbix_server.conf  /app/zabbix/etc/zabbix_server.conf_bak修改为ListenPort=10051LogFile=/app/zabbix/log/zabbix_server.logPidFile=/app/zabbix/log/zabbix_server.pidDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbixListenIP=127.0.0.1AlertScriptsPath=/app/zabbix/share/zabbix/alertscripts复制为启动脚本cp /root/zabbix-2.4.8/misc/init.d/debian/zabbix-server /etc/init.d/修改/etc/init.d/zabbix-serverPID=/app/zabbix/log/$NAME.pid加权限chmod u+x /etc/init.d/zabbix-server10.建目录并做日志切割处理mkdir /app/zabbix/log chown -R zabbix.zabbix /app/zabbix/logvi /etc/logrotate.d/zabbix_server增加如下语句:/app/zabbix/log/zabbix_server.log{    daily    rotate 7    compress    missingok    notiempty    create 0640 zabbix zabbix    shardscripts}11.启动zabbix_server/etc/init.d/zabbix-server start然后查看是否成功ps aux |grep zabbixnetstat -tupnl |grep zabbix
查看zabbix_server启动日志cat /app/zabbix/log/zabbix_server.log 43736:20150529:095819.674 Starting Zabbix Server. Zabbix 2.2.9 (revision 52686).43736:20150529:095819.674 ****** Enabled features ******43736:20150529:095819.674 SNMP monitoring:           YES43736:20150529:095819.674 IPMI monitoring:           YES43736:20150529:095819.674 WEB monitoring:            YES43736:20150529:095819.675 VMware monitoring:         YES43736:20150529:095819.675 Jabber notifications:       NO43736:20150529:095819.675 Ez Texting notifications:  YES43736:20150529:095819.675 ODBC:                      YES43736:20150529:095819.675 SSH2 support:               NO43736:20150529:095819.675 IPv6 support:               NO43736:20150529:095819.675 ******************************43736:20150529:095819.675 using configuration file: /opt/zabbix/etc/zabbix_server.conf43736:20150529:095819.686 current database version (mandatory/optional): 02020000/0202000143736:20150529:095819.686 required mandatory version: 0202000043740:20150529:095819.721 server #2 started [db watchdog #1]43739:20150529:095819.722 server #1 started [configuration syncer #1]43742:20150529:095819.724 server #4 started [poller #2]43741:20150529:095819.735 server #3 started [poller #1]43743:20150529:095819.739 server #5 started [poller #3]43745:20150529:095819.743 server #7 started [poller #5]43744:20150529:095819.748 server #6 started [poller #4]43749:20150529:095819.756 server #8 started [unreachable poller #1]43752:20150529:095819.763 server #10 started [trapper #2]43751:20150529:095819.764 server #9 started [trapper #1]43755:20150529:095819.774 server #11 started [trapper #3]43756:20150529:095819.775 server #12 started [trapper #4]43757:20150529:095819.776 server #13 started [trapper #5]43761:20150529:095819.781 server #14 started [icmp pinger #1]43762:20150529:095819.782 server #15 started [alerter #1]43764:20150529:095819.786 server #16 started [housekeeper #1]43764:20150529:095819.786 executing housekeeper43766:20150529:095819.799 server #17 started [timer #1]43767:20150529:095819.801 server #18 started [http poller #1]43771:20150529:095819.815 server #20 started [history syncer #1]43774:20150529:095819.823 server #22 started [history syncer #3]43773:20150529:095819.825 server #21 started [history syncer #2]43770:20150529:095819.827 server #19 started [discoverer #1]43778:20150529:095819.837 server #23 started [history syncer #4]43764:20150529:095819.842 housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.050062 sec, idle 1 hour(s)]43780:20150529:095819.845 server #24 started [escalator #1]43781:20150529:095819.846 server #25 started [proxy poller #1]43736:20150529:095819.849 server #0 started [main process]43783:20150529:095819.851 server #26 started [self-monitoring #1]3)查看zabbix-server进程root@192.168.1.124:~# ps aux |grep zabbixzabbix    43736  0.0  0.3 161016  3552 ?        S    09:58   0:00 /usr/local/sbin/zabbix_serverzabbix    43739  0.0  0.2 161024  2628 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: configuration syncer [synced configuration in 0.001632 sec, idle 60 sec]zabbix    43740  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: db watchdog [synced alerts config in 0.001054 sec, idle 60 sec]zabbix    43741  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #1 [got 0 values in 0.000002 sec, idle 5 sec]zabbix    43742  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #2 [got 0 values in 0.000003 sec, idle 5 sec]zabbix    43743  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #3 [got 0 values in 0.000004 sec, idle 5 sec]zabbix    43744  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #4 [got 0 values in 0.000002 sec, idle 5 sec]zabbix    43745  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #5 [got 0 values in 0.000003 sec, idle 5 sec]zabbix    43749  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000004 sec, idle 5 sec]zabbix    43751  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]zabbix    43752  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]zabbix    43755  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]zabbix    43756  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]zabbix    43757  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]zabbix    43761  0.0  0.1 161340  2008 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000006 sec, idle 5 sec]zabbix    43762  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.000148 sec, idle 30 sec]zabbix    43764  0.0  0.2 161264  2256 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.050062 sec, idle 1 hour(s)]zabbix    43766  0.0  0.2 161016  2248 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000016 sec, 0 maintenances in 0.000663 sec, idle 30 sec]zabbix    43767  0.0  0.2 161016  2244 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: http poller #1 [got 0 values in 0.000515 sec, idle 5 sec]zabbix    43770  0.0  0.3 162516  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000871 sec, idle 60 sec]zabbix    43771  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000002 sec, idle 5 sec]zabbix    43773  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000001 sec, idle 5 sec]zabbix    43774  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 5 sec]zabbix    43778  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000002 sec, idle 5 sec]zabbix    43780  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: escalator [processed 0 escalations in 0.000148 sec, idle 3 sec]zabbix    43781  0.0  0.1 161016  1996 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000003 sec, idle 5 sec]zabbix    43783  0.0  0.1 161016  1772 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: self-monitoring [processed data in 0.000003 sec, idle 1 sec]root      43791  0.0  0.0   7836   888 pts/1    S+   10:01   0:00 grep --color=auto zabbix4)查看zabbix监听端口netstat -tupnl |grep zabbixtcp        0      0 192.168.1.124:10051     0.0.0.0:*               LISTEN      43736/zabbix_server

12 安装zabbix-agent和zabbix-web
---放置网站
mkdir /var/www/html/zabbix
cp -a /app/zabbix-2.2.9/frontends/php/ /var/www/html/zabbix/
chown www-data /var/www/html/zabbix/ -R


13 访问http://IP地址/zabbix/就出现以下网站了


点next后出现红字部分


根据红字提示接下来解决1)先备份下原配置文件cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.bak2)修改/etc/php5/apache2/php.ini内容如下always_populate_raw_post_data = -1 注释解开  3)上述全部完成后就可以看到下面图片了

填写对应的DB信息


接下来next


接下来next


接下来next


默认账户(Admin)和密码zabbix


---安装zabbix-agent
./configure  --enable-agent  --prefix=/app/zabbix
make
make install
 做软连接
ln -s /app/zabbix/bin/* /usr/local/bin/
ln -s /app/zabbix/sbin/* /usr/local/sbin/


创建zabbix组和用户
groupadd zabbix
useradd -s /bin/false -g zabbix zabbix


--复制配置文件
cp /app/zabbix/etc/zabbix_agentd.conf  /app/zabbix/etc/zabbix_agentd.conf_bak
vi /app/zabbix/etc/zabbix_agentd.conf
ListenPort=10050
LogFile=/app/zabbix/log/zabbix_agentd.log
PidFile=/app/zabbix/log/zabbix_agentd.pid
Server=192.168.3.72
ServerActive=192.168.3.72:10051
Hostname=192.168.3.98
Include=/app/zabbix/etc/zabbix_agentd.conf.d/


复制为启动脚本
cp /app/zabbix-2.2.9/misc/init.d/debian/zabbix-agent /etc/init.d/
vi /etc/init.d/zabbix-agent
PID=/app/zabbix/log/$NAME.pid
加权限 chmod u+x /etc/init.d/zabbix-agent


--建日志
mkdir /app/zabbix/log
 chown -R zabbix.zabbix /app/zabbix/log
vi /etc/logrotate.d/zabbix_agent
增加如下语句:/app/zabbix/log/zabbix_agent.log{
    daily
    rotate 7
    compress
    missingok
    notiempty
    create 0640 zabbix zabbix
    shardscripts
}


--加入开机自启
update-rc.d zabbix-server defaults
update-rc.d zabbix-agent defaults
/etc/init.d/zabbix-agent start


--测试是否开通
zabbix_get -s 192.168.3.98 -p 10050 -k "system.cpu.load[all,avg1]"


在监控web页面上将被监控的服务器启动监控

                                             
0 0
原创粉丝点击