Cacti installation in a Linux environment:

Source: Internet
Author: User
Tags deprecated php language rrd rrdtool snmp

This is a learning process notes, if there are most similarities, then you and I must be classmates, just do not know it!

Cacti Overview

Cacti is a software implemented using the PHP language, the main function is to use the SNMP service to obtain relevant data, and then use RRDtool to store and update data when necessary with RRDtool to generate icons for users to view relevant data, so, SNMP and RRDtool is the key to cacti. SNMP is related to the collection of data, Rrtdool is related to the storage of data and the generation of graphs.

MySQL with PHP program used to store some variable data and call the variable data, such as host name, host IP,SNMP community name, port number, template information and other variables. SNMP is not stored in MySQL after fetching the data, but is stored in the RRD file generated by Rrtdool (under the Rra folder in the cacti root directory). RRDtool Update and storage of data is the processing of the RRD file. The RRD file is a fixed-size file (Round Robin Archive), and the amount of data that can be stored is defined at the time of creation.

Is the cacti architecture:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7F/CE/wKioL1ct8RLz7OF0AABszGTO_wI529.png "title=" 1.png " alt= "Wkiol1ct8rlz7of0aabszgto_wi529.png"/>

is the cacti mode of operation:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7F/CE/wKioL1ct8TCSfab5AAB6BQ6sYtw536.png "title=" 2.png " alt= "Wkiol1ct8tcsfab5aab6bq6sytw536.png"/>

Deployment of cacti:

because cacti relies on the LNMP environment, the LNMP environment needs to be built first before deploying cacti.

First we install mysql,apache,php and related plugins with the Yum installation:

Yum install-y httpd php php-mysql mysql mysql-server mysql-devel php-gd libjpeg libjpeg-devel libpng libpng-devel

     start HTTP, as follows:

[[Email protected] ~]# /etc/init.d/httpd startstarting httpd: httpd: could  not reliably determine the server ' S fully qualified domain name,  using 211.98.71.195 for ServerName                                                              [  OK   ]/start HTTP When the above problems occur, the solution is as follows:                                                [[email  Protected] ~]# vim /etc/httpd/conf/httpd.conf     /Open this file and change the #servername   to   servername localhost:80                                                           then reboot:   [[email protected] ~]# /etc/init.d/ httpd restartstopping httpd:                                              [  OK   ]Starting httpd:                                              [  OK  ]

     start MySQL: The following

[[Email protected] ~]# /etc/init.d/mysqld startinitializing mysql database:   installing mysql system tables ... 160508  3:37:29 [warning]  '--skip-locking '  is deprecated and will  be removed in a future release. Please use  '-- Skip-external-locking '  instead. Okfilling help tables ... 160508  3:37:29 [warning]  '--skip-locking '  is deprecated and will  be removed in a future release. Please use  '-- Skip-external-locking '  instead. okto start mysqld at boot time you have to copysupport-files/ Mysql.server to the right place for your systemplease remember to  set a password for the mysql root user ! To do so, start&nbSp;the server, then issue the following commands:/usr/bin/mysqladmin -u  root password  ' New-password '/usr/bin/mysqladmin -u root -h lvs  password  ' New-password ' Alternatively you can run:/usr/bin/mysql_secure_installationwhich  will also give you the option of removing the testdatabases  and anonymous user created by default.  This isstrongly  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.plcd  /usr/mysql-test ; perl mysql-test-run.plplease report any problems with  the /usr/bin/mysqlbug script!                                                              [  OK  ]Starting mysqld:                                              [  OK  ]

     install cacti and its required plugins: (We're deploying a master monitor here, and we don't have a client for the time being)

[[email protected] ~]#  yum install -y cacti  net-snmp   net-snmp-utils  rrdtool net-snmp-devel net-snmp-libs lm-sensors php-xml  zlib libpng freetype cairo-devel pango-devel gd[[email protected] ~]#  /etc/init.d/snmpd start           / Start the SNMP service starting snmpd:                                              [  ok  ][[ email protected] ~]# mysql -u root                 /mysql database Welcome to the mysql monitor.   commands end with&nbSP;;  or \g.your mysql connection id is 2server version: 5.1.73-log  Source distributionCopyright  (c)  2000, 2013, Oracle and/or its  Affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql> create database cacti;                   /Create cacti Database! mysql> grant all on cacti.* to  ' cactiuser ' @ ' localhost '  identified  by  ' Cactiuser ';   /creates a user and authorizes the user. query ok, 0 rows affected (0.00 sec) mysql> use cacti;                     /Select Cacti Database database changedmysql>  source /usr/share/doc/cacti-0.8.8b/cacti.sql;    /Importing SQL Files query ok, 0  rows affected  (0.01 sec) query ok, 1 row affected  (0.00 sec) Query  OK, 1 row affected  (0.00 sec) query ok, 1 row affected  (0.00 SEC) query ok, 1 row affected  (0.00 sec) query ok, 1 row affected   (0.00 SEC) query ok, 1 row affected  (0.00 sec) Query OK, 0  rows affected  (0.04 sec) query ok, 1 row affected  (0.00 sec) query ok, 1 row affected  (0.01 sec) query ok, 1 row affected   (0.00 SEC) query ok, 1 row affected  (0.00 sec) Query ok, 1 row  affected  (0.00 sec) mysql> flush privileges; query ok, 0 rows affected  (0.00 sec) mysql> quit; Bye

    Edit cacti configuration file:

