当前位置: 首页 > wzjs >正文

实训课网站开发个人小结简述seo的优势

实训课网站开发个人小结,简述seo的优势,网站中队人物介绍怎么做,深圳网站建设方维文章目录 Vagrant安装vagrant安装 VirtualBox如何使用 Ansible安装AnsiblePlaybook测试创建hosts文件创建setup.yml文件 Vagrant Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境。它使用Oracle的开源VirtualBox虚拟化系统,使用 Chef创建自动…

文章目录

    • Vagrant
      • 安装vagrant
      • 安装 VirtualBox
      • 如何使用
    • Ansible
      • 安装Ansible
      • Playbook测试
        • 创建`hosts`文件
        • 创建`setup.yml`文件

Vagrant

Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境。它使用Oracle的开源VirtualBox虚拟化系统,使用 Chef创建自动化虚拟环境

Documentation | Vagrant | HashiCorp Developer官方手册

HashiCorp Cloud Platform-Vagrant查询镜像网站

安装vagrant

Install | Vagrant | HashiCorp Developer

安装 VirtualBox

Oracle VirtualBox

启动报错Error relaunching VirtualBox VM process: 5

  • 避坑!注意卸载完美平台再启动恢复(不玩cs无视之)

如何使用

如何在 Vagrant 中使用这个盒子
第 1 步
选项 1:创建 Vagrantfile 并启动 box (Windows用cmd)vagrant init bento/ubuntu-20.04 --box-version 202407.23.0选项 2:打开 Vagrantfile 并将内容替换为以下内容
#-----------------------s-----------------------------
hosts = {"host1" => "192.168.0.221","host2" => "192.168.0.222","host3" => "192.168.0.223"
}Vagrant.configure("2") do |config|hosts.each do |name, ip|config.vm.define name do |machine|machine.vm.box = "bento/ubuntu-20.04"machine.vm.box_version = "202407.23.0"machine.vm.hostname = "%s" % namemachine.vm.network :public_network,bridge: "en1", ip: ipmachine.vm.provider "virtualbox" do |v|v.name = namev.customize ["modifyvm", :id, "--memory", 1024]endendend
end#-----------------------e-----------------------------
步骤 2
启动您的虚拟机vagrant up #启动
vagrant halt #关闭
vagrant destroy #销毁
vagrant ssh 
  • 网络

    • network

      • 公共网络(与本机同网段)machine.vm.network :public_network
      • 私有网络(NAT)machine.vm.network :public_network
    • bridge 如果主机上有多个网络接口可用,Vagrant 将 要求您选择虚拟机应桥接到的接口。默认的 可以通过向网络定义添加子句来指定接口。:bridge

       #Vagrant 将 要求您选择虚拟机应桥接到的接口。默认的 可以通过向网络定义添加子句来指定接口config.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"#对于某些提供程序,可以指定要桥接的适配器列表 对:config.vm.network "public_network", bridge: ["en1: Wi-Fi (AirPort)","en6: Broadcom NetXtreme Gigabit Ethernet Controller",]```
  • Hyper-V配置(服务器性能配置cpu、memory内存等) Configuration- Hyper-V Provider | Vagrant | HashiCorp Developer

Ansible

ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。Ansible架构相对比较简单,仅需通过SSH连接客户机执行任务即可

安装Ansible

安装 Ansible — Ansible 社区文档

安装完整的 Ansible 软件包:pipx

#安装pipx#aptsudo apt install pipx # apt 默认目录 /usr/bin/pipx#pythonpython3 -m pip install --user pipxpython3 -m pipx ensurepath
#安装完整的 Ansible 软件包
pipx install --include-deps ansible

Playbook测试

Ansible Playbook 提供可重复、可重用、简单的配置管理和多机部署系统,非常适合部署复杂的应用程序。如果您需要多次使用 Ansible 执行任务,请编写 playbook 并将其置于源代码控制之下。然后,您可以使用 playbook 推送新配置或确认远程系统的配置。

