【移動應(yīng)用開發(fā)技術(shù)】LAMP+NAGIOS+CACTI完整實(shí)現(xiàn)筆記_第1頁
【移動應(yīng)用開發(fā)技術(shù)】LAMP+NAGIOS+CACTI完整實(shí)現(xiàn)筆記_第2頁
【移動應(yīng)用開發(fā)技術(shù)】LAMP+NAGIOS+CACTI完整實(shí)現(xiàn)筆記_第3頁
【移動應(yīng)用開發(fā)技術(shù)】LAMP+NAGIOS+CACTI完整實(shí)現(xiàn)筆記_第4頁
【移動應(yīng)用開發(fā)技術(shù)】LAMP+NAGIOS+CACTI完整實(shí)現(xiàn)筆記_第5頁
已閱讀5頁,還剩14頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

【移動應(yīng)用開發(fā)技術(shù)】LAMP+NAGIOS+CACTI完整實(shí)現(xiàn)筆記

源碼包:httpd-2.2.24.tar.gzphp-5.2.17.tar.gzcdmysql-5.1.73-linux-x86_64-glibc23.tar.gz其余依賴程序均通過yum源來安裝,推薦EPEL和CentOS163鏡像//epel鏡像

操作步驟:mysql安裝:tarzxfmysql-5.1.73-linux-x86_64-glibc23.tar.gz-C/usr/local/mvmysql-5.1.73-linux-x86_64-glibc23/mysqlchown-Rmysql.rootmysql/

#修改mysql目錄的權(quán)限chown-Rmysql.mysql/data/

#修改mysql數(shù)據(jù)目錄的權(quán)限初始化mysql./scripts/mysql_install_db

--basedir=/usr/local/mysql

\

--datadir=/usr/local/mysql/data

\

--defaults-file=/usr/local/mysql/f

\

--skip-name-resolve

--user=mysql

拷貝自啟動腳本:cpmysql.server/etc/init.d/mysqld修改啟動腳本中的內(nèi)容,明確告訴啟動腳本mysql的運(yùn)行路徑basedir=/usr/local/mysql

#46行

datadir=/usr/local/mysql/data

#47行pid_file=/usr/local/mysql/mysql_v51.pid

#59行conf=/usr/local/mysql/f

#218行

f配置文件主要部分[mysqld]

port

=

3306

socket

=

/usr/local/mysql/mysql.sock

skip-external-locking

key_buffer_size

=

16M

max_allowed_packet

=

1M

table_open_cache

=

64

sort_buffer_size

=

512K

net_buffer_length

=

8K

read_buffer_size

=

256K

read_rnd_buffer_size

=

512K

myisam_sort_buffer_size

=

8M

/etc/init.d/mysqldstartStartingMySQL.[

OK

]

源碼編譯安裝http:先安裝apr-1.5.1,編譯安裝時指定:./configure--prefix=/usr/local/apr--disable-ipv6

LDFLAGS=-L/usr/lib64apr-util-1.5.3,編譯安裝時指定:./configure

--prefix=/usr/local/apr

\

--with-apr=/usr/local/apr/bin/apr-1-config

\

--with-mysql=/usr/local/mysql

\

LDFLAGS=-L/usr/lib64編譯安裝apache./configure

--prefix=/usr/local/apache2

\-

-enable-so

\

--enable-modules=all

\

--enable-mods-shared=all

\-

-with-mpm=worker

--with-apr=/usr/local/apr/bin/apr-1-config

\

--with-apr-util=/usr/local/apr/bin/apu-1-config

\

--with-pcre

\

--enable-disk-cache

\

--enable-mem-cache

\

--enable-file-cache

\

--enable-cache

\

--enable-cgi

\

--enable-authn-alias

\

--enable-proxy

\

--enable-proxy-ftp

\

--enable-proxy-http

\

--enable-proxy-scgi

\

--enable-proxy-connect

\

--enable-proxy-balancer

\

--enable-suexec

\

LDFLAGS=-L/usr/lib64

make&&makeinstallchown-Rapache.rootapache2/

http配置主要部分:篇幅問題無法寫全ServerRoot"/usr/local/apache2"Listen8085ServerName27:8085DocumentRoot"/usr/local/apache2/htdocs"<IfModuledir_module>

DirectoryIndexindex.htmlindex.php</IfModule>

編譯安裝php:編譯參數(shù)參照yum源安裝的PHP包時使用的選項./configure

--build=x86_64-redhat-linux-gnu

