Difference between revisions of "Install Cacti on CentOS 5"

From CSLabsWiki
(saving to avoid losing curent status)
m
Line 2: Line 2:
 
{{ outdated }}
 
{{ outdated }}
   
This page summarizes how to perform a basic installation of Cacti on CentOS 5.
+
This page summarizes how to perform a basic installation of Cacti on CentOS 5. This tutorial assumes you are either logged in as root or have sudo.
   
 
==Install==
 
==Install==
Line 27: Line 27:
   
 
*Configure iptables to allow Apache traffic
 
*Configure iptables to allow Apache traffic
**<code>/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT</code>
+
**<code>/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT</code>
 
**<code>/etc/init.d/iptables save</code>
 
**<code>/etc/init.d/iptables save</code>
 
**<code>/etc/init.d/iptables restart</code>
 
**<code>/etc/init.d/iptables restart</code>
   
===Install & Configure Cacti===
+
===Install & Configure Cacti and MySQL===
   
 
*Install Cacti & Required Dependencies
 
*Install Cacti & Required Dependencies
 
**<code>yum install cacti mysql-server liberation-fonts</code>
 
**<code>yum install cacti mysql-server liberation-fonts</code>
   
====Configure MySQL====
 
 
*Configure <code>mysqld</code> to start on boot
 
*Configure <code>mysqld</code> to start on boot
 
**<code>/sbin/chkconfig --levels 345 mysqld on</code>
 
**<code>/sbin/chkconfig --levels 345 mysqld on</code>
Line 58: Line 57:
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
   
mysql> GRANT ALL ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'password';
+
mysql> GRANT ALL ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'CACTIUSER-PASSWORD-GOES-HERE';
 
Query OK, 0 rows affected (0.00 sec)
 
Query OK, 0 rows affected (0.00 sec)
   
 
mysql> quit
 
mysql> quit
 
Bye
 
Bye
  +
</pre></code>
  +
  +
*Populate cacti database (Note: You will use the password you created for <code>cactiuser</code> here)
  +
**<code>/usr/bin/mysql cacti -u cactiuser -p < /var/www/cacti/cacti.sql</code>
  +
  +
*Modify <code>/var/www/cacti/include/config.php</code> to have correct password for the cacti database
  +
<code><pre>
  +
$database_password = "CACTIUSER-PASSWORD-GOES-HERE";
  +
</pre></code>
  +
  +
*Modify root's crontab to update Cacti every five minutes
  +
**<code>crontab -e</code>
  +
<code><pre>
  +
# Used to update Cacti
  +
*/5 * * * * /usr/bin/php /var/www/cacti/poller.php >> /var/log/cacti 2>&1
  +
</pre></code>
  +
  +
*Modified <code>/etc/httpd/conf.d/cacti.conf</code> to fix url and allow access from anywhere
  +
<code><pre>
  +
Alias /cacti /var/www/cacti/
  +
<Directory /var/www/cacti/>
  +
DirectoryIndex index.php
  +
Options -Indexes
  +
AllowOverride all
  +
AddType application/x-httpd-php .php
  +
php_flag magic_quotes_gpc on
  +
php_flag track_vars on
  +
</Directory>
 
</pre></code>
 
</pre></code>
   
 
*Start Apache
 
*Start Apache
 
**<code>/etc/init.d/httpd start</code>
 
**<code>/etc/init.d/httpd start</code>
  +
  +
*Go to <code>http://servername/cacti/</code></code> & go through the following screens
  +
   
 
==Verify Install==
 
==Verify Install==

Revision as of 02:00, 21 April 2010


This page summarizes how to perform a basic installation of Cacti on CentOS 5. This tutorial assumes you are either logged in as root or have sudo.

Install

Add RPMForge Yum Repository

Install & Configure Prerequisites

  • Install Apache
    • yum install httpd
  • Configure Apache to start on boot
    • /sbin/chkconfig --levels 345 httpd on
  • Configure iptables to allow Apache traffic
    • /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
    • /etc/init.d/iptables save
    • /etc/init.d/iptables restart

Install & Configure Cacti and MySQL

  • Install Cacti & Required Dependencies
    • yum install cacti mysql-server liberation-fonts
  • Configure mysqld to start on boot
    • /sbin/chkconfig --levels 345 mysqld on
  • Start mysqld
    • /etc/init.d/mysqld start
  • Set the password for the MySQL root user
    • /usr/bin/mysqladmin -u root password 'PASSWORD-GOES-HERE'
  • Create the MySQL cacti database (Note: The password you will be prompted for is the one you just set.)
    • /usr/bin/mysqladmin -u root -p create cacti
  • Log into the MySQL database and grant the cactiuser access to the cacti database
    • /usr/bin/mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 46
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'CACTIUSER-PASSWORD-GOES-HERE';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
  • Populate cacti database (Note: You will use the password you created for cactiuser here)
    • /usr/bin/mysql cacti -u cactiuser -p < /var/www/cacti/cacti.sql
  • Modify /var/www/cacti/include/config.php to have correct password for the cacti database
$database_password = "CACTIUSER-PASSWORD-GOES-HERE";
  • Modify root's crontab to update Cacti every five minutes
    • crontab -e
# Used to update Cacti
*/5 * * * * /usr/bin/php /var/www/cacti/poller.php >> /var/log/cacti 2>&1
  • Modified /etc/httpd/conf.d/cacti.conf to fix url and allow access from anywhere
Alias /cacti /var/www/cacti/
<Directory /var/www/cacti/>
    DirectoryIndex index.php
    Options -Indexes
    AllowOverride all
    AddType application/x-httpd-php .php
    php_flag magic_quotes_gpc on
    php_flag track_vars on
</Directory>
  • Start Apache
    • /etc/init.d/httpd start


Verify Install

  • Try logging into your new Cacti installation by going to http://servername/cacti/ and logging in with admin and the password you set.