Cacti Monitoring Server configuration tutorial (based on centos+nginx+mysql+php Environment building)

Source: Internet
Author: User
Tags cairo fpm install php mcrypt rrdtool snmp snmp port


Cacti Monitoring Server configuration tutorial (based on centos+nginx+mysql+php Environment building)

Install centos web panel
Specific cases:
LAN has two hosts, a Linux, a Windows, now need to configure a cacti monitoring server to monitor the two hosts
Environment Description:
1. Linux Host
Operating system: CentOS 6.2
IP Address: 192.168.21.164
Subnet Mask: 255.255.255.0
Gateway: 192.168.21.2
dns:8.8.8.8 8.8.4.4

Centos web panel
2. Windows host
Operating system: Windows Server 2003
IP Address: 192.168.21.130
Subnet Mask: 255.255.255.0
Gateway: 192.168.21.2
dns:8.8.8.8 8.8.4.4

Install centos web panel on centos 7
3, need to configure the Cacti monitoring server
Operating system: CentOS 6.2
IP Address: 192.168.21.169
Subnet Mask: 255.255.255.0
Gateway: 192.168.21.2
dns:8.8.8.8 8.8.4.4
Tutorial Start:
First, install the configuration Cacti monitoring Server
1. Installation system: Please refer to
CentOS 6.2 Installation (Super detailed illustrated tutorial): http://www.osyunwei.com/archives/1537.html
2, set the IP address, gateway, DNS: please refer to
CentOS 6.0 Set IP address, gateway, dns:http://www.osyunwei.com/archives/423.html
Note: The CentOS 6.2 IP address, gateway, DNS settings are identical to CentOS 6.0

Virtualmin vs centos web panel
3, configure the firewall, start 80 ports, 3306 ports, 161 ports
Vi/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
-A input-m state--state new-m udp-p UDP--dport 161-j ACCEPT
Special Note: Many netizens add these two rules to the last line of the firewall configuration, causing the firewall to fail to start, the correct one should be added to the default 22 port under this rule
After adding the firewall rules as follows: centos web panel tutorial
System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
#########################################################
# Firewall configuration written by System-config-firewall
# Manual Customization of this file are not recommended.
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m state--state established,related-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
-A input-m state--state new-m udp-p UDP--dport 161-j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT
#########################################################
/etc/init.d/iptables Restart #最后重启防火墙使配置生效
4. Turn off SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: Wq Save, close
Shutdown-r now #重启系统
5, install nginx+mysql+php, build cacti web running environment
Software source code Package storage location:/USR/LOCAL/SRC
Source Package Compilation Installation location:/usr/local/software Name
Download the package:
(1), download Nginx (currently stable version)
Http://nginx.org/download/nginx-1.0.14.tar.gz
(2), download pcre (support Nginx pseudo-static)
Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
(3), download MySQL
Http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz
(4), download PHP
Http://cn.php.net/distributions/php-5.3.10.tar.gz
(5), download CMake (MySQL compilation tool)
Http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
(6), download Libmcrypt (phplibmcrypt module)
Ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
Installing nginx+mysql+php
(1) Install the compilation Tools and library files (install using the CentOS Yum command)
Yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel Keyut Ils patch perl kernel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err- Devel libsepol-devel libselinux-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurses* L ibtool* libxml2 libxml2-devel Patch
(2), installation Libmcrypt
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.7.tar.gz #解压
CD libmcrypt-2.5.7 #进入目录
./configure #配置
Make #编译
Make install #安装
(3), installation CMake
Cd/usr/local/src
Tar zxvf cmake-2.8.7.tar.gz
CD cmake-2.8.7
./configure
Make #编译
Make install #安装
(4), installation Pcre
Cd/usr/local/src
Mkdir/usr/local/pcre #创建安装目录
Tar zxvf pcre-8.30.tar.gz
CD pcre-8.30
./configure--prefix=/usr/local/pcre #配置
Make
Make install
(5), install MySQL
Groupadd MySQL #添加mysql组
useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, does not allow MySQL users to log in directly to the system
Mkdir-p/data/mysql #创建MySQL数据库存放目录
Chown-r Mysql:mysql/data/mysql #设置MySQL数据库目录权限
Mkdir-p/usr/local/mysql #创建MySQL安装目录
Cd/usr/local/src
Tar zxvf mysql-5.5.21.tar.gz #解压
CD mysql-5.5.21
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc #配置
Make #编译
Make install #安装
Cd/usr/local/mysql
CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, you can overwrite it directly)
Vi/etc/my.cnf #编辑配置文件, added in [mysqld] section
DataDir =/data/mysql #添加MySQL数据库路径
./scripts/mysql_install_db--user=mysql #生成mysql系统数据库
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Chkconfig mysqld on #加入开机启动
Vi/etc/rc.d/init.d/mysqld #编辑
Basedir =/usr/local/mysql #MySQL程序安装路径
DataDir =/data/mysql #MySQl数据库存放目录
Service mysqld Start #启动
Vi/etc/profile #把mysql服务加入系统环境变量: Add the following line at the end
Export path= $PATH:/usr/local/mysql/bin
The following two lines link the MYSLQ library file to the default location of the system, so you can compile software like PHP without specifying the MySQL library file address.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Shutdown-r now #需要重启系统, wait for the system to restart after the operation continues under the terminal command line
Mysql_secure_installation #设置Mysql密码
Press Y to enter the password 2 times as prompted
or modify the password directly/usr/local/mysql/bin/mysqladmin-u root-p password "123456" #修改密码
Service mysqld Restart #重启
To this, MySQL installation is complete!
(6), installation Nginx
Groupadd www #添加www组
Useradd-g www www-s/bin/false #创建nginx运行账户www并加入到www组, www users are not allowed to log in directly to the system CD/USR/LOCAL/SRC
Tar zxvf nginx-1.0.14.tar.gz
CD nginx-1.0.14
./configure--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-openssl=/usr/-- with-pcre=/usr/local/src/pcre-8.30
Note:--with-pcre=/usr/local/src/pcre-8.30 points to the source package decompression path, not the installation path, otherwise it will be an error
Make
Make install
/usr/local/nginx/sbin/nginx #启动nginx
Set Nginx on Start
Vi/etc/rc.d/init.d/nginx #编辑启动文件添加下面内容
=======================================================
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# It is v.0.0.2 version.
# Chkconfig:-85 15
# Description:nginx is a high-performance Web and proxy server.
# It has a lot of features, but it's not for everyone.
# Processname:nginx
# Pidfile:/var/run/nginx.pid
# config:/usr/local/nginx/conf/nginx.conf
Nginxd=/usr/local/nginx/sbin/nginx
Nginx_config=/usr/local/nginx/conf/nginx.conf
Nginx_pid=/usr/local/nginx/logs/nginx.pid
Retval=0
Prog= "Nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
[${networking} = "No"] && exit 0
[-X $nginxd] | | Exit 0
# Start Nginx daemons functions.
Start () {
If [-e $nginx _pid];then
echo "Nginx already running ..."
Exit 1
Fi
Echo-n $ "Starting $prog:"
Daemon $nginxd-C ${nginx_config}
Retval=$?
Echo
[$RETVAL = 0] && Touch/var/lock/subsys/nginx
Return $RETVAL
}
# Stop Nginx daemons functions.
Stop () {
Echo-n $ "Stopping $prog:"
Killproc $nginxd
Retval=$?
Echo
[$RETVAL = 0] && rm-f/var/lock/subsys/nginx/usr/local/nginx/logs/nginx.pid
}
Reload () {
Echo-n $ "Reloading $prog:"
#kill-hup ' Cat ${nginx_pid} '
Killproc $nginxd-hup
Retval=$?
Echo
}
# See how we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Reload
Reload
;;
Restart
Stop
Start
;;

