zoukankan      html  css  js  c++  java
  • cloud init local 开机时间长和无法获取元数据

    在 /etc/netsvc.conf 里面添加一行

    hosts=local4

    结束时应用
    datasource:
      Ec2:
        timeout: 5
        max_wait: 10
    但它根本不起作用,超时仍为50秒,max_wait为120秒。 我的操作系统Red Hat 6,cloud-init版本:0.7.4

    # Force only Ec2 being enabled
    datasource_list: ['Ec2']
    datasource:
      Ec2:
        metadata_urls: [ 'http://169.254.169.254' ]
        timeout: 5 # (defaults to 50 seconds)
        max_wait: 10 # (defaults to 120 seconds)
    EOF
    
    # Remove default datasource_list
    rm -f /etc/cloud/cloud.cfg.d/90_dpkg.cf
    apt-get -y install pump cloud-utils cloud-init cloud-initramfs-growroot 
        bash-completion
    
    # Speed up cloud-init by only using Ec2 and a specific metadata url
    cat >> /etc/cloud/cloud.cfg.d/91_Ec2_override.cfg << EOF
    
    # Force only Ec2 being enabled
    datasource_list: ['Ec2']
    datasource:
      Ec2:
        metadata_urls: [ 'http://169.254.169.254' ]
        timeout: 5 # (defaults to 50 seconds)
        max_wait: 10 # (defaults to 120 seconds)
    EOF
    
    # Remove default datasource_list
    rm -f /etc/cloud/cloud.cfg.d/90_dpkg.cfg

     

     

    进入系统后修改文件/etc/systemd/system/network-online.target.wants/networking.service

    命令:sudo vim /etc/systemd/system/network-online.target.wants/networking.service

    将里面的TimeoutStartSec=5min 修改为TimeoutStartSec=2sec

    然后重启系统,就可以生效了,开机速度很快。

    root@u1801:~# systemctl enable cloud-init cloud-final cloud-init-local cloud-config
    Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-init.service → /lib/systemd/system/cloud-init.service.
    Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-final.service → /lib/systemd/system/cloud-final.service.
    Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-init-local.service → /lib/systemd/system/cloud-init-local.service.
    Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-config.service → /lib/systemd/system/cloud-config.service.
    root@u1801:~# 

     

     

  • 相关阅读:
    Java String, StringBuffer和StringBuilder实例
    java中字符串的比较
    java中子类继承父类时是否继承构造函数
    Java中抽象类和接口的用法和区别
    与(&)、非(~)、或(|)、异或(^)
    Linux03
    Linux02
    Linux01
    力扣算法题
    算法 栈、队列、二分查找
  • 原文地址:https://www.cnblogs.com/dream397/p/13431650.html
Copyright © 2011-2022 走看看