前期准备

  #先生成公私钥对ssh-keygen -t rsals /root/.ssh/  #有目录id_rsa  id_rsa.pub#讲vagrant创建的文件夹`.vagrant`传到主机(我这里是Ubuntu24),修改权限chmod 600 .vagrant/machines/host1/virtualbox/private_keychmod 600 .vagrant/machines/host2/virtualbox/private_keychmod 600 .vagrant/machines/host3/virtualbox/private_key#先连接一遍测试	ssh -i .vagrant/machines/host1/virtualbox/private_key vagrant@192.168.0.221ssh -i .vagrant/machines/host2/virtualbox/private_key vagrant@192.168.0.222ssh -i .vagrant/machines/host3/virtualbox/private_key vagrant@192.168.0.223#连接报错Failed to connect to the host via ssh: @@@WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! #使用 ssh-keygen 命令清除旧的公钥ssh-keygen -R 192.168.0.221ssh-keygen -R 192.168.0.222ssh-keygen -R 192.168.0.223

如使用私钥还需要密码,在~/.ssh/ config添加以下内容

如果仍报错 no mutual signature supported,需强制使用 RSA 算法:

sudo cat >> ~/.ssh/config << EOF
Host *PubkeyAcceptedKeyTypes=+ssh-rsaHostKeyAlgorithms=+ssh-rsa
EOF
创建hosts文件
host1 ansible_host=192.168.0.221
host2 ansible_host=192.168.0.222
host3 ansible_host=192.168.0.223[all:vars]
ansible_ssh_private_key_file=.vagrant/machines/{{ inventory_hostname }}/virtualbox/private_key
创建setup.yml文件

当前目录下有以下文件/文件夹,再执行setup.yml

hosts、setup.yml、.vagrant/

ansible-playbook -i hosts setup.yml

---
# 目标主机组:all 表示所有主机
- hosts: all# 启用权限提升(默认使用 sudo)become: true# 切换到 root 用户执行任务become_user: root# 使用 vagrant 用户进行 SSH 连接remote_user: vagrant# 禁用事实收集(目标机无 Python 时需关闭)gather_facts: false	tasks:# 1. 等待 SSH 服务就绪(在控制机本地执行)- name: Wait for ssh to be upbecome: false  # 此任务不需要提权wait_for:port: 22     # 检测端口 22delay: 5     # 每次检测间隔 5 秒connect_timeout: 5  # 连接超时时间timeout: 360  # 总等待时间(秒)host: "{{ ansible_host }}"  # 目标主机 IPdelegate_to: localhost  # 在控制机执行# 2. 安装 Python(使用 raw 模块绕过 Ansible 的 Python 依赖)- name: Installs pythonraw: |# 替换为国内镜像源并更新#sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list#sed -i 's/esm.ubuntu.com//g' /etc/apt/sources.listapt-get update -y && apt-get install -y python  # 安装 Pythonargs:executable: /bin/bash  # 指定解释器# 3. 创建目标目录(用于存放 SSH 密钥)- name: Creates destination directoryfile:path: /root/.ssh/  # 目录路径state: directory   # 确保目录存在mode: 0700         # 目录权限owner: root        # 属主# 4. 推送 RSA 公钥(优先尝试)- name: Pushes user's rsa key to root's vagrant boxcopy:src: ~/.ssh/id_rsa.pub          # 本地公钥路径dest: /root/.ssh/authorized_keys  # 目标路径owner: rootmode: 0600       # 安全权限register: rsa       # 注册结果变量ignore_errors: yes  # 允许失败(若无 RSA 密钥)# 5. 推送 DSA 公钥(仅当 RSA 失败时尝试)- name: Pushes user's dsa key to root's vagrant boxcopy:src: ~/.ssh/id_dsa.pubdest: /root/.ssh/authorized_keysowner: rootmode: 0600when: rsa is failed  # 条件触发register: dsaignore_errors: yes# 6. 推送 ED25519 公钥(前两者均失败时尝试)- name: Pushes user's ed25519 key to root's vagrant boxcopy:src: ~/.ssh/id_ed25519.pubdest: /root/.ssh/authorized_keysowner: rootmode: 0600when: dsa is failed  # 前两个任务均失败时执行# 7. 检查 DNS 解析是否正常- name: Checks if resolver is working properlycommand: host -t A baidu.com  # 测试解析(原 ansible.cc 已过时)register: nsignore_errors: yes# 8. 若 DNS 解析失败,配置备用 DNS(Google Public DNS)- name: Pushes new resolver configuration if resolver failslineinfile:path: /etc/resolv.confregexp: "^nameserver "line: "nameserver 114.114.114.114"  # 替换为 Google DNSstate: presentwhen: ns is failed# 9. 验证 DNS 配置是否生效- name: Checks if resolver is working properly with new nameservercommand: host -t A baidu.comwhen: ns is failed# 10. 完成提示(调试用)- name: Final greetingdebug:msg: "All tasks completed! Your Vagrant VMs are ready."

