在具有多个 WFE 的服务器场环境中部署计时器作业的最佳实践
我有一个计时器工作,我只想为整个农场每天运行一次。如何
- 在多 WFE 环境中部署它?我是在每个 WFE 中运行 stsadm -o deploysolution 命令,还是仅在我想要运行该命令的地方运行?
- 我应该在哪里激活该功能?它应该仅从特定的 WFE 激活吗?
- SPJobLockType 的值应该是多少。
i have a timer job which i want to run only once per day, for the entire farm. How do I
- Deploy it in a multiple WFE environment? Do I run the stsadm -o deploysolution command in every WFE, or just the one where I want to run it?
- Where should i activate the feature? Should it be activated only from a particular WFE?
- What should be the value of the SPJobLockType.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您需要一个场范围的功能,来安装运行此作业的服务。这是我的做法(老实说,使用同事编写的代码,但他不这么认为)。
使用功能事件接收器创建 feature.xml 文件。
在事件接收器内部:
这将创建场中每台服务器上可用的服务。
有关子类的更多详细信息:
...
当然还有 Execute 方法。
现在,在中央管理中,转到服务器上的操作/服务。选择所需的服务器并启动服务。
回答您的问题清单:
1. 解决方案只需部署一次,独立于 WFE。
2. 由于该功能是场范围内的,因此应在 Central Admin 中激活。
3. SPJobLockType 是 SPJobLockType.Job
这并不完全是您想象的那样,但它的优点是让您可以轻松选择作业的运行位置,即使在安装该功能很久之后(例如,如果服务器因其他内容而过载) 。
OnFeatureActivated 方法可以更智能,它会检查每个服务器是否存在该服务,并在需要时添加它。但在 OnFeatureDeactivated 中从每个服务中删除该服务更简单。因此,如果您添加新服务器,请停用然后重新激活该功能。
It looks like you need a farm-scoped feature, that installs a service that runs this job. Here is how I did it (using code written by a colleague, to be honest, but he's not in SO).
Create a feature.xml file with a feature event receiver.
Inside the event receiver:
This creates a service available on every server in the farm.
Some more details on the subclasses:
...
and of course the Execute method.
Now, in Central Admin, go to Operations / Services on server. Choose the desired server and start the service.
To answer your list of questions:
1. Deploy the solution just once, independently of a WFE.
2. As the feature is farm-scoped, it should be activated in Central Admin.
3. The SPJobLockType is SPJobLockType.Job
This is not exactly what you imagined, but it has the advantage of letting you easily choose where the job is run, even long after you install the feature (e.g. if a server becomes overloaded with other stuff).
The OnFeatureActivated method could be smarter and check for each server if the service exists and add it if needed. But it is simpler to remove the service from every service in OnFeatureDeactivated. So, if you add new servers, deactivate then reactivate the feature.