Wishlist 0 ¥0.00

mysql经典的8小时问题-wait_timeout

前段时间 现网突然频繁报出 连接不上数据库,偶滴的妖孽,其他地方都是用mysql,也没遇到这个问题呀。

java.io.EOFExceptionat 
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1913)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2304)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2803)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)

场景出现的理论依据
MySQL 的默认设置下,当一个连接的空闲时间超过8小时后,MySQL 就会断开该连接,而 c3p0/dbcp 连接池则以为该被断开的连接依然有效。在这种情况下,如果客户端代码向c3p0/dbcp 连接池请求连接的话,连接池就会把已经失效的连接返回给客户端,客户端在使用该失效连接的时候即抛出异常。

如果你只是个程序员,你会想着,在去对数据库做操作前,我不是先对数据库连接做个校验或判断什么的,连接是working的,我才干活,那么你得到的解决方案-或许就是这样的

#c3p0配置
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 -->   
<property name="maxIdleTime">60</property>  
<!-- 当连接池连接耗尽时,客户端调用getConnection()后等待获取新连接的时间,
超时后将抛出SQLException,如设为0则无限期等待。单位毫秒。默认: 0 -->   
<property name="checkoutTimeout" value="3000"/>  
<!--c3p0将建一张名为Test的空表,并使用其自带的查询语句进行测试。
如果定义了这个参数那么属性preferredTestQuery将被忽略。
你不能在这张Test表上进行任何操作,它将只供c3p0测试使用。默认值: null -->   
 <property name="automaticTestTable">Test</property>  
<!--因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的   
  时候都将校验其有效性。建议使用idleConnectionTestPeriod或automaticTestTable   
  等方法来提升连接测试的性能。Default: false -->   
<property name="testConnectionOnCheckout">false</property>   
<!--如果设为true那么在取得连接的同时将校验连接的有效性。Default: false -->   
<property name="testConnectionOnCheckin">true</property> 
<!--每60秒检查所有连接池中的空闲连接。Default: 0 -->   
<property name="idleConnectionTestPeriod">60</property>  

如果你只是个DBA,你会想着,为什么数据库连接自己断了,是不是哪里有配置,我得去看看,那么你得到的解决方案-可能就是这样的

#my.cnf
wait_timeout=31536000  
interactive_timeout=31536000  

加大wait_timeout的时间。

But 现实环境中需要你考虑的是:

  1. 你设置多久检查一次连接有效的时间 依据是什么?
  2. 默认加大/减小wait_timeout除了解决当前问题,会不会带来其他影响?

个人当前觉得此题 第一需考虑的是:
你业务当前高峰期mysql_connection是多少?保留多久connection在高峰期都不会撑爆你数据库连接池?
如果你知道这个池-那么是改mysql ?还是改c3p0?还是双管齐下都是有据可循且不会带来后遗症的-最佳解决方案

如我当前有环境,一个现网的后台管理系统,使用人数在50以内,那么我wait_timeout 就是默认8小时,c3p0不用做连接有效性检查等,都是万事ok的。

而我还有一个EPG前台管理系统,用户量在300万以内,如果我wait_timeout为8小时,那我一到高峰期肯定就是死翘翘的,会有太多的TCP连接没关闭,
数据库连接数肯定是不够的。
因EPG的一个访问-一次对数据库操作量不大,查询完数据就完成ok啦,wait_timeout 设置在120s内应该是够用啦,那么相对应的c3p0中 设置小于wait_timeout 的时间有效性检查 -就能确保获取到连接是有效的。

请根据业务场景,来配置参数,不要解决了A问题,带来了B问题。



作者:灼灼2015
链接:https://www.jianshu.com/p/69dcae4454b3
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

MySQL中interactive_timeout和wait_timeout的区别

在用mysql客户端对数据库进行操作时,打开终端窗口,如果一段时间没有操作,再次操作时,常常会报如下错误:

