Wednesday, October 18, 2017

.::: Install Cacti 1.0.x on Centos 7/Rhel 7 Using MariaDB :::.

Cacti is a complete frontend to RRDTool, it stores all of the necessary information to create graphs and populate them with data in a MySQL database. The frontend is completely PHP driven. Along with being able to maintain Graphs, Data Sources, and Round Robin Archives in a database, cacti handles the data gathering. There is also SNMP support for those used to creating traffic graphs with MRTG.

UPDATE:
Since new release is out, I added the procedures for upgrading cacti 1.0.1 to 1.0.x; and from 1.0.x to 1.1.x
1. Disable SELinux
[root@TeguhLab data]# cat /etc/selinux/config | grep SELINUX
# SELINUX= can take one of these three values:
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
SELINUXTYPE=targeted
[root@TeguhLab data]#

2. Disable Firewall
[root@TeguhLab data]# systemctl disable firewalld.service
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
[root@TeguhLab data]# systemctl stop firewalld.service
[root@TeguhLab data]# systemctl status firewalld.service
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled)
   Active: inactive (dead)

Oct 12 14:34:50 TeguhLab systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 12 14:34:54 TeguhLab systemd[1]: Started firewalld - dynamic firewall daemon.
Oct 12 14:33:05 TeguhLab systemd[1]: Stopping firewalld - dynamic firewall daemon...
Oct 12 14:33:06 TeguhLab systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@TeguhLab data]#

3. Configure hosts
[root@TeguhLab data]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.10 TeguhLab
[root@TeguhLab data]#

4. Install Package patch & wget
# yum -y install wget mlocate

5. Install package cacti & snmp
# yum -y install net-snmp netsnmp-devel net-snmp-utils mariadb mariadb-devel gcc help2man rrdtools php php-snmp php-process php-mysql php-pdo php-ldap php-mbstring php-xml git rrdtool

6. Configure date.timezone on php
[root@TeguhLab data]# cat /etc/php.ini | grep date.time
; http://php.net/date.timezone
;date.timezone =Asia/Jakarta
[root@TeguhLab data]#

7. Download the sources, change
# wget http://www.cacti.net/downloads/cacti-1.0.1.tar.gz

[root@TeguhLab data]# wget http://www.cacti.net/downloads/cacti-1.0.1.tar.gz
--2017-10-12 16:02:20--  http://www.cacti.net/downloads/cacti-1.0.1.tar.gz
Resolving www.cacti.net (www.cacti.net)... 104.28.9.127, 104.28.8.127, 2400:cb00:2048:1::681c:87f, ...
Connecting to www.cacti.net (www.cacti.net)|104.28.9.127|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.cacti.net/downloads/cacti-1.0.1.tar.gz [following]
--2017-10-12 16:02:20--  https://www.cacti.net/downloads/cacti-1.0.1.tar.gz
Connecting to www.cacti.net (www.cacti.net)|104.28.9.127|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7230227 (6.9M) [application/x-gzip]
Saving to: ‘cacti-1.0.1.tar.gz’

100%[===================================================================================>] 7,230,227    253KB/s   in 18s   

2017-10-12 16:02:40 (390 KB/s) - ‘cacti-1.0.1.tar.gz’ saved [7230227/7230227]

[root@TeguhLab data]# ls
cacti-1.0.1.tar.gz
[root@TeguhLab data]# cp cacti-1.0.1.tar.gz /var/www/
[root@TeguhLab data]# cd /var/www/
[root@TeguhLab www]# ls
cacti-1.0.1.tar.gz  cgi-bin  html
[root@TeguhLab www]# tar -xvf cacti-1.0.1.tar.gz
[root@TeguhLab www]# ls
cacti-1.0.1  cacti-1.0.1.tar.gz  cgi-bin  html
[root@TeguhLab www]# mv cacti-1.0.1 cacti
[root@TeguhLab www]# ls
cacti  cacti-1.0.1.tar.gz  cgi-bin  html
[root@TeguhLab www]#


8. Change permission folder cacti
# chown -R apache:apache /var/www/cacti

[root@TeguhLab data]# chown -R apache:apache /var/www/cacti
[root@TeguhLab data]#

9. Install Database & configuration database
http://teguhth.blogspot.co.id/2017/10/install-mariadb-101-on-centosrhel-using.html
create user 'cactiuser' identified by 'cactipwd';
create database cacti;
grant all privileges on cacti.* to 'cactiuser'@'%' identified by 'cactipwd' with grant option;
FLUSH PRIVILEGES;

create user 'cactiuser' identified by 'cactipwd';
create database cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipwd';
FLUSH PRIVILEGES;