Status
Status $prog
Retval=$?
;;
*)
echo $ "Usage: $prog {start|stop|restart|reload|status|help}"
Exit 1
Esac
Exit $RETVAL
=======================================================
: wq! Save Exit
chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限
Chkconfig Nginx on #设置开机启动
System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
/etc/rc.d/init.d/nginx restart
Service Nginx Restart
=======================================================
(7), install PHP
Cd/usr/local/src
TAR-ZVXF php-5.3.10.tar.gz
CD php-5.3.10
Mkdir-p/USR/LOCAL/PHP5 #建立php安装目录
./configure--PREFIX=/USR/LOCAL/PHP5--with-config-file-path=/usr/local/php5/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-gd--with-iconv-- With-freetype--with-jpeg--with-png--with-zlib--with-libxml--enable-xml--enable-discard-path-- Enable-magic-quotes--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization --with-curlwrappers--enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect--enable-mbstring-- Enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip-- Enable-soap--without-pear--with-gettext--with-mime-magic--enable-suhosin--enable-session--with-mcrypt-- With-curl #配置
Make #编译
Make install #安装
CP Php.ini-production/usr/local/php5/etc/php.ini #复制php配置文件到安装目录
Rm-rf/etc/php.ini #删除系统自带配置文件
Ln-s/usr/local/php5/etc/php.ini/etc/php.ini #添加软链接
Ln-s/usr/local/php5/bin/php/usr/bin/php #添加软连接
cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf #拷贝模板文件为php-fpm configuration file
Vi/usr/local/php5/etc/php-fpm.conf #编辑
user = www #设置php-fpm run account is www
Group = www #设置php-fpm run Group is www
PID = Run/php-fpm.pid #取消前面的分号
Set PHP-FPM boot up
CP/USR/LOCAL/SRC/PHP-5.3.10/SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM #拷贝php-fpm to startup directory
chmod +x/etc/rc.d/init.d/php-fpm #添加执行权限
Chkconfig PHP-FPM on #设置开机启动
Vi/usr/local/php5/etc/php.ini #编辑配置文件
Found:;d Ate.timezone =
Modified to: Date.timezone = PRC #设置时区
Found: expose_php = On
Modified to: expose_php = OFF #禁止显示php版本的信息
Found: Display_errors = On
Modified to: display_errors = OFF #关闭错误提示
(8), configure Nginx support PHP
Vi/usr/local/nginx/conf/nginx.conf
Modify the/usr/local/nginx/conf/nginx.conf configuration file, you need to make the following changes
User www www; #首行user去掉注释, modify the Nginx run group to www www; must be the same as the User,group configuration in/usr/local/php5/etc/php-fpm.conf, or PHP will run in error
Index index.php index.html index.htm; #添加index. php
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
#取消FastCGI the comment for the server section location, and note the parameters of the Fastcgi_param row, change to $document_root$fastcgi_script_name, or use the absolute path
/etc/init.d/nginx Restart #重启nginx
cd/usr/local/nginx/html/#进入nginx默认网站根目录
rm-rf/usr/local/nginx/html/* #删除默认测试页
Chown www.www/usr/local/nginx/html/-R #设置目录所有者
chmod 700/usr/local/nginx/html/-R #设置目录权限
Shutdown-r now #重启
Service Nginx Restart #重启nginx
Service mysqld Restart #重启mysql
/USR/LOCAL/PHP5/SBIN/PHP-FPM #启动php-FPM
/ETC/RC.D/INIT.D/PHP-FPM Restart #重启php-fpm
/ETC/RC.D/INIT.D/PHP-FPM Stop #停止php-FPM
/ETC/RC.D/INIT.D/PHP-FPM Start #启动php-fpm
6. Installation Configuration Cacti Web Service
(1) Install RRDtool, NET-SNMP and related dependencies (install using the CentOS Yum command)
Yum install RRDtool net-snmp rrdtool-devel net-snmp-devel net-snmp-utils net-snmp-python Net-snmp-perl lm_sensors-devel File-devel rpm-devel file Intltool libart_lgpl libart_lgpl-devel elfutils pango-devel* cairo-devel* mysql-devel Mod_auth _mysql php-mysql Cairo Dejavu-fonts-common.noarch Dejavu-lgc-sans-mono-fonts.noarch Dejavu-sans-mono-fonts.noarch Fontpackages-filesystem.noarch libxft libxrender Libthai pango pixman perl-rrdtool net-snmp net-snmp-utils tcp_ Wrappers-devel
Chkconfig snmpd on #设置snmpd开机启动
Service SNMPD Start #启动snmpd服务
(2) Download and install cacti
Cacti:http://www.cacti.net/downloads/cacti-0.8.7i.tar.gz
Cd/usr/local/src
Tar zxvf cacti-0.8.7i.tar.gz
CD cacti-0.8.7i
Cp-r */usr/local/nginx/html
Chown www.www/usr/local/nginx/html/-R #设置目录所有者
chmod 700/usr/local/nginx/html/-R #设置目录权限
(3), configure cacti Database
Mysql-u root-p #输入密码进入MySQL控制台
Create DATABASE IF not EXISTS cactidb default charset UTF8 COLLATE utf8_general_ci; #创建数据库cactidb
Insert into Mysql.user (Host,user,password) VALUES (' localhost ', ' cactiuser ', Password (' 123456 ')); #创建数据库用户cactiuser Password 123456
Grant all on cactidb.* to ' cactiuser ' @ '% ' of ' identified by ' 123456 ' with GRANT option; #授权用户cactiuser对数据库cactidb完全访问
Flush privileges; #刷新系统授权表 to make the settings effective
Use CACTIDB
Source/usr/local/nginx/html/cacti.sql #导入cacti数据库文件
Exit #退出MySQL控制台
vi/usr/local/nginx/html/include/config.php #配置数据库连接
$database _type = "MySQL";
$database _default = "CACTIDB"; #数据库名称
$database _hostname = "localhost"; #主机名称, the default is
$database _username = "Cactiuser"; #数据库用户名
$database _password = "123456"; #数据库密码
$database _port = "3306"; #MySQL数据库默认连接端口
$database _ssl = false;
Open http://192.168.21.169/
The following interface appears



