[rhel6.5]cacti的安装配置

  • rhel6.5安装配置cacti

    两台主机:
    IP:172.25.23.20 172.25.23.21
    内核版本2.6.32-431.el6.x86_64
    软件版本:
    cacti-0.8.8h.tar.gz
    cacti-spine-0.8.8h.tar.gz

  • 首先在172.25.23.20上面安转cacti依赖的软件包

[root@my Desktop]# yum install rrdtool mysql-server php httpd php-mysql  php-xml net-snmp-* -y
  • 安装Yum没有提供的软件包php-snmp,通过软件包php-snmp-5.3.3-26.el6.x86_64.rpm来进行安装
[root@server20 ~]# rpm -ivh /mnt/php-snmp-5.3.3-26.el6.x86_64.rpm
warning: /mnt/php-snmp-5.3.3-26.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:php-snmp               ########################################### [100%]
  • 编辑配置文件更改时区
[root@server20 ~]# vim /etc/php.ini 
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Shanghai
  • 解压cacti的主文件,到httpd的发布目录里面
[root@server20 mnt]# tar zxf cacti-0.8.8h.tar.gz -C /var/www/html/
[root@server20 mnt]# ln -sv /var/www/html/cacti-0.8.8h/ /var/www/html/cacti
`/var/www/html/cacti' -> `/var/www/html/cacti-0.8.8h/
  • 启动httpd服务:
[root@server20 html]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
  • 确保服务的启动状态是正常的
    这里写图片描述

  • 修改cacti的配置文件cacti/include/config.php 关于数据库连接的选项

[root@server20 html]# vim cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "westos";
$database_port = "3306";
$database_ssl = false;

/*
   Edit this to point to the default URL of your Cacti install
   ex: if your cacti install as at http://serverip/cacti/ this
   would be set to /cacti/
*/
//$url_path = "/cacti/";
$url_path = "/cacti/";

/* Default session name - Session name must contain alpha characters */
//$cacti_session_name = "Cacti";
$cacti_session_name = "Cacti";
  • 启动myql数据库并且进行数据库的安全设置,因为这是安装数据库之后的第一次使用
[root@server20 html]# /etc/init.d/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 server20.com 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 /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
  • 确保启动状态是正常的
    这里写图片描述
  • 执行数据库的安全配置脚本
[root@server20 html]# mysql_secure_installation 




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL
  • 创建cacti数据库,并且执行cacti数据库的导入操作
[root@server20 html]# mysql -pwestos -e "create database cacti"
[root@server20 html]# mysql -pwestos cacti < cacti/cacti.sql
  • 执行授权操作
[root@server20 html]# mysql -pwestos -e "grant all on cacti.* to cacti@localhost identified by 'westos'"
  • 确保登录是正常的
[root@server20 html]# mysql -ucacti -pwestos cacti
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
  • 在使用浏览器进行刷新
    这里写图片描述
  • 点击next
    这里写图片描述
  • 选择New Install,点击next;
    这里写图片描述
  • 确保这里的状态都是正常的,点击进入login界面
    这里写图片描述
  • 点击进行登陆,这里使用的用户名和密码都是admin;
    这里写图片描述
  • 登陆之后,会强制进行用户密码的修改,输入新的密码;
    这里写图片描述
  • 点击之后进入新的页面
    这里写图片描述
  • 选择device可以查看本机的设备的信息

  • 点击graphs,可以选择时间段,查看平均负载等信息
    这里写图片描述

  • 查看/var/www/html/cacti文件的属主或者属组,,然后添加制定的用户

[root@server20 cacti]# useradd -u 1000 cacti 
  • 切换到这个用户并且创建定时任务
[root@server20 cacti]# su - cacti
[cacti@server20 ~]$ crontab -e
*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1

crontab: installing new crontab
[cacti@server20 ~]$ logout
  • 复制时区文件到系统时间文件里面