ERROR 2013 (HY000): Lost connection to MySQL server during query
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...

 

这个报错信息就意味着当前的连接已经断开,需要重新建立连接。

 

那么,连接的时长是如何确认的?

其实,这个与interactive_timeout和wait_timeout的设置有关。

 

首先,看看官方文档对于这两个参数的定义

interactive_timeout

默认是28800,单位秒,即8个小时

The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the CLIENT_INTERACTIVE option to mysql_real_connect(). See also wait_timeout.

 

wait_timeout

默认同样是28800s

The number of seconds the server waits for activity on a noninteractive connection before closing it.

On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()). See also interactive_timeout.

 

根据上述定义,两者的区别显而易见

1> interactive_timeout针对交互式连接,wait_timeout针对非交互式连接。所谓的交互式连接,即在mysql_real_connect()函数中使用了CLIENT_INTERACTIVE选项。

     说得直白一点,通过mysql客户端连接数据库是交互式连接,通过jdbc连接数据库是非交互式连接。 

2> 在连接启动的时候,根据连接的类型,来确认会话变量wait_timeout的值是继承于全局变量wait_timeout,还是interactive_timeout。

 

下面来测试一下,确认如下问题

1. 控制连接最大空闲时长的是哪个参数。

2. 会话变量wait_timeout的继承问题

 

Q1:控制连接最大空闲时长的是哪个参数

A1:wait_timeout

验证

只修改wait_timeout参数

复制代码
mysql> select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout');
+---------------------+----------------+
| variable_name       | variable_value |
+---------------------+----------------+
| INTERACTIVE_TIMEOUT | 28800          |
| WAIT_TIMEOUT        | 28800          |
+---------------------+----------------+
2 rows in set (0.03 sec)

mysql> set session WAIT_TIMEOUT=10;
Query OK, 0 rows affected (0.00 sec)
-------等待10s后再执行
mysql> select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout');
ERROR 2013 (HY000): Lost connection to MySQL server during query
复制代码

可以看到,等待10s后再执行操作,连接已经断开。

 

只修改interactive_timeout参数

复制代码
mysql> select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout');
+---------------------+----------------+
| variable_name       | variable_value |
+---------------------+----------------+
| INTERACTIVE_TIMEOUT | 28800          |
| WAIT_TIMEOUT        | 28800          |
+---------------------+----------------+
2 rows in set (0.06 sec)

mysql> set session INTERACTIVE_TIMEOUT=10;
Query OK, 0 rows affected (0.00 sec)
----------等待10s后执行 mysql
> select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout'); +---------------------+----------------+ | variable_name | variable_value | +---------------------+----------------+ | INTERACTIVE_TIMEOUT | 10 | | WAIT_TIMEOUT | 28800 | +---------------------+----------------+ 2 rows in set (0.06 sec)
复制代码

 

Q2:会话变量wait_timeout的继承问题

A2:如果是交互式连接,则继承全局变量interactive_timeout的值,如果是非交互式连接,则继承全局变量wait_timeout的值。

验证:

只修改全局变量interactive_timeout的值

复制代码
mysql> select variable_name,variable_value from information_schema.global_variables where variable_name in ('interactive_timeout','wait_timeout'); 
+---------------------+----------------+ | variable_name | variable_value | +---------------------+----------------+ | INTERACTIVE_TIMEOUT | 28800 | | WAIT_TIMEOUT | 28800 | +---------------------+----------------+ 2 rows in set (0.13 sec) mysql> set global INTERACTIVE_TIMEOUT=10; Query OK, 0 rows affected (0.00 sec) mysql> select variable_name,variable_value from information_schema.global_variables where variable_name in ('interactive_timeout','wait_timeout');
+---------------------+----------------+ | variable_name | variable_value | +---------------------+----------------+ | INTERACTIVE_TIMEOUT | 10 | | WAIT_TIMEOUT | 28800 | +---------------------+----------------+ 2 rows in set (0.00 sec)
复制代码

 