\

--host=x86_64-redhat-linux-gnu

\

--target=x86_64-redhat-linux-gnu

\

--prefix=/usr/local/php

\

--with-libdir=lib64

\

--with-config-file-path=/usr/local/php/etc

\

--with-apxs2=/usr/local/apache2/bin/apxs

\

--disable-debug

\

--with-pic

\

--disable-rpath

\

--with-bz2

\

--with-exec-dir=/usr/bin

\

--with-freetype-dir=/usr

\

--with-png-dir=/usr

\

--with-xpm-dir=/usr

\

--enable-gd-native-ttf

\

--without-gdbm

\

--with-gettext

\

--with-gmp

\

--with-iconv

\

--with-jpeg-dir=/usr

\

--with-openssl

\

--with-pcre-regex=/usr

\

--with-zlib

\

--with-layout=GNU

\

--enable-exif

\

--enable-ftp

\

--enable-magic-quotes

\

--enable-sockets

\

--enable-sysvsem

\

--enable-sysvshm

\

--enable-sysvmsg

\

--with-kerberos

\

--enable-ucd-snmp-hack

\

--enable-shmop

\

--enable-calendar

\

--without-sqlite

\

--with-libxml-dir=/usr

\

--enable-xml

\

--enable-force-cgi-redirect

\

--enable-pcntl

\

--with-imap=shared

\

--with-imap-ssl

\

--enable-mbstring=shared

\

--enable-mbregex

\

--with-gd=shared

\

--enable-bcmath=shared

\

--enable-dba=shared

\

--with-db4=/usr

\

--with-xmlrpc=shared

\

--with-ldap=shared

\

--with-ldap-sasl

\

--with-mysql=shared,/usr/local/mysql

\

--with-mysqli=shared,/usr/local/mysql/bin/mysql_config

\

--enable-dom=shared

\

--enable-wddx=shared

\

--with-snmp=shared,/usr

\

--enable-soap=shared

\

--with-xsl=shared,/usr

\

--enable-xmlreader=shared

\

--enable-xmlwriter=shared

\

--with-curl=shared,/usr

\

--enable-fastcgi

\

--enable-pdo=shared

\

--with-pdo-odbc=shared,unixODBC,/usr

\

--with-pdo-mysql=shared,/usr/local/mysql/bin/mysql_config

\

--with-pdo-sqlite=shared,/usr

\

--enable-json=shared

\

--enable-zip=shared

\

--without-readline

\

--enable-sysvmsg=shared

\

--enable-sysvshm=shared

\

--enable-sysvsem=shared

\

--enable-posix=shared

\

--with-unixODBC=shared,/usr

\

--with-mysql-sock=/usr/local/mysql/mysql.sock

\

--with-iconv-dirmake的時候加上ZEND_EXTRA_LIBS防止過程中報錯makeZEND_EXTRA_LIBS='-liconv'php配置:extension_dir="/usr/local/php/lib/php/20060613-zts/"extension=pdo_mysql.so

#此處為范例,多個模塊需要添加多個extensiondate.timezone=Asia/Shanghai

LAMP環(huán)境完成后,檢查php加載狀況,在/usr/local/apache2/htdocs/下創(chuàng)建index.php文件語法:<?phpphpinfo();?>通過訪問http://domainname//index.php訪問可以發(fā)現(xiàn)php插件是否正常加載

Apache

:

cat/usr/local/apache2/build/config.nice

#查看編譯參數(shù)

apachectl-t-DDUMP_MODULES

#查看加載模塊MySQL:

grepconfigure/usr/local/mysql/bin/mysqlbug

#查看mysql編譯參數(shù)PHP:

/usr/local/php/bin/php-i|grepconfigure

#查看PHP編譯參數(shù)

為了方便調(diào)用命令把Apache、Mysql、PHP三個軟件的執(zhí)行文件路徑寫入環(huán)境變量~/.bash_profilePATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/apache/bin:/usr/local/php/binLD_LIBRARY_PATH=/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/mysql/lib:/usr/local/lib:/usr/local/lib64

#64位環(huán)境下添加該環(huán)境變量,方便編譯安裝時查看庫文件。source~/.bash_profile使當(dāng)前環(huán)境變量生效