[[email protected] ~]# vim /usr/share/cacti/include/config.php $database _type =  "MySQL"; $database _default =  "cacti"; $database _hostname =  " localhost "; $database _username = " Cactiuser ";       /name and password when authorized in the database $ database_password =  "Cactiuser"; $database _port =  "3306"; $database _ssl = false; [[email protected] ~]# vim /etc/httpd/conf.d/cacti.confdeny from all  revision changed to  Allow from all [[email protected] ~]# /etc/init.d/httpd  restartstopping httpd:                                              [  OK  ] Starting httpd:                                             [   OK  ]

Then is the Web Access, in the browser input http://ip/cacti! in the browser access, there will always be the following problems

Fatal:cannot Connect to MySQL server on ' localhost '. Please make sure the specified a valid MySQL database name in ' include/config.php '

It was always felt that the database authorization problem, and then all kinds of detection is not error, later a command resolved the following:

Ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock

After normal, the following interface will appear in the browser input http://ip/cacti:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/CF/wKioL1ct-grBAGSJAAA_sFH8dro593.png "title=" 1.png " alt= "Wkiol1ct-grbagsjaaa_sfh8dro593.png"/>

This step directly next, then the following interface will appear:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7F/CF/wKioL1ct-irypAmaAAAZuSVowHs625.png "title=" 2.png " alt= "Wkiol1ct-irypamaaaazusvowhs625.png"/>

Since we are installing for the first time, select the new installation, then next: The following interface appears:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7F/CF/wKioL1ct-paRQxb8AAF0xj-M20U189.png "title=" 3.png " alt= "Wkiol1ct-parqxb8aaf0xj-m20u189.png"/>

This step we see the location of various files, if all display found, you can click on the finish, if you can find the appropriate location, is generally the default! Next:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/D1/wKiom1ct-hHzsnX4AABlW87YbDc330.png "title=" 4.png " alt= "Wkiom1ct-hhzsnx4aablw87ybdc330.png"/>

Enter the account number and password, both admin, default, and then the next step will force the password change:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/D1/wKiom1ct-myAYh_1AABm1cmJWQ8730.png "title=" 5.png " alt= "Wkiom1ct-myayh_1aabm1cmjwq8730.png"/>

Click Save, then go to Next: 650) this.width=650; "Src=" http://s1.51cto.com/wyfs02/M01/7F/CF/ Wkiol1ct-2tr2f3oaacme7hebh0969.png "title=" 6.png "alt=" Wkiol1ct-2tr2f3oaacme7hebh0969.png "/>

Click Settings----Path on the left to open the console, such as:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/CF/wKioL1ct-9_wOWM2AADuerba49s316.png "title=" 7.png " alt= "Wkiol1ct-9_wowm2aaduerba49s316.png"/> Click Graps into the Monitoring system interface, and found no graphics such as:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7F/CF/wKioL1ct_CqiPdqxAACrdVlFmk8321.png "title=" 8.png " alt= "Wkiol1ct_cqipdqxaacrdvlfmk8321.png"/> This time we run the following command to generate the graph:

[[email protected] ~]# /usr/bin/php /usr/share/cacti/poller.phpphp warning:   strtotime ():  it is not safe to rely on the system ' s  timezone settings. you are *required* to use the date.timezone  Setting or the date_default_timezone_set ()  function. in case you used  any of those methods and you are still getting this  warning, you most likely misspelled the timezone identifier. we  selected  ' asia/chongqing '  for  ' cst/8.0/no dst '  instead in /usr/share/cacti/ Include/global_constants.php on line 165php warning:  date ():  It is  not safe to rely on the system ' S timezone settings. you  are *required*&nbsP;to use the date.timezone setting or the date_default_timezone_set ()   Function. in case you used any of those methods and you  are still getting this warning, you most likely misspelled  the timezone identifier. we selected  ' asia/chongqing '  for  ' CST/8.0/no  DST '  instead in /usr/share/cacti/include/global_constants.php on line 165tifier.  We selected  ' asia/chongqing '  for  ' cst/8.0/no dst '  instead in / usr/share/cacti/include/global_constants.php on line 166 /process is long, at the end we can check the command return value! [[email protected] ~]# echo $?0                           /returns the number "0" Instructions, the command runs with the correct results

When you look at the monitoring image, you will find such as:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/D1/wKiom1ct_CDTbjzhAAFe8jPFsBg750.png "title=" 9.png " alt= "Wkiom1ct_cdtbjzhaafe8jpfsbg750.png"/>

You will find that the coordinates have appeared, but there are no images; the command we just ran, write the scheduled task:

[[email protected] ~]# Crontab-eno crontab for root-using an empty onecrontab:installing new Crontab[[email protected] ~]# CRONTAB-L*/5 * * * */usr/bin/php/usr/share/cacti/poller.php >/dev/null 2>&1

After a while, you will find that the graphic appears as follows: Because the load of your simulator is not very high, this period of time will be quite long!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/D1/wKiom1ct_NbTpY8SAAFvXxVD7Ag574.png "title=" 32.png "alt=" Wkiom1ct_nbtpy8saafvxxvd7ag574.png "/>

So far we have completed the cacti monitoring! For cacti application and cacti how to add monitoring client, will continue to update in the subsequent blog post!

This article is from "Custom" blog, declined reprint!

Cacti installation in a Linux environment:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.