ZABBIX安装配置过程

1.环境描述:

redhat 6.5

zabbix 2.4.5

172.30.0.195

wps791F.tmp

2.环境准备:

yum install pcre*

yum install openssl*

yum -y install net-snmp-devel curl-devel

yum -y install automake autoconf libtool make

yum -y install gcc gcc-c++ glibc

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

3.安装配置php

3.1 php下载安装

wget http://cn2.php.net/distributions/php-5.5.25.tar.gz

tar zxvf php-5.5.25.tar.gz

./configure --prefix=/usr/local/php-5.5.0 --with-config-file-path=/usr/local/php-5.5.25/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

make && make install

3.2 php配置

3.2.1 php.ini的配置:

注意到编译参数位置--with-config-file-path=/usr/local/php-5.5.5/etc

复制一下php.ini到指定位置

cp /usr/local/php-5.5.0/php.ini  /usr/local/php-5.5.0/etc/php.ini

修改参数:

vim /usr/local/php-5.5.0/etc/php.ini  //修改以下地方

date.timezone =Asia/Shanghai

post_max_size =32M

max_execution_time =300

max_input_time =300

3.2.2 启动php-fmp

/usr/local/php-5.5.0/sbin/php-fpm

3.2.3解决nginx下php-fpm不记录php错误日志的方法

修改php-fpm.conf中配置 没有则增加

catch_workers_output = yes

error_log = /data/logs/nginx/php-fpm.log

修改php.ini中配置,没有则增加

log_errors = On

error_reporting=E_ALL&~E_NOTICE

error_log = /data/logs/nginx/php_errors.log

3.2.4若在编译阶段没有指定bcmath模块,可在后续安装,其他未安装模块方法类似

cd /u01/soft/php-5.5.25/ext/bcmath

/usr/local/php-5.5.0/bin/phpize

./configure --with-php-config=/usr/local/php-5.5.0/bin/php-config

make && make install

vi /usr/local/php-5.5.0/etc/php.ini 添加

extension=bcmath.so

4.安装配置nginx

4.1 这里使用简单的yum安装nginx

yum install ngnix

4.2配置nginx

在/etc/nginx/nginx.conf默认配置文件中,在http代码块中添加以下代码:

        server{

                        listen       88;

                        root   /data/site/zabbix-server.com;

                        index  index.html index.htm index.php;

                        location ~ .*\.(php|php5)?$

                        {

                                        fastcgi_pass  127.0.0.1:9000;

                                        fastcgi_index index.php;

                                        include fastcgi.conf;

                        }

                        access_log /data/logs/nginx/zabbix-server.com.access.log;

        }

4.3启动nginx

service ngnix start

5.安装配置Mysql

5.1安装mysql

rpm -ivh MySQL-server-advanced-5.6.22-1.el6.x86_64.rpm MySQL-client-advanced-5.6.22-1.el6.x86_64.rpm MySQL-devel-advanced-5.6.22-1.el6.x86_64.rpm

5.2修改root密码

在安装完毕后会有一段提示,root默认密码存储在哪个文件里,可以查看。

more /root/.mysql_secret

然后使用默认密码连接mysql并修改当前root密码

mysql> set password=password('abc123');

5.3创建指定数据库和用户

mysql> create database zabbix character set utf8;

Query OK, 1 row affected (0.06 sec)

mysql>  grant all on zabbix.* to zabbix@localhost identified by 'redhat';

Query OK, 0 rows affected (0.05 sec)

6.Zabbix服务安装配置

6.1安装Zabbix

wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz

tar zxvf zabbix-2.4.5.tar.gz

./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl

make && make install

6.2使用zabbix样本sql创建mysql数据库表结构

[root@mongodb-mms mysql]# ls

data.sql  images.sql  schema.sql

[root@mongodb-mms mysql]# pwd

/u01/soft/zabbix-2.4.5/database/mysql

[root@mongodb-mms mysql]# mysql -uzabbix -p'redhat' zabbix < schema.sql

Warning: Using a password on the command line interface can be insecure.

[root@mongodb-mms mysql]# mysql -uzabbix -p'redhat' zabbix < images.sql

Warning: Using a password on the command line interface can be insecure.

[root@mongodb-mms mysql]# mysql -uzabbix -p'redhat' zabbix < data.sql

Warning: Using a password on the command line interface can be insecure.

6.3 修改services

[root@mongodb-mms zabbix-2.4.5]# cat >> /etc/services <<eof

> zabbix-agent    10050/tcp                           #ZabbixAgent

> zabbix-agent    10050/udp                           #Zabbix Agent

> zabbix-trapper  10051/tcp                            #ZabbixTrapper

> zabbix-trapper  10051/udp                             #Zabbix Trapper

> eof

6.4修改zabbix服务数据库配置文件

# vim /usr/local/zabbix/etc/zabbix_server.conf   //修改以下内容

DBName=zabbix

DBUser=zabbix

DBPassword=redhat

DBSocket=/tmp/mysql.sock  

DBPort=3306

6.5 将zabbix配置成服务

[root@mongodb-mms zabbix-2.4.5]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/

[root@mongodb-mms zabbix-2.4.5]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/

分别修改/etc/init.d/zabbix_server、zabbix_agentd将其中的BASEDIR改为实际zabbix的安装位置,如我们这里的/usr/local/zabbix

vim /etc/init.d/zabbix_server

BASEDIR=/usr/local/zabbix

6.6启动zabbix

service zabbix_server start

service zabbix_agentd  start

6.7进入web界面配置

htttp://172.30.0.195:88

wps7930.tmp

wps7931.tmp

7.Zabbix agent安装配置

7.1 zabbix server服务器的agent配置

vim /usr/local/zabbix-2.2.2/etc/zabbix_agentd.conf

Server=127.0.0.1

ServerActive=127.0.0.1

Hostname=Zabbix server

Server和ServerActive都指定zabbixserver的IP地址,不同的是,前者是被动后者是主动。

重启agent即可

/usr/local/zabbix-2.2.2/sbin/zabbix_agentd restart

7.2 其他服务器的agent配置

7.2.1 添加zabbix用户

useradd -s /sbin/nologin -d /dev/null zabbix

7.2.2 agent的下载安装

wget http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-agent-2.4.5-1.el6.x86_64.rpm

wget http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-2.4.5-1.el6.x86_64.rpm

rpm -ivh zabbix-*

7.2.3 修改agent配置文件

vi /etc/zabbix/zabbix_agentd.conf

Server=172.30.0.195

Hostname=Mongodb-test1

附:一种简单的修改配置方法:

sed -i 's/^Server=.*$/Server=172.30.0.195./g' /etc/zabbix/zabbix_agentd.conf 

sed -i 's/^Hostname=.*$/Hostname= Mongodb-test1/g' /etc/zabbix/zabbix_agentd.conf 

7.2.4 修改service配置

cat>>/etc/services<  

zabbix_agent 10050/tcp 

zabbix_trap 10051/tcp 

EOF

7.2.5 启动agent

agent默认的配置文件为/etc/zabbix/zabbix_agentd.conf,所以一般无需指定

/usr/sbin/zabbix_agentd

7.2.6 检查agent是否成功(另需要在zabbix中查看host是否有一个Z绿色标志)

netstat -utlnp | grep zabbix 

/usr/local/zabbix/bin/zabbix_get  -s172.30.0.233 -p10050 -k"net.if.in[eth0]"

/usr/local/zabbix/bin/zabbix_get  -s172.30.0.233 -p10050 -k"system.uptime"

日志文件/var/log/za...

你可能感兴趣的:(style,border,target,title,blank)