centos7.4源码安装cacti仙人掌1.1.26版本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7.4源码安装cacti仙人掌1.1.26版本相关的知识,希望对你有一定的参考价值。
centos7.4源码安装cacti仙人掌1.1.26版本
此实验需要联网,所以要两块网卡,一块仅主机,一块桥接
所需软件压缩包
vi all.repo
---本地yum仓库
[base]
name=Centos-repo.repo
baseurl=file:///mnt
enabled=1
gpgcheck=0
---新增中科大mariadb源-------光盘自带的版本过低----
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos74-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
----------搭建阿里云yum仓库-------------
[Ali]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
yum install -y \ //安装httpd ,及mariadb,及php和其他依赖包插件
httpd \
MariaDB-client MariaDB-server \
MariaDB-devel \
php \
php-snmp \
php-ldap \
php-pdo \
php-mysql \
php-devel \
php-pear \
php-common \
php-gd \
php-mbstring \
php-xml \
php-process \
net-snmp \
net-snmp-utils \
net-snmp-libs \
net-snmp-agent-libs \
net-snmp-devel \
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
vi /etc/httpd/conf/httpd.conf
ServerName www.aa.com
vi /etc/httpd/conf.d/php.conf ——————末尾新增
LoadModule php5_module modules/libphp5.so
vi /etc/php.ini
safe_mode=off //在[PHP]下插入
date.timezone = PRC //去掉注释
systemctl stop firewalld.service //关闭防火墙
setenforce 0 //临时关闭SElinux
systemctl start httpd.service //启动httpd服务
systemctl start mariadb.service //启动mariadb数据库服务
netstat -anpt | grep 80
netstat -anpt | grep 3306
mysql_secure_installation 安全配置向导
初次运行直接回车
是否设置root用户密码,输入y并回车或直接回车
设置root用户的密码
再输入一次你设置的密码
是否删除匿名用户,生产环境建议删除,所以直接回车
是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
是否删除test数据库,直接回车
是否重新加载权限表,直接回车(这一步上图没有截全)
vi /var/www/html/index.php //编辑网页测试文件
<?php
phpinfo();
?>
测试,在浏览器中输入192.168.80.100
如上图,表示httpd和php已正常启动,并连接成功
vi /etc/my.cnf.d/server.cnf //配置cacti网页安装的参数
//[mysqld]下配置以下内容
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
character_set_client = utf8mb4
max_connections = 100
max_heap_table_size = 256M
max_allowed_packet = 16777216
join_buffer_size = 64M
tmp_table_size = 64M
innodb_file_per_table = ON
innodb_buffer_pool_size = 1024M
innodb_doublewrite = OFF
innodb_lock_wait_timeout = 50
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
mysql -u root -p //登入数据库
CREATE DATABASE cacti character set utf8 collate utf8_bin;
GRANT all ON cacti. TO ‘cacti‘@‘%‘ IDENTIFIED BY ‘admin123‘;
GRANT all ON cacti. TO ‘cacti‘@‘localhost‘ IDENTIFIED BY ‘admin123‘;
flush privileges;
vi /var/www/html/index.php
<?php
$link=mysqli_connect(‘192.168.80.100‘,‘cacti‘,‘admin123‘);
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
?>
测试检测mysql 与php是否协同工作,在浏览器中输入192.168.80.100
如上图所示,表示mysql 与php正协同工作
安装cacti
tar xf cacti-1.1.26.tar.gz
mv cacti-1.1.26 /var/www/html/cacti
mysql -ucacti -p cacti < /var/www/html/cacti/cacti.sql
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot mysql -p
mysql -u root -p
grant select on mysql.time_zone_name to ‘cacti‘@‘%‘ IDENTIFIED BY ‘admin123‘;
//在数据库中为时区文件授权
flush privileges;
vi /var/www/html/cacti/include/config.php
$database_username = ‘cacti‘;
$database_password = ‘admin123‘;
配置SNMP
vi /etc/snmp/snmpd.conf
com2sec notConfigUser 127.0.0.1 public //改成环回口地址 41
access notConfigGroup "" any noauth exact all none none //把systemview改成all 62
view all included .1 80 // 去掉#号 85
systemctl restart snmpd.service
systemctl enable snmpd.service
useradd -r -M cacti
chown -R cacti /var/www/html/cacti/rra/
chown -R cacti /var/www/html/cacti/log/
chown -R apache.apache /var/www/html/cacti/resource/
chown -R apache.apache /var/www/html/cacti/cache
chown -R apache.apache /var/www/html/cacti/scripts
crontab -e
/5 * /usr/bin/php /var/www/html/cacti/poller.php >> /tmp/cacti_rrdtool.log
安装cacti-spine优化数据轮询速度
ln -s /usr/lib64/libmysqlclient.so.18.0.0 /usr/lib64/libmysqlclient.so
tar xf cacti-spine-1.1.26.tar.gz
cd cacti-spine-1.1.26
./configure && make && make install
cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
vi /usr/local/spine/etc/spine.conf //修改相关参数
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass admin123
DB_Port 3306
RDB_Host localhost
RDB_Database cacti
RDB_User cacti
RDB_Pass admin123
RDB_Port 3306
systemctl restart httpd
systemctl restart mariadb
-----------登录到页面-----------
192.168.80.181/cacti/
……
安装步骤:
输入账号admin和密码admin
重设密码,密码为大写小写特殊字符组合,如Abc123a,
Console -> 设置(Cacti Settings) -> Poller -> 在 Poller Type 下拉框中选择 spine ,点击保存 (Save)。注意:假如使用spine的话,下面两项轮训时间和计划任务间隔时间都要设置为every Minute
在添加完设备和图形后,需要重建采集器缓存。
去cacti上查看
管理设备(device)
查看linux状态为UP即可,注意不要着急spine方式刚刚启动需要2-5分钟左右时间,有快有慢
设置主机的IP地址:设备——>点击local linux machine
然后直接选图形,可以查看cacti处理后的图片
![](http://i2.51cto.com/images/blog/201803/31/5ff22eaae933cc0a018d3a41eb7e4127.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5=
如上图所示,cacti正在监控linux主机
以上是关于centos7.4源码安装cacti仙人掌1.1.26版本的主要内容,如果未能解决你的问题,请参考以下文章