CACTI搭建:搭建前先通過YUM安裝net-snmp,net-snmp-libs,net-snmp-utils,net-snmp-devel,elfutils-libelf-devel-static,elfutils-devel,lm_sensors-devel,lm_sensors,beecrypt-devel包,Cacti主要依賴snmp協(xié)議獲取備監(jiān)控主機(jī)的信息。Cacti下載地址:/downloads/tarzxfcacti-0.8.8b.tar.gzmvcacti-0.8.8b/usr/local/apache2/htdocs/cactimysql

-u

root

-p

mysql>

create

database

cactidb;

mysql>

grant

all

privileges

on

cactidb.*

to

'cacti'@'27'

identified

by

'cacti'

with

grant

option;

mysql>

flush

privileges;

mysql>

use

cactidb

mysql>

source

/usr/local/apache2/htdocs/cacti/cacti.sql

#導(dǎo)入cacti表結(jié)構(gòu)修改cacti配置文件include/config.php

include/global.php

$database_type

=

"mysql";

$database_default

=

"cacti";

$database_hostname

=

"27";

$database_username

=

"cacti";

$database_password

=

"cacti";

$database_port

=

"3306";

$database_ssl

=

false;

$url_path

=

"/cacti/";

chmod

-R

775

rra/

log/

scripts/

#修改cacti目錄中的文件執(zhí)行權(quán)限

27:8085/cti/install/index.php

通過頁面安裝cacti配置時注意執(zhí)行命令路徑是否被找到,如路徑不對后續(xù)也可以再設(shè)置。

安裝部分插件:thold-v0.5.0.tgzmonitor-v1.3-1.tgzsettings-v0.71-1.tgz解壓后移至插件目錄下mvsettingsmonitorthold/usr/local/apache2/htdocs/cacti/plugins/激活插件安裝cacti-spine插件cacti-spine-0.8.8b./configure

--with-mysql

\

--with-snmp=/usr/include/net-snmp

\

LDFLAGS=-L/usr/local/mysql/lib編譯過程中遇到CannotfindUCD-SNMPlibraries(snmp)報錯,查看configure文件,里面把snmp庫路徑指向--with-snmp所指的路徑之后,而snmp默認(rèn)的庫安裝路徑是/usr/lib64,因此通過軟鏈方式解決:ln-s/usr/lib64/libsnmp*/usr/include/net-snmp/lib64/還有一類據(jù)說是spine-0.8.7c文檔提供的編譯方式[root@SH-021Y-DBAPcacti-spine-0.8.8b]aclocal[root@SH-021Y-DBAPcacti-spine-0.8.8b]libtoolize[root@SH-021Y-DBAPcacti-spine-0.8.8b]autoconf&&autoheader&&automake這類編譯過程需要借助autoconf,automake工具。直接從GNU上下載最近版本的就可以了。發(fā)現(xiàn)yum來的或者低版本的會遇到些問題。GNU軟件下載地址,另外GNU現(xiàn)在在募集免費(fèi)軟件基金。畢竟一直在使用,大家能支援的就支援點(diǎn)吧。/software

安裝完成后進(jìn)spine行配置vi

/usr/local/spine/etc/spine.conf

DB_Host

10.x.x.127

DB_Database

cactidb

DB_User

cacti

DB_Pass

cacti

DB_Port

3306

DB_PreG

0

Cacti搭建完成以后,出現(xiàn)無法生成圖片的方式,觀察cacti.log正常執(zhí)行poller.php腳本生產(chǎn)數(shù)據(jù),查看

查看apache的error日志,一直出現(xiàn)如下報錯:

ERROR:opening'*.rrd':Nosuchfileordirectory很明顯是沒有在rra下創(chuàng)建文件圖片數(shù)據(jù)文件,但是rra的權(quán)限已經(jīng)給到777了啊,對于這類頭疼的問題只能一點(diǎn)點(diǎn)的試在數(shù)據(jù)源目錄下選擇一臺主機(jī),選擇其中一個數(shù)據(jù)模板內(nèi)容,打開debug模式看到那行rrdtool的命令,粘貼到主機(jī)上運(yùn)行,確認(rèn)錯誤的原因。查看生產(chǎn)圖形數(shù)據(jù)的語句檢查是否運(yùn)行正常!

插件的錯誤訪問網(wǎng)站尋找解決方式

安裝Nagios下載地址:

http://sourceforge.jp/projects/sfnet_nagios/releases/最新nagios-plugin地址:/download/plugins/nrpe下載地址:wget/projects/nagios/files/nrpe-2.x/nrpe-2.9/nrpe-2.9.tar.gz目前能獲取的最新版本:nagios-4.0.8.tar.gznagios-plugins-2.0.3.tar.gz

