cactiuser mysql,搭建cacti监控

首先搭建LAMP环境

#yum -y

install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng

libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib

zlib-devel glibc glibc-devel glib2 gd gd-devel glib2-devel bzip2

bzip2-devel ncurses ncurses-devel curl curl-devel openssl

openssl-devel libmcrypt-devel libtool

libtool-devel

安装mysql

#yum install

bison

#tar -zxf

cmake-2.8.4.tar.gz

#./configure

#gmake

#make

install

#tar -zxf

mysql-5.5.14.tar.gz

#cmake

./

#make

#make

install

#cp

my-medium.cnf /etc/my.cnf

#cp

mysql.server /etc/init.d/mysqld

# chmod 770

/etc/init.d/mysqld

#chmod +w

/usr/local/mysql

#chown -R

mysql:mysql /usr/local/mysql

#mkdir -p

/data/mysql/data/

#chown -R

mysql:mysql /data/mysql/

#vim

/etc/my.cnf

加入以下内容

user =

mysql

basedir =

/usr/local/mysql

datadir =

/data/mysql/data

log-error =

/data/mysql/mysql_error.log

pid-file =

/data/mysql/mysql.pid

#./scripts/mysql_install_db --user=mysql

--datadir=/data/mysql/data

--basedir=/usr/local/mysql

#ln -s

/usr/local/mysql/bin/mysql /bin/

#/etc/init.d/mysqld start

#/usr/local/mysql/bin/mysqladmin -u root password

123456

安装httpd

# useradd www

-s /sbin/nologin

#tar -jxvf

httpd-2.2.24.tar.bz2

#./configure

--prefix=/usr/local/apache --enable-module=so

--enable-deflate=shared --enable-expires=shared

--enable-rewrite=shared --enable-cache --enable-file-cahe

--enable-mem-cache --enable-disk-cache --enable-static-support

--enable-ssl --enable-so

#make

&& make install

#ln -s

/usr/local/apache/bin/apachectl /etc/init.d/httpd

#

/etc/init.d/httpd start

安装PHP

# tar -zxvf

php-5.3.6.tar.gz

#./configure

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

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

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

--with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd

--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib

--enable-safe-mode --enable-mbstring --with-gd

--enable-gd-native-ttf --with-openssl --enable-zip

--enable-sockets

# make

&& make install

# cp

php.ini-development /usr/local/php/etc/php.ini

查看是否生成PHP模块

# ls

/usr/local/apache/modules/ |grep php

libphp5.so

#vim

/usr/local/apache/conf/httpd.conf

找到AddType模块处添加

AddType

application/x-httpd-php-source .phps

AddType

application/x-httpd-php .php .phtml

在index.html前添加index.php

更改用户

www

更改主目录路径

/data/www/htdocs

更改日志路径

/data/www/logs/access_log

/data/www/logs/error_log

# chown

www:www /data/www/ -R

#

/etc/init.d/httpd -k restart

测试

http://IP/index.php

出现PHP测试页说明LAMP环境搭建完成

部署CACTI

安装rrdtool

# yum install

cairo-devel libxml2-devel pango-devel pango libpng-devel freetype

freetype-devel libart_lgpl-devel pear pear-devel

#tar -zxvf

rrdtool-1.4.7.tar.gz

#./configure

--prefix=/usr/local/rrdtool/

#make

&& make install

安装snmp

# yum install

net-snmp net-snmp-devel net-snmp-libs

net-snmp-utils

# chkconfig

--level 3 snmpd on

#

/etc/init.d/snmpd start

# vim

/etc/snmp/snmpd.conf

修改如下

# sec.name

source community

40 # sec.name

source community

41 com2sec

notConfigUser 127.0.0.1 public

61 # group

context sec.model sec.level prefix read write

notif

62 access

notConfigGroup "" any noauth exact all none

none

84 ##

incl/excl subtree mask

85 view all

included .1 80

#

/etc/init.d/snmpd restart

# $ snmpwalk

-v 2c -c public 127.0.0.1 if //测试

安装cacti

解压cacti,移动到/data/www/下

#tar -zxvf

cacti-0.8.7g.tar.gz

#mv

cacti-0.8.7g /data/www/cacti

#chown www:www

/data/www/cacti/ -R

给cacti添加别名

# vim

/usr/local/apache/conf/httpd.conf

在最下增加如下

Alias /cacti/

"/data/www/cacti/"

AllowOverride

None

Options

None

Order

allow,deny

Allow from

all

或者添加虚拟主机

在mysql中创建cacti数据库,并授权给用户

mysql> create database

cacti;

mysql> grant all on cacti.* to

cactiuser@localhost identified by 'cactipwd';

mysql> flush privileges;

导入数据库

# mysql

-ucactiuser -pcactipwd cacti < cacti.sql

如有报错,执行以下即可

#vim

cacti.sql

:%s/TYPE=MyISAM/ENGINE=MyISAM/g

修改cacti配置脚本

# vim

include/config.php

主要修改与mysql的连接

安装

先做软连接

#ln -s

/usr/local/rrdtool/bin/rrdtool /usr/local/bin/

#ln -s

