Bài viết này hướng đẫn cách cài đặt cacti lên centos 6 chỉ với 1 cú enter.
Bắt đầu thôi
1. Chuẩn bị server
Server: Centos 6.x bản 64bit
Ram: 512mb trở lên
HDD: 8GB trở lên.
Note: script cài được cho bản 32 bit, tuy nhiên 1 số plugin 32 bit hiện không tìm thấy nữa :) nên nếu sử dụng 32bit thì chấp nhận thiếu hụt vài tính năng.
2. Cài đặt.
Tạo file /root/cacti_install.sh với nội dung sau:
# !/bin/sh
# Author: sanbangtatca022015@gmail.com
# Script for install cacti 0.8.8c, spine 0.8.8c and various plugins on Centos Linux Release 6.x
# Version : 1.2
# Date : 24-4-2015
# Tam thoi tat firewall
chkconfig iptables off
service iptables stop
# Tat SELINUX
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
/usr/sbin/setenforce 0
# Update Server
yum update -y
yum install -y wget
mkdir -p /usr/src/cacti
cd /usr/src/cacti
# Cai dat apache & Mysql
yum install -y httpd
chkconfig httpd on
service httpd start
yum install -y mysql-server
chkconfig mysqld on
service mysqld start
mysqladmin -u root password fn@1314
yum install -y php php-gd php-mysql php-cli php-ldap php-snmp php-mbstring php-mcrypt
service httpd restart
# Cai dat rrdtool & snmp
yum install -y rrdtool perl-rrdtool
yum install -y net-snmp-utils
yum install -y tftp-server
chkconfig xinetd on
service xinetd start
# Download va cai dat cacti
wget http://www.cacti.net/downloads/cacti-0.8.8c.tar.gz
tar zxvf cacti-0.8.8c.tar.gz
# Neu phien ban cacti dinh cai co then ban va loi thi tai ve va patch.
# wget http://www.cacti.net/downloads/patches/0.8.8a/snmpv3_priv_proto_none.patch
#cd cacti-0.8.8a
yum install -y patch
#patch -p1 -N < ../snmpv3_priv_proto_none.patch
#cd ..
mkdir /var/www/html/cacti/
mv -f cacti-0.8.8c/* /var/www/html/cacti
rm -rf cacti-0.8.8c
chown -R apache:apache /var/www/html/cacti
service httpd restart
mysql -u root -pfn@1314 -e 'CREATE DATABASE `cacti` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;'
mysql -u root -pfn@1314 -e "CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';"
mysql -u root -pfn@1314 -e 'GRANT ALL PRIVILEGES ON `cacti` . * TO 'cactiuser'@'localhost';'
mysql -u cactiuser -pcactiuser cacti < /var/www/html/cacti/cacti.sql
cat > /etc/cron.d/cacti <<EOF
*/5 * * * * apache /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
EOF
# cai dat trinh bien dich ma nguon C++ & cai dat Spine
yum install -y gcc gcc-c++ make automake patch libtool net-snmp-devel openssl-devel mysql mysql-devel rsyslog-mysql
wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8c.tar.gz
tar zxvf cacti-spine-0.8.8c.tar.gz
cd cacti-spine-0.8.8c
./configure
make && make install
cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
cd /usr/src/cacti
#------------------------------------------------------#
# cai dat plugins
wget http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz -O settings.tgz
tar zxvf settings*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/settings
wget http://docs.cacti.net/_media/plugin:clog-v1.7-1.tgz -O clog.tgz
tar zxvf clog*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/clog
wget http://docs.cacti.net/_media/plugin:thold-v0.4.9-3.tgz -O thold.tgz
tar zxvf thold*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/thold
wget http://docs.cacti.net/_media/plugin:monitor-v1.3-1.tgz -O monitor.tgz
tar zxvf monitor*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/monitor
wget http://docs.cacti.net/_media/plugin:realtime-v0.5-2.tgz -O realtime.tgz
tar zxvf realtime*.tgz -C /var/www/html/cacti/plugins
mkdir -p /var/www/html/cacti/plugins/realtime/cache
chown -R apache:apache /var/www/html/cacti/plugins/realtime
yum install -y unzip
wget http://www.network-weathermap.com/files/php-weathermap-0.97a.zip
unzip php-weathermap-0.97a.zip -d /var/www/html/cacti/plugins/
chown -R apache:apache /var/www/html/cacti/plugins/weathermap
wget http://docs.cacti.net/_media/plugin:mactrack-v2.9-1.tgz -O mactrack.tgz
tar zxvf mactrack*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/mactrack
wget http://docs.cacti.net/_media/plugin:syslog-v1.22-2.tgz -O syslog.tgz
tar zxvf syslog*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/syslog
wget http://docs.cacti.net/_media/plugin:routerconfigs-v0.3-1.tgz -O routerconfigs.tgz
tar zxvf routerconfigs*.tgz -C /var/www/html/cacti/plugins
mkdir -p /var/www/html/cacti/plugins/routerconfigs/backups
chown -R apache:apache /var/www/html/cacti/plugins/routerconfigs
wget http://docs.cacti.net/_media/plugin:docs-v0.4-1.tgz -O docs.tgz
tar zxvf docs*.tgz -C /var/www/html/cacti/plugins
mv -f /var/www/html/plugins/docs* /var/www/html/cacti/plugins/docs
chown -R apache:apache /var/www/html/cacti/plugins/docs
wget http://nchc.dl.sourceforge.net/project/cacti-reportit/cacti-reportit/reportit_v073/reportit_v073.tar.gz -O reportit.tar.gz
tar zxvf reportit*.tar.gz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/reportit
wget http://docs.cacti.net/_media/plugin:rrdclean-v0.41.tgz -O rrdclean.tgz
tar zxvf rrdclean*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/rrdclean
wget http://docs.cacti.net/_media/plugin:discovery-v1.5-1.tgz -O discovery.tgz
tar zxvf discovery*.tgz -C /var/www/html/cacti/plugins
chown -R apache:apache /var/www/html/cacti/plugins/discovery
if [ "$HOSTTYPE" == "x86_64" ]; then
wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/wmi-1.3.14-2.el6.art.x86_64.rpm
rpm -Uvh wmi-1.3.14-2.el6.art.x86_64.rpm
elif [ "$HOSTTYPE" == "i386" ]; then
wget http://www6.atomicorp.com/channels/atomic/centos/6/i386/RPMS/wmi-1.3.14-2.el6.art.i686.rpm
rpm -Uvh wmi-1.3.14-2.el6.art.i686.rpm
fi
wget https://github.com/neclimdul/CactiWMI/blob/master/wmi.php -O /var/www/html/cacti/scripts/wmi.php
chown -R apache:apache /var/www/html/cacti/scripts/wmi.php
service httpd restart
Cuối cùng chạy lệnh:
# sh cacti_install.sh Pha 1 tách cafe rồi ngồi đợi thôi :)3. Cấu hình cacti:
Sau khi cài đặt xong, truy cập vào địa chỉ : http://IP_server/cacti Tài khoản mặc định: admin password admin Bấm Ok để lưu cấu hình.
Vào setting/poller
Chọn poller là spin rồi ấn save
Vậy là xong
Các bước add host vào cacti các bạn tự google nhé :)
Không có nhận xét nào:
Đăng nhận xét