tech note

インフラ技術や車についてつぶやいていくブログ

Cacti 簡単インストール手順

f:id:tea_cat:20180911024324j:plain
一個前のVersion 0.8.8hを以下に簡単にすばやくインストール出来るかに特化したものです
OSはCentOS6(64bit)系です。

レポジトリインストール

rpm -ivh http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm
rpm -ivh http://repo.mysql.com//mysql57-community-release-el6-9.noarch.rpm

yum -y install epel-release
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

cat <<'EOF' >|/etc/yum.repos.d/dag.repo
[dag]
name=Dag
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag/
enabled=0
gpgcheck=0
gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
EOF

Cacti インストール

v0.8.8h

wget http://koozali.groenz.co.nz/releases/9/smecontribs/x86_64/RPMS/cacti-0.8.8h-1.el6.noarch.rpm
yum install mysql-server httpd mod_ssl php-xml dejavu-fonts-common dejavu-lgc-sans-mono-fonts dejavu-sans-mono-fonts fontpackages-filesystem php php-cli php-ldap php-mbstring php-mysqlnd php-pdo php-pecl-mysql php-snmp rrdtool --enablerepo=epel,remi,remi-php56
yum install cacti-0.8.8h-1.el6.noarch.rpm
yum install php-gmp php-gd php-posix --enablerepo=epel,remi,remi-php56
yum install --enablerepo=dag cacti-spine

v1.xなら

yum install cacti mysql-server httpd mod_ssl php-xml --enablerepo=epel,remi,remi-php70 -y
yum install php-gmp php-gd php-posix --enablerepo=epel,remi,remi-php70 -y
yum install --enablerepo=dag cacti-spine -y

mysql起動

/etc/init.d/mysqld start
chkconfig mysqld on
grep "password is generated" /var/log/mysqld.log
mysql_secure_installation
Y
mysql -p
SHOW VARIABLES LIKE 'validate_password%';
uninstall plugin validate_password;
set password for root@localhost = '';
SHOW VARIABLES LIKE 'validate_password%';
\q

cp -ip /etc/my.cnf /etc/.backup/my.cnf
echo 'sql-mode="NO_ENGINE_SUBSTITUTION"' >> /etc/my.cnf
echo 'loose-log_timestamps= SYSTEM' >> /etc/my.cnf
echo 'innodb_buffer_pool_size = 4G' >> /etc/my.cnf
echo 'character-set-server=utf8' >> /etc/my.cnf
/etc/init.d/mysqld restart

cacti準備

cd /usr/share/doc/cacti-0.8.8h/
sed -i 's/MyISAM/InnoDB/g' cacti.sql
mysql -uroot -e "CREATE DATABASE cacti;"
mysql -uroot -e "GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser';"
mysql -uroot -e "FLUSH PRIVILEGES;"
mysql -ucactiuser -pcactiuser cacti < cacti.sql

sed -i 's/^#\(.*\)/\1/g' /etc/cron.d/cacti
sed -i -e 's/\sAllow from localhost/        Allow from all/g' /etc/httpd/conf.d/cacti.conf
sed -i -e 's|;date.timezone =|date.timezone = "Asia/Tokyo"|g' /etc/php.ini

mkdir /var/log/cacti/
chown cacti. /var/log/cacti/
touch /var/log/cacti/cacti.log
chown cacti:apache /var/log/cacti/cacti.log

Apache起動準備

vi /etc/hosts
hogehoge.net

echo "ServerName `hostname`" >| /etc/httpd/conf.d/servername.conf

書き換え
<     Options Indexes FollowSymLinks
---
>     Options -Indexes FollowSymLinks

Apache起動

/etc/init.d/httpd start
chkconfig httpd on

必要ならば

cd /var/lib/cacti/rra/
chown cacti. *

cronを1分間隔へ

vi /etc/cron.d/cacti
*/1 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

spineのパス

/usr/bin/spine

/var/log/cacti/cacti.log