Sunday, November 1, 2015

Install Cacti - CentOS 6

Install Cacti - CentOS 6

OS: CentOS 6.5 - 64bits
IP: 124.124.124.160/24

Install Apache
yum install httpd httpd-devel
Install MySQL
yum install mysql mysql-server
Start service mysqld
/etc/init.d/mysqld start
Enable mysqld service permanently
chkconfig mysqld on
Reset password for mysql to new password is "rhce2015"
mysqladmin -u root -p password rhce2015
Install PHP
yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-mysql
Install PHP-SNMP
yum install php-snmp
Install NET-SNMP
yum install net-snmp-utils net-snmp-libs php-pear-Net-SMTP
Install RRDtool
yum install rrdtool
Start service: Apache, MySQL and SNMP
/etc/init.d/httpd start
/etc/init.d/mysqld start
/etc/init.d/snmpd start
Enable service: Apache, MySQL and SNMP to startup
chkconfig httpd on
chkconfig mysqld on
chkconfig snmpd on
Add Repository
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
Installing Cacti Tool
yum install cacti
Configure MySQL
Login to mysql as user "root" and create user and database for cacti
mysql -u root -p
mysql> create database cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'centos65';
mysql> flush privileges;
mysql> exit
Find cacti.sql file
rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.8b/cacti.sql
Restore default cacti database to our created database
mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql
Edit cacti database
vi /etc/cacti/db.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";        ## Name of the Cacti Database ##
$database_hostname = "localhost";
$database_username = "cacti";       ## Username for Cacti database ##  
$database_password = "centos65";              ## Database password ##
$database_port = "3306";
$database_ssl = false;
/*

Configure Apache server
vi /etc/httpd/conf.d/cacti.conf
With content
Alias /cacti /usr/share/cacti
 <Directory /usr/share/cacti/>
     <IfModule mod_authz_core.c>
     # httpd 2.4
     Require host localhost
          </IfModule>
               <IfModule !mod_authz_core.c>
                 # httpd 2.2
                 Order deny,allow
                 Deny from all
                 Allow from 124.124.124.0/24
          </IfModule>
 </Directory>
  

Restart Apache
/etc/init.d/httpd restart
Allow port 80 in iptables
vi /etc/sysconfig/iptables
Add this line
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart iptables
/etc/init.d/iptables restart
Configure Cron for Cacti
vi /etc/cron.d/cacti
with this content
*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Run Cacti installer
http://124.124.124.160/cacti
New Install
Finish installation

Login into cacti with default username and password is admin.
And this page will forced us to change the default password
Loged in


Add other server:
Devices --> Add -->

Here is the sample of graph Memory Usage


#CentOS #Cacti #Vannakk

No comments:

Post a Comment