开启另外一个mysql客户端,查看会话变量的值

复制代码
mysql> select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout');
+---------------------+----------------+ | variable_name | variable_value | +---------------------+----------------+ | INTERACTIVE_TIMEOUT | 10 | | WAIT_TIMEOUT | 10 | +---------------------+----------------+ 2 rows in set (0.00 sec)
复制代码

发现,WAIT_TIMEOUT的值已经变为10了。

 

但通过jdbc测试,wait_timeout的值依旧是28800

复制代码
public class Jdbc_test {
    @SuppressWarnings("static-access")
    public static void main(String[] args) throws Exception {
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
         String url = "jdbc:mysql://192.168.244.10:3306/test";
         String user = "root";
         String password = "123456";
         Class.forName("com.mysql.jdbc.Driver");
         conn = DriverManager.getConnection(url, user, password);
         stmt = conn.createStatement();
         String sql = "select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout')";
         rs = stmt.executeQuery(sql);
         while (rs.next()) {
             System.out
                     .println(rs.getString(1)+":  "+rs.getString(2));
         }
    }
}
复制代码

结果输出如下:

INTERACTIVE_TIMEOUT:  10
WAIT_TIMEOUT:  28800

 

 只修改全局变量wait_timeout的值

复制代码
mysql> select variable_name,variable_value from information_schema.global_variables where variable_name in ('interactive_timeout','wa
it_timeout');+---------------------+----------------+
| variable_name       | variable_value |
+---------------------+----------------+
| INTERACTIVE_TIMEOUT | 28800          |
| WAIT_TIMEOUT        | 28800          |
+---------------------+----------------+
2 rows in set (0.17 sec)

mysql> set global WAIT_TIMEOUT=20;
Query OK, 0 rows affected (0.07 sec)

mysql> select variable_name,variable_value from information_schema.global_variables where variable_name in ('interactive_timeout','wa
it_timeout');+---------------------+----------------+
| variable_name       | variable_value |
+---------------------+----------------+
| INTERACTIVE_TIMEOUT | 28800          |
| WAIT_TIMEOUT        | 20             |
+---------------------+----------------+
2 rows in set (0.00 sec)
复制代码

 

开启另外一个mysql客户端,查看会话变量的值

复制代码
mysql> select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout');
+---------------------+----------------+
| variable_name       | variable_value |
+---------------------+----------------+
| INTERACTIVE_TIMEOUT | 28800          |
| WAIT_TIMEOUT        | 28800          |
+---------------------+----------------+
2 rows in set (0.03 sec)
复制代码

WAIT_TIMEOUT的值依旧是28800.

 

查看jdbc的结果

复制代码
public class Jdbc_test {
    @SuppressWarnings("static-access")
    public static void main(String[] args) throws Exception {
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
         String url = "jdbc:mysql://192.168.244.10:3306/test";
         String user = "root";
         String password = "123456";
         Class.forName("com.mysql.jdbc.Driver");
         conn = DriverManager.getConnection(url, user, password);
         stmt = conn.createStatement();
         String sql = "select variable_name,variable_value from information_schema.session_variables where variable_name in ('interactive_timeout','wait_timeout')";
         rs = stmt.executeQuery(sql);
         while (rs.next()) {
             System.out
                     .println(rs.getString(1)+":  "+rs.getString(2));
         }
         Thread.currentThread().sleep(21000);
         sql = "select 1 from dual";
         rs = stmt.executeQuery(sql);
         while (rs.next()) {
             System.out
                     .println(rs.getInt(1));
         }

    }
}
复制代码

查看jdbc的结果

INTERACTIVE_TIMEOUT:  28800
WAIT_TIMEOUT:  20

同时,新增了一段程序,等待20s后,再次执行查询,报如下错误:

复制代码
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 12 ms ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3009)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2895)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3438)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2477)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1422)
    at com.victor_01.Jdbc_test.main(Jdbc_test.java:29)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2452)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2906)
    ... 8 more