Click Next




Please select the type of installation
Select New Install #安装
Click Next and the following screen appears







Each option below is [Ok:file FOUND], which indicates that the configuration file path is all correct
Click Finish, the login screen appears




User Name:admin
Password:admin
After the first login succeeds, you must set a new password




Enter two new password, click Save, enter Cacti control page






Yum install-y Vixie-cron #安装计划任务, may not be preinstalled on some systems



Chkconfig Crond on #设为开机启动



Crontab-e #设置每隔5分钟Cacti采集一次数据



*/5 * * * * php/usr/local/nginx/html/poller.php &>/dev/null



Service Crond Start #启动crond



/usr/bin/php/usr/local/nginx/html/poller.php #手动刷新数据



At this point, the Cacti Monitoring Server installation is complete
Second, configure the monitored host
1. Configuring Windows Host
Description: To monitor a Windows host using cacti, SNMP (Simple Network Management Protocol) needs to be installed on the monitored host



The following installation configures SNMP



Start-Settings-Control Panel-Add or Remove Programs-add remove Windows Components









Find the management and monitoring tools, tick the front, tick in the point details: Simple Network Management Protocol (SNMP), then OK, next



System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link












Start the installation until the installation is complete (note: You will be prompted to insert the Windows system CD during the installation process, which needs to be prepared in advance.) )



