zoukankan      html  css  js  c++  java
  • Linux系统源码安装cloud-init

    参考:https://cloud.tencent.com/document/product/213/12587
    使用以下命令下载 cloud-init 源码包

    官网下载地址:https://launchpad.net/cloud-init/+download

    wget https://launchpad.net/cloud-init/trunk/17.1/+download/cloud-init-17.1.tar.gz

    安装 cloud-init 依赖包

    setuptools 
    jinja2 
    prettytable 
    oauthlib 
    configobj 
    pyyaml 
    requests 
    jsonpatch 
    jsonschema 
    six
      
    yum install python-pip -y
    pip install setuptools jinja2 prettytable oauthlib pyyaml requests jsonpatch jsonschema six --upgrade

    安装

    tar -zxvf cloud-init-17.1.tar.gz
    cd ./cloud-init-17.1
    python setup.py build
    python setup.py install --init-system systemd

    其中,--init-system 的可选参数有:(systemd,sysvinit,sysvinit_deb,sysvinit_freebsd,sysvinit_openrc,sysvinit_suse,upstart);[default: None],需要根据当前操作系统使用的自启动服务管理方式是什么进行选择,如果选择出错则 cloud-init 服务无法开机自启动,本例以 systemd 自启动服务管理为例。

    centos/redhat 6用的是sysvinit, 7系列用的是systemd, ubuntu用的是是upstart

    添加 syslog 用户

    useradd syslog

    设置 cloud-init 服务开机自启动

    systemctl enable cloud-init-local.service
    systemctl start cloud-init-local.service
    systemctl enable cloud-init.service
    systemctl start cloud-init.service
    systemctl enable cloud-config.service
    systemctl start cloud-config.service
    systemctl enable cloud-final.service
    systemctl start cloud-final.service
    systemctl status cloud-init-local.service
    systemctl status cloud-init.service
    systemctl status cloud-config.service
    systemctl status cloud-final.service

    CentOS 和 Red Hat 操作系统特殊执行:将/lib/systemd/system/cloud-init-local.service文件内容替换为如下:

    [Unit]
    Description=Initial cloud-init job (pre-networking)
    Wants=network-pre.target
    After=systemd-remount-fs.service
    Before=NetworkManager.service
    Before=network-pre.target
    Before=shutdown.target
    Conflicts=shutdown.target
    RequiresMountsFor=/var/lib/cloud
     
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/cloud-init init --local
    ExecStart=/bin/touch /run/cloud-init/network-config-ready
    RemainAfterExit=yes
    TimeoutSec=0
     
    # Output needs to appear in instance console output
    StandardOutput=journal+console
     
    [Install]
    WantedBy=cloud-init.target

    /lib/systemd/system/cloud-init.service文件内容替换为如下:

    [Unit]
    Description=Initial cloud-init job (metadata service crawler)
    Wants=cloud-init-local.service
    Wants=sshd-keygen.service
    Wants=sshd.service
    After=cloud-init-local.service
    After=systemd-networkd-wait-online.service
    After=networking.service
    After=systemd-hostnamed.service
    Before=network-online.target
    Before=sshd-keygen.service
    Before=sshd.service
    Before=systemd-user-sessions.service
    Conflicts=shutdown.target
     
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/cloud-init init
    RemainAfterExit=yes
    TimeoutSec=0
     
    # Output needs to appear in instance console output
    StandardOutput=journal+console
     
    [Install]
    WantedBy=cloud-init.target
  • 相关阅读:
    【codevs1079】回家
    【codevs1245】最小的N个和
    【codevs1231】最优布线问题
    【codevs1078】最小生成树
    【NOIP1999】【codevs1083】Cantor表
    【NOIP2006】【codevs1075】明明的随机数
    【NOIP2001】【codevs1011】数的计算
    【POJ2259】Team Queue(队列,模拟)
    【LOJ119】单源最短路 模板
    Jzoj4900 平方数
  • 原文地址:https://www.cnblogs.com/gushiren/p/9512765.html
Copyright © 2011-2022 走看看