复制代码

 

总结

1. 控制连接最大空闲时长的wait_timeout参数。

2. 对于非交互式连接,类似于jdbc连接,wait_timeout的值继承自服务器端全局变量wait_timeout。

    对于交互式连接,类似于mysql客户单连接,wait_timeout的值继承自服务器端全局变量interactive_timeout。

3. 判断一个连接的空闲时间,可通过show processlist输出中Sleep状态的时间

复制代码
mysql> show processlist;
+----+------+----------------------+------+---------+------+-------+------------------+
| Id | User | Host                 | db   | Command | Time | State | Info             |
+----+------+----------------------+------+---------+------+-------+------------------+
|  2 | root | localhost            | NULL | Query   |    0 | init  | show processlist |
|  6 | repl | 192.168.244.20:44641 | NULL | Sleep   | 1154 |       | NULL             |
+----+------+----------------------+------+---------+------+-------+------------------+
2 rows in set (0.03 sec)
复制代码

 

参考

1. http://www.cnblogs.com/cenalulu/archive/2012/06/20/2554863.html

2. http://www.cnblogs.com/Alight/p/4118515.html

3. http://ronaldbradford.com/blog/sqlstatehy000-general-error-2006-mysql-server-has-gone-away-2013-01-02/

10 Tips for a Fast Joomla Website

Is your Joomla website slow? You should definitely work on that: users hate slow websites, and they may leave your site earlier then they otherwise would, resulting in low conversion. Any site that needs more then 2 seconds to load could be at risk. Also, Google even says that site speed is used to determine your place in their rankings. What is nice to know: it should not be that hard to improve the speed of your Joomla website. While sometimes you can hear stories that Joomla is slow, this will usually be because of incorrect setup or bad hosting companies, and you can work on both. Especially if you know what to look at, improving the speed of your Joomla website may not be too hard, and making it load in less then a second should be possible.  
10 Tips for a Fast Joomla Website
 

Before jumping off, first make sure to check how fast your website currently is. There are a number of online tools that can help you to determine this. All of the following ones also give you detailed information about any possible issues:

Now that we know our current performance, let's start optimizing. One thing to keep in mind: Backup first! Then make step by step improvements, and after every optimization step, check that your site still functions correctly (make sure to clear your cache between steps).

1) Choose a good webhost

Choosing the right host for your website is crucial. Regardless of how well you may have optimized your website, a bad host can screw up all your efforts, and make your site slow. Before making your choice, check out reviews and forums. Especially avoid free hosts, sooner or later you will feel why they are free..... Also compare shared and dedicated hosting packages. Dedicated usually means faster, but of course it will be more expensive.

2) Joomla Cache

Cache is a way of serving pre-generated content to your users. This means that the server does not have to look up all information requested in the database every time a page is requested. Instead, a saved 'view' is offered to the browser (if your content has changed, this means the users temporarily receive old information, unless you clear your cache). Joomla is capable of serving 3 types of cache:

  • Component views
  • Module views
  • Page views

The first 2 settings are determined by one setting in your Global Configuration:

joomla-cache

Set it to Conservative. Optionally you can also set the time different than the default of 15 minutes. If globally, cache is switched on, you can switch it off again for specific modules from the Advanced tab in selected modules.

Page views are only cached if you switch on the System - Cache plugin in the Plugin Manager:

system-cache

Just set it to Enabled, and leave default parameters. Be aware that there can sometimes be issues with caching, especially for dynamic pages like contactforms, captcha's, etc.

If you have issues with cache, there are extensions that can assist you with this:

3) G-Zip

In Global Configuration, on the Server tab, you will find the setting to turn on G-zip:

g-zip

With G-zip turned on, your pages are compressed in a zip-file, sent to the browser on your PC, and unpacked there. Except for really ancient versions of IE, it is supported in all browsers, and should be safe to turn on.

