zabbix安装
基础环境:
Nginx:1.9.7
Mysql:5.5.32
PHP:5.5.30( zabbix_3.0 要求php版本至少在5.4以上 )
Nginx安装:
1.rpm -qa pcre pcre-devel
2.yum install pcre pcre-devel openssl openssl-devel -y
4.useradd nginx -s /sbin/nologin -M
5../configure --user=nginx --group=nginx --prefix=/application/nginx-1.9.7 --with-http_stub_status_module --with-http_ssl_module
make && make installln -s /application/nginx-1.9.7 /application/nginx
6.ls -l /application/
7./application/nginx/sbin/nginx
8.ps -ef|grep nginx
9.ss -lntup|grep nginx
[root@zabbix_3.0 conf]# egrep -v "#|^$" nginx.conf.default > nginx.conf
[root@zabbix_3.0 conf]# vim /application/nginx/conf/nginx.conf
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.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.(php|php5)?$ {
root /application/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /application/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}
}
MySql安装:
yum install tree nmap lrzsz dos2unix -y
[root@zabbix_3.0 tools]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz [root@zabbix_3.0 tools]# mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32[root@zabbix_3.0 tools]# ln -s /application/mysql-5.5.32/ /application/mysql
[root@zabbix_3.0tools]# useradd mysql -s /sbin/nologin -M[root@zabbix_3.0 tools]# chown -R mysql.mysql /application/mysql
[root@zabbix_3.0 tools]# cd /application/mysql
vim /etc/hosts[root@zabbix_3.0 mysql]# ./scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
cp support-files/mysql.server /etc/init.d/mysqld
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
cp support-files/my-small.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
source /etc/profile
[root@zabbix_3.0 application]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@zabbix_3.0 application]# cp -a /application/mysql/bin/* /usr/local/sbin
service mysqld start
mysqladmin -uroot password jiayuan.com
PHP安装:
1.yum -y install zlib-devel libxml2-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel
2.wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gzcd libiconv-1.14./configure --prefix=/usr/local/libiconvmakemake installcd ../
3.yum -y install libmcrypt-devel mhash mcrypt
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
php 5.5.30:( --with-mysqli=mysqlnd和--with-gettext一定要加上,否则前者不装时安装 zabbix时database type没有选项 默认出来的数据库是SqLite 3,且不能切换 ,后者不装时,会报PHP gettext warning)
./configure \
--prefix=/application/php5.5.30 \
--with-mysql=/application/mysql/ \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--with-gettext \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp \
--enable-opcache=no
make && make install
[root@zabbix_3.0 php-5.5.30]# ln -s /application/php-5.5.30/ /application/php
生成配置php配置文件
[root@zabbix_3.0 php-5.5.30]# pwd
/tools/php-5.5.30
[root@zabbix_3.0 php-5.5.30]# cp php.ini-production /application/php/lib/php.ini
[root@zabbix_3.0 php-5.5.30]# cd /application/php/etc/
[root@zabbix_3.0 etc]# pwd
/application/php/etc
[root@zabbix_3.0 etc]# cp php-fpm.conf.default php-fpm.conf
php启动测试
[root@zabbix_3.0 etc]# /application/php/sbin/php-fpm
验证是否成功启动
[root@zabbix_3.0 etc]# netstat -lntup|grep php-fpm
验证LNMP安装是否成功。
Zabbix安装:
[root@zabbix_3.0 ~]# wget http://110.96.193.9:81/1Q2W3E4R5T6Y7U8I9O0P1Z2X3C4V5B/downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha4/zabbix-3.0.0alpha4.tar.gz
[root@zabbix_3.0 ~]# tar xf zabbix-3.0.0alpha4.tar.gz
[root@zabbix_3.0 ~]# groupadd zabbix
[root@zabbix_3.0 ~]# useradd -g zabbix zabbix
[root@zabbix_3.0 ~]# ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2 #添加软连接
[root@zabbix_3.0 ~]# /sbin/ldconfig #使配置立即生效
[root@zabbix_3.0 ~]# cd zabbix-3.0.0alpha4
[root@oldboy zabbix-3.0.0alpha4]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
参数说明
―prefix=/usr/local/zabbix为指定安装目录为/usr/local/zabbix
―enable-server为安装zabbix服务端程序
―enable-agent为安装agent程序
―with-mysql为使用mysql数据库
―enable-ipv6为启用ipv6支持
―with-net-snmp为启用snmp支持
―with-libcurl为启用curl
―with-libxml2编译xml模块,主要用于监控vm虚拟机
[root@oldboy zabbix-3.0.0alpha4]# make && make install
shell> mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> flush privileges;
mysql> quit;
按照SQL语句顺序导入SQL:
shell> mysql -uzabbix -p<password> zabbix < database/mysql/schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -uzabbix -p<password> zabbix < database/mysql/images.sql
shell> mysql -uzabbix -p<password> zabbix < database/mysql/data.sql
修改zabbix.conf:
[root@oldboy zabbix-3.0.0alpha4]# vim /usr/local/etc/zabbix_server.conf
增加:DBPassword=zabbix
DBName=zabbix #数据库名称
DBUser=zabbix #数据库用户名
DBPassword=jiayuan.com #数据库密码
ListenIP=localhost #数据库ip地址
AlertScriptsPath=****/zabbix/alertscripts #zabbix运行脚本存放目录
zabbix 3.0启动方式:
[root@oldboy zabbix-3.0.0alpha4]# cp /application/tools/zabbix-3.0.0alpha4/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server #服务端
[root@oldboy zabbix-3.0.0alpha4]# cp /application/tools/zabbix-3.0.0alpha4/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd #客户端
shell> zabbix_server
修改php.ini:(php5.5默认值较小)
vim /application/php/lib/php.ini 主要为下面几个参数
PHP option post_max_size 16M
PHP option max_execution_time 300
PHP option max_input_time 300
PHP time zone Asia/Shanghai
然后启动php
/application/php/sbin/php-fpm
配置web环境:
cd /application/tools/zabbix-3.0.0alpha4/frontends cp -rf php /application/nginx/html/zabbix
中文支持:
zabbix实际是有中文语言的,我们可以通过修改web端源文件来开启中文语言。
修改你的 locales . inc . php 这个文件
'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true], #也就是把false改为true
然后点击zabbix监控网页端右上角人头头像修改为中文语言即可。
更换语言后,图形会出现乱码,我们做如下修改即可。
修改你的defines.inc.php 这个文件
#修改第93行
define('ZBX_FONT_NAME', 'msyh');
#修改第45行改为
define('ZBX_GRAPH_FONT_NAME', 'msyh')
然后下载微软雅黑字体,改名为msyh传入/home/www/zabbix/fonts 目录下即可。
安装Zabbix-Agent端
1.在agent.jason.com主机上安装:
wget http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2
groupadd zabbix-agent
useradd -g zabbix-agent zabbix-agent
./configure --prefix=/usr/local/zabbix-agent --enable-agent
make install
2.编辑配置文件:
mkdir /var/log/zabbix
chown -R zabbix-agent:zabbix-agent /var/log/zabbix/
vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf
------------------------------------------------------------>
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.19.74
ServerActive=192.168.19.74
Hostname=agent.jason.com
User=zabbix-agent
<------------------------------------------------------------
/usr/local/zabbix-agent/sbin/zabbix_agentd -c /usr/local/zabbix-agent/etc/zabbix_agentd.conf