10. Configuration mysql_tzinfo_to_sql  /usr/share/zoneinfo | mysql -p mysql
# mysql_tzinfo_to_sql  /usr/share/zoneinfo | mysql -p mysql

[root@TeguhLab ~]# mysql_tzinfo_to_sql  /usr/share/zoneinfo | mysql -p mysql
Enter password:
[root@TeguhLab ~]#

11. Konfigurasi snmpd
# systemctl enable snmpd.service
# systemctl start snmpd.service
# systemctl status snmpd.service

[root@TeguhLab www]# systemctl enable snmpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.
[root@TeguhLab www]# systemctl start snmpd.service
[root@TeguhLab www]# systemctl status snmpd.service
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
   Loaded: loaded (/usr/lib/systemd/system/snmpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-10-12 16:07:33 WIB; 11s ago
 Main PID: 1603 (snmpd)
   CGroup: /system.slice/snmpd.service
           └─1603 /usr/sbin/snmpd -LS0-6d -f

Oct 12 16:07:33 TeguhLab systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
Oct 12 16:07:33 TeguhLab snmpd[1603]: NET-SNMP version 5.7.2
Oct 12 16:07:33 TeguhLab systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon..
[root@TeguhLab www]#

12. Konfigurasi database Cacti
[root@TeguhLab www]# mysql -u cactiuser -p cacti < /var/www/cacti/cacti.sql
Enter password:
[root@TeguhLab www]#

13. Konfigurasi Cacti
# cat /var/www/cacti/include/config.php | grep database

[root@TeguhLab www]# cat /var/www/cacti/include/config.php | grep database
/* make sure these values reflect your actual database/host/user/password */
$database_type     = 'mysql';
$database_default  = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactipwd';
$database_port     = '3306';
$database_ssl      = false;
#$rdatabase_type     = 'mysql';
#$rdatabase_default  = 'cacti';
#$rdatabase_hostname = 'localhost';
#$rdatabase_username = 'cactiuser';
#$rdatabase_password = 'cactiuser';
#$rdatabase_port     = '3306';
#$rdatabase_ssl      = false;
/* save sessions to a database for load balancing */
[root@TeguhLab www]#

14. Konfigurasi httpd
# cat /etc/httpd/conf.d/cacti.conf
# cat /etc/httpd/conf/httpd.conf | grep ServerName

[root@TeguhLab www]#  cat /etc/httpd/conf.d/cacti.conf
Alias /cacti/ /var/www/cacti/
<Directory /var/www/cacti/>
    DirectoryIndex index.php
    Options -Indexes
    AllowOverride all
    order deny,allow
    deny from all
    allow from all
    AddType application/x-httpd-php .php
    php_flag magic_quotes_gpc on
    php_flag track_vars on
</Directory>
[root@TeguhLab www]#
[root@TeguhLab www]# cat /etc/httpd/conf/httpd.conf | grep ServerName
# ServerName gives the name and port that the server uses to identify itself.
#ServerName www.example.com:80
ServerName 127.0.0.1:80
[root@TeguhLab www]#

15. Konfigurasi cronjob untuk Cacti
[root@TeguhLab www]# cat /etc/cron.d/cacti
#*/5 * * * *    cacti    php /var/www/cacti/poller.php &>/dev/null
*/5 * * * * cacti /usr/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
[root@TeguhLab www]#

16. Start httpd
# systemctl enable httpd.service 
# systemctl restart httpd.service  
# systemctl status httpd.service

[root@TeguhLab www]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@TeguhLab www]# systemctl restart httpd.service
[root@TeguhLab www]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-10-12 16:16:14 WIB; 6s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 1964 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─1964 /usr/sbin/httpd -DFOREGROUND
           ├─1986 /usr/sbin/httpd -DFOREGROUND
           ├─1987 /usr/sbin/httpd -DFOREGROUND
           ├─1988 /usr/sbin/httpd -DFOREGROUND
           ├─1989 /usr/sbin/httpd -DFOREGROUND
           └─1990 /usr/sbin/httpd -DFOREGROUND

Oct 12 16:16:14 TeguhLab systemd[1]: Starting The Apache HTTP Server...
Oct 12 16:16:14 TeguhLab systemd[1]: Started The Apache HTTP Server.
[root@TeguhLab www]#

17. Running cacti.
Open browser and type using url
http://IP_cacti/cacti/
example
http://10.10.10.10/cacti/

if you fresh install or upgrade. firts run as below then next next, choose fresh install or upgrade
http://IP_cacti/cacti/install/
example
http://10.10.10.10/cacti/install/

tutotial http://logch.blogspot.co.id/2017/02/install-cacti-spine-in-centos-7-with.html?m=1

No comments:

Post a Comment

Popular Posts