After you have switched it on, you can use a tool to check the compression rate, like this one: www.feedthebot.com/tools/gzip. Often you will find that your content has been compressed over 50%!

If you find that it did not work, it could be that your host does not support mod_gzip, or has it switched off.

4) Remove unneeded extensions

Pick your extensions wisely. Some extensions have a horrible effect on your site speed. The major trouble makers are:

  • Social media scripts like counters for likes and tweets. They usually need additional javascripts, and connect to the remote network, which can slow you down terribly.
  • Large sliders and image shows. All images in the slideshow need to be loaded for the slider to function, which may take long with full-width images.
  • Also scripts like Googla Analytics, Google Webfonts, etc. can slow you down more then you would expect...

Even if you need features like these, at least think about whether you actually need them on your home-page. If you can off-load them to a contact-page or portfolio-page, only that page is affected!

5) Browser caching in .htaccess

Assuming you have renamed your htaccess.txt file to .htaccess, you can use it to add some code which tells your browser not to request specific image types from the server if they are already present on your PC. As often images make up a large chunck of a given web page, this saves a lot of bandwidth. A sample that could work is the following:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType etc, etc.
</IfModule>

See this article for some more advanced possibilities with .htaccess.

6) Optimize your images

Images are often responsible for more KB's then the rest of your web page, so they need to be optimized. Most importantly, make sure to use correctly-sized images. Secondly though, you can often further reduce the size of images dramatically by using compression tools that strip unnecessary data that you even didn't know was there. Even if you used the correct procedure to save images from Photoshop using Save for Web and Devices, a .png can still lose up to another 75% without visually being affected!!! Some tools that can help you to do so are:

Advanced users can also use techniques like image sprites and Base64 encoding.

7) Use a CDN

If you use a Content Delivery Network, your static files will not be served from the location of your web host, but from the global network of servers of your CDN provider. This ensures that users far away from the server receive their files from the nearest location, except for the HTML code that contains the content that often changes.

This sounds complicated, but actually it is quite easy to implement, and not even that expensive. It is not only good for sites operating globally, but also for sites in large countries.

8) Optimize CSS + Javascript

Especially modern sites often have many CSS and Javascript files, They all add up in size AND number of HTTP-requests. Also they often stop further loading of the page while they are executing. Luckily, there are techniques to overcome many of these issues:

  • Compress these files. This removes white space. While this affects readability of the code, it often saves dozens of percents in size.
  • Combine multiple files into one. Instead of many separate files, you only have one large CSS and one large JS file.
  • Use a defer or async attribute in the scripts to dealy execution.

Make sure your site still works as desired, sometimes some files need to be excluded. All this sounds nice, but it also can seem awfully complicated to implemented. Partially, you can perform these optimizations in your template, but what about the files that are not loaded from your template, but from the Joomla core, or extensions? Luckily, there is a nice solution: extensions! This brings us to item 9:

9) Speed optimization extensions

There are a number of extensions that can be a great help in speeding up your site. They especially address the issues described under item 8, while they often have some extra options under the Advanced tab. You should really try them out, results can be stunning! The best known are the following:

  • JCH-Optimize: Excellent for combining and compressing your files. It also offers option to set the defer and async parameter for Javascript. It is even capable of configuring images to sprites.
  • JBetolo: Similar to JCH-Optimize, while it also offers CDN-support, .htaccess tuning, and even Smush.it support.
  • Yireo ScriptMerge: The usual CSS and JS compression / combining capabilities. Extra are the options to base64-encode small images, plus support for jsmin-binary and WebP.
  • aeSecure: A new extension to watch out for. Mainly a security extension, but it also offers speed improvements.

10) Optimize for mobile devices

Even if your site loads fast on a desktop, it may not perform very well on mobile devices. If you use the Google Pagespeed tool to check the speed of your site, you may have seen a separate tab for mobile performance. Even with improved techniques like 4G, sites still may not load fast enough.

