搭建lamp
創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都做網(wǎng)站、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿(mǎn)足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的楚雄州網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!安裝epel源
rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
epel.repo epel-testing.repo
修改epel.repo中的enable=1
yum install -y mysqlmysql-server php-mysql httpd php php-pdo lm_sensors net-snmp php-snmpnet-snmp-utils perl-Net-Daemon perl-PlRPC perl-DBI rrdtool perl-rrdtoolperl-DBD-MySQL net-snmp-libs libart_lgpl-devel
service httpdstart
如果啟動(dòng)報(bào)錯(cuò):[root@linux211yum.repos.d]# service httpd start
Starting httpd: httpd:Could not reliably determine the server's fully qualified domain name, using192.168.2.211 for ServerName
[ OK ]
vi /etc/httpd/conf/httpd.conf
將ServerName www.example.com:80前面的注釋去掉
root@linux211 conf]# service httpd start Starting httpd: [ OK ] |
service mysqld start
[root@linux211 conf]# service mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h linux211 password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com [ OK ] Starting mysqld: [ OK ] |
設(shè)置為開(kāi)機(jī)啟動(dòng)
chkconfig httpd on
chkconfig mysqld on
查看防火墻狀態(tài)
[root@linux211 conf]# /etc/init.d/iptables status Firewall is stopped. |
如果沒(méi)有關(guān)閉,就關(guān)閉防火墻
/etc/init.d/iptablesstop
驗(yàn)證lamp是否可用
vim /var/www/html/index.php
|
http://ip地址/index.php
顯示除了php的版本信息,說(shuō)明lamp是可用的
2.安裝nagios
groupadd nagcmd
useradd -m nagios
usermod -a -G nagcmdnagios
把a(bǔ)pache加入到nagcmd組,以便于在通過(guò)web Interface操作nagios時(shí)能夠具有足夠的權(quán)限
usermod -a -G nagcmdapache
下載Nagios,開(kāi)始編譯安裝
wget http://sourceforge.net/projects/nagios/?source=directory
--2014-02-25 14:01:05-- http://sourceforge.net/projects/nagios/?source=directory Resolving sourceforge.net... 216.34.181.60 Connecting to sourceforge.net|216.34.181.60|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 43274 (42K) [text/html] Saving to: `index.html?source=directory' 100%[=============================================================================================================================>] 43,274 51.3K/s in 0.8s 2014-02-25 14:01:08 (51.3 KB/s) - `index.html?source=directory' saved [43274/43274] |
下載nagios安裝包
wget http://prdownloads.sourceforge.net/sourceforge/nagios
/nagios-3.4.3.tar.gz
tar -zxvfnagios-3.4.3.tar.gz
cd nagios
[root@linux211 nagios]# ./configure --with-command-group=nagcmd checking for a BSD-compatible install... /usr/bin/install -c checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking whether make sets $(MAKE)... yes checking for strip... /usr/bin/strip checking how to run the C preprocessor... gcc -E checking for egrep... grep -E checking for ANSI C header files... yes checking whether time.h and sys/time.h may both be included... yes checking for sys/wait.h that is POSIX.1 compatible... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking arpa/inet.h usability... yes checking arpa/inet.h presence... yes checking for arpa/inet.h... yes checking ctype.h usability... yes checking ctype.h presence... yes checking for ctype.h... yes checking dirent.h usability... yes checking dirent.h presence... yes |
make all
make[1]: Entering directory `/root/nagios/base' gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o broker.o broker.c gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nebmods.o nebmods.c gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o ../common/shared.o ../common/shared.c gcc -Wall -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o checks.o checks.c |
make install
make install-init
make install-config
makeinstall-commandmode
實(shí)現(xiàn)在httpd的配置文件目錄(conf.d)中創(chuàng)建Nagios的Web程序配置文件
makeinstall-webconf
創(chuàng)建一個(gè)登錄nagios web程序的用戶(hù),這個(gè)用戶(hù)帳號(hào)在以后通過(guò)web登錄nagios認(rèn)證時(shí)所用
htpasswd -c/usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: Re-type new password: Adding password for user nagiosadmin |
以上過(guò)程配置結(jié)束以后需要重新啟動(dòng)httpd:
servicehttpd restart
Stopping httpd: [ OK ] Starting httpd: [ OK ] |
編譯、安裝nagios-plugins
下載安裝包
wget http://assets.nagios.com/downloads/nagiosplugins/
nagios-plugins-1.5.tar.gz
tar -zxvfnagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure --with-nagios-user=nagios--with-nagios-group=nagios
make
make install
把nagios添加為系統(tǒng)服務(wù)并將之加入到自動(dòng)啟動(dòng)服務(wù)隊(duì)列
chkconfig --add nagios
chkconfig nagios on
檢查其主配置文件的語(yǔ)法是否正確
/usr/local/nagios/bin/nagios-v /usr/local/nagios/etc/nagios.cfg
Checking contact groups... Checked 1 contact groups. Checking service escalations... Checked 0 service escalations. Checking service dependencies... Checked 0 service dependencies. Checking host escalations... Checked 0 host escalations. Checking host dependencies... Checked 0 host dependencies. Checking commands... Checked 24 commands. Checking time periods... Checked 5 time periods. Checking for circular paths between hosts... Checking for circular host and service dependencies... Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check |
啟動(dòng)nagios服務(wù)
service nagios start
安裝NRPE
wget http://prdownloads.sourceforge.net/sourceforge/
nagios/nrpe-2.13.tar.gz
tar -zxvfnrpe-2.13.tar.gz
cd nrpe-2.13
./configure
checking for initgroups... yes checking for closesocket... no checking for socklen_t... yes checking for type of socket size... size_t checking for SSL headers... SSL headers found in /usr/local/ssl checking for SSL libraries... configure: error: Cannot find ssl libraries |
安裝缺失的庫(kù)
yum -y installopenssl-devel
然后重新執(zhí)行./configure就ok啦
checking for strtoul... yes checking for initgroups... yes checking for closesocket... no checking for socklen_t... yes checking for type of socket size... size_t checking for SSL headers... SSL headers found in /usr/local/ssl checking for SSL libraries... SSL libraries found in /usr/lib64 *** Generating DH Parameters for SSL/TLS *** Generating DH parameters, 512 bit long safe prime, generator 2 This is going to take a long time ........................+......................+.+......................+........................................+....................+.......+.....+............+........................................................................++*++*++*++*++*++* checking for Kerberos include files... could not find include files checking for perl... /usr/bin/perl configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating subst config.status: creating include/config.h *** Configuration summary for nrpe 2.13 11-11-2011 ***: General Options: ------------------------- NRPE port: 5666 NRPE user: nagios NRPE group: nagios Nagios user: nagios Nagios group: nagios Review the options above for accuracy. If they look okay, type 'make all' to compile the NRPE daemon and client. |
make all
cp src/check_nrpe/usr/local/nagios/libexec/
至此服務(wù)端搭建成功
客戶(hù)端配置
tar -zxvfnagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
/configure--with-nagios-user=nagios --with-nagios-group=nagios
make
報(bào)錯(cuò)
/usr/bin/install: invalid user `nagios' make[2]: *** [install-libexecPROGRAMS] Error 1 make[2]: Leaving directory `/opt/nagios/nagios-plugins-1.5/plugins' make[1]: *** [install-am] Error 2 make[1]: Leaving directory `/opt/nagios/nagios-plugins-1.5/plugins' make: *** [install-recursive] Error 1 |
解決辦法如下
useradd nagios
mkdir /usr/local/nagios 如果目錄存在就不需要?jiǎng)?chuàng)建了
chown nagios:nagios/usr/local/nagios
ll /usr/local
make
make install
安裝NRPE
tar -zxvfnrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
cp src/check_nrpe /usr/local/nagios/libexec/
vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,server IP
vim /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote PluginExecutor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server =/usr/local/nagios/bin/nrpe
server_args = -c/usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1 192.168.2.211
vim /etc/services
nrpe 5666/tcp #nrpe
service xinetd star
[root@tomcat1 nrpe-2.13]# service xinetd start xinetd: unrecognized service |
報(bào)錯(cuò)處理
yum -y install xinetd
安裝成功之后執(zhí)行
service xinetd star
[root@tomcat1 nrpe-2.13]# service xinetd start Starting xinetd: [ OK ] |
測(cè)試NRPE是否正常工作
/usr/local/nagios/libexec/check_nrpe-H 127.0.0.1
root@tomcat1 nrpe-2.13]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 NRPE v2.13 |
cd /usr/local/nagios/
ls
cd etc/
ll
mkdir objects
為服務(wù)端增加NRPE命令
vi commands.cfg
define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$-c $ARG1$
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。