** 환경

CentOS 7 x86_64

Cacti 1.1.38 


****   centos 7.0 부터 iptables 설정이 아주 이상해졌다.

아래 과정을 꼭 해주길 권장한다.

systemctl stop firewalld

systemctl disable firewalld

/etc/selinux  - disabled


/etc/iptables.sh  생성관리



###  apache 2.4 설치

# Install Apache 2.4

sudo yum install httpd -y

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

sudo systemctl start httpd.service

sudo systemctl enable httpd.service



###  MariaDB 10.2 설치

# Install MariaDB 10.2

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

sudo yum install MariaDB-server MariaDB-client -y

sudo systemctl start mariadb.service

sudo systemctl enable mariadb.service


###  MariDB root password 설정

# Secure MariaDB 10.2

sudo /usr/bin/mysql_secure_installation

# When prompted, answer questions as below:

# - Enter current password for root (enter for none): Just press the Enter button

# - Set root password? [Y/n]: Y

# - New password: your-MariaDB-root-password

# - Re-enter new password: your-MariaDB-root-password

# - Remove anonymous users? [Y/n]: Y

# - Disallow root login remotely? [Y/n]: Y

# - Remove test database and access to it? [Y/n]: Y

# - Reload privilege tables now? [Y/n]: Y


###  cacti database 생성

# Create a MariaDB database for Cacti

mysql -u root -p

# For security purposes, be sure to replace "cacti", "cactiuser", and "yourpassword" with your own ones. 

CREATE DATABASE cacti;

CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword';

GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

EXIT;



###   PHP7.1 설치

# Install required PHP 7.1 components for Cacti

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

sudo yum install -y mod_php71w php71w-process php71w-common php71w-pdo php71w-xml php71w-ldap php71w-mbstring php71w-gd php71w-snmp php71w-mysqlnd php71w-cli php71w-mcrypt php71w-opcache php71w-imap php71w-intl

sudo cp /etc/php.ini /etc/php.ini.bak

sudo sed -i 's#;date.timezone =#date.timezone = America/Los_Angeles#' /etc/php.ini



###  snmp 설치
 yum install -y net-snmp net-snmp-utils rrdtool
 systemctl start snmpd.service
 systemctl enable snmpd.service


###  CACTI 1.1.38 다운로드

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

cacti-1.1.38.tar.gz


tar zxvf cacti-1.1.38.tar.gz 

  mv /root/cacti-1.1.38 /opt/cacti


ln -s /opt/cacti-1.1.38 /var/www/html/cacti

touch /opt/cacti/log/cacti.log

 chown -R apache:apache /opt/cacti




###   CACTI SQL SB 추가

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

mysql -u root -p cacti < /var/www/html/cacti/cacti.sql

mysql -u root -p

# In the MySQL shell:

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'yourpassword';

FLUSH PRIVILEGES;

EXIT;




###    cacti config.php 수정

vi /var/www/html/cacti/include/config.php


$database_type     = 'mysql';

$database_default  = 'cacti';

$database_hostname = 'localhost';

$database_username = 'cactiuser';

$database_password = 'yourpassword';

$database_port     = '3306';

$database_ssl      = false;

$url_path = '/cacti/';




###  crontab 추가

 crontab -u apache -e



*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1





####  apache cacti.conf 추가

cat <<EOF | sudo tee -a /etc/httpd/conf.d/cacti.conf

<VirtualHost *:80>

ServerAdmin admin@example.com

DocumentRoot /var/www/html/

ServerName cacti.example.com

ServerAlias www.cacti.example.com

<Directory /var/www/html/cacti/>

Options FollowSymLinks

AllowOverride All

Order allow,deny

allow from all

</Directory>

ErrorLog /var/log/httpd/cacti.example.com-error_log

CustomLog /var/log/httpd/cacti.example.com-access_log common

</VirtualHost>

EOF



systemctl restart httpd.service



###  my.cnf 수정

vi /etc/my.cnf


[client]

default-character-set=utf8mb4

[mysql]

default-character-set=utf8mb4

[mysqld]

collation-server=utf8mb4_unicode_ci

init-connect='SET NAMES utf8mb4'

character-set-server = utf8mb4

max_heap_table_size=256M

tmp_table_size=80M

join_buffer_size=80M

innodb_buffer_pool_size=963M

innodb_doublewrite=OFF

innodb_flush_log_at_timeout=3

innodb_read_io_threads=32

innodb_write_io_threads=16



systemctl restart mariadb.service



**  mariadb 재시작 시 error 가 발생하는 경우가 생긴다.

이 때 /var/lib/mysql/  

ib_logfile0

ib_logfile1

ibdata1


3개의 파일을 삭제 한 뒤 다시 시작하면 된다.



참고url

https://www.vultr.com/docs/how-to-install-cacti-1-1-on-centos-7

http://idchowto.com/?p=11107


by 초보인척 2018. 5. 10. 12:34