nrpe-2.9.tar.gztar

zxf

nagios-4.0.8.tar.gz

./configure

--with-nagios-user=nagios

\

--with-nagios-group=nagios

\

--with-command-user=nagios

\

--with-command-group=nagios

\

--with-httpd-conf=/usr/local/apache2/conf

make

all

make

install

-

This

installs

the

main

program,

CGIs,

and

HTML

files

make

install-init

-

This

installs

the

init

script

in

/etc/rc.d/init.d

make

install-commandmode

-

This

installs

and

configures

permissions

on

the

directory

for

holding

the

external

command

file

make

install-config

-

This

installs

*SAMPLE*

config

files

in

/usr/local/nagios/etc

You'll

have

to

modify

these

sample

files

before

you

can

use

Nagios.

Read

the

HTML

documentation

for

more

info

on

doing

this.

Pay

particular

attention

to

the

docs

on

object

configuration

files,

as

they

determine

what/how

things

get

monitored!

make

install-webconf

-

This

installs

the

Apache

config

file

for

the

Nagios

web

interface

make

install-exfoliation

-

This

installs

the

Exfoliation

theme

for

the

Nagios

web

interface

make

install-classicui

-

This

installs

the

classic

theme

for

the

Nagios

web

interfacetar

zxf

nagios-plugins-2.0.3.tar.gz

./configure

--with-nagios-user=nagios

--with-nagios-group=root

--enable-redhat-pthread-workaround

make

&&

make

install./configure

--with-nrpe-user=nagios

\

--with-nrpe-group=nagios

\

--with-nagios-user=nagios

\

--with-nagios-group=nagios

\

--enable-command-args

General

Options:

NRPE

port:

5666

#默認(rèn)端口為5666

make

all

make

install-plugin

make

install-daemon

make

install-daemon-config

make

install-xinetdScriptAlias

/nagios/cgi-bin

"/usr/local/nagios/sbin"

<Directory

"/usr/local/nagios/sbin">

Options

ExecCGI

AllowOverride

None

Order

allow,deny

Allow

from

all

AuthName

"Nagios

Access"

AuthType

Basic

AuthUserFile

/usr/local/nagios/etc/htpasswd.users

Require

valid-user

</Directory>

Alias

/nagios

"/usr/local/nagios/share"

<Directory

"/usr/local/nagios/share">

Options

None

AllowOverride

None

Order

allow,deny

Allow

from

all

AuthName

"Nagios

Access"

AuthType

Basic

AuthUserFile

/usr/local/nagios/etc/htpasswd.users

Require

valid-user

</Directory>

Alias

/pub/p_w_picpaths

"/usr/local/nagios/share/docs/p_w_picpaths"

<Directory

"/usr/local/nagios/share/docs/p_w_picpaths">

Options

None

AllowOverride

None

Order

allow,deny

Allow

from

all

AuthName

"Nagios

Access"

AuthType

Basic

AuthUserFile

/usr/local/nagios/etc/htpasswd.users

Require

valid-user

</Directory>在http的配置文件中添加上面的內(nèi)容后,通過http的秘鑰命令在nagios配置目錄中生產(chǎn)秘鑰文件。htpasswd

-c

/usr/local/nagios/etc/htpasswd.users

nagiosadmin修改NRPE配置vi

/usr/local/nagios/etc/nrpe.cfg

allowed_hosts=10.x.0.0/24

vi

/etc/xinetd.d/nrpe

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

=

27

}

vi

/etc/services

nrpe

5666/tcp

#

NRPE

service

xinetd

restart

netstat

-anltp

|

grep

5666

/usr/local/nagios/libexec/check_nrpe

-H

10.x.x.127

#測試

NRPE

v2.15

在啟動nagios之后發(fā)現(xiàn)部分監(jiān)控報警沒啟動,啟動時發(fā)現(xiàn)如下報錯:Error:Couldnotopencommandfile'/usr/local/nagios/var/rw/nagios.cmd'forupdate!在nagios.cfg中對該命令進(jìn)行解釋,參考了網(wǎng)上的解決方式,發(fā)現(xiàn)修改命令權(quán)限為777時,無報錯,判斷一定是權(quán)限的問題。但此方法僅臨時解決問題,當(dāng)nagios重啟后,該命令重新創(chuàng)建,問題依然存在??吹浇忉屩刑岬?/p>

“ItisalsowherethecommandCGIwillwritecommandsthataresubmitted