The key to improving this is to only load what is really needed. Hiding stuff with bootstrap classes like hidden-phone and hidden-tablet does not decrease bandwidth needed. One possibility is to use user-agent detection to check if you are on a mobile device, not just on a resized browser window. Having detected a mobile agent, you can then selectively disable module positions.

The NoNumber Advanced Module Manager is a tool that can be used to implement this.

了解Windows Server 2008服务器的系统状态备份内容

Ntbackup是大家熟悉的在Windows 2003 Server系统中用来进行系统备份的工具,Windows Server 2008和Windows Server 2008 R2中用Windows Server backup代替了Ntbackup。那么Windows Server backup在进行系统状态备份时,究竟是如何决定哪些文件时系统状态文件的呢?

当完成一个系统状态备份之后,我们可以通过检查C:\Windows\logs\WindowsServerBackup中的备份日志来得到本系统状态文件的完整列表。可以想象,在域控制器上的系统状态文件列表和Web服务器上的列表是不同的。那系统又是如何得知这些不同的呢?

要回答以上的问题,我们先要理解Snapshot。Snapshot即所谓的系统快照工具,对于服务器来说,利用其可以轻松地创建、加载、恢复系统快照,以实现服务器系统的备份和还原。Windows Server backup并不是对系统当前磁盘的物理文件进行备份,而是请操作系统先创建一个系统状态的Snapshot。我们可以把这个Snapshot看作是一个虚拟的磁盘。Windows Server backup仅仅对这个虚拟磁盘作备份操作。

实际上, Windows Server backup服务本身并不十分理解系统状态究竟应该包括那些具体文件。当操作系统创建Snapshot时 ,它会查询当前系统中安装的VSS Writers。如果某个Writer的VSS_USAGE_TYPE属性设置为VSS_UT_BOOTABLESYSTEMSTATE 或VSS_UT_SYSTEMSERVICE。这个Writers将负责提供他认为需要在系统状态中备份的文件内容。

typedef enum VSS_USAGE_TYPE {

VSS_UT_UNDEFINED  = 0,

VSS_UT_BOOTABLESYSTEMSTATE   = 1,

VSS_UT_SYSTEMSERVICE = 2,

VSS_UT_USERDATA   = 3,

 VSS_UT_OTHER  = 4

} ;

在Windows server 2008和Windows Server 2008 R2系统中,系统状态备份的绝大多数内容由System Writer提供。System Writer运行于Cryptographic Services (CryptSvc) 的系统服务中。一般情况下,他用于枚举以下的系统文件:

  • 所有系统安装的静态文件. 它包括所有被Windows Resource Protection (WRP)保护的文件.

  • 所有Windows Side-by-Side (WinSxS) 目录的内容

  • 所有即插即用的驱动程序

  • 所有运行在用户模式的服务以及非即插即用的驱动程序

  • 所有CryptSvc 所拥有的目录文件(catalog)

了解以上的工作机制,我们再回到之前的一个问题:有没有办法改变或排除一些系统状态信息的的内容?答案是肯定的。但这不是Windows Server backup需要完成的工作,而更多是依赖于提供系统状态信息的各个VSS Writers。如果某些文件是由一个特定的Write枚举出来的而这个Write又提供相应的接口来改变它所枚举的内容,我们就可以改变系统备份具体内容。例如,对于System Writer,我们可以通过ExcludedBinaryPaths的注册表来排出一些文件 (在Windows Server 2008
R2 SP1中已经包含了这个设置。对于Windows Server 2008和Windows Server 2008 R2,需要安装升级包http://support.microsoft.com/?id=980794才能使用这个设置)。

希望以上的信息对大家了解Windows Server 2008服务器的系统状态备份有所帮助。

 

本博文仅供参考,微软公司对其内容不作任何责任担保或权利赋予。

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.