In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail the example analysis of Openstack files and metadata injection for everyone. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
openstack can inject files into the instance when creating the instance, or pass some parameters to the instance, which can be very useful in some cases, such as modifying the root password, injecting the ssh key, customizing the instance (for example, later) Note: Only the failure of injecting files will cause the instance creation process to fail. The support for injection can be loop, guestfs, nbd, mount, etc., where mount is not secure. Default usage: img_handlers="loop,nbd,guestfs" For nbd, under ubuntu only need to load the kernel module (modprobe nbd) and install qemu-nbd under centos is more troublesome, need to manually compile nbd and qemu-nbd Guestfs method is relatively simple, just need to install the correct package can, under ubuntu install guestmount, centos need to install libguestfs and fuse
This document is in nova command line mode, graphics support for some parameters is not yet available
To use nova, you need to set the following parameters
export OS_USERNAME=user
export OS_PASSWORD=pass
export OS_TENANT_NAME='tenant'
export OS_AUTH_URL=http://localhost:5000/v2.0
inject ssh key
a) Create key (ssh-keygen)
b) Add key pair
i. nova keypair-add --pub_key .ssh/id_rsa.pub mykey
c) Inject the key when creating an instance
i. nova boot --key_name mykey --image id_of_image --flavor 1 name_of_instance
Note: id_of_image can be obtained via nova image-list
injection file
If I wanted to inject the.vimrc file into a newly created instance, I could:
nova boot --file /root/.vimrc=/root/.vimrc --image id_of_image --flavor 1 name_of_instance
Note: Multiple files can be injected (up to 5), just write multiple--file
inject metadata
Key-value pairs can be passed into the instance through--meta, and after injection, they will be written in the/meta.js file and stored in the/meta.js file of the virtual machine in a similar way to python dictionary.
nova boot --meta key2=value2 --meta key1=value1 --image id_of_image --flavor 1 name_of_instance
Cat/meta.js #In virtual machines
{"key2": "value2", "key1": "value1"}
Examples:
Suppose we want the newly created instance to run an initialization script, but this script will vary depending on different requirements, we can do so
When creating the mirror template, add it to/etc/rc.local
/opt/init.py
Init.py can read injected metadata (meta.js) such as
{"url": "http://example.com/init.sh"}
Get the address of the initialization script, download it and execute it. The advantage is that you can have multiple initialization files for different needs without modifying the template.
About "Openstack file and metadata injection example analysis" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.