码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix安装部署

时间:2017-08-19 13:05:37      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:com   配置   替换   host   html   远程   ide   sqlite   ast   

Zabbix安装配置

第1章 安装及介绍

1.1 Zabbix介绍

zabbix(音同 zabbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。

zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

zabbix由2部分构成,zabbix server与可选组件zabbix agent。

zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

1.2 安装zabbix准备软件

Mysql  :mysql-5.6.23.tar.gz
Php    :php-5.5.30.tar.gz
Nginx  :nginx-1.9.6.tar.gz
Zabbix-server :zabbix-3.0.3.tar.gz
Zabbix-cli    :zabbix-agent-3.0.3-1.el6.x86_64.rpm

1.3 Lnmp搭建

1.3.1 安装lnmp所需依赖包

yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel pcre pcre-devel net-snmp-devel cmake 

1.3.2 安装nginx

tar zxf nginx-1.9.6.tar.gz

cd /home/shangbang/tools/nginx-1.9.6

useradd nginx -s /sbin/nologin -M 

./configure --user=nginx --group=nginx --prefix=/application/nginx --error-log-path=/application/nginx/error_log --pid-path=/application/nginx/pid

make && make install

chown -R nginx:nginx /application/nginx/

grep -Ev "#|^$" /application/nginx/conf/nginx.conf.default >/application/nginx/conf/nginx.conf

cat >/application/nginx/conf/nginx.conf<<EOF
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm index.php;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
   location ~ .*\.(php|php5)?$
   {     
     fastcgi_pass  127.0.0.1:9000;
     fastcgi_index index.php;
     include fastcgi.conf;       
   }
    }
}
EOF

cp /home/shangbang/tools/nginx-1.9.6/objs/nginx /etc/init.d/

/etc/init.d/nginx

ps -ef |grep nginx

1.3.3 Mysql安装

yum install ncurses-devel openssl-devel cmake -y

useradd -M -s /sbin/nologin mysql

tar xf mysql-5.6.23.tar.gz 

cd mysql-5.6.23

cmake -DCMAKE_INSTALL_PREFIX=/application/mysql -DMYSQL_DATADIR=/application/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DWITH_DEBUG=0 -DWITH_SSL=system

make && make install

cp support-files/my-default.cnf /etc/my.cnf

chown -R mysql.mysql /application/mysql/

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

chown -R root /application/mysql/

chown -R mysql /application/mysql/data/

cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig mysqld on

echo PATH=/application/mysql/bin/:$PATH >>/etc/profile

source /etc/profile

service mysqld start

mysqladmin -u root password 123.asd

mysql -uroot -p123.asd

create database zabbix character set utf8 collate utf8_bin;

grant all privileges on zabbix.* to zabbix@localhost identified by zabbix;

 flush privileges;

1.1.1 Php安装

tar xf libmcrypt-2.5.8.tar.gz

cd /home/shangbang/tools/libmcrypt-2.5.8

./configure

make && make install

cp -r /home/shangbang/tools/libmcrypt-2.5.8/ /home/shangbang/tools/php-5.5.30/

cd ../

tar zxf php-5.5.30.tar.gz

cd php-5.5.30

./configure --prefix=/application/php --with-config-file-path=/application/php/etc --enable-fpm --with-mysql=/application/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-pear --with-curl --with-openssl --enable-bcmath --enable-sockets --with-mysqli --with-gettext --enable-pdo=shared  --with-pdo-sqlite=shared

make && make install

cp /home/shangbang/tools/php-5.5.30/php.ini-development     /application/php/etc/php.ini

cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf

cp /home/shangbang/tools/php-5.5.30/sapi/fpm/php-fpm /etc/init.d/

sed -i s#;date.timezone =#date.timezone = Asia/Shanghai#g /application/php/etc/php.ini

sed -i s#max_input_time = 60#max_input_time = 300#g /application/php/etc/php.ini

sed -i s#max_execution_time = 30#max_execution_time = 300#g /application/php/etc/php.ini

sed -i s#;always_populate_raw_post_data = On#always_populate_raw_post_data = -1#g 
/application/php/etc/php.ini

sed -i s#post_max_size = 8M#post_max_size = 16M#g /application/php/etc/php.ini
/etc/init.d/php-fpm

ps -ef |grep php

1.4 安装zabbix

1.4.1 Zabbix-server操作

tar -zxf zabbix-3.0.3.tar.gz

cd /home/shangbang/tools/zabbix-3.0.3

./configure --prefix=/application/zabbix  --enable-server --enable-agent --with-net-snmp --with-libcurl --with-libxml2 --with-mysql

make && make install

groupadd zabbix

useradd zabbix -s /sbin/nologin -M -g zabbix

mysql -uroot -p123.asd
##将zabbix数据导入数据库按照顺序来不能乱
mysql -uzabbix -pzabbix zabbix < /home/shangbang/tools/zabbix-3.0.3/database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < /home/shangbang/tools/zabbix-3.0.3/database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < /home/shangbang/tools/zabbix-3.0.3/database/mysql/data.sql
##复制zabbix页面文件到nginx
cp -r /home/shangbang/tools/zabbix-3.0.3/frontends/php/ /application/nginx/html/zabbix

chown -R zabbix:zabbix /application/zabbix/
##清空配置重新写入
>/application/zabbix/etc/zabbix_server.conf

cat >/application/zabbix/etc/zabbix_server.conf<<EOF
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/tmp/mysql.sock
ListenIP=127.0.0.1
Timeout=4
LogSlowQueries=3000
EOF

cp /home/shangbang/tools/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_server /etc/init.d/

sed -i s#BASEDIR=/usr/local#BASEDIR=/application/zabbix#g /etc/init.d/zabbix_server

echo "/application/mysql/lib/" >>/etc/ld.so.conf

ldconfig

/etc/init.d/zabbix_server start

1.4.2 安装客户端操作

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum -y install unixODBC

rpm -ivh zabbix-agent-3.0.3-1.el6.x86_64.rpm 

sed -i s#ServerActive=127.0.0.1#ServerActive=192.168.1.72#g /etc/zabbix/zabbix_agentd.conf 

sed -i s#Server=127.0.0.1#Server=192.168.1.72#g /etc/zabbix/zabbix_agentd.conf   

/etc/init.d/zabbix-agent start
##测试返回值是1为通
/application/zabbix/bin/zabbix_get  -s 192.168.1.72 -k agent.ping

 

1.5 Zabbix修改中文界面and修改乱码问题

1.5.1 修改zabbix中文

 

 

 技术分享

 

 技术分享

 

1.5.2 修改zabbix web界面乱码

在windows下复制这个到zabbix server下
/application/nginx/html/zabbix/fonts
[root@kvm2 fonts]# ls
DejaVuSans.ttf  simkai.ttf
[root@kvm2 fonts]# 

 

 技术分享

 

 

vim /application/nginx/html/zabbix/include/defines.inc.php

%s/DejaVuSans/simkai     将所有的DejaVuSans替换成simkai
这样zabbix就不会有乱码了

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

zabbix安装部署

标签:com   配置   替换   host   html   远程   ide   sqlite   ast   

原文地址:http://www.cnblogs.com/Carr/p/7395655.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!