{"id":34950,"date":"2024-09-05T16:19:18","date_gmt":"2024-09-05T09:19:18","guid":{"rendered":"http:\/\/jupitek.maudemo.vip\/index.php\/2024\/09\/05\/use-akamais-metadata-service-with-cloud-init-on-any-distribution\/"},"modified":"2024-09-05T16:19:18","modified_gmt":"2024-09-05T09:19:18","slug":"use-akamais-metadata-service-with-cloud-init-on-any-distribution","status":"publish","type":"post","link":"https:\/\/jupitek.maudemo.vip\/index.php\/2024\/09\/05\/use-akamais-metadata-service-with-cloud-init-on-any-distribution\/","title":{"rendered":"S\u1eed d\u1ee5ng Akamai\u2019s Metadata Service v\u1edbi Cloud-Init tr\u00ean m\u1ecdi h\u1ec7 \u0111i\u1ec1u h\u00e0nh"},"content":{"rendered":"<p><a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/metadata\/\">D\u1ecbch v\u1ee5 Metadata<\/a>&nbsp;c\u1ee7a Akamai&nbsp;cung c\u1ea5p cho b\u1ea1n kh\u1ea3 n\u0103ng t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u1ea5u h\u00ecnh h\u1ec7 th\u1ed1ng khi tri\u1ec3n khai Compute Instance. \u0110i\u1ec1u n\u00e0y ch\u1ee7 y\u1ebfu \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n b\u1eb1ng c\u00e1ch th\u00eam d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng d\u01b0\u1edbi d\u1ea1ng c\u00e1c t\u1eadp l\u1ec7nh cloud-config. C\u00e1c t\u1eadp l\u1ec7nh n\u00e0y \u0111\u01b0\u1ee3c x\u1eed l\u00fd b\u1edfi ph\u1ea7n m\u1ec1m cloud-init ch\u1ea1y trong h\u1ec7 th\u1ed1ng c\u1ee7a phi\u00ean b\u1ea3n m\u1edbi tri\u1ec3n khai. \u0110\u1ec3 t\u00ecm hi\u1ec3u th\u00eam v\u1ec1 c\u00e1ch th\u00eam d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng v\u00e0 \u0111\u1ecbnh d\u1ea1ng d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng, h\u00e3y xem&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/metadata\/#add-user-data\">Th\u00eam d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng khi tri\u1ec3n khai Compute Instance<\/a>&nbsp;.<\/p>\n<p>Cloud-init \u0111\u00e3 h\u1ed7 tr\u1ee3 d\u1ecbch v\u1ee5 Metadata c\u1ee7a Akamai k\u1ec3 t\u1eeb&nbsp;<a href=\"https:\/\/github.com\/canonical\/cloud-init\/releases\/tag\/23.3\" target=\"_blank\" rel=\"noreferrer noopener\">phi\u00ean b\u1ea3n 23.3.1<\/a>&nbsp;(ph\u00e1t h\u00e0nh v\u00e0o th\u00e1ng 8 n\u0103m 2023). M\u1eb7c d\u00f9 phi\u00ean b\u1ea3n cloud-init n\u00e0y \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u01b0a v\u00e0o m\u1ed9t s\u1ed1 h\u00ecnh \u1ea3nh ph\u00e2n ph\u1ed1i do Akamai cung c\u1ea5p, nh\u01b0ng h\u1ea7u h\u1ebft c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i \u0111\u1ec1u kh\u00f4ng c\u00e0i \u0111\u1eb7t cloud-init theo m\u1eb7c \u0111\u1ecbnh. H\u01a1n n\u1eefa, phi\u00ean b\u1ea3n cloud-init \u0111\u01b0\u1ee3c cung c\u1ea5p trong kho l\u01b0u tr\u1eef g\u00f3i c\u1ee7a h\u1ea7u h\u1ebft c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i \u0111\u1ec1u c\u0169 h\u01a1n v\u00e0 kh\u00f4ng t\u01b0\u01a1ng th\u00edch v\u1edbi d\u1ecbch v\u1ee5 Metadata.<\/p>\n<p>H\u01b0\u1edbng d\u1eabn n\u00e0y h\u01b0\u1edbng d\u1eabn b\u1ea1n c\u00e1ch c\u00e0i \u0111\u1eb7t phi\u00ean b\u1ea3n m\u1edbi c\u1ee7a cloud-init tr\u00ean c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i hi\u1ec7n kh\u00f4ng \u0111\u01b0\u1ee3c d\u1ecbch v\u1ee5 Metadata h\u1ed7 tr\u1ee3 ch\u00ednh th\u1ee9c. B\u1eb1ng c\u00e1ch \u0111\u00f3, b\u1ea1n c\u00f3 th\u1ec3 t\u1ea1o h\u00ecnh \u1ea3nh ph\u00e2n ph\u1ed1i Metadata-ready \u0111\u1ec3 c\u00f3 th\u1ec3 b\u1eaft \u0111\u1ea7u s\u1eed d\u1ee5ng l\u1ea1i c\u00e1c t\u1eadp l\u1ec7nh cloud-init hi\u1ec7n c\u00f3 c\u1ee7a m\u00ecnh tr\u00ean n\u1ec1n t\u1ea3ng Akamai.<\/p>\n<h2 id=\"deploy-a-compute-instance\">Tri\u1ec3n khai m\u1ed9t phi\u00ean b\u1ea3n t\u00ednh to\u00e1n<a href=\"https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/#deploy-a-compute-instance\"><\/a><\/h2>\n<p>B\u01b0\u1edbc \u0111\u1ea7u ti\u00ean l\u00e0 t\u1ea1o m\u1ed9t Compute Instance m\u1edbi ch\u1ea1y b\u1ea3n ph\u00e2n ph\u1ed1i b\u1ea1n ch\u1ecdn. N\u1ebfu b\u1ea3n ph\u00e2n ph\u1ed1i \u0111\u00e3 ch\u1ecdn \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u00e1nh d\u1ea5u l\u00e0 t\u01b0\u01a1ng th\u00edch v\u1edbi cloud-init, b\u1ea1n kh\u00f4ng c\u1ea7n ph\u1ea3i l\u00e0m theo c\u00e1c b\u01b0\u1edbc trong h\u01b0\u1edbng d\u1eabn n\u00e0y. N\u1ebfu b\u1ea3n ph\u00e2n ph\u1ed1i kh\u00f4ng t\u01b0\u01a1ng th\u00edch v\u1edbi cloud-init, h\u00e3y ti\u1ebfp t\u1ee5c v\u1edbi h\u01b0\u1edbng d\u1eabn n\u00e0y \u0111\u1ec3 t\u1ea1o m\u1ed9t h\u00ecnh \u1ea3nh t\u01b0\u01a1ng th\u00edch v\u1edbi cloud-init cho b\u1ea3n ph\u00e2n ph\u1ed1i n\u00e0y. \u0110\u1ec3 bi\u1ebft chi ti\u1ebft v\u1ec1 kh\u1ea3 n\u0103ng t\u01b0\u01a1ng th\u00edch c\u1ee7a Metadata\/cloud-init, h\u00e3y xem&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/metadata\/#availability\">T\u1ed5ng quan v\u1ec1 D\u1ecbch v\u1ee5 Metadata &gt; Kh\u1ea3 d\u1ee5ng<\/a>&nbsp;.<\/p>\n<p>Phi\u00ean b\u1ea3n n\u00e0y t\u1ea1o th\u00e0nh c\u01a1 s\u1edf cho m\u1eabu tri\u1ec3n khai cloud-init. Xem h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/platform\/get-started\/\">B\u1eaft \u0111\u1ea7u v\u1edbi Linode<\/a>&nbsp;v\u00e0&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/create\/\">T\u1ea1o phi\u00ean b\u1ea3n Compute<\/a>&nbsp;c\u1ee7a ch\u00fang t\u00f4i . C\u00e1c h\u01b0\u1edbng d\u1eabn trong h\u01b0\u1edbng d\u1eabn n\u00e0y bao g\u1ed3m c\u00e1c h\u1ec7 th\u1ed1ng d\u1ef1a tr\u00ean Debian, Ubuntu v\u00e0 RHEL (CentOS, Fedora, AlmaLinux, Rocky Linux, v.v.). C\u00e1c b\u01b0\u1edbc ch\u01b0a \u0111\u01b0\u1ee3c x\u00e1c minh v\u1edbi c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i kh\u00e1c nh\u01b0ng c\u00f3 th\u1ec3 th\u00edch \u1ee9ng v\u1edbi m\u1ed9t s\u1ed1 s\u1eeda \u0111\u1ed5i.<\/p>\n<h2 id=\"install-cloud-init\">C\u00e0i \u0111\u1eb7t Cloud-Init<a href=\"https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/#install-cloud-init\"><\/a><\/h2>\n<p>D\u1ecbch v\u1ee5 Metadata c\u1ee7a Akamai y\u00eau c\u1ea7u m\u1ed9t phi\u00ean b\u1ea3n c\u00f3 cloud-init phi\u00ean b\u1ea3n 23.3.1 tr\u1edf l\u00ean. M\u1eb7c d\u00f9 cloud-init c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t th\u00f4ng qua tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i tr\u00ean h\u1ea7u h\u1ebft c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i, nh\u01b0ng th\u00f4ng th\u01b0\u1eddng c\u00e1c phi\u00ean b\u1ea3n \u0111\u00f3 c\u0169 h\u01a1n v\u00e0 kh\u00f4ng h\u1ed7 tr\u1ee3 d\u1ecbch v\u1ee5 Metadata c\u1ee7a Akamai. C\u00e1c b\u01b0\u1edbc d\u01b0\u1edbi \u0111\u00e2y s\u1ebd ch\u1ec9 cho b\u1ea1n c\u00e1ch c\u00e0i \u0111\u1eb7t cloud-init t\u1eeb ngu\u1ed3n.<\/p>\n<p>1.C\u00e0i \u0111\u1eb7t Git v\u00e0 Pip cho Python 3.<\/p>\n<p>Debian v\u00e0 ubuntu: <\/p>\n<pre class=\"wp-block-code\"><code>apt update\napt install git python3-pip<\/code><\/pre>\n<p>CentOS, Fedora, AlmaLinux, Rocky Linux, v.v.<\/p>\n<pre class=\"wp-block-code\"><code>dnf install git python3-pip<\/code><\/pre>\n<p>2.Sao ch\u00e9p kho l\u01b0u tr\u1eef cloud-init Git v\u00e0 thay \u0111\u1ed5i v\u00e0o th\u01b0 m\u1ee5c kho l\u01b0u tr\u1eef. B\u01b0\u1edbc n\u00e0y c\u0169ng thay \u0111\u1ed5i v\u00e0o th\u01b0&nbsp;<code>\/tmp\/<\/code>m\u1ee5c tr\u01b0\u1edbc, v\u00ec kho l\u01b0u tr\u1eef ch\u1ec9 c\u1ea7n \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef t\u1ea1m th\u1eddi.<\/p>\n<pre class=\"wp-block-code\"><code>cd \/tmp\/\ngit clone https:\/\/github.com\/cloud-init\/cloud-init.git\ncd cloud-init\/<\/code><\/pre>\n<p>3.C\u00e0i \u0111\u1eb7t c\u00e1c \u0111i\u1ec1u ki\u1ec7n ti\u00ean quy\u1ebft c\u1ee7a d\u1ef1 \u00e1n.<\/p>\n<pre class=\"wp-block-code\"><code>pip3 install -r requirements.txt<\/code><\/pre>\n<p>V\u1edbi m\u1ed9t s\u1ed1 b\u1ea3n ph\u00e2n ph\u1ed1i m\u1edbi h\u01a1n, b\u1ea1n c\u00f3 th\u1ec3 c\u1ea7n ch\u1ea1y l\u1ec7nh tr\u00ean v\u1edbi t\u00f9y&nbsp;<code>--break-system-packages<\/code>ch\u1ecdn. \u0110i\u1ec1u n\u00e0y ghi \u0111\u00e8 l\u00ean th\u00f4ng s\u1ed1 k\u1ef9 thu\u1eadt c\u1ed1 g\u1eafng ng\u0103n ng\u1eeba xung \u0111\u1ed9t gi\u1eefa tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i h\u1ec7 \u0111i\u1ec1u h\u00e0nh v\u00e0 Pip.<\/p>\n<pre class=\"wp-block-code\"><code>pip3 install -r requirements.txt --break-system-packages<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: \u0110\u1eb7c t\u1ea3&nbsp;<a href=\"https:\/\/peps.python.org\/pep-0668\/\" target=\"_blank\" rel=\"noreferrer noopener\">PEP 668<\/a>&nbsp;c\u1ed1 g\u1eafng ng\u0103n ng\u1eeba xung \u0111\u1ed9t gi\u1eefa c\u00e1c g\u00f3i Python \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t th\u00f4ng qua tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i OS v\u00e0 PIP. \u0110\u1eb7c t\u1ea3 n\u00e0y khuy\u1ebfn ngh\u1ecb c\u00e0i \u0111\u1eb7t c\u00e1c g\u00f3i v\u1edbi Pip trong m\u00f4i tr\u01b0\u1eddng \u1ea3o Python, nh\u01b0&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/how-to-manage-packages-and-virtual-environments-on-linux\/#manage-virtual-environments-in-linux\">Virtualenv<\/a>&nbsp;.<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">C\u00e1ch ti\u1ebfp c\u1eadn \u0111\u00f3 kh\u00f4ng hi\u1ec7u qu\u1ea3 v\u1edbi tr\u00ecnh c\u00e0i \u0111\u1eb7t cloud-init, do \u0111\u00f3 c\u00e1c b\u01b0\u1edbc \u1edf \u0111\u00e2y khuy\u1ebfn ngh\u1ecb ghi \u0111\u00e8 th\u00f4ng s\u1ed1 k\u1ef9 thu\u1eadt. Trong c\u00e1c th\u1eed nghi\u1ec7m c\u1ee7a ch\u00fang t\u00f4i, \u0111i\u1ec1u n\u00e0y kh\u00f4ng g\u00e2y ra b\u1ea5t k\u1ef3 s\u1ef1 c\u1ed1 n\u00e0o, nh\u01b0ng h\u00e3y l\u01b0u \u00fd r\u1eb1ng vi\u1ec7c s\u1eed d\u1ee5ng t\u00f9y ch\u1ecdn n\u00e0y c\u00f3 th\u1ec3 \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn h\u00e0nh vi c\u1ee7a m\u1ed9t s\u1ed1 g\u00f3i Python.<\/p>\n<p>4.X\u00e2y d\u1ef1ng v\u00e0 c\u00e0i \u0111\u1eb7t cloud-init t\u1eeb d\u1ef1 \u00e1n.<\/p>\n<pre class=\"wp-block-code\"><code>python3 setup.py build\npython3 setup.py install --init-system systemd<\/code><\/pre>\n<h2 id=\"configure-cloud-init\">C\u1ea5u h\u00ecnh Cloud-Init<a href=\"https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/?tabs=centos-fedora-almalinux-rocky-linux-etc#configure-cloud-init\"><\/a><\/h2>\n<p>M\u1ed9t v\u00e0i b\u01b0\u1edbc c\u1ea5u h\u00ecnh l\u00e0 c\u1ea7n thi\u1ebft \u0111\u1ec3 chu\u1ea9n b\u1ecb c\u00e0i \u0111\u1eb7t cloud-init ch\u1ea1y \u0111\u00fang tr\u00ean phi\u00ean b\u1ea3n. C\u00e1c b\u01b0\u1edbc d\u01b0\u1edbi \u0111\u00e2y kh\u1edfi \u0111\u1ed9ng cloud-init v\u00e0 th\u00eam ngu\u1ed3n d\u1eef li\u1ec7u Akamai c\u1ea7n thi\u1ebft \u0111\u1ec3 tri\u1ec3n khai v\u1edbi d\u1ecbch v\u1ee5 Metadata.<\/p>\n<p>1.Kh\u1edfi t\u1ea1o cloud-init tr\u00ean h\u1ec7 th\u1ed1ng. L\u00e0m nh\u01b0 v\u1eady c\u0169ng s\u1ebd \u0111\u01b0a ra phi\u00ean b\u1ea3n; \u0111\u1ea3m b\u1ea3o phi\u00ean b\u1ea3n \u00edt nh\u1ea5t l\u00e0&nbsp;<code>23.3.1<\/code>\u0111\u1ec3 \u0111\u1ea3m b\u1ea3o kh\u1ea3 n\u0103ng t\u01b0\u01a1ng th\u00edch v\u1edbi d\u1ecbch v\u1ee5 Akamai Metadata.<\/p>\n<pre class=\"wp-block-code\"><code>cloud-init init --local<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>Cloud-init v. 23.3.3 running 'init-local' at Mon, 27 Nov 2023 22:31:40 +0000. Up 105.67 seconds.<\/code><\/pre>\n<p>2.X\u00e1c minh tr\u1ea1ng th\u00e1i c\u1ee7a d\u1ecbch v\u1ee5 cloud-init.<\/p>\n<pre class=\"wp-block-code\"><code>cloud-init status<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>status: running\n<\/code><\/pre>\n<p>3.Th\u00eam&nbsp;<code>Akamai<\/code>v\u00e0o&nbsp;<code>datasource_list<\/code>m\u1ed9t trong c\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh cloud-init. X\u00e1c \u0111\u1ecbnh v\u1ecb tr\u00ed t\u1ec7p c\u1ea5u h\u00ecnh ph\u00f9 h\u1ee3p nh\u01b0 sau.<\/p>\n<ul>\n<li>Tr\u00ean nhi\u1ec1u Akamai Compute Instances m\u1edbi, t\u1ec7p c\u1ea5u h\u00ecnh cloud-init \u0111\u01b0\u1ee3c bao g\u1ed3m t\u1ea1i&nbsp;<code>\/etc\/cloud\/cloud.cfg.d\/99-linode.cfg<\/code>. C\u1ea5u h\u00ecnh n\u00e0y \u0111\u01b0\u1ee3c \u01b0u ti\u00ean v\u00e0 n\u1ebfu b\u1ea1n c\u00f3, b\u1ea1n n\u00ean th\u00eam ngu\u1ed3n d\u1eef li\u1ec7u v\u00e0o \u0111\u00f3.<\/li>\n<li>N\u1ebfu b\u1ea1n kh\u00f4ng c\u00f3 t\u1ec7p&nbsp;<code>99-linode.cfg<\/code>\u0111\u01b0\u1ee3c \u0111\u1ec1 c\u1eadp \u1edf tr\u00ean, b\u1ea1n n\u00ean th\u00eam ngu\u1ed3n d\u1eef li\u1ec7u v\u00e0o t\u1ec7p c\u1ea5u h\u00ecnh cloud-init m\u1eb7c \u0111\u1ecbnh:&nbsp;<code>\/etc\/cloud\/cloud.cfg<\/code>.<\/li>\n<\/ul>\n<p>Trong c\u1ea3 hai tr\u01b0\u1eddng h\u1ee3p, h\u00e3y t\u00ecm&nbsp;<code>datasource_list<\/code>v\u00e0 th\u00eam&nbsp;<code>Akamai<\/code>l\u00e0m m\u1ee5c nh\u1eadp \u0111\u1ea7u ti\u00ean, nh\u01b0 hi\u1ec3n th\u1ecb b\u00ean d\u01b0\u1edbi. N\u1ebfu t\u00f9y&nbsp;<code>datasource_list<\/code>ch\u1ecdn ch\u01b0a c\u00f3 trong t\u1ec7p c\u1ea5u h\u00ecnh, h\u00e3y th\u00eam n\u00f3 v\u1edbi&nbsp;<code>Akamai<\/code>t\u01b0 c\u00e1ch l\u00e0 m\u1ee5c duy nh\u1ea5t trong m\u1ea3ng.<\/p>\n<pre class=\"wp-block-code\"><code>...\n\ndatasource_list: &#91; Akamai, NoCloud, ConfigDrive, None ]\n\n...<\/code><\/pre>\n<p>4.T\u1eaft phi\u00ean b\u1ea3n n\u00e0y, c\u00f3 th\u1ec3 t\u1eeb d\u00f2ng l\u1ec7nh b\u1eb1ng l\u1ec7nh b\u00ean d\u01b0\u1edbi ho\u1eb7c t\u1eeb trong Cloud Manager.<\/p>\n<pre class=\"wp-block-code\"><code>shutdown<\/code><\/pre>\n<h2 id=\"create-a-custom-image\">T\u1ea1o m\u1ed9t h\u00ecnh \u1ea3nh t\u00f9y ch\u1ec9nh<a href=\"https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/?tabs=centos-fedora-almalinux-rocky-linux-etc#create-a-custom-image\"><\/a><\/h2>\n<p>T\u1ea1o m\u1ed9t h\u00ecnh \u1ea3nh t\u1eeb thi\u1ebft l\u1eadp phi\u00ean b\u1ea3n \u1edf tr\u00ean cho ph\u00e9p b\u1ea1n tri\u1ec3n khai c\u00e1c phi\u00ean b\u1ea3n m\u1edbi t\u1eadn d\u1ee5ng d\u1ecbch v\u1ee5 Metadata v\u00e0 c\u00e1c t\u1eadp l\u1ec7nh tri\u1ec3n khai cloud-init t\u00f9y ch\u1ec9nh. \u0110\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin v\u1ec1 c\u00e1ch t\u1ea1o h\u00ecnh \u1ea3nh c\u1ee7a Akamai Compute Instance, b\u1ea1n c\u00f3 th\u1ec3 tham kh\u1ea3o h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/tools\/images\/guides\/capture-an-image\/#capturing-an-image-through-cloud-manager\">Capture an Image<\/a>&nbsp;c\u1ee7a ch\u00fang t\u00f4i .<\/p>\n<p>Sau \u0111\u00e2y l\u00e0 t\u00f3m t\u1eaft c\u00e1c b\u01b0\u1edbc b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng \u0111\u1ec3 t\u1ea1o \u1ea3nh c\u01a1 s\u1edf t\u1eeb phi\u00ean b\u1ea3n m\u00e0 b\u1ea1n \u0111\u00e3 c\u00e0i \u0111\u1eb7t cloud-init.<\/p>\n<ol>\n<li>\u0110i\u1ec1u h\u01b0\u1edbng \u0111\u1ebfn ph\u1ea7n&nbsp;<strong>H\u00ecnh \u1ea3nh<\/strong>&nbsp;c\u1ee7a Tr\u00ecnh qu\u1ea3n l\u00fd \u0111\u00e1m m\u00e2y.<\/li>\n<li>Ch\u1ecdn&nbsp;<strong>T\u1ea1o h\u00ecnh \u1ea3nh<\/strong>&nbsp;.<\/li>\n<li>Tr\u00ean bi\u1ec3u m\u1eabu k\u1ebft qu\u1ea3:\n<ul>\n<li>Ch\u1ecdn Compute Instance m\u00e0 b\u1ea1n \u0111\u00e3 c\u00e0i \u0111\u1eb7t cloud-init<\/li>\n<li>Ch\u1ecdn \u1ed5 \u0111\u0129a li\u00ean quan<\/li>\n<li>Ch\u1ec9 ra r\u1eb1ng h\u00ecnh \u1ea3nh&nbsp;<em>t\u01b0\u01a1ng th\u00edch v\u1edbi cloud-init<\/em><\/li>\n<li>\u0110\u1eb7t nh\u00e3n cho h\u00ecnh \u1ea3nh<\/li>\n<li>Ch\u1ecdn t\u00f9y ch\u1ecdn&nbsp;<strong>T\u1ea1o h\u00ecnh \u1ea3nh<\/strong><\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/create-image-cloud-init.png\" alt=\"T\u1ea1o m\u1ed9t h\u00ecnh \u1ea3nh t\u1eeb m\u1ed9t phi\u00ean b\u1ea3n c\u01a1 s\u1edf v\u1edbi cloud-init\" width=\"482\" height=\"425\"><\/li>\n<li>\u0110\u1ee3i qu\u00e1 tr\u00ecnh t\u1ea1o ho\u00e0n t\u1ea5t. B\u1ea1n c\u00f3 th\u1ec3 xem ti\u1ebfn tr\u00ecnh t\u1eeb ph\u1ea7n&nbsp;<strong>H\u00ecnh \u1ea3nh<\/strong>&nbsp;c\u1ee7a Cloud Manager.<\/li>\n<\/ol>\n<h2 id=\"deploy-an-instance-with-user-data\">Tri\u1ec3n khai m\u1ed9t Instance v\u1edbi User-Data<a href=\"https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/?tabs=centos-fedora-almalinux-rocky-linux-etc#deploy-an-instance-with-user-data\"><\/a><\/h2>\n<p>V\u1edbi h\u00ecnh \u1ea3nh cloud-init c\u01a1 b\u1ea3n \u0111\u00e3 s\u1eb5n s\u00e0ng, b\u1ea1n c\u00f3 th\u1ec3 tri\u1ec3n khai phi\u00ean b\u1ea3n m\u1edbi c\u1ee7a d\u1ecbch v\u1ee5 Metadata v\u00e0 d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng cloud-init b\u1ea5t c\u1ee9 khi n\u00e0o b\u1ea1n c\u1ea7n. Tham kh\u1ea3o h\u01b0\u1edbng d\u1eabn c\u1ee7a ch\u00fang t\u00f4i v\u1ec1 c\u00e1ch&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/tools\/images\/guides\/deploy-image-to-new-linode\/\">Tri\u1ec3n khai H\u00ecnh \u1ea3nh t\u1edbi Phi\u00ean b\u1ea3n Compute m\u1edbi<\/a>&nbsp;\u0111\u1ec3 tri\u1ec3n khai h\u00ecnh \u1ea3nh. Tham kh\u1ea3o h\u01b0\u1edbng d\u1eabn c\u1ee7a ch\u00fang t\u00f4i v\u1ec1 c\u00e1ch&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/configure-and-secure-servers-with-cloud-init\/\">S\u1eed d\u1ee5ng Cloud-Init \u0111\u1ec3 T\u1ef1 \u0111\u1ed9ng C\u1ea5u h\u00ecnh v\u00e0 B\u1ea3o m\u1eadt M\u00e1y ch\u1ee7 c\u1ee7a B\u1ea1n<\/a>&nbsp;\u0111\u1ec3 bi\u1ebft th\u00eam v\u1ec1 c\u00e1ch th\u00eam d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng v\u00e0o phi\u00ean b\u1ea3n m\u1edbi.<\/p>\n<p>C\u00e1c b\u01b0\u1edbc sau \u0111\u00e2y h\u01b0\u1edbng d\u1eabn b\u1ea1n tri\u1ec3n khai m\u1edbi \u0111\u01a1n gi\u1ea3n t\u1eeb h\u00ecnh \u1ea3nh cloud-init c\u01a1 s\u1edf. \u0110i\u1ec1u n\u00e0y bao g\u1ed3m m\u1ed9t t\u1eadp l\u1ec7nh d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng cloud-init \u0111\u01a1n gi\u1ea3n \u0111\u01b0\u1ee3c m\u00f4 ph\u1ecfng theo h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/set-up-and-secure\/\">Thi\u1ebft l\u1eadp v\u00e0 b\u1ea3o m\u1eadt phi\u00ean b\u1ea3n t\u00ednh to\u00e1n<\/a>&nbsp;c\u1ee7a ch\u00fang t\u00f4i .<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: C\u00e1c Compute Instance m\u1edbi tri\u1ec3n khai kh\u00f4ng c\u00f3 quy\u1ec1n truy c\u1eadp m\u1ea1ng trong qu\u00e1 tr\u00ecnh kh\u1edfi \u0111\u1ed9ng. \u0110i\u1ec1u n\u00e0y ng\u0103n kh\u00f4ng cho cloud-init ch\u1ea1y \u0111\u00fang c\u00e1ch. M\u1ed9t s\u1ed1 b\u01b0\u1edbc cu\u1ed1i c\u00f9ng b\u00ean d\u01b0\u1edbi gi\u1ea3i quy\u1ebft v\u1ea5n \u0111\u1ec1 n\u00e0y, kh\u1edfi \u0111\u1ed9ng l\u1ea1i quy tr\u00ecnh cloud-init sau l\u1ea7n kh\u1edfi \u0111\u1ed9ng \u0111\u1ea7u ti\u00ean.<\/p>\n<p>1.\u0110i\u1ec1u h\u01b0\u1edbng \u0111\u1ebfn ph\u1ea7n&nbsp;<strong>T\u1ea1o Linode<\/strong>&nbsp;c\u1ee7a Tr\u00ecnh qu\u1ea3n l\u00fd \u0111\u00e1m m\u00e2y v\u00e0 ch\u1ecdn tab&nbsp;<strong>H\u00ecnh \u1ea3nh<\/strong>&nbsp;.<\/p>\n<p>2.Trong menu th\u1ea3 xu\u1ed1ng H\u00ecnh \u1ea3nh, h\u00e3y ch\u1ecdn h\u00ecnh \u1ea3nh b\u1ea1n v\u1eeba t\u1ea1o.<img loading=\"lazy\" decoding=\"async\" loading=\"lazy\" width=\"667\" height=\"319\" src=\"https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/create-instance-new-image.png\" alt=\"\u1ea2nh ch\u1ee5p m\u00e0n h\u00ecnh tri\u1ec3n khai m\u1ed9t phi\u00ean b\u1ea3n t\u1eeb m\u1ed9t h\u00ecnh \u1ea3nh t\u00f9y ch\u1ec9nh\"><\/p>\n<p>3.Ch\u1ecdn m\u1ed9t khu v\u1ef1c m\u00e0 d\u1ecbch v\u1ee5 Si\u00eau d\u1eef li\u1ec7u kh\u1ea3 d\u1ee5ng. Nh\u1eefng khu v\u1ef1c n\u00e0y \u0111\u01b0\u1ee3c li\u1ec7t k\u00ea trong&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/metadata\/#availability\">t\u00e0i li\u1ec7u tham kh\u1ea3o<\/a>&nbsp;Si\u00eau d\u1eef li\u1ec7u .<\/p>\n<p>4.Ch\u1ecdn g\u00f3i phi\u00ean b\u1ea3n mong mu\u1ed1n, nh\u1eadp nh\u00e3n cho phi\u00ean b\u1ea3n m\u1edbi v\u00e0 t\u1ea1o th\u00f4ng tin x\u00e1c th\u1ef1c cho ng\u01b0\u1eddi d\u00f9ng g\u1ed1c.<\/p>\n<p>5.M\u1edf r\u1ed9ng ph\u1ea7n&nbsp;<strong>Th\u00eam d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng<\/strong>&nbsp;v\u00e0 nh\u1eadp d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng mong mu\u1ed1n c\u1ee7a b\u1ea1n. Sau \u0111\u00e2y l\u00e0 v\u00ed d\u1ee5 c\u01a1 b\u1ea3n h\u1eefu \u00edch cho nhi\u1ec1u tr\u01b0\u1eddng h\u1ee3p m\u1edbi.<\/p>\n<pre class=\"wp-block-code\"><code>#cloud-config\n\n# Configure a limited user\nusers:\n  - default\n  - name: example-user\n    groups:\n      - sudo\n    sudo:\n      - ALL=(ALL) NOPASSWD:ALL\n    shell: \/bin\/bash\n    ssh_authorized_keys:\n      - \"SSH_PUBLIC_KEY\"\n\n# Perform system updates\npackage_update: true\npackage_upgrade: true\n\n# Configure server details\ntimezone: 'US\/Central'\nhostname: examplehost\n\n# Harden SSH access\nruncmd:\n  - sed -i '\/PermitRootLogin\/d' \/etc\/ssh\/sshd_config\n  - echo \"PermitRootLogin no\" &gt;&gt; \/etc\/ssh\/sshd_config\n  - systemctl restart sshd<\/code><\/pre>\n<p>6.B\u1eaft \u0111\u1ea7u tri\u1ec3n khai b\u1eb1ng c\u00e1ch ch\u1ecdn&nbsp;<strong>Create Linode<\/strong>&nbsp;v\u00e0 \u0111\u1ee3i phi\u00ean b\u1ea3n m\u1edbi \u0111\u01b0\u1ee3c tri\u1ec3n khai. B\u1ea1n c\u00f3 th\u1ec3 theo d\u00f5i ti\u1ebfn tr\u00ecnh c\u1ee7a phi\u00ean b\u1ea3n n\u00e0y t\u1eeb ph\u1ea7n&nbsp;<strong>Linodes<\/strong>&nbsp;c\u1ee7a Cloud Manager.<\/p>\n<p>7.Truy c\u1eadp phi\u00ean b\u1ea3n v\u1edbi t\u01b0 c\u00e1ch l\u00e0 ng\u01b0\u1eddi d\u00f9ng root th\u00f4ng qua b\u1ea3ng \u0111i\u1ec1u khi\u1ec3n Lish. T\u00ecm hi\u1ec3u c\u00e1ch th\u1ef1c hi\u1ec7n trong h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/lish\/\">Truy c\u1eadp b\u1ea3ng \u0111i\u1ec1u khi\u1ec3n h\u1ec7 th\u1ed1ng c\u1ee7a b\u1ea1n b\u1eb1ng Lish (Linode Shell)<\/a>&nbsp;.<\/p>\n<p>8.\u0110\u1eb7t l\u1ea1i cloud-init. \u0110i\u1ec1u n\u00e0y \u0111\u1ea3m b\u1ea3o r\u1eb1ng, trong l\u1ea7n kh\u1edfi \u0111\u1ed9ng ti\u1ebfp theo, cloud-init ch\u1ea1y nh\u01b0 th\u1ec3 kh\u1edfi \u0111\u1ed9ng h\u1ec7 th\u1ed1ng ban \u0111\u1ea7u.<\/p>\n<pre class=\"wp-block-code\"><code>cloud-init clean &amp;&amp; cloud-init clean --logs<\/code><\/pre>\n<p>9.Kh\u1edfi \u0111\u1ed9ng l\u1ea1i phi\u00ean b\u1ea3n.<\/p>\n<pre class=\"wp-block-code\"><code>reboot<\/code><\/pre>\n<p>Sau khi phi\u00ean b\u1ea3n kh\u1edfi \u0111\u1ed9ng l\u1ea1i, b\u1ea1n c\u00f3 th\u1ec3 x\u00e1c minh vi\u1ec7c th\u1ef1c thi cloud-init b\u1eb1ng c\u00e1ch \u0111\u0103ng nh\u1eadp v\u1edbi t\u01b0 c\u00e1ch l\u00e0 ng\u01b0\u1eddi d\u00f9ng \u0111\u00e3 t\u1ea1o \u2014&nbsp;<code>example-user<\/code>trong v\u00ed d\u1ee5 tr\u00ean. B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00e1c b\u01b0\u1edbc trong h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/install-and-update-software-with-cloud-init\/#verify-update-and-installation\" target=\"_blank\" rel=\"noreferrer noopener\">S\u1eed d\u1ee5ng Cloud-Init \u0111\u1ec3 c\u00e0i \u0111\u1eb7t v\u00e0 c\u1eadp nh\u1eadt ph\u1ea7n m\u1ec1m tr\u00ean m\u00e1y ch\u1ee7 m\u1edbi c\u1ee7a ch\u00fang t\u00f4i<\/a>&nbsp;\u0111\u1ec3 x\u00e1c minh c\u00e1c b\u1ea3n c\u1eadp nh\u1eadt g\u00f3i h\u1ec7 th\u1ed1ng.<\/p>\n<h2 id=\"more-information\">Th\u00f4ng tin th\u00eam<\/h2>\n<p>B\u1ea1n c\u00f3 th\u1ec3 mu\u1ed1n tham kh\u1ea3o c\u00e1c ngu\u1ed3n sau \u0111\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin v\u1ec1 ch\u1ee7 \u0111\u1ec1 n\u00e0y. M\u1eb7c d\u00f9 ch\u00fang t\u00f4i cung c\u1ea5p v\u1edbi hy v\u1ecdng r\u1eb1ng ch\u00fang s\u1ebd h\u1eefu \u00edch, nh\u01b0ng xin l\u01b0u \u00fd r\u1eb1ng ch\u00fang t\u00f4i kh\u00f4ng th\u1ec3 \u0111\u1ea3m b\u1ea3o t\u00ednh ch\u00ednh x\u00e1c ho\u1eb7c t\u00ednh k\u1ecbp th\u1eddi c\u1ee7a c\u00e1c t\u00e0i li\u1ec7u \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef b\u00ean ngo\u00e0i.<\/p>\n<ul>\n<li><a href=\"https:\/\/cloudinit.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\">T\u00e0i li\u1ec7u Cloud-init<\/a><\/li>\n<\/ul>\n<p>Ngu\u1ed3n: https:\/\/www.linode.com\/docs\/guides\/using-metadata-cloud-init-on-any-distribution\/?tabs=centos-fedora-almalinux-rocky-linux-etc<\/p>\n","protected":false},"excerpt":{"rendered":"<p>D\u1ecbch v\u1ee5 Metadata&nbsp;c\u1ee7a Akamai&nbsp;cung c\u1ea5p cho b\u1ea1n kh\u1ea3 n\u0103ng t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u1ea5u h\u00ecnh h\u1ec7 th\u1ed1ng khi tri\u1ec3n khai Compute Instance. \u0110i\u1ec1u n\u00e0y ch\u1ee7 y\u1ebfu \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n b\u1eb1ng c\u00e1ch th\u00eam d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng d\u01b0\u1edbi d\u1ea1ng c\u00e1c t\u1eadp l\u1ec7nh cloud-config. C\u00e1c t\u1eadp l\u1ec7nh n\u00e0y \u0111\u01b0\u1ee3c x\u1eed l\u00fd b\u1edfi ph\u1ea7n m\u1ec1m cloud-init ch\u1ea1y trong h\u1ec7<\/p>\n","protected":false},"author":1,"featured_media":35950,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[132],"tags":[],"class_list":["post-34950","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-init"],"_links":{"self":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/34950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/comments?post=34950"}],"version-history":[{"count":0,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/34950\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media\/35950"}],"wp:attachment":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media?parent=34950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/categories?post=34950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/tags?post=34950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}