#---server---#
yum设置
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.save
wget
mv CentOS-Base.repo.5 CentOS-Base.repo
rpm --import
yum -y install yum-fastestmirror
安装一下程序包
yum -y install gcc glibc glibc-common gd gd-devel openssl-devel mysql-devel
安装apache
./configure --prefix=/fgn/theron/apache2 --enable-so --enable-mods-shared=most && make && make install
安装mysql
创建mysql账号和目录
userdel mysql
groupadd mysql
useradd mysql -d /fgn/theron/mysql -g mysql
mkdir -p /fgn/theron/mysql/data /fgn/theron/mysql/tmp
chown -R mysql:mysql /fgn/theron/mysql
./configure '--prefix=/fgn/theron/mysql' '--with-unix-socket-path=/fgn/theron/mysql/tmp/mysql.sock' '--localstatedir=/fgn/theron/mysql/data' '--with-mysqld-user=mysql' '--without-debug' '--with-big-tables' '--with-charset=utf8' '--with-extra-charsets=all' '--with-pthread' '--enable-thread-safe-client' '--enable-assembler' '--without-ndb-debug--with-innodb' '--with-archive-storage-engine' '--with-client-ldflags=-all-static' '--with-readline' '--enable-local-infile' && make && make install
如果安装双mysql,注意先移走/etc/my.cnf
./scripts/mysql_install_db --datadir=/fgn/theron/mysql/data --user=mysql
chown -R mysql:mysql /fgn/theron/mysql
mv /etc/my.cnf /etc/my.cnf.bak
mv /usr/bin/mysql /usr/bin/mysql.bak
ln -s /fgn/theron/mysql/bin/mysql /usr/bin/mysql
chown -R mysql:mysql /fgn/theron/mysql
安装php
./configure --with-apxs2=/fgn/theron/apache2/bin/apxs --prefix=/fgn/theron/php5 --with-mysql=/fgn/theron/mysql --with-config-file-path=/fgn/theron/php5/etc/ --with-libxml-dir=/usr --with-gd=/usr --with-pcre-regex --enable-mbstring=all --with-libmbfl --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --enable-xml --enable-sockets --enable-ucd-snmp-hack && make && make install
cp php.ini-dist /fgn/theron/php5/lib/php.ini
添加路径/fgn/theron/php5/lib/php至/fgn/theron/php5/lib/php.ini
配置/fgn/theron/apache2/conf/httpd.conf
DocumentRoot "/usr/local/apache2/htdocs" ==> DocumentRoot "/fgn/theron/www"
==>
DirectoryIndex index.html ==> DirectoryIndex index.html index.htm index.php index.phtml index.phps
LoadModule php5_module modules/libphp5.so
加上此两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
set-variable = max_connections=100
测试php
vim /fgn/theron/www/test.php
创建nagios账号:
/usr/sbin/useradd nagios && passwd nagios
/usr/sbin/groupadd nagcmd (创建一个用户组名为nagcmd用于从Web接口执行外部命令。将nagios用户和apache用户都加到这个组中)
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd daemon
/usr/sbin/usermod -G nagcmd apache
下载nagios core
wget
下载nagios plugs
wget
安装nagios
cd /fgn/theron/soft
tar zxf nagios-3.2.1.tar.gz
cd nagios-3.2.1
./configure --with-command-group=nagcmd --prefix=/fgn/theron/nagios
make all
make install
make install-init
make install-config
make install-commandmode
安装nagios-plugins
cd /fgn/theron/soft
tar zxf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/fgn/theron/nagios && make && make install
验证
ls /fgn/theron/nagios/libexec
配置nagios的WEB接口
方法一:直接在安装nagios时 make install-webconf
创建一个nagiosadmin的用户用于Nagios的WEB接口登录。记下你所设置的登录口令,一会儿你会用到它。
htpasswd -c /fgn/theron/nagios/etc/htpasswd.users nagiosadmin
重启Apache服务以使设置生效。
service httpd restart
方法二:
创建vhost.conf
NameVirtualHost *:8080
ServerName
ScriptAlias /nagios/cgi-bin /fgn/theron/nagios/sbin
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /fgn/theron/nagios/etc/htpasswd
Require valid-user
Alias /nagios /fgn/theron/nagios/share
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /fgn/theron/nagios/etc/htpasswd
Require valid-user
echo "conf/vhost.conf" >> ./httpd.conf
/fgn/theron/apache2/bin/htpasswd -c /fgn/theron/nagios/etc/htpasswd test
New password: (输入12345)
Re-type new password: (再输入一次密码)
Adding password for user test
查看认证文件的内容
less /fgn/theron/nagios/etc/htpasswd
test:OmWGEsBnoGpIc 前半部分是用户名test,后面是加密后的密码
本例添加的是test 用户名,需要改 cgi.cfg 配置文件,允许test用户
authorized_for_system_information=test
authorized_for_configuration_information=test
authorized_for_system_commands=test
authorized_for_all_services=test
authorized_for_all_hosts=nagiosadmin,test
authorized_for_all_service_commands=test
authorized_for_all_host_commands=test
如果有多用户,请用逗号格开
重启apache
/fgn/theron/apache2/bin/apachectl restart
用账号test/12345登陆nagios:
http://:18080/nagios/
#---client---#
下载nagios plugs
wget
安装nagios-plugins
useradd nagios
cd /fgn/theron/soft
tar zxf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/fgn/theron/nagios && make && make install
下载nrpe
wget
安装nrpe(安装nrpe插件,本监控端可以不装)
tar xzvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/fgn/theron/nagios/
make all
make install-plugin
make install-daemon
make install-daemon-config
cp init-script /etc/init.d/nrpe
chmod 755 /etc/init.d/nrpe
chkconfig --add nrpe
chkconfig --level 3 nrpe on
nagios-plugins编译错误ld returned 1 exit status
************************************************
gcc -DNP_VERSION=\"1.4.14\" -g -O2 -o check_http check_http.o sslutils.o netutils.o utils.o -L/fgn/theron/soft/nagios-plugins-1.4.14/plugins ../lib/libnagiosplug.a ../gl/libgnu.a -lnsl -lresolv -lssl -lcrypto -lpthread
/fgn/usr/bin/../lib/gcc/i386-redhat-linux/4.1.2/../../../libssl.a(kssl.o): In function `kssl_sget_tkt':
(.text+0x2165): undefined reference to `krb5_kt_free_entry'
/fgn/usr/bin/../lib/gcc/i386-redhat-linux/4.1.2/../../../libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
(.text+0x96): undefined reference to `inflate'
collect2: ld returned 1 exit status
make[2]: *** [check_http] 错误 1
make[2]: Leaving directory `/fgn/theron/soft/nagios-plugins-1.4.14/plugins'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/fgn/theron/soft/nagios-plugins-1.4.14'
make: *** [all] 错误 2
************************************************
解决办法:
rpm -qf /usr/lib/libssl.a
openssl-devel-0.9.8e-7.el5
rpm -qf /usr/lib/libcrypto.a
openssl-devel-0.9.8e-7.el5
yum -y install openssl openssl-devel
make clean
export CFLAGS=-ldl
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/fgn/theron/nagios/ && make && make install
阅读(2226) | 评论(0) | 转发(0) |