如何在不重新安装服务的情况下停止和重启 VM
How to stop and restart VM without reinstall service
场景
Cloudify 2.7 应用程序运行一个tomcat服务实例
目标
我想停止(关闭)并启动使用 OpenStack API 的 VM 托管 tomcat,无需 Cloudify 重新安装 tomcat 配方。
我尝试做的事情
我尝试使用维护模式,遵循this指南:
Setting a service instance to maintenance mode will disable host machine failure detection for that specific service instance.
This means that during the specified time period, a failure or a restart of a service instance host machine will NOT result in a provisioning of a new machine and service instance.
所以,我执行了以下命令:
1. cloudify@default> connect VM_MNG_IP
2. cloudify@default> use-application <application_name>
3. cloudify@tommy> invoke <service_name> cloudify:start-maintenance-mode 300
4. Shut off the tomcat VM using OpenStack API
5. Start the tomcat VM using OpenStack API
之后,我在Cloudify的Orchestrator日志中看到的是tomcat服务的重新安装过程。换句话说,tomcat VM 现在托管两个 tomcat 处理单元。
ls -al /root/gigaspaces/work/processing-units
<application_name>_tomcat_1_1278947587
<application_name>_tomcat_1_2029943570
有人可以建议我应该怎么做才能实现我的目标吗?
这是 Cloudify 2.7 提供的默认 tomcat 服务的正确行为 - 重启后,tomcat 文件会重新下载并部署到本地。
如果您想要不同的行为,您可能需要调整 tomcat 配方以将 tomcat 文件保存在不同的位置(默认安装将所有文件保存在每个实例的工作目录中,它将在重新启动后被替换)。您可以更改配方以查找现有安装并使用它(如果存在)。
查看以下文件:
https://github.com/CloudifySource/cloudify-recipes/blob/master/services/tomcat/tomcat_init.groovy
https://github.com/CloudifySource/cloudify-recipes/blob/master/services/tomcat/tomcat_install.groovy
您可能需要编辑这些文件才能实现您的目标。请注意如何将 catalina_base 设置为上下文 属性,并且 AntBuilder 用于下载 tomcat 安装并将其保存到共享位置。这些是您需要更改的文件。
请考虑 Cloudify 2.x 已结束生命周期 - 您应该考虑迁移到 Cloudify 3:http://getcloudify.org/guide/3.1/quickstart.html
场景
Cloudify 2.7 应用程序运行一个tomcat服务实例
目标
我想停止(关闭)并启动使用 OpenStack API 的 VM 托管 tomcat,无需 Cloudify 重新安装 tomcat 配方。
我尝试做的事情
我尝试使用维护模式,遵循this指南:
Setting a service instance to maintenance mode will disable host machine failure detection for that specific service instance. This means that during the specified time period, a failure or a restart of a service instance host machine will NOT result in a provisioning of a new machine and service instance.
所以,我执行了以下命令:
1. cloudify@default> connect VM_MNG_IP
2. cloudify@default> use-application <application_name>
3. cloudify@tommy> invoke <service_name> cloudify:start-maintenance-mode 300
4. Shut off the tomcat VM using OpenStack API
5. Start the tomcat VM using OpenStack API
之后,我在Cloudify的Orchestrator日志中看到的是tomcat服务的重新安装过程。换句话说,tomcat VM 现在托管两个 tomcat 处理单元。
ls -al /root/gigaspaces/work/processing-units
<application_name>_tomcat_1_1278947587
<application_name>_tomcat_1_2029943570
有人可以建议我应该怎么做才能实现我的目标吗?
这是 Cloudify 2.7 提供的默认 tomcat 服务的正确行为 - 重启后,tomcat 文件会重新下载并部署到本地。
如果您想要不同的行为,您可能需要调整 tomcat 配方以将 tomcat 文件保存在不同的位置(默认安装将所有文件保存在每个实例的工作目录中,它将在重新启动后被替换)。您可以更改配方以查找现有安装并使用它(如果存在)。
查看以下文件:
https://github.com/CloudifySource/cloudify-recipes/blob/master/services/tomcat/tomcat_init.groovy https://github.com/CloudifySource/cloudify-recipes/blob/master/services/tomcat/tomcat_install.groovy
您可能需要编辑这些文件才能实现您的目标。请注意如何将 catalina_base 设置为上下文 属性,并且 AntBuilder 用于下载 tomcat 安装并将其保存到共享位置。这些是您需要更改的文件。
请考虑 Cloudify 2.x 已结束生命周期 - 您应该考虑迁移到 Cloudify 3:http://getcloudify.org/guide/3.1/quickstart.html