* 환경

  - Ubuntu 16.04 LTS

  - Cacti 1.1.38.tar.gz



apt-get update

apt-get upgrade


## Mysql Server 설치

apt-get install mysql-server-5.7   (최신)


## php, apache2 설치

apt-get install php-xml php-ldap php-mbstring php-gd php-snmp php-gmp rrdtool snmp librrds-perl apache2


## Cacti 1.1.38 다운 (최신)

wget https://www.cacti.net/downloads/cacti-1.1.38.tar.gz

cacti-1.1.38.tar.gz


## cacti 압축 해제

tar zxvf cacti-1.1.38.tar.gz


mv cacti-1.1.38 /opt/cacti


## Log 경로 설정

mkdir /opt/logs

  touch /opt/logs/cacti.log

  touch /opt/logs/httpd_access.log

  touch /opt/logs/httpd_error.log

  chown -R www-data /opt/logs/*



## Mysql cacti DB 생성

mysqladmin --user=root --password create cacti

mysql --user root -p cacti < /opt/cacti/cacti.sql

 mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

 mysql --user root --password mysql


###Enter your mysql root password.
###This will enter you into the mysql console for mysql database.
###NOTE: ‘somepassword’ referenced here is the cacti user password and must be the same as used in cacti configuration in the next section

mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'somepassword';
mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'somepassword';

Exit



## cacti config 수정

vi /opt/cacti/include/config.php 


### Find these variables and make the following changes

$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = somepassword;
$database_port = '3306';
$database_ssl = false;
$url_path = '';




##  file permissions 설정

chown -R www-data:www-data /opt/cacti/resource/snmp_queries

  chown -R www-data:www-data /opt/cacti/resource/script_server

  chown -R www-data:www-data /opt/cacti/resource/script_queries

  chown -R www-data:www-data /opt/cacti/scripts

  chown -R www-data:www-data /opt/cacti/rra/ /opt/cacti/log/

  chown -R www-data:www-data /opt/cacti/cache/mibcache

  chown -R www-data:www-data /opt/cacti/cache/realtime

  chown -R www-data:www-data /opt/cacti/cache/spikekill




##   Apache config

touch /etc/apache2/sites-available/cacti.conf

  vi /etc/apache2/sites-available/cacti.conf 

<VirtualHost *:80>

    <Location />
       require all granted
   </Location>

   ServerAdmin webmaster@localhost
   DocumentRoot /opt/cacti
   ErrorLog /opt/logs/httpd_error.log
   CustomLog /opt/logs/httpd_access.log combined

</VirtualHost>


  rm /etc/apache2/sites-enabled/*

  a2ensite cacti.conf



##   crontab 등록

vi /etc/crontab

###Add line at bottom

*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1


##  MySQL my.cnf 튜닝

vi /etc/mysql/mysql.conf.d/mysqld.cnf ###Add following lines to the bottom of the configuration file: Max_heap_table_size = 256M Tmp_table_size = 64M Join_buffer_size = 64M Innodb_doublewrite = OFF Innodb_buffer_pool_size = 963M Innodb_flush_log_at_timeout = 3 Innodb_read_io_threads = 32 Innodb_write_io_threads = 16



/etc/init.d/apache2 restart

/etc/init.d/mysql restart



*****  여기까지 했지만 cacti server IP 접근을 해도 500 error 만 나오고 정상적으로 열리지 않았다.

온갖 구글링을 해서 php7.0 버전이 너무 높아 호환성 에러가 나는 것을 찾았다.

apt-get install libapache2-mod-php

apt-get install php-curl

apt-get install php-mysql


추가 설치 후 정상 접속 가능



##    cacti 접속 후 기본 setup

http://[cacti server IP address]

default account 

admin  //  admin





참고 url

https://www.blackhillsinfosec.com/how-to-install-cacti-on-ubuntu/

https://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=qna_function&wr_id=391359

https://github.com/spotweb/spotweb/issues/134

https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/setup-cacti-network-monitoring-tool-on-ubuntu-14-04-linux-mint-17.html





by 초보인척 2018. 5. 9. 15:17