加入安裝來源

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm

安裝PHPMariaDBCacti

# yum -y install cacti mariadb-server php-xml php-session php-sockets php-ldap php-gd

啟動apachemariadbsnmp

# systemctl start httpd.service
# systemctl start snmpd.service

# systemctl start mariadb.service

設定mariadbroot帳密及安全性

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):按「enter,因為預設無密碼

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.

 

Set root password? [Y/n] 輸入「Y」按「enter,設定root的密碼

New password:密碼一次

Re-enter new password:密碼二次

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them.  This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment.

 

Remove anonymous users? [Y/n] 輸入「Y」按「enter,禁止匿名存取

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] 輸入「Y」按「enter,禁止root遠端存取

 ... Success!

 

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] 輸入「Y」按「enter,移除測試資料庫

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] 輸入「Y」按「enter,重新載入剛剛的設定

 ... Success!

 

Cleaning up...

 

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

 

Thanks for using MariaDB!

建立cacti所用的資料庫

# mysql -u root –p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 45
Server version: 5.5.50-MariaDB MariaDB Server
 
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> create database cacti;
Query OK, 1 row affected (0.00 sec)

 

MariaDB [(none)]> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';
 

MariaDB [(none)]> flush privileges;

cacti的資料庫結構匯入DB

#  mysql cacti < /usr/share/doc/cacti-0.8.8h/cacti.sql -u root -p

Enter password:輸入剛剛設定的root密碼

修改cacti設定檔內連結資料庫的預設帳密

# vi /usr/share/cacti/include/config.php

找到

$database_username = "cactiuser"; 修改成第5步驟設定的使用者

$database_password = "cactipassword"; 修改成第5步驟設定的密碼

修改cacti目錄內的權限

# mkdir /var/log/cacti

# touch /var/log/cacti/cacti.log

# cd /usr/share/cacti

# chown -R cacti rra/ log

cacti輪詢snmp資料設為定時執行

# vi /etc/cron.d/cacti

將內容中最前面的#拿掉

#*/5 * * * *    cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

變成

*/5 * * * *    cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

cacti第一次執行會由網頁安裝,設定為可由非本機執行

# vi /etc/httpd/conf.d/cacti.conf
找到
<Directory /usr/share/cacti/>
        <IfModule mod_authz_core.c>
                # httpd 2.4
                # Require host localhost 找到這行,前方加上#
                Require all granted 新增這行進去
        </IfModule>
        <IfModule !mod_authz_core.c>
                # httpd 2.2
                Order deny,allow
                Deny from all
                Allow from localhost
        </IfModule>
</Directory>

設定防火牆讓服務通行

# firewall-cmd --permanent --zone=public --add-service=http

# firewall-cmd --reload

重啟服務讓設定生效

# systemctl restart httpd.service
# systemctl restart snmpd.service
# systemctl restart mariadb.service

將服務加到開機啟動

# systemctl enable httpd.service
# systemctl enable snmpd.service

# systemctl enable mariadb.service

開啟cacti的網頁(http://SERVERIP/cacti)開始進行設定

Next

Next

Finish

預設帳密是admin/admin

第一次登入會要求改密碼

完成安裝

 

arrow
arrow
    文章標籤
    centos7 install cacti
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()