您好,登錄后才能下訂單哦!
1.軟件安裝
1.1 更新系統(tǒng)
yum -y install wget vim-enhanced
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/{*.repo,backup}
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.163.com/.help/CentOS7-Base-163.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rm -rf /var/cache/yum
rm -rf /var/cache/man
yum makecache
yum update
1.2 安裝 Cacti 部署環(huán)境所需軟件包
1.2.1 添加 MariaDB YUM 倉(cāng)庫(kù),執(zhí)行以下腳本
echo '# MariaDB 10.2 CentOS repository list - created 2017-07-03 06:59 UTC
#http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://ipv4.mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64
gpgkey=https://ipv4.mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
'>/etc/yum.repos.d/Mariadb.repo
1.2.2 安裝軟件環(huán)境
yum install -y httpd mariadb mariadb-server mariadb-devel net-snmp net-snmp-utils net-snmp-libs net-snmp-agent-libs net-snmp-devel php php-snmp php-ldap php-pdo php-mysql php-devel php-pear php-common php-gd php-mbstring php-xml php-process rrdtool rrdtool-php rrdtool-perl rrdtool-devel gcc openssl-devel dos2unix autoconf automake binutils libtool cpp postfix glibc-headers kernel-headers glibc-devel gd gd-devel help2man ntpdate wget patch
2.環(huán)境配置
2.1 配置 PHP
修改 PHP 主配置文件 /etc/php.ini
關(guān)閉安全模式,以支持 rrdtool,允許 exec() 訪問(wèn)
[PHP]
safe_mode = Off
設(shè)置時(shí)區(qū)
[Date]
date.timezone = Asia/Shanghai
2.2 配置 Web 服務(wù)器 Apache httpd
編輯 /etc/httpd/conf.d/php.conf 配置文件,確保文件含有
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php5-script .php
2.3 配置數(shù)據(jù)庫(kù) MariaDB
為安全起見(jiàn),設(shè)置數(shù)據(jù)庫(kù) root 用戶密碼
systemctl start mariadb
mysqladmin -uroot password xxx123
導(dǎo)入時(shí)區(qū)數(shù)據(jù)到 mysql 數(shù)據(jù)庫(kù)
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot mysql -p
修改 /etc/my.cnf.d/server.cnf 文件,確保文件含有
[mysqld]
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
character_set_client = utf8mb4
max_connections = 100
max_heap_table_size = 4096M
max_allowed_packet = 16777216
join_buffer_size = 64M
tmp_table_size = 64M
innodb_file_per_table = ON
innodb_buffer_pool_size = 25600M
innodb_doublewrite = OFF
innodb_lock_wait_timeout = 50
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
2.4 配置 SNMP
配置 net-snmp-agent, 修改配置文件 /etc/snmp/snmpd.conf
將41行
com2sec notConfigUser default public
改為
com2sec notConfigUser 127.0.0.1 public
將62行
access notConfigGroup "" any noauth exact systemview none none
改為
access notConfigGroup "" any noauth exact all none none
將85行
#view all included .1 80
改為
view all included .1 80
3.安裝配置 Cacti
3.1 下載解壓 Cacti 安裝包
useradd -r -M cacti
cd /var/www/html/
wget https://github.com/Cacti/cacti/archive/release/1.1.38.tar.gz
tar -zxvf 1.1.38.tar.gz
cp -R cacti-release-1.1.38/ /var/www/html/cacti
cd /var/www/html/cacti
3.2 創(chuàng)建 cacti 數(shù)據(jù)庫(kù),創(chuàng)建 cactiuser 用戶,設(shè)置相關(guān)授權(quán)
mysql -u root -p
CREATE database cacti default character set utf8;
create user 'cacti'@'localhost' identified by 'xxx3';
grant all privileges on cacti.* to cacti@localhost;
grant select on mysql.time_zone_name to 'cacti'@'localhost' identified by 'xxx3';
flush privileges;
3.3 導(dǎo)入 Cacti 默認(rèn)數(shù)據(jù)庫(kù)
use cacti;
source /var/www/html/cacti/cacti.sql;
flush privileges;
quit
3.4 編輯 /var/www/html/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "xxx3"
/* load up old style plugins here */
$plugins = array();
//$plugins[] = 'thold';
3.5 創(chuàng)建 cacti 系統(tǒng)用戶,設(shè)置 graph/log 目錄權(quán)限
chown -R apache.apache /var/www/html/
chown -R cacti /var/www/html/
chown -R apache.apache /var/www/html/cacti/
chown -R cacti /var/www/html/cacti/{rra,log}/
chmod -R 777 /var/www/html/cacti/{rra,log}/
3.6 添加定時(shí)任務(wù)
crontab -e
*/1 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
4.配置防火墻
4.1 配置 firewalld 防火墻
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-port=161/udp
firewall-cmd --permanent --add-port=162/udp
firewall-cmd --reload
4.2 關(guān)閉selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
5.安裝 spine
5.1 下載解壓與 Cacti 相同版本號(hào) Spine 源碼安裝包
cd /usr/local/src
wget http://www.cacti.net/downloads/spine/cacti-spine-1.1.38.tar.gz
tar xf cacti-spine-1.1.38.tar.gz
5.2 源碼編譯安裝 spine
ln -s /usr/lib64/libmysqlclient.so.18.0.0 /usr/lib64/libmysqlclient.so
ntpdate ntp.sjtu.edu.cn
cd cacti-spine-1.1.38
./configure && make && make install
5.3 復(fù)制修改配置文件
cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
vim /etc/spine.conf
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass xxx3
DB_Port 3306
RDB_Host localhost
RDB_Database cacti
RDB_User cacti
RDB_Pass xxx3
RDB_Port 3306
5.4 測(cè)試
/usr/local/spine/bin/spine
將會(huì)出現(xiàn)以下結(jié)果
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 1.1.38 starting
SPINE: Time: 0.0429 s, Threads: 5, Devices: 0
6.設(shè)置重啟、開(kāi)機(jī)啟動(dòng)相關(guān)服務(wù)
systemctl restart httpd
systemctl restart mariadb
systemctl restart crond
systemctl restart snmpd
systemctl enable httpd
systemctl enable mariadb
systemctl enable crond
systemctl enable snmpd
7.登錄 Cacti WEB 頁(yè)面修改 Cacti 配置
Console -> 設(shè)置(Cacti Settings) -> Paths -> 在 Spine Binary File Location 文本框內(nèi)填入配置文件路徑 /usr/local/spine/bin/spine ,在 Spine Config File Path 框內(nèi)填入配置文件路徑 /usr/local/spine/etc/spine.conf,點(diǎn)擊保存 (Save)。
Console -> 設(shè)置(Cacti Settings) -> Poller -> 在 Poller Type 下拉框中選擇 spine ,點(diǎn)擊保存 (Save)。
8.特別提示
在添加完設(shè)備和圖形后,需要重建采集器緩存。
Console –> 系統(tǒng)工具 –> Rebuild Poller Cache
附:
比如說(shuō)cacti平臺(tái)要求更改默認(rèn)端口號(hào)(例改為10010),且做白名單限制(例只允許IP地址123.123.123.123登錄),相關(guān)設(shè)置如下
1、改端口號(hào)
vim /etc/httpd/conf/httpd.conf
在第137行下修改Listen:80為L(zhǎng)isten:10010,保存退出。
2、防火墻放行10010端口號(hào)
vim /etc/sysconfig/iptables
添加防火墻規(guī)則
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10010 -j ACCEPT
重啟防火墻服務(wù)
service iptables restart
3、做白名單訪問(wèn)限制
vim /etc/httpd/conf/httpd.conf
在第318行下, <Directory "/var/www/html">內(nèi)添加如下內(nèi)容并保存退出
Order allow,deny
Allow from 123.123.123.123
重啟httpd服務(wù)
service httpd restart
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。