如何从开发人员控制台向现有VM添加启动脚本? [英] How do I add a startup script to an existing VM from the developer console?
本文介绍了如何从开发人员控制台向现有VM添加启动脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Google Cloud Platform上已有一个已经配置的虚拟机.它是在没有启动脚本的情况下创建的,但我现在想添加一个. /p>
如何从console.developers.google.com网络界面添加它?
解决方案
您可以通过创建新的自定义元数据字段将启动脚本添加到已创建的VM.请按照下列步骤操作:
- 进入虚拟机的配置页面:导航至 https://console.developers.google.com 单击您的项目.转到计算"->计算引擎"->"VM实例".单击您的VM的名称.
- 向下滚动到自定义元数据".点击修改.
- 创建一个新的元数据字段.将密钥设置为
startup-script
. -
将启动脚本粘贴到value字段中.不要忘记shebang.这是一个有效脚本的示例.
#! /bin/bash apt-get update apt-get install -y apache2 cat <<EOF > /var/www/index.html <html><body><h1>Hello World</h1> <p>This page was created from a simple startup script!</p> </body></html> EOF
- 重新启动您的VM.享受令人赞叹的启动脚本的收益.
I have an existing, already configured VM on Google Cloud Platform. It was created without a startup script, but I'd like to add one now.
How do I add it from the console.developers.google.com web interface?
解决方案
You can add a startup script to an already created VM by creating a new custom metadata field. Follow these steps:
- Get to your VM's configuration page: Navigate to https://console.developers.google.com Click your project. Go to Compute -> Compute Engine -> VM Instances. Click the name of your VM.
- Scroll down to Custom Metadata. Click Edit.
- Create a new metadata field. Set the key to
startup-script
. Paste your startup script into the value field. Don't forget the shebang. Here's an example of a valid script.
#! /bin/bash apt-get update apt-get install -y apache2 cat <<EOF > /var/www/index.html <html><body><h1>Hello World</h1> <p>This page was created from a simple startup script!</p> </body></html> EOF
- Restart your VM. Enjoy the yields of your awesome startup script.
这篇关于如何从开发人员控制台向现有VM添加启动脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文