[root@server20 rra]# cd /usr/share/zoneinfo/Asia/
[root@server20 Asia]# pwd
/usr/share/zoneinfo/Asia
[root@server20 Asia]# cp Shanghai /etc/localtime 
cp: overwrite `/etc/localtime'? y
  • 关于localhost使用cacti来监控系统性能的配置已经完成,接下来配置cacti监控172.25.23.21
  • 首先安装net-snmp-*
[root@server21 ~]# yum install -y net-snmp-* -y
  • 启动snmpd服务:
[root@server21 ~]# /etc/init.d/snmpd start 
Starting snmpd:                                            [  OK  ]
[root@server21 ~]# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
  • 修改配置文件如下
[root@server21 ~]# vim /etc/snmp/snmpd.conf 
# First, map the community name "public" into a "security name"

#       sec.name  source          community
#com2sec notConfigUser  default       public
com2sec local           localhost       westos
com2sec mynetwork       172.25.23.0/24  westos

# Second, map the security name into a group name:

#       groupName      securityModel securityName
#group   notConfigGroup v1           notConfigUser
#group   notConfigGroup v2c           notConfigUser

group   MyRWGroup       v1              local
group   MyRWGroup       v2c             local
group   MyRWGroup       usm             local

group   MyROGroup       v1              mynetwork
group   MyROGroup       v2c             mynetwork
group   MyROGroup       usm             mynetwork

# Third, create a view for us to let the group have rights to:

# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
view    systemview    included   .1.3.6.1.2.1
view    systemview    included   .1.3.6.1.2.1.25.1.1

view all included .1                                    80

# Finally, grant the group read-only access to the systemview view.

#       group          context sec.model sec.level prefix read   write  notif
#access  notConfigGroup ""      any       noauth    exact  systemview none none

access  MyROGroup ""      any       noauth    exact  all none none
access  MyRWGroup ""      any       noauth    exact  all all none

#syslocation Unknown (edit /etc/snmp/snmpd.conf)
#syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)


syslocation RHEL6.5
syscontact Root  <linux1213@westos.org>

# Check the / partition and make sure it contains at least 10 megs.

#disk / 10000
disk / 10000
  • 使用命令探测snmpd服务是否正常启动
[root@server21 ~]# snmpwalk -v 1 -c westos localhost IP-MIB::ipAdEntIfIndex
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
IP-MIB::ipAdEntIfIndex.172.25.23.21 = INTEGER: 2
  • 显示的结果如下:

这里写图片描述

  • server20.com上面进行探测
[root@server20 ~]# snmpwalk -v 1 -c westos 172.25.23.21 IP-MIB::ipAdEntIfIndex
  • 确保探测的结果如下
    这里写图片描述

  • 是上面对于配置文件的修改,可以通过检查错误日志来查看文件的修改是否是正确的

  • 文件是/var/log/messages,
    这里写图片描述

  • 点击device之后,点击Add
    这里写图片描述

  • 按照这个要求进行创建
    这里写图片描述
    这里写图片描述
  • 创建server21.com的图形
    这里写图片描述
    这里写图片描述
  • 接下来点击Graphy treedefault tree
    这里写图片描述
  • 接下来点击add用于添加新的图形界面
    这里写图片描述
  • 这里 改为 host 然后点击save进行保存
    这里写图片描述

  • 这里就可以看到hosts server21.com发送回来的信息了
    这里写图片描述

  • 接下来配置cacti-spine-0.8.8h
  • 首先编译环境的依赖问题
[root@server20 cacti-spine-0.8.8h]# yum install -y net-snmp-devel mysql-devel openssl-devel dos2unix autoconf automake binutils libtool gcc cpp glibc-headers  kernel-headers glibc-devel 
  • 然后执行
[root@server20 ~]# tar zxf cacti-spine-0.8.8h.tar.gz -C /usr/local/
[root@server20 ~]# cd /usr/local/cacti-spine-0.8.8h/

[root@server20 cacti-spine-0.8.8h]# sh bootstrap 
  • 直到出现这个画面
    这里写图片描述
  • 执行
[root@server20 cacti-spine-0.8.8h]# ./configure 
[root@server20 cacti-spine-0.8.8h]# make
[root@server20 cacti-spine-0.8.8h]# make install 
  • 首先复制配置文件
[root@server20 local]# cd spine/
[root@server20 spine]# ls
bin  etc
[root@server20 spine]# cd etc/
[root@server20 etc]# ls
spine.conf.dist
[root@server20 etc]# pwd
/usr/local/spine/etc
[root@server20 etc]# cp spine.conf.dist /etc/spine.conf
  • 修改poller Type的类型为spine
    这里写图片描述
  • 同时还需要添加spine的配置路径
    这里写图片描述
  • 然后更改配置文件,添加连接数据库的信息
[root@server20 bin]# vim /etc/spine.conf
DB_Host         localhost
DB_Database     cacti
DB_User         cacti
DB_Pass         westos
DB_Port         3306
  • 使用绝对路径的方式启动服务
[root@server20 bin]# /usr/local/spine/bin/spine 
  • 通过上面的方式就完成了,插件spine的配置
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值