byusers”,覺得應(yīng)該是apache的用戶需要有對該文件具有寫的權(quán)限,因此修改apache的所屬可選組為nagios,問題徹底解決。usermod

-G

apache,nagios

nagios關(guān)于nagios的配置內(nèi)容,需要另開篇詳述。這里就不在說明

雙劍合璧Nagios+CactiCacti通過npc(Nagiospluginfor

Cacti)插件將Nagios集成在一起。wget

/sourceforge/nagios/ndoutils-2.0.0.tar.gztar

xvf

ndoutils-2.0.0.tar.gz

./configure

--prefix=/usr/local/nagios

\

--mandir=/usr/local/share/man

\

--enable-mysql

\

--disable-pgsql

\

--with-ndo2db-user=nagios

\

--with-ndo2db-group=nagios

\

--with-mysql

這里需要特別注意的是,仔細(xì)觀察編譯內(nèi)容,當(dāng)出現(xiàn)如下情況時說明mysql的庫文件沒有找到,雖然可以正常安裝該軟件,但啟動時最終會導(dǎo)致"Support

for

the

specified

database

server

is

either

not

yet

supported,

or

was

not

found

on

your

system."這樣的錯誤信息:

***

MySQL

library

could

not

be

located...

**************************

You

chose

to

compile

NDOutils

with

MySQL

support,

but

I

was

unable

to

locate

the

MySQL

library

on

your

system.

If

the

library

is

installed,

use

the

--with-mysql-lib

argument

to

specify

the

location

of

the

MySQL

library.

installed,

use

the

--with-mysql=DIR

argument

to

specify

the

location

of

the

MySQL

library,

We

assume

mysql_config

is

in

DIR/dir

NOTE:

After

you

install

the

necessary

libraries

on

your

system:

1.

Make

sure

/etc/ld.so.conf

has

an

entry

for

the

directory

in

which

the

MySQL

libraries

are

installed.

2.

Run

'ldconfig'

to

update

the

run-time

linker

options.

3.

Run

'make

devclean'

in

the

NDBXT

distribution

to

clean

out

any

old

references

to

your

previous

compile.

4.

Rerun

the

configure

script.

TIP:

Try

the

following

./configure

--with-mysql=/usr/lib/mysql

********************************************************************

如果出現(xiàn)如下報錯信息:

In

file

included

from

io.c:11:

../include/config.h:261:25:

error:

mysql/mysql.h:

No

such

file

or

directory

../include/config.h:262:26:

error:

mysql/errmsg.h:

No

such

file

or

directory

修改include/config.h中第261行的內(nèi)容去掉mysql/,這是因為生產(chǎn)的編譯文件路徑指定錯誤。

make

&&

make

install

cd

config

cp

ndo2db.cfg-sample

/usr/local/nagios/etc/ndo2db.cfg

cp

ndomod.cfg-sample

/usr/local/nagios/etc/ndomod.cfg

vi

/usr/local/nagios/etc/ndo2db.cfg

socket_name=/usr/local/nagios/var/ndo.sock

db_name=cactidb

db_prefix=npc_

db_user=cacti

db_pass=cacti

debug_level=1

debug_file=/usr/local/nagios/var/ndo2db.debug

vi

/usr/local/nagios/etc/nagios.cfg

broker_module=/usr/local/nagios/bin/ndomod.o

config_file=/usr/local/nagios/etc/ndomod.cfg到這步需要做個小改動,因為ndoutils的數(shù)據(jù)庫腳本中定義的表名為nagios_,而配置文件中定義為npc_,需要手動改一下腳本nstalldb,upgradedb及mysql.sql的內(nèi)容將nagios替換為npc。替換的方式用vi在command模式下:%s/nagios_/npc_/除此之外還有perl的相關(guān)包也需要安裝,主要是DBI,Data::ShowTables,DBD::mysql,一般通過perl的CPAN項目(類似YUM)安裝。涉及的相關(guān)包如lynx,ncftp,ftpcpan源地址使用

/cpan/CPAN>

o

conf

urllist

push

/cpan/

CPAN>

o

conf

prerequisites_policy

follow

CPAN>

o

conf

commit

CPAN>

install

DBD::mysql一切就緒后運(yùn)行ndoutil的升級庫腳本:cd

ndoutils-2.0.0/db

./installdb

-u

cacti

-p

cacti

-h

10.x.x.127

-d

cactidb

#for

a

new

installation

./upgradedb

-u

cacti

-p

cacti

-h

10.

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論