Start-run, enter services.msc OK, open service management









Locate the SNMP Service option, double-click Open, switch to security options, click Add under Accept community name, and the SNMP services configuration appears



Group permissions: Read-only



Group Name: Public



Finally determined






Check: Accept SNMP packets from these hosts, add the following points, enter the IP address of the cacti monitoring host in the hostname, IP, or IPX addresses



Enter here: 192.168.21.169, finally, apply, OK.









Finally, restart the Windows system, and the monitored Windows Host settings are complete.
2. Configure the Linux host



Note: To use cacti to monitor a Linux host, you need to install NET-SNMP and other related packages on the monitored host;



Also need to open firewall UDP161 port



(1), open firewall UDP161 port



Vi/etc/sysconfig/iptables #编辑防火墙配置



-A input-m state--state new-m udp-p UDP--dport 161-j ACCEPT



/etc/init.d/iptables Restart #重启防火墙使配置生效



(2), install NET-SNMP (here the Yum command using CentOS is installed online)



Yum-y Install NET-SNMP



Chkconfig snmpd on #设置开机启动



Service SNMPD Start #启动snmpd



(2), configuring SNMP



Cp/etc/snmp/snmpd.conf/etc/snmp/snmpd.confbak #备份配置文件



Vi/etc/snmp/snmpd.conf #编辑, modify to the following content


1 com2sec notConfigUser  192.168.21.169       public
2 access  notConfigGroup ""any       noauth    exact  all  none none
3 view all    included  .1                               80


Netstat-nlup |grep ": 161" #检查snmp服务器是否运行, a similar output appears, indicating that SNMP is operating properly



UDP 0 0 0.0.0.0:161 0.0.0.0:* 2765/snmpd



At this point, the monitored Linux host settings are complete.
Iii. setting up the Cacti Monitoring server to monitor Windows and Linux hosts



1. Adding monitoring to Windows hosts



Management-devices, click Add in the upper-right corner, adding the host












The relevant options are described in detail:



Description: Description



Hostname: Host name, IP address of the host to monitor, here is 192.168.21.130



Host Template: Hosting templates, selecting Windows 2000/xp Host



Monitor host: The back tick indicates enable



SNMP COMMUNITY:SNMP community Name, be sure to be the same as the SNMP community name set before Windows host, otherwise the monitoring fails, this is public



SNMP PORT:SNMP Port, default is 161



Other options default to



Finally, click Save and the following interface will appear






Click Create Graphs for this host: Add graphics to this console, select the check box on the right for the object you want to monitor,



Click Create To add









Note that the last item, select a graphics type, 32-bit host select In/out Bytes; 64-bit host select In/out Bytes (64-bit)



The following interface appears, and then click Add









Click on the graphs Monitor in the navigation bar above to enter the monitoring interface,



Select the host we just added, you can already see the graph of monitoring, but this time there is no data, data acquisition is 5 minutes polling



Wait a few minutes, refresh, you will see the following interface, this time the monitoring data has been.






Windows Host monitoring Settings complete



2. Adding monitoring to Linux hosts



Add the same method as Windows



Note: Hostname: Host name fill in Linux host ip,host template host templates select Local Linux machine






System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link












Add the last point, and then click Create Graphs for this host to add graphics to the



Select the right check box for the object you want to monitor, click Add



The following interface appears, then click Create To add









Then click on the Graphs Monitor in the navigation bar above, go to the Monitoring screen, select the Linux host you just added,



Also wait a few minutes, you will see the following monitoring data






Linux Host Monitoring Setup Complete



At this point, the Cacti Monitoring Server configuration tutorial is complete


» Article Link: http://www.osyunwei.com/archives/3209.html


Cacti Monitoring Server configuration tutorial (based on centos+nginx+mysql+php Environment building)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.