1.准备需要
[root@server1 html]# yum install -y php##安装php,支持动态数据
[root@server1 ~]# /etc/init.d/httpd start##开启httpd
[root@server1 html]# pwd
/var/www/html
[root@server1 html]# ls ##当前路劲需要的文件
class_socket.php config.php index.html index.php purge_action.php static
[root@server1 html]# vim config.php
8 ///数据库信息/
9 //数据库信息
10 // $host = "localhost";
11 // $user = "";
12 // $passwd = "";
13 // $dbname = "bansys";
14 // $conn = mysql_connect($host, $user, $passwd) or die('Unable to connect database...');
15 // mysql_select_db($dbname,$conn);
16 // $query = "select ResourceIP from purgeapp_resource";
17 // $results = mysql_query($query,$conn);
18
19 // while ($row=mysql_fetch_row($results)) {
20 // $varnish_host[] = $row[0];
21 // }
22 //mysql_close($conn);
23
24
25 //varnish主机列表
26 //可定义多个主机列表
27 $var_group1 = array(
28 'host' => array('172.25.38.1'),
29 'port' => '80',
30 );
31
32
33
34 //varnish群组定义
35 //对主机列表进行绑定
36 $VAR_CLUSTER = array(
37 'www.westos.com' => $var_group1,
38 );
39
40
41 //varnish版本
42 //2.x和3.x推送命令不一样
43 $VAR_VERSION = "3";
[root@server1 html]# vim /etc/varnish/default.vcl
7 acl westos {
8 "127.0.0.1";
9 "172.25.38.1"/24;
10 }
11
12 backend web1 {
13 .host = "172.25.38.2";
14 .port = "80";
15 }
16
17 backend web2 {
18 .host = "172.25.38.3";
19 .port = "80";
20 }
21 director lb round-robin {
22 {.backend = web1;}
23 {.backend = web2;}
24 }
25
26
27 sub vcl_recv {
28
29
30 if (req.request == "BAN") {
31 if (!client.ip ~ westos) {
32 error 405 "Not allowed.";
33 }
34 ban("req.url ~ " + req.url);
35 error 200 "ban added";
36 }
37
38
39
40 if (req.http.host ~ "^(www.)?westos.org") {
41 set req.http.host = "www.westos.org";
42 set req.backend = lb;
43 return (pass);
44 }
45 elsif (req.http.host ~ "^bbs.westos.org") {
46 set req.backend = web2;
47 }
48 else {error 404 "westos cache";
49 }
50 }
[root@server1 html]# /etc/init.d/varnish reload
2.cacti图形化管理
[root@server1 ~]# yum install -y httpd php php-mysql mysql-server rrdtool##安装
[root@server1 ~]# yum install -y php-snmp-5.3.3-26.el6.x86_64.rpm
[root@server1 ~]# yum install -y net-snmp-*
[root@server1 ~]# vim /etc/php.ini
943 [Date]
944 ; Defines the default timezone used by the date functions
945 ; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
946 date.timezone =Asia/Shanghai
[root@server1 cacti]# /etc/init.d/mysqld start##开启数据库
[root@server1 cacti]# mysqladmin create cacti##创建数据库cacti
[root@server1 cacti]# mysql cacti <cacti.sql ##导入数据库内容,此处可以自己创建表,填写内容
[root@server1 cacti]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant all on cacti.* to cacti@localhost identified by 'westos';##创建用户,并授权
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;##刷新权限
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@server1 include]# pwd##当前所在路径
/var/www/html/cacti/include
[root@server1 include]# vim config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";##数据库用户名
$database_password = "westos";##密码
$database_port = "3306";
$database_ssl = false;
$url_path = "/cacti/";
$cacti_session_name = "Cacti";
[root@server1 cacti]# useradd -u 1000 cacti##更改当前文件的权限信息
[root@server1 cacti]# yum install -y crontabs##定时
[root@server1 cacti]# su cacti
[cacti@server1 cacti]$ crontab -e
*/5 * * * * php /var/www/html/cacti/poller.php >/dev/null 2>&1 ##每五分钟产生一次消息
测试,值得注意的是:初始帐号和密码均为admin,会让你强制修改密码
此处若是不是绿色,可以按照它的要求进行更改设置
可以进行添加所要管理的数据
----------------------------------------------------