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:~# 

     

     

  • 相关阅读:
    Webpack4不求人(5) ——编写自定义插件
    Webpack4不求人(4)——编写自定义Loader
    Webpack4不求人(3) ——性能优化
    Webpack4不求人(2) ——手把手搭建TypeScript+React16+ReactRouter5同构应用脚手架
    Shell脚本快速入门(1)
    kafka二进制协议分析与PHP客户端开发
    深入浅出ES6的标准内置对象Proxy
    ES6的Set类型
    深入浅出ES6的迭代器
    Javascript事件系统
  • 原文地址:https://www.cnblogs.com/dream397/p/13431650.html
Copyright © 2011-2022 走看看