请选择 进入手机版 | 继续访问电脑版
查看: 594|回复: 1

Zabbix监控之Centos基于LNMP环境安装

34

主题

34

帖子

138

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
138
羊大仙 发表于 2015-12-10 20:22:05 | 显示全部楼层 |阅读模式

 

本文描述zabbixlnmp环境中的搭建过程,为减少配置难度,mysql,php采用yum安装。系统版本是centos6.4。

本安装过程以直接高效的方式叙述。


1Yum安装mysql

mysql使用yum安装方式

yum install mysql-servermysql-devel mysql

/etc/init.d/mysqld start

 

2Yum安装php

yum安装后的php配置文件是/etc/php.ini

yum install -y php php-mysqlphp-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpcphp-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm

 

sed -i 's/^user =.*/user =nginx/g' /etc/php-fpm.d/www.conf

sed -i 's/^group =.*/group =nginx/g' /etc/php-fpm.d/www.conf

/etc/init.d/php-fpm start

 

3、编译安装nginx

3.1 安装pcre

nginx安装需要pcre的支持。

wget  ftp://ftp.csx.cam.ac.uk/pub/soft ... re/pcre-8.33.tar.gz

yum install gcc*   #解决编译无gcc包问题

tar -zxf pcre-8.33.tar.gz

cd pcre-8.33

./configure

echo $?

make && make install

3.2 安装nginx

wget  http://nginx.org/download/nginx-1.4.7.tar.gz

useradd nginx -s /sbin/nologin-M

./configure --user=nginx--group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module--with-http_ssl_module

echo $?

make && make install

 

3.3 测试nginx

[root@qssec-centos-01nginx-1.4.7]# /usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx:error while loading shared libraries: libpcre.so.1: cannot open shared objectfile: No such file or directory

 

echo /usr/local/lib>>/etc/ld.so.conf

ldconfig

 

[root@qssec-centos-01nginx-1.4.7]# /usr/local/nginx/sbin/nginx -t      

nginx: the configuration file/usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file/usr/local/nginx/conf/nginx.conf test is successful

#此时可以在浏览器输入nginx的IP地址。


4、配置nginx关联php

4.1 修改nginx配置文件

nginx.conf中加入如下红色内容

vi/usr/local/nginx/conf/nginx.conf

    server {

        listen       80;

        server_name  localhost;

        location / {

            root   html;

            index  index.html index.htm index.php;

        }

        location ~ \.php$ {

            root           html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            include        fastcgi_params;

            include        fastcgi.conf;

        }

}

#红色这段作用是把php结尾的url交给php进程处理。

 

4.2 添加phpinfo

创建phpinfo文件

cat >/usr/local/nginx/html/index.php <<EOF

<?php

phpinfo();

?>

EOF


4.3 测试Php解析

在浏览器输入测试urlhttp://IP/index.php,出现如下界面则解析成功。


5、安装zabbix server

5.1 安装zabbix server

yum -y install libcurl-develnet-snmp-devel  #视实际情况系统环境,如果后面欠缺某些库,可以再次yum

useradd zabbix -s/sbin/nologin

 

cd /usr/local/src

wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz/download

tar zxf zabbix-2.2.2.tar.gz

cd zabbix-2.2.2

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

make && make install

 

5.2 创建数据库,添加授权账号

 

create database zabbix characterset utf8;

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

delete from mysql.user whereuser="";  #删除空用户名

flush privileges;

 

5.3 导入数据库

cd /usr/local/src/zabbix-2.2.2

mysql -uzabbix -pzabbix-h127.0.0.1 zabbix < database/mysql/schema.sql

mysql -uzabbix -pzabbix-h127.0.0.1 zabbix < database/mysql/images.sql

mysql -uzabbix -pzabbix-h127.0.0.1 zabbix < database/mysql/data.sql


5.4 拷贝zabbix启动文件

cpmisc/init.d/fedora/core/zabbix_server /etc/init.d/

cpmisc/init.d/fedora/core/zabbix_agentd /etc/init.d/

 

5.5 修改配置文件及启动文件

sed -i 's/^DBUser=.*$/DBUser=zabbix/g'/usr/local/zabbix/etc/zabbix_server.conf

sed -i's/^.*DBPassword=.*$/DBPassword=zabbix/g'/usr/local/zabbix/etc/zabbix_server.conf

sed -i 's/^.*DBHost=.*$/DBHost=127.0.0.1/g'/usr/local/zabbix/etc/zabbix_server.conf

 

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

sed -i's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g'/etc/init.d/zabbix_agentd


5.6 添加zabbix服务端口

cat >>/etc/services<<EOF

zabbix-agent 10050/tcp ZabbixAgent

zabbix-agent 10050/udp ZabbixAgent

zabbix-trapper 10051/tcpZabbix Trapper

zabbix-trapper 10051/udpZabbix Trapper

EOF


5.7 启动zabbix服务

/etc/init.d/zabbix_serverstart

/etc/init.d/zabbix_agentdstart

echo "/etc/init.d/zabbix_serverstart" >> /etc/rc.local

echo "/etc/init.d/zabbix_agentdstart" >> /etc/rc.local

 

netstat -plnt|grep zabbix

