Installing Cacti on CentOS with yum

I’ve been wanting to try the Cacti network graphing system for a while, but wasn’t sure how much effort it would take. Well, it wasn’t too bad, and here are the steps that I used. Hopefully this will save someone else a few minutes.I started with the CentOS 4.3 Server CD. I really like having a single CD that will install what’s necessary for a server. I use the .iso and VMWare Server, and can have a server installed from scratch in very little time. For this server, I chose to customize the list of packages. I unchecked Mail Server, Windows File Server, DNS Name Server, FTP Server, and Printing Support. I added System Tools. I’ll assume that you have your OS installed at this point.

Configure yum. Since I want to use yum as much as possible, and cacti is not in the default CentOS repositories, I added Dag to my list of repositories. This is as simple as creating the file /etc/yum.repos.d/Dag.repo and putting the following in it:

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1
protect=0

That last option (“protect=0″) only does anything if you’ve installed the ProtectBase plugin for yum. This plugin keeps yum from updating system or base packages from non-CentOS repositories (or however you want to configure it). You can read about it here.

Install prerequisites. Now we need to install the packages that Cacti depends on, and the Cacti package itself. Use yum, and allow it to install any dependencies for the following packages. Just running “yum install cacti” might have caught all of these too, but I didn’t try that.

shell# yum install net-snmp
shell# yum install mysql
shell# yum install mysql-server
shell# yum install cacti

Configure Apache. By default, the cacti.conf file in /etc/httpd/conf.d is set to deny access to everyone. I made a copy of the file for safekeeping and then edited cacti.conf to remove the line “deny from all”.

Start services. Now we need to start some services and set them to start whenever the machine starts up:

shell# service mysqld start
shell# service httpd start
shell# chkconfig –level 345 mysqld on
shell# chkconfig –level 345 httpd on

Configure mysql. Now your server is actually serving up Cacti documentation from http://servername/cacti/docs/html/index.html. These last steps are from the Installing under Unix page at http://servername/cacti/docs/html/install_unix.html.

shell# mysqladmin –user=root create cacti
shell# cd /var/www/cacti
shell# mysql cacti < cacti.sql
shell# mysql --user=root mysql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactiuser';
mysql> flush privileges;
mysql> exit
shell#

Schedule the poller. Add a line like the following to /etc/crontab to schedule the poller:

*/5 * * * * cacti php /var/www/cacti/poller.php > /dev/null 2>&1

Complete the installation. Browse to http://servername/cacti/index.php and follow the instructions to complete the installation. You should just need to click Next>, Next>, Finish.

Login and begin to use Cacti. Login as admin, password admin, and change the password as required. Now you’re ready to start using Cacti! After I gain some experience, I may post some tips.

18 thoughts on “Installing Cacti on CentOS with yum

  1. Bennett Haselton

    Great instructions, thanks!

    One thing: in the line where you wrote:
    chkconfig -level 345 mysqld on
    your blogging software evidently converted the regular ASCII “-” character into a high-order ASCII character 0x96, a “high-order ASCII dash”. This meant when I tried copying and pasting the command into my console window, it didn’t work. I don’t know if there’s a way to force the blogging software to publish it as a regular dash.

  2. Bennett Haselton

    Actually, I should have written:
    chkconfig –level 345 mysqld on

    That’s two regular ASCII dashes, not one, before the word “level”. Unfortunately a lot of word-processing systems will auto-convert this into the 0x96 character, which is probably what your blogging software did. It might do that when I post this comment too.

  3. Bennett Haselton

    Same thing happens with another command in the instructions:
    GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactiuser';

    Those should be regular single quotes around the words “cactiuser”, but your blog apparently converted them into those fancy curly-quotes (the same thing that Microsoft Word does).

  4. sepand

    i run */5 * * * * cacti php /var/www/cacti/poller.php > /dev/null 2>&1

    insted place it in cron fild and cacti stop showing updated graph what should i do. thanks

  5. karl.kranich Post author

    The only thing that I can suggest is that sometimes in the crontab you need to specify the full path to executables. Figure out where php resides and put in the full path instead of just “php”.

  6. sepand

    i understand that CentOS by self add the crontab and does not necessary to manually do the cron. if you do it just mess the system and it stop working.

  7. mustu

    hey! i did as written above. everything went fine but the index.php isn’t opening. i didn’t get any permission or any kind of error but just a blank page.. can u help me whats goign wrong?

  8. Pingback: Cacti Install on RHEL 5 or CentOS 5 « W dream

  9. Pingback: Installing Cacti on CentOS Linux 5.4 « Aaron Walrath – Another IT guy

  10. Jorge

    It installed perfectly, but i’m not able to get graphs. I have looked into the rra directory and there are no files. Can you please advice?

  11. karl.kranich Post author

    Sorry, but I haven’t been running cacti for a while — I’m not sure what to suggest.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>