Monday, May 31, 2010

Cacti Setup Guide on Mac OS X

1) Install PHP and MySQL 5 (not covered).  These instructions assume MySQL 5 was installed from MacPorts.

Check to make sure the PHP variable "mysql.default_socket" is set to path
   /opt/local/var/run/mysql5/mysqld.sock by viewing the output of this terminal command:
# php -i

If not, locate the php.ini file for your version of PHP and type the path there.

2) Set Cacti permissions.
# sudo chown -R : /opt/local/share/cacti/
3) Setup MySQL and prepare it for Cacti. Configure MySQL (new MySQL installs)
# sudo -u mysql /opt/local/lib/mysql5/bin/mysql_install_db
###########################################################
# A startup item has been generated that will aid in
# starting mysql5-server with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
###########################################################
--->  Installing mysql5-server @5.1.45_0
******************************************************
* In order to setup the database, you might want to run
* sudo -u _mysql mysql_install_db5
* if this is a new install
******************************************************

$ sudo -u _mysql mysql_install_db5
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:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h MacBook.local password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql5/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 /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

Start MySQL:
# sudo /opt/local/share/mysql5/mysql/mysql.server start

Set MySQL to start at system boot (optional)
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Set a root MySQL password. Follow the instructions that were given after you executed 'mysql_install_db' above.

Create a cacti MySQL user and cacti database.
# mysql5 -u root -p (login with new root password when prompted)
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on cacti.* to cacti@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on cacti.* to cacti;
mysql> SET PASSWORD FOR cacti@localhost = OLD_PASSWORD('');
mysql> create database cacti;
mysql> exit;

Import the cacti database.
# sudo cat /opt/local/share/cacti/cacti.sql | mysql5 -u root -p cacti (cacti is the db name)

Verify the Cacti Database.
#mysql5 -u root -p
mysql> use cacti;
mysql> show tables;
mysql> exit;
4) Edit /opt/local/share/cacti/include/config.php to match your MySQL information.

        $database_type = "mysql";
        $database_default = "cacti";
        $database_hostname = "localhost";
        $database_username = "cacti";
        $database_password = "";

5) Place a symlink for Cacti inside your Apache document root.
# ln -s /opt/local/share/cacti  /cacti
6) Edit the Cacti user's crontab file.
# sudo -u crontab -e

  Insert the crontab entry below:
        */5 * * * * /opt/local/bin/php /opt/local/share/cacti/poller.php > /dev/null 2>&1


8) If you installed Cacti with the 'plugins' variant for Cacti Plugin Architecture support, you must perform these additional steps.

   a) Import the PA schema.
        # cd /opt/local/share/cacti
        # sudo cat /opt/local/share/cacti/pa.sql | mysql5 -u root -p cacti (cacti is the db name)

   b) Download the particular Cacti plugin(s) you want and copy their folders to /opt/local/share/cacti/plugins//.
      For example:
        /opt/local/share/cacti/plugins/weathermap/

   c) Edit /opt/local/share/cacti/include/global.php - modify the url_path to reflect Cacti's default URL
      and add an entry to load each plugin you install; the weathermap plugin is an example:

        $config['url_path'] = '/cacti/';

        $plugins = array();
        $plugins = 'weathermap';

   d) Enable the plugin in the Cacti web interface; this creates a top-level tab for the plugin in the Cacti interface
        Console -> User Management  (select a Cacti user and check the 'View Weathermaps' checkboxes)

7) Go to http://localhost/cacti/install/index.php.
        The default user/password is admin/admin.  Select 'New Install', enter
        the paths for SNMP / RRDtool / PHP (see below), and click 'Finish'.
        You may now use Cacti at http://localhost/cacti/index.php.

Paths:
        snmpwalk binary path: /usr/bin/snmpwalk
        snmpget binary path: /usr/bin/snmpget

        RRDtool binary path: /opt/local/bin/rrdtool
        PHP binary path: /opt/local/bin/php (if not using MacPorts PHP, use appropriate path)

No comments:

Post a Comment

Hi, for all of those who already put comments on my blog post, thanks.. really appreciate it. And for those who have not, just put your comments here :)