文章转载自:

http://7OvyUPsn.cwpny.cn
http://DnNdCsxn.cwpny.cn
http://1N5dlan1.cwpny.cn
http://9PcsxDS4.cwpny.cn
http://KMywYzis.cwpny.cn
http://eL8dsoiL.cwpny.cn
http://pyTb5Kf2.cwpny.cn
http://tojmVZ75.cwpny.cn
http://RTk2vIkx.cwpny.cn
http://PQ2OIPFZ.cwpny.cn
http://PzNCv6hc.cwpny.cn
http://FLqReegC.cwpny.cn
http://hqiyZlkZ.cwpny.cn
http://7TbwToX6.cwpny.cn
http://AxYoJNpy.cwpny.cn
http://4HRy7Q3n.cwpny.cn
http://XQShlLIl.cwpny.cn
http://e3cR3bgx.cwpny.cn
http://QCiBwZPW.cwpny.cn
http://xqyugoqB.cwpny.cn
http://OGnpGPex.cwpny.cn
http://cgrA0bmX.cwpny.cn
http://ROGlObNN.cwpny.cn
http://vr8tuJp6.cwpny.cn
http://FdFxDXBR.cwpny.cn
http://6qwQrIMu.cwpny.cn
http://W78d88bM.cwpny.cn
http://OtxKJIcZ.cwpny.cn
http://pJmFMpP7.cwpny.cn
http://pedYHhpO.cwpny.cn
http://www.dtcms.com/wzjs/769601.html

相关文章:

  • 百度 手机网站 友好性求个网站谢谢
  • 医疗类网站源码自己制作菜单的app
  • 广州网站建设方案案例苏州网页设计方法
  • 2019做地方门户网站建筑公司网站石家庄
  • 那个网站可以做微课网站树状栏目有点
  • 公选课网页制作与网站建设小学网站建设与管理办法
  • 做网站视频点播难不难推广广告赚钱软件
  • 网站 keywords舟山网络科技有限公司
  • 深圳企业黄页网站腾讯广告投放平台
  • 长沙建设公司网站长沙seo优化多少钱
  • phpcms做企业网站授权php网站访问量代码
  • 网站开发命名规则wordpress音乐批量上传
  • 公司建立网站的意义京东网站建设的意义
  • 做淘宝团购的网站西安都有哪些公司
  • 网站开发 流程最近的新闻头条
  • 阅读网站建设规划书珠海的门户网站有哪些
  • 网站建设走什么科目网络公司
  • 自己设计一个网站首页宣传网站建设方案模板
  • 网站建设施工图片全球设计网优秀版式作品
  • 网站需要人员做一借款撮合网站
  • django做的网站源码邯郸做网站价格
  • 东莞市公司网站建设怎么样兰州网站建设redu
  • 淘宝店铺推广渠道有哪些网店产品seo如何优化
  • 成都专业网站建设价格网络推广公司怎么报税
  • 网页设计网站方案企业文化墙创意设计图
  • 合肥有什么好的网站建设公司上海外贸公司最新招聘
  • 网站开发使用哪些开发语言梦幻西游网页版官方网站
  • 软件开发 网站建设 游戏开发网站建设的报告
  • 网站页面相似度检测安康网站设计
  • 企业网站关键词优化排名应该怎么做做期货资讯网站