【php精品源码栏目提醒】:网学会员为广大网友收集整理了,手把手教你搭建功能强大的监控平台cacti+nagios(源码安装) - 其它资料,希望对大家有所帮助!
源码安装 cactinagios目录索引安装前的准备工作 1、 操作系统要求 2、 配置编译环境以及安装一些依赖包 3、 关闭不需要的服务(以下未列出的一律关闭)可选操作 4、 下载所需软件包LAMP 环境的搭建 1、 mysql 的安装 2、 apache 的安装 3、
php 的安装 4、 验证安装CACTI 的安装 1、 安装 rrdtool 2、 安装 net‐snmp 3、 解压 cacti 包并做好安装前的配置 4、 安装 cacti‐spine 5、 安装 cactiNagios 的安装 1、 nagios 的安装 2、 编译并安装 Nagios 插件安装前的准备工作1、操作系统要求CentOS_5.5 或 RedHat5.5 (RedHat5.5 不能使用 yum 命令有关如何修改 RedHat使用 CentOS 的更新源请参照以下连接)http://wenku.baidu.com/view/bc394286ec3a87c24028c432.html2、配置编译环境以及安装一些依赖包Yuminstall–ypangoglibpangopango‐develcairogdgd‐develgccglibcglibc‐common3、关闭不需要的服务(以下未列出的一律关闭)可选操作atdcrondirqbalancemicrocode_ctlnetworksendmailsshdsyslog4、下载所需软件包以下连接是我个人上传到 rayfile 的源代码包, 有兴趣的朋友也可以上各个官方网站去下载(有些版本间存在不兼容的情况)下列版本都已测试过没有问题。
mysql‐5.0.75.tar.gzhttp://www.rayfile.com/zh‐cn/files/221522b5‐b8eb‐11e0‐8c4d‐0015c55db73d/httpd‐2.2.19.tar.gzhttp://www.rayfile.com/zh‐cn/files/e641fc57‐b8e7‐11e0‐8f26‐0015c55db73d/
php‐5.2.17.tar.gzhttp://www.rayfile.com/zh‐cn/files/8a9baef3‐b8eb‐11e0‐aa46‐0015c55db73d/rrdtool‐1.4.5.tar.gzhttp://www.rayfile.com/zh‐cn/files/9ce70a38‐b8eb‐11e0‐bd61‐0015c55db73d/cacti‐0.8.7g.tar.gzhttp://www.rayfile.com/zh‐cn/files/eed7469c‐b8ea‐11e0‐aa26‐0015c55db73d/cacti‐spine‐0.8.7g.tar.gzhttp://www.rayfile.com/zh‐cn/files/f94cb330‐b8ea‐11e0‐b425‐0015c55db73d/nagios‐3.2.3.tar.gzhttp://www.rayfile.com/zh‐cn/files/afc734bd‐b8eb‐11e0‐b9af‐0015c55db73d/nagios‐plugins‐1.4.15.tar.gzhttp://www.rayfile.com/zh‐cn/files/bbbc71d1‐b8eb‐11e0‐b7d2‐0015c55db73d/LAMP 环境的搭建1、mysql 的安装groupaddmysqluseradd‐r‐gmysqlmysqlcd/usr/localtarzxvf/path/to/mysql‐5.0.75.tar.gz./configure–prefix/usr/local/mysqlmakemakeinstallcdmysqlchown‐Rmysql.chgrp‐Rmysql.bin/mysql_install_db‐‐usermysqlchown‐Rroot.chown‐Rmysqlvarcpshare/mysql/my‐medium.cnf/etc/my.cnfbin/mysqld_safe‐‐usermysqlcpshare/mysql/mysql.server/etc/init.d/mysqldchkconfig–addmysqldchkconfig–level3mysqldon2、apache 的安装tarzxvfhttpd‐2.2.19.tar.gzcdhttpd‐2.2.19./configure‐‐prefix/usr/local/apache‐‐enable‐modulesomakemakeinstall/usr/local/apache/bin/httpd‐kstartecho/usr/local/apache/bin/httpd‐kstart/etc/rc.d/rc.local编辑 httpd.conf 文件配置对
PHP 文件的解析vi/usr/local/apache/conf/httpd.conf添加、修改以下内容LoadModulephp5_module modules/libphp5.soAddTypeapplication/x‐httpd‐
php.phpDirectoryIndexindex.htmlindex.
php3、
php 的安装tarzxvfphp‐5.2.17.tar.gzcdphp‐5.2.17./configure --prefix/usr/local/
php --with-apxs2/usr/local/apache/bin/apxs--with-mysql/usr/local/mysql --enable-sockets makemakeinstallcpphp.ini‐dist/usr/local/
php/lib/
php/
php.inivi/usr/local/
php/etc/
php.ini4、验证安装验证 apache 跟
php 是否工作正常,创建 index.
php 文件vi/usr/local/apache/htdocs/index.
php将以下内容写入到 index.
php 并保存推出修改完后启动 apache, 在浏览器中输入 http://服务器地址/index.
php 出现下图表示工作正常。
验证
php 与 mysql 是否工作正常,把里面的内容改为vi/var/www/html/index.
php修改完后刷新刚刚的页面出现“OK”字样表示工作正常。
至此 LAMP 环境已成功搭建CACTI 的安装1、安装 rrdtooltarzxvfrrdtool‐1.4.5.tar.gz cdrrdtool‐1.4.5./configure‐‐prefix/usr/local/rrdtoolmakemakeinstall2、安装 netsnmptarzxvf net‐snmp‐5.6.tar.gzcdnet‐snmp‐5.6./configure‐‐prefix/usr/local/net‐snmp‐‐with‐mysql/usr/local/mysql/bin/mysql_config makemakeinstall提示信息defaultversionof‐snmp‐version3:3(在这里版本通常有三种形式:12c3) :Systemcontactinformation(配置该设备的联系信息) 120606906qq.com(也可以是邮箱地址)Systemlocation该系统设备的地理位置:shenzhenP.R.CLocationtowritelogfile日志文件位置:/var/log/snmpd.logLocationtoWritepersistent数据存储目录:/var/net‐snmp3、解压 cacti 包并做好安装前的配置tarzxvfcacti‐0.8.7g.tar.gzcdcacti‐0.8.7gmvcacti‐0.8.7g/usr/local/apache/htdocs/cactiuseraddcactipasswdcacti将 cacti 目录权限赋予 cacti 用户和 cacti 组chown–Rcacti:cacti/usr/local/apache/htdocs/cacticrontab–ucacti–e加入以下内容 每隔 1 分钟去
php 代理上的数据(取数据的时间可根据个人需求更改)/1/usr/local/
php/bin/
php/usr/local/apache/htdocs/cacti/poller.
php/dev/null21创建 cacti 数据库cd/usr/local/apache/htdocs/cacti/usr/local/mysql/bin/mysql–uroot–pmysqlcreatedatabasecactimysqlgrantalloncacti.tocactilocalhostidentifiedbycactimysqlflushprivilegesmysqlquit/usr/local/mysql/bin/mysql‐ucacti‐pcactiusecactimysqlshowtables数据库创建完毕编辑 cacti 的配置文件 config.phpglobal.
php 设置连接数据库的用户名以及密码编辑 cacti 的 config.
php 文件找到下列参数vi/usr/local/apache/htdocs/include/config.phpdatabase_typemysqldatabase_defaultcactidatabase_hostnamelocalhostdatabase_usernamecactiuserdatabase_passwordcactiuserdatabase_port3306修改为database_typemysqldatabase_defaultcactidatabase_hostnamelocalhostdatabase_usernamecactidatabase_passwordcactidatabase_port3306编辑 cacti 的 global.
php 文件找到下列参数vi/usr/local/apache/htdocs/include/global.phpdatabase_typemysqldatabase_defaultcactidatabase_hostnamelocalhostdatabase_usernamecactiuserdatabase_passwordcactiuserdatabase_port3306修改为database_typemysqldatabase_defaultcactidatabase_hostnamelocalhostdatabase_usernamecactidatabase_passwordcactidatabase_port33064、安装 cactispinetarzxvfcacti‐spine‐0.8.7g.tar.gzcdcacti‐spine‐0.8.7g./configure‐‐prefix/usr/local/cacti‐spine‐‐with‐mysql/usr/local/mysql‐‐with‐snmp/usr/local/net‐snmpmakemakeinstall5、安装 cacti在 IE 中输入 http://服务器地址/cacti这一步非常重要一定要配置好正确的文件路径 cacti 才能正常工作,下图提示配置文件不能正常的找到我们可以在 linux 中使用 find 命令来查找相应的文件。
find/‐namerrdtool 来查找各个文件然后将正确的路径输入到相应的文本框中下图是我在 linux 中查找到的配置文件的路径如果你是按照本文档做的路径应该和我的是一样的,输入正确路径后还是提示NOTFOUND不用管他直接 Finish初始用户密码都是 admin登录之后点击“Settings”然后打开“Paths”检查配置文件是否全部正常找到,下图显示OK: FILE FOUND表示配置文件都已工作正常。
等几分钟打开“graphs”如果有图形,那么恭喜你 cacti 已正常工作如果没有请检查 cacti 目录下的 rra 目录下是否有生成.rra 结尾的文件,如果没有一般是权限问题请详细检查目录权限ls /usr/local/apache/htdocs/cacti/rraNagios 的安装1、nagios 的安装建立一个帐号/usr/sbin/useraddnagiospasswdnagios创建一个用户组名为 nagcmd 用于从 Web 接口执行外部命令。
将 nagios 用户和apache 用户都加到这个组中。
/usr/sbin/groupaddnagcmd/usr/sbin/usermod‐Gnagcmdnagios编译与安装 Nagiostarzxvfnagios‐3.2.3.tar.gzcdnagios‐3.2.3./configure‐‐with‐command‐groupnagcmdmakeallmakeinstallmakeinstall‐initmakeinstall‐configmakeinstall‐commandmode配置 web 接口编辑 httpd.conf 文件vim/usr/local/apache/conf/httpd.conf在配置文件的最后边添加一下语句ScriptAlias/nagios/cgi‐bin/usr/local/nagios/sbin OptionsExecCGI AllowOverrideNone Orderallowdeny Allowfromall AuthNameNagiosAccess AuthTypeBasic AuthUserFile/usr/local/nagios/etc/htpasswd.users Requirevalid‐userAlias/nagios/usr/local/nagios/share OptionsNone AllowOverrideNone Orderallowdeny Allowfromall AuthNameNagiosAccess AuthTypeBasic AuthUserFile/usr/local/nagios/etc/htpasswd.users Requirevalid‐user创建一个 nagiosadmin 的用户用于 Nagios 的 WEB 接口登录。
记下你所设置的登录口令,一会儿你会用到它。
/usr/local/apache/bin/htpasswd ‐c /usr/local/nagios/etc/htpasswd.usersnagiosadmin设置密码Newpassword:重启 Apache 服务以使设置生效。
/usr/local/apache/bin/httpd‐krestart2、编译并安装 Nagios 插件tarzxvfnagios‐plugins‐1.4.15.tar.gzcdnagios‐plugins‐1.4.15./configure‐‐with‐nagios‐usernagios‐‐with‐nagios‐groupnagiosmakemakeinstall把 Nagios 加入到服务列表中以使之在系统启动时自动启动chkconfig‐‐addnagioschkconfignagioson验证 Nagios 的样例配置文件/usr/local/nagios/bin/nagios‐v/usr/local/nagios/etc/nagios.cfg如果没有报错,可以启动 Nagios 服务servicenagiosstart打开 IE 浏览器输入 http://服务器地址/nagios 弹出用户密码界面输入刚刚设置好的用户名 nagiosadmin 和密码,回车后出现下图表示 nagios 已正常安装。
恭喜您已经成功安装了 cacti 与 nagios。