概述
首先介绍我的实验环境
源IIS7服务器
OS:Windows server 2008 Datacenter
机器名称:web1
IP:192.168.1.20/24
安装的IIS Role Services如下


目标IIS7服务器
OS:Windows server 2008 Datacenter
机器名称:web2
IP:192.168.1.30/24
安装与源IIS7相同的Role Services
笔者的环境中共有里面有三个测试网站,如下图所示


网站目录放在E:\web,里面共有3个网站。日志目录放在E:\IISlog,如下图所示


其中web目录给iusr和IIS_iusrs分配了只读权限,Administrator和system分配了完全控制权限,如下图所示
Iusr和IIS_iusrs的权限




Administrators和system的权限




介绍完实验环境后,接下来介绍IIS7的用户和组,IIS7使用IUSR内建帐号替代了以前的IUSR_MachineName帐号,使用IIS_IUSRS内建组替代以前了IIS_WPG组,IUSR是个内建帐号,他不再需要密码。逻辑上您能够认为他就是NETWORKSERVICE或LOCALSERVICE帐号。内建的帐号和组是由操作系统确保的,这样就能够确保有一个唯一的SID,IIS甚至做得更好,他确保了新的帐号名称和组名称永远不会被本地化。例如,无论您安装的是那种语言版本的Windows,IIS帐号名称将永远是IUSR,而组名称将永远是IIS_IUSRS。
这对于我们将网站迁移到另外一台IIS7的最大好处是可以使用xcopy /o无缝拷贝文档连同他们的所有权和ACL信息到不同的机器上
参考资料Understanding User and Group Accounts with IIS7
URL: http://www.IIS.net/1026/SinglePageArticle.ashx
接下来介绍IIS7网站的配置文件,IIS7涉及到的配置文件就是站点下的Web.config和以及C:\Windows\System32\inetsrv\config下的配置文件,都是基于文本的XML文件。其中C:\Windows\System32\inetsrv\config\applicationHost.config里面的physicalPath定义了每个网站的物理路径,如果目标IIS7服务器的网站目录与源IIS7服务器网站目录不一致,那么在将applicationHost.config复制到目标IIS7服务器后,还要将physicalPath的路径改成目标服务器中的实际路径,以下为web1中C:\Windows\System32\inetsrv\config\applicationHost.config里面涉及physicalPath的内容。
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<site name="hello" id="2">
<application path="/" applicati>
<virtualDirectory path="/" physicalPath="E:\web\Hello" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:www.hello.com" />
</bindings>
</site>
<site name="diy" id="3">
<application path="/" applicati>
<virtualDirectory path="/" physicalPath="E:\web\diy" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:www.diy.com" />
</bindings>
</site>
<site name="beijing2008" id="4">
<application path="/" applicati>
<virtualDirectory path="/" physicalPath="E:\web\beijing2008" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:www.beijing2008.com" />
</bindings>
</site>
在介绍完后实验环境及相关的背景知识后,接下来就开始进行迁移操作
将目标IIS7服务器也就是web2中执行以下命令,将源IIS7服务器也就是web1的网站内容复制到web2的相同路径
xcopy \\192.168.1.20\e$\web /o /e /h /r e:\web
在web2执行以下命令,将web1的日志复制到web2的相同路径
xcopy \\192.168.1.20\e$\IISlog /o /e /h /r e:\IISlog
在web2执行以下命令,将web1的所有IIS配置文件复制到web2的相同路径
xcopy \\192.168.1.20\c$\Windows\System32\inetsrv\config /o /e /h /r c:\windows\system32\inetsrv\config
复制完成后,检查web2的网站目录权限,发现与web1网站目录所设的权限一致,如下图所示




然后打开web2的IIS管理界面,发现里面的内容与web1的内容完全一样!


测试迁移后的网站是否可以正常访问,在这次实验环境中,通过修改web2的hosts来解释域名


在web2打开IE浏览器,分别测试以上三个网址,结果非常成功!






总结:IIS7服务器之间迁移是非常简单的,由于IIS7将所有配置都存在xml文件中,不再使用二进制的metabase来存储配置,这对于迁移一个有成百上千网站的Web服务器无疑提供了更多的手段和方法。在我的实验环境中,只需要通过一个xcopy命令就可以从一个iis7服务器将所有网站完全迁移到另外一个IIS7网站。
最后
以上就是文艺睫毛膏为你收集整理的Win2008 iis7服务器中批量迁移到另外一台IIS7的实现步骤的全部内容,希望文章能够帮你解决Win2008 iis7服务器中批量迁移到另外一台IIS7的实现步骤所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复