第四阶段 :安全与监控 Linux监控和安全运维

监控介绍

monitor  cacti(rrdtool) 画图 监控网络设备 流量 展现历史数据功能

nagios 监控服务的状态 磁盘 内存 不会记录数据 一目了然 可自己写脚本

zabbix 

cacti安装

rpm -ivh http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm

yum install  epel-release

yum install -y httpd php php-mysql mysql mysql-server mysql-devel php-gd libjpeg libjpeg-devel libpng libpng-devel

yum install -y cacti net-snmp net-snmp-utils rrdtool 

/etc/init.d/mysqld start
/etc/init.d/httpd  start
/etc/init.d/snmpd start

netstat -lnp|grep 8   有端口占用时 使用  或者直接关闭 nginx

kill -9 +进程

vim /etc/httpd/conf.d/cacti.conf  

把"Deny from all" 改为  "Allow from all"

/etc/init.d/httpd  restart

mysql -uroot  -e "create database cacti"

mysql -uroot -e "grant all on cacti.* to 'cacti'@'127.0.0.1' identified by 'cacti';"

mysql -uroot cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql

vim /usr/share/cacti/include/config.php

$database_type = "mysql";
$database_default = "cacti";
$database_name = "cacti";
$database_hostname = "127.0.0.1";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$database_ssl = false;

ip/cacti  访问 出现错误:

FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'

mysql -u cacti -pcacti 确发现无法访问,返回信息如下:
ERROR 1045 (28000): Access denied for user 'cacti'@'localhost' (using password: YES)

我是这样操作的/
mysql -u root -p
use mysql;
grant all privileges on cacti.* to cacti@"localhost" identified by 'cacti';
flush privileges;
再修改vim /usr/share/cacti/include/config.php
$database_hostname = "localhost";   这个没改
在测试mysql -u cacti -pcacti

关闭  setenforce 0   临时
修改/etc/selinux/config 文件

将SELINUX=enforcing改为SELINUX=disabled

重启

ip/cacti/

/usr/bin/php /usr/share/cacti/poller.php

vim /etc/php.ini

增加

 date.timezone = 'Asia/Chongging'
cront -e

*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php

 

 

你可能感兴趣的:(linux,监控,安全运维)