tcp        0     0 0.0.0.0:10050              0.0.0.0:*                   LISTEN      834/zabbix_agentd  

tcp        0     0 0.0.0.0:10051              0.0.0.0:*                   LISTEN      769/zabbix_server  


5.8 复制web端到nginx的工作目录

cd /usr/local/src/zabbix-2.2.2

cp -ra frontends/php//usr/local/nginx/html/zabbix

chown -R nginx.nginx  /usr/local/nginx/html/zabbix


5.9 在浏览器输入http://IP/zabbix/index.php

wKiom1PyHriSeGhTAAH0w2CGeH4096.jpg

 

5.10 修改php配置满足zabbix安装要求

sed -i 's/^\(.*\)date.timezone=.*$/date.timezone = Asia\/Shanghai/g' /etc/php.ini
sed -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /etc/php.ini
sed -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /etc/php.ini
sed -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /etc/php.ini
/etc/init.d/php-fpm restart


wKiom1PyHrbQmba2AAJQANd5LL4008.jpg

 

5.11 zabbix连接数据库

  输入上述配置的用户名密码:

  数据库名称为:zabbix

  数据库用户名:zabbix

  数据库密码:zabbix

wKiom1PyHrzBkgDFAAIu8qz0oaU461.jpg

  

5.12 登陆zabbix

    默认用户名:admin

    默认密码:zabbix

RPKPWM@A.jpg " style="float:none;" alt="wKioL1PyH9LzchKJAAF_tgbbOKI739.jpg" />

 

6、调整zabbix显示中文

点击右上角profile处出现该界面。

wKioL1PyH9aDnGw4AAGst6LFdB4478.jpg


7centos安装Zabbix client

useradd zabbix -s/sbin/nologin -M

 

tar -zxf zabbix-2.2.2.tar.gz

cd zabbix-2.2.2

./configure--prefix=/usr/local/zabbix --enable-agent

make install

 

cpmisc/init.d/fedora/core/zabbix_agentd /etc/init.d/

#修改/usr/local/zabbix/etc/zabbix_agentd.conf中的server ip

#修改/etc/init.d/server_agentd中的BASEDIR

 

[root@qssec-centos-02zabbix-2.2.2]# netstat -plnt|grep zabbix

tcp        0     0 0.0.0.0:10050              0.0.0.0:*                   LISTEN      17870/zabbix_agentd

 

8ubuntu安装Zabbix client

apt-get install zabbix-agent

vi /etc/zabbix/zabbix_agentd.conf   #修改server IP

 

如果apt-get安装不成功,可删除apt安装的zabbix-agent包:dpkg -r zabbix-agent;dpkg -P zabbix-agent,然后再apt-get安装。

 

9debian安装zabbix client

tar -zxf zabbix-2.2.2.tar.gz

cd zabbix-2.2.2/

 ls

 ./configure --prefix=/usr/local/zabbix--enable-agent

 make install

 

cpmisc/init.d/debian/zabbix-agent /etc/init.d

 

vi/usr/local/zabbix/etc/zabbix_agentd.conf  #修改server ip

vi /etc/init.d/zabbix-agent    #指定zabbix_agentd路径

 

 

 

到此zabbix server端与client端都安装完成。




本文出自 “楊雲” 博客,请务必保留此出处http://yangrong.blog.51cto.com/6945369/1541810

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

2412

主题

2667

帖子

7788

积分

论坛元老

Rank: 8Rank: 8

积分
7788
Michaappar 发表于 2017-5-26 05:23:10 | 显示全部楼层
Consommation Viagra France  Lasix Cost Medicamentos Cialis Viagra Buy Prevacid Online Cheap  Cheap Cytotec Tablets Cheaper Rx4u Acheter Cialis Pro  Order Zoloft Without Script Acheter Cialis 10 Milligrams Discount Worldwide Fedex Shipping Isotretinoin Pills  Purchase Generic Zoloft Kamagra Oral Jelly Hamburg Get Tab Worldwide Dutasteride In Internet Fedex Shop  Viagra Sample Buy Avanafil Endometrin Without Prescription  Buy Priligy Viagra Online Over The Counter Mediformin Levitra Durata Di Azione  Buy Kamagra Fish Flex Cephalexin Keflex 500mg Capsules  Order Generic Strattera Cialis 10 Mg Prezzo In Farmacia Xenical 120 Mg  Zoloft Order Caracteristicas De Propecia Acheter Vrai Cytotec  Cytotec Cost Cialis E Altri Levitra Significato  Canadian Cheap Cialis Cialis Mail Order Buy Wellbutrin Without A Perscrition  Propecia Sale Generic Tamoxifen 20mg Keflex 500mg 3 Times A Day  Nolvadex Cost Prix Propecia Suisse Zithromax Stomach Pain  Order Xenical Tablets Viagra Per Ragazzi Buy Viagra Professional Online  Propecia Price Best Sites For Viagra Gonorrhea Meds At Walmart  Order Amoxil Onlines Forum Cialis Achat Internet Cialis Viagra Effets Secondaires  Vibramycin Pills Propecia Low Cost Tigerfil 100 Mg  Best Levitra Prices Cialis Corazon Amoxicillin 875 Mg For Ear Infections  Purchase Cytotec Usa Kamagra Bericht
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表