/usr/local/php/bin/php /usr/bin/

添加timezone

更改php时区

编辑php.ini,将timezone改成PRC

http://IP/cacti/install

这里基本不会报错了,如果有文件没找到,最软链接即可解决

点击finish,出现登陆界面,默认账号口令都是admin

#crontab

–e

*/5 * * * *

/usr/bin/php /data/www/cacti/poller.php

2>&1

注:此lamp环境加cacti-0.8.7g,问题很多,而且目前为止,就算全解决,还有一个最重要的,就是不装spine不出图,所以下面要装spine

安装spine

#tar -zxvf

cacti-spine-0.8.7g.tar.gz

#aclocal

#libtoolize

--force

#autoconf

#autoheader

#automake

#./configure

--prefix=/usr/local/spine

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

#make

&& make install

#cd

/usr/local/spine/etc/

#cp

spine.conf.dist spine.conf

#vim

spine.conf

#ln -s

/usr/local/mysql/lib/libmysqlclient.so.18

/usr/lib64/

#./spine

SPINE: Using

spine config file [../etc/spine.conf]

SPINE: Version

0.8.7g starting

SPINE: Time:

0.1604 s, Threads: 1, Hosts: 2

/usr/local/spine/bin/spine

测试命令:

# /usr/bin/php

-q /data/www/cacti/poller.php --force --debug  //测试生成rra文件情况

# snmpwalk -v

2c -c public 127.0.0.1 if  //测试snmp

#

/usr/local/rrdtool/bin/rrdtool fetch localhost_hdd_free_10.rrd

AVERAGE  //打开rra文件,看里面数据

Cacti插件安装

1.

cacti-plugin

#tar -zxvf

cacti-plugin-0.8.7g-PA-v2.8.tar.gz

# cp

cacti-plugin-0.8.7g-PA-v2.8.diff /data/www/cacti/

# cp pa.sql

/data/www/cacti/

#patch -p1 -N

< cacti-plugin-0.8.7g-PA-v2.8.diff

//打补丁

#vim pa.sql

//%s/TYPE=MyISAM/ENGINE=MyISAM/g

#mysql

-ucactiuser -pcactipwd cacti <

pa.sql

#vim

/data/www/cacti/include/global.php //$config['url_path'] =

'/cacti/';

2.安装setting

#tar -zxvf

settings-v0.71-1.tgz

#mv settings

/data/www/cacti/plugins/

3.安装monitor

# tar -zxvf

monitor-v1.3-1.tgz

# mv monitor

/data/www/cacti/plugins/

# mysql

-ucactiuser -pcactipwd cacti <

monitor.sql

# vim

/data/www/cacti/include/config.php

$plugins =

array();

$plugins[] =

'settings'; //添加setting插件

$plugins []=

'monitor'; //添加monitor插件

继续点击启动,方法同setting

报错解决方法(部分有效):

1.导入cacti.sql时提示:TYPE=MyISAM不对

将cacti.sql里面所有的TYPE=MyISAM 替换成 ENGINE=MyISAM

mysql5.5取消了type 只能用engine!!否则会出现以下错误:

ERROR 1064

(42000) at line 5: You have an error in your SQL syntax; check the

manual that corresponds to your MySQL server version for the right

syntax to use near 'TYPE=MyISAM' at line 6

命令为:

vi

/var/www/html/cacti/cacti.sql

然后输入:

:1,%s/TYPE=MyISAM/ENGINE=MyISAM/g

或者 :1,%s/TYPE=MyISAM/ENGINE=MyISAM/gc

多了个提示对话框

最后重启:/usr/local/apache2/bin/apachectl restart

2.session_start(): Failed to initialize storage

module

解决方法1:

#vim

php.ini

将如下0修改成1

session.auto_start = 1

解决方法2:

在报错的文件里的session

start();之前加入如下代码:ini_set(‘session.save_handler’, ‘files’);

解决方法3:

在php.ini文件里,显式指定session的save_path(比如 /temp)然后重启web服务。

解决方法4:

在session_start前面增加上面的内容

if(!is_dir(’./tmp/’))mkdir (’./tmp/’,

0700);

session_save_path(’./tmp/’);

session_start();

解决方法5:

将/tmp目录所属组修改www

3.进入ip/cacti时区错误

解决方法1:

date_default_timezone_set('Asia/shanghai');

就加在

$database_type

= "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "cactiuser";

$database_port

= "3306";

date_default_timezone_set('Asia/shanghai');

//手动添加

重启生效apache

/usr/local/apache2/bin/apachectl restar

解决方法2:

修改/etc/php.ini:

找到date.timezone,去掉前面的注释并

改为

date.timezone = PRC

date.timezone

= Asia/Shanghai

4.打补丁之后,图片无法正常显示

# vim

/data/www/cacti/include/global.php

if (!

isset($url_path)) {

$url_path =

"";

}

$config['url_path'] =

'/cacti/';

define('URL_PATH', $url_path);

5.安装插件后,日志中提示数据库错误

修复 //修复时会提示缺少libmysqlclient.so.15,如果没有可以cp过来

# mysqlcheck

--repair cacti -u root –p //修复索引

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值