httpd: Syntax error on line 61 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after> 这是由于selinux引起的,所以需要这样一下:
chcon -t textrel_shlib_t libphp5.so
原因是Linux有一个SELinux保护模式引起的。
Syntax error on line 268 of /usr/local/apache2/conf/httpd.conf:
Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after> 解决办法
2.不关闭SELINUX的方法:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart
# setenforce 1
或者按照以下方法:
编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。
编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。
安装rddtool
需要先安装
libart
./configure -prefix=/usr/local/libart
已经安装过了freetype了就不需要再装了
安装rrdtool 时的参数
./configure --disable-tcl --disable-python --prefix=/usr/local/rrdtool --with-freetype=/usr/local/include/ --with-libart=/usr/local/libart
安装cacti
Cacti的安装
1.下载Cacti软件包,并安装到/var/www/html/cacti
wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
tar -xvzf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /var/www/html/cacti
2.配置数据库
mysql -u root -p 123456
mysql> create database cacti;
mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti'
with grant option;
mysql> grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'cacti'
with grant option;
mysql>flush privileges;
mysql> use cacti;
mysql> source /var/www/html/cacti/cacti.sql;
3.配置Cacti以连接数据库
vi /var/www/html/cacti/include/config.php 依照如下修改:
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
vi /var/www/html/cacti/include/global.php 依照如下修改:
/* Default database settings*/
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$config['url_path'] = '/cacti/';
4.添加cacti用户
[root@localhost proc]#useradd -s nologin cacti
[root@localhost proc]#passwd cacti
5.修改cacti目录属主
[root@localhost proc]#chown -R cacti:cacti /var/www/html/cacti/
6.编辑crontab
[root@localhost proc]#crontab -e cacti
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
/usr/bin/php /usr/local/apache2/
7.关闭SELinux
[root@localhost proc]#setenforce 0
8.用浏览器访问http://localhost/cacti/
若看到以下画面,则可以进行之后的配置(默认用户名、密码:admin)
装rddtool和版本有关,起先装的1.2.3,怎么也不行,后来装了1.4.4就可以了.人品问题了
然后需要给rra以及cacti目录权限 属于cacti
Cacti插件安装及配置
必须现安装好插件扩展PIA 2.8,才能安装、使用其他插件
wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz
tar -xvzf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
mv cacti-plugin-arch /var/www/html/cacti/
cd /var/www/html/cacti/
mysql -u root -p 123456 cacti < cacti-plugin-arch/pa.sql
patch -p1 -N < cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff
rm -rf cacti-plugin-arch
chown -R cacti:cacti /var/www/html/cacti
1. 修改global.php,设定数据库的相关参数,以及config路径.
vi /var/www/html/cacti/include/global.php,修改并增加如下内容:
/* Default database settings*/
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$config['url_path'] = '/cacti/';
$plugins = array();
修改Cacti用户权限,增加插件使用权限
显示 Plugin-Management
User Management -> "admin" or "other user" -> "Realm Permissions" -> "Plugin
安装插件
a)下载插件
wget http://cactiusers.org/downloads/settings.tar.gz
wget http://cactiusers.org/downloads/monitor.tar.gz
wget http://cactiusers.org/downloads/realtime.tar.gz
wget http://cactiusers.org/downloads/syslog.tar.gz
wget http://cactiusers.org/downloads/thold.tar.gz
wget http://cactiusers.org/downloads/tools.tar.gz
wget http://cactiusers.org/downloads/update.tar.gz
wget http://downloads.sourceforge.net/project/cacti-reportit/cacti-reportit/reportit_v061/reportit_v061.tar.gz
wget http://www.constructaegis.com/downloads/npc-2.0.4.tar.gz
插件都放到plus里
c)修改global.php,增加插件说明
vi /var/www/html/cacti/include/global.php
$plugins[] = 'settings';
$plugins[] = 'thold';
$plugins[] = 'npc';
$plugins[] = 'syslog';
$plugins[] = 'aggregate';
$plugins[] = 'reportit';
$plugins[] = 'update';
$plugins[] = 'tools';
d)下载安装json(NPC插件需要json支持) 这个默认系统支持
e) 修改权限
将所有插件mv到/var/www/html/cacti/plugins目录下,然后User Management -> "admin"
or "other user" -> "Realm Permissions" -> "Plugin Management" -> 打勾并保存,
插件安装排错
a)realtime插件安装问题
realtim插件安装好后,点击web界面的[graphs]页,选一个图,可发现在其右下角已经出
现了一个realtime的logo,但当点此logo进行realtime查看时,会发现弹出的窗口中显示:
“The image cache directory doesn't exist.Please create it and set permissions
and then attempt to open an other realtime graph.”
提示没有Cache目录以及权限等。
解决方案:
[root@localhost proc]#makedir /var/www/html/cacti/cache
[root@localhost proc]#chmod 777 -R /var/www/html/cacti/cache
之后,还要进入console-->configuration-->settings-->misc,设置”Cache Directory”为
/var/www/html/cacti/cache/b)
Syslog插件安装问题
在cacti中访问syslog栏目是会出现以下提示:
1 Warning: include(./include/html/inc_timespan_settings.php) [function.include]:
failed to open stream: No such file or directory in
/var/www/html/plugins/syslog/syslog.php on line 126
2 Warning: include() [function.include]: Failed opening
'./include/html/inc_timespan_settings.php' for inclusion
(include_path='.:/usr/share/pear') in /var/www/html/plugins/syslog/syslog.php on
line 126
只需将/plugins/syslog/syslog.php的第126行
#include($syslog_config["graphtime"] ? "./include/html/inc_timespan_settings.php"
: "plugins/syslog/html/syslog_timespan_settings.php");
修改为:
#include($syslog_config["graphtime"] ?
"./lib/timespan_settings.phpplugins/syslog/html/syslog_timespan_setti
ngs.php");即可
、Nagios安装及配置
1. 依赖软件包安装
yum -y install gcc glibc glibc-common gd gd-devel
搭建nagios环境
日期:2010-03-27 作者:root
1.安装nagios
1)nagios需要一些基础支持套件才能运行,如apache,gcc,glibc,gd库等。
#/usr/sbin/useradd -m nagios 添加一个名为nagios的用户用以专门跑nagios
#/usr/sbin/groupadd nagios 添加nagios用户组,用以通过web页面提交外部控制命令
#/usr/sbin/usermod -a -G nagios daemon 将运行apache用户daemon加入nagios组
2)安装nagios
编译nagios前要安装gd-devel否则nagios的map不能显示
在安装nagios时#./configure步骤加一组参数:--with-gd-lib=/usr/local/modules/gd/lib
原始的Nagios中文版不能绘制中文字符串,与GD的字库处理方式有关。GD有自己的字库文件(点阵形式、ASC码编码)。gdImageString的第二个参数即GD自己的字库的索引,第五个参数则是一个ASC编码的字符串。而GD自己的字库是不支持中文的。显然,大名鼎鼎的GD不可能只支持自己的字库,他用函数gdImageStringFT来支持用外部字库绘制utf-8编码的字符串,这里面包含了中文的支持。
#tar xzf nagios-cn-3.2tar.gz
#cd nagios-cn-3.2
yum -y install gcc glibc glibc-common gd gd-devel
/configure -prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-httpd-conf=/usr/local/apache2/conf/extra/ --with-gd=/usr
搭建nagios环境
日期:2010-03-27 作者:root
1.安装nagios
1)nagios需要一些基础支持套件才能运行,如apache,gcc,glibc,gd库等。
#/usr/sbin/useradd -m nagios 添加一个名为nagios的用户用以专门跑nagios
#/usr/sbin/groupadd nagios 添加nagios用户组,用以通过web页面提交外部控制命令
#/usr/sbin/usermod -a -G nagios daemon 将运行apache用户daemon加入nagios组
2)安装nagios
#tar xzf nagios-cn-3.2tar.gz
#cd nagios-cn-3.2
#./configure --with-command-group=nagios --with-httpd-conf=/usr/local/apache/conf/extra/ --with-apache=/usr/local/apache2 --with-gd
#make all
#make install
#make install-init
#make install-config
#make install-commandmode
这时nagios基本已经安装完成,默认安装后的配置文件用于启动nagios是没有问题的。
#vi usr/local/nagios/etc/objects/contacts.cfg
修改nagiosadmin这行其中的邮件地址为你的email地址,以将报警邮件发到你的邮箱
#make install-webconf 安装nagios的web接口
#/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
设置登陆web界面时HTTP验证的账号密码
vi /usr/local/apache/conf/httpd.conf
添加一下两行
# nagios default settings
Include conf/extra/nagios.conf
#/usr/local/apache/bin/apachectl -k restart
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 验证配置文件没问题
#service nagiosrestart 启动nagios
2 安装nagios-plugins
nagios-plugins是nagios官方提供的一套插件程序,nagios监控主机的功能其实都是通过执行插件程序来实现的。
#tar xzf nagios-plugins-1.4.13.tar.gz
#cd nagios-plugins-1.4.13
#./configure –with-nagios-user=nagios –with-nagios-group=nagios
#make
#make install
安装插件,安装后所有插件命令将被安装到/usr/local/nagios/libexec 目录下
编译安装ndoutils 先安装mysql-devel
./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql LDFLAGS=-L/usr/local/mysql/lib --with-mysql-inc=/usr/local/mysql/include/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql
/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg 向数据库写数据的服务
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
在web上看到这样一个问题,这个是我自己定义在nrpe.cfg里面的,换了N多方式,看了N多文章,都没能找到这个问题出在哪里,百思不得其解。就要把我郁闷死了!!!!!!~~~~
(硬态 状态) 当前的状态: 紧急
状态信息: NRPE: Command 'check_disk' not defined
在命令行下:
[root@nagiosserver etc]# ../libexec/check_nrpe -H 192.168.1.12 -c check_disk
NRPE: Command 'check_disk' not defined
在按照别人的步骤一步一步走下来还是出现这样的问题,试验了n多方法之后还是无果。
在今天这个时刻,突然开窍了。
之前怎么就没想到这个需要监控与被监控端命令配置要必须一致,否则就会出现如上的错误。
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
待续................
2011.3.27 夜
nagios
9. NRPE安装
cd nrpe-2.12
需要先装openssl openssl-devel
./configuremake all
make install plugin
make install-daemon
make install-daemon-config
执行
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
编辑/etc/rc.local,增加如下命令语句:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
/usr/local/nagios/libexec/check_nrpe -H localhost
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
我在安装nagios过程中, 监控机和被监控机的配置都配好了,可以监控端口了,我在被监控机(192.168.1.113)上装好了nagios-plugin 、nrpe,如下:
[root@yibaner install]# useradd nagios -s /sbin/nologin -M
[root@yibaner install]# tar xvf nagios-plugins-1.4.13.tar
[root@yibaner install]# cd nagios-plugins-1.4.13
[root@yibaner nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios
[root@yibaner nagios-plugins-1.4.13]# make && make install
[root@yibaner nagios-plugins-1.4.13]# chown -R nagios:nagios /usr/local/nagios/ //修改文件权限
(2) nrpe的程序的安装:
[root@yibaner src]# tar zxvf nrpe-2.12.tar.gz
[root@yibaner nrpe-2.12]# cd nrpe-2.12
[root@yibaner nrpe-2.12]# ./configure
[root@yibaner nrpe-2.12]# make all
[root@yibaner nrpe-2.12]# make install-plugin
[root@yibaner nrpe-2.12]# make install-daemon
[root@yibaner nrpe-2.12]# make install-daemon-config //都没报错
修改nrpe.cfg配置文件
server_address=127.0.0.1
allowed_hosts=192.168.1.115,127.0.0.1 //192.168.1.115是我的监控机
[root@localhost ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@localhost ~]# netstat -apl | grep 5666
tcp 0 0 localhost.localdomain:5666 *:* LISTEN 3582/nrpe
5666端口也开启了,iptables我也关了!
[root@yibaner nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
正常的返回值为被监控服务器上安装的NRPE的版本信息:
NRPE v2.12
在监控机上我装上了nrpe,安装如下:
[root@server1 yahoon]# tar -zxvf nrpe-2.8.1.tar.gz
[root@server1 yahoon]# cd nrpe-2.8.1
[root@server1 nrpe-2.8.1]# ./configure
[root@server1 nrpe-2.8.1]# make all
[root@server1 nrpe-2.8.1]# make install-plugin //成功配置,都不报错的
iptables也关了
测试:
[root@server1 nrpe-2.8.1]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.113 //113是我的被监控机
显示如下:Connection refused by host
什么原因!谢谢了!非常谢谢!
我在115监控机用telnet连113上的5666时出现如下:
[root@localhost nagios]# telnet 192.168.1.113 5666
Trying 192.168.1.113...
telnet: connect to address 192.168.1.113: Connection refused
telnet: Unable to connect to remote host: Connection refused
这是不是说明5666端口关闭了? 可是端口5666确实是开启了,iptables也关了,selinux 也关了 ,两台电脑之间能PING通,我都测试了,这又是什么原因呢?搞晕了!
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
注意,该命令为nagios启动进程,只能有一个在运行.特此声明.
出处:http://yantaohncz.blog.运维网.com/727950/565411