徐汇网站建设微网站的建设

广州酒饮酒类交易中心 2026/09/09 17:51:49

一、yum方式部署

1、配置yum源

#备份mv/etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupmv/etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backupmv/etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup#下载wget-O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repowget-O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo#清除、刷新缓存yum clean all yum makecache

安装ansible

yuminstall-y ansible

验证

[root@control2 yum.repos.d]# ansible --versionansible2.9.27 configfile=/etc/ansible/ansible.cfg configured module search path=[u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']ansible python module location=/usr/lib/python2.7/site-packages/ansible executable location=/usr/bin/ansible python version=2.7.5(default, Oct142020,14:45:30)[GCC4.8.520150623(Red Hat4.8.5-44)]

二、离线安装

1、下载ansible安装包

#配置yum源wget-O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repowget-O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo#清除、刷新缓存yum clean all yum makecache#安装yum-plugin-downloadonlyyuminstallyum-plugin-downloadonly#下载安装包及依赖yuminstall--downloadonly --downloaddir=./ansible-packages ansible#将下好的安装包传到内网服务器

安装ansible

cdansible-packages/ yum localinstall -y *.rpm##查看版本[root@conctol3 ansible-packages]# ansible --versionansible2.9.27 configfile=/etc/ansible/ansible.cfg configured module search path=[u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']ansible python module location=/usr/lib/python2.7/site-packages/ansible executable location=/usr/bin/ansible python version=2.7.5(default, Oct142020,14:45:30)[GCC4.8.520150623(Red Hat4.8.5-44)]

三、编译安装

1、下载、安装

#公网机器下载wgethttps://releases.ansible.com/ansible/ansible-2.9.27.tar.gz#内网机器需要有相应python依赖#挂载镜像配置本地YUM源mount/dev/sr0 /mnrvim/etc/yum.repos.d/localyum.repo[base]name=basebaseurl=file:///mntenabled=1gpgcheck=0yum -yinstallpython-jinja2 PyYAML python-paramiko python-babel python-cryptotarzxvf ansible-2.9.27.tar.gzcdansible-2.9.27 python setup.py build python setup.pyinstall[root@conctol3 ansible-2.9.27]# ansible --versionansible2.9.27 configfile=None configured module search path=[u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']ansible python module location=/usr/lib/python2.7/site-packages/ansible-2.9.27-py2.7.egg/ansible executable location=/usr/bin/ansible python version=2.7.5(default, Oct142020,14:45:30)[GCC4.8.520150623(Red Hat4.8.5-44)]

配置文件解释

ansible配置文件查找顺序: 首先检查ANSIBLE_CONFIG变量定义的配置文件 其次检查当前目录下./ansible.cfg文件 再次检查当前用户家目录下~/ansible.cfg文件 最后检查/etc/ansible/ansible.cfg文件 /etc/ansible/ansible.cfg :主配置文件,配置ansible工作特性;(有那么几个选项不是固定死的) /etc/ansible/hosts :主机清单文件,管理的目标主机地址清单;(根基ansible.cfg配置的位置) /etc/ansible/roles/ :存放角色的目录。(根据ansible.cfg配置的位置)

进行配置:

#创建文件夹 mkdir -p /root/ansible/roles #切换工作目录 cd /root/ansible mkdir /root/ansible/mycollection #编辑配置文件 cat > /root/ansible/ansible.cfg << 'EOF' [defaults] # 指定 inventory 文件位置 inventory = /root/ansible/inventory # 禁用 SSH 主机密钥检查 host_key_checking = False # 设置默认远程用户 remote_user = root # 设置默认 SSH 私钥文件 private_key_file = ~/.ssh/id_rsa # 连接超时时间 timeout = 10 # 并发数 forks = 5 # 使用 gather_facts gathering = smart # 远程用户 remote_user = root [ssh_connection] # SSH 管道化,提高效率 pipelining = True # SSH 参数 ssh_args = -o ControlMaster=auto -o ControlPersist=60s # 控制路径 control_path = %(directory)s/%%h-%%r [privilege_escalation] # 提权设置 become = True become_method = sudo become_user = root become_ask_pass = False become_flags = -H -S EOF #确认配置文件生效 ansible --version

编写主机清单文件

vim/root/ansible/inventory[dev]node1#[test]#node2#[prod]#node3#node4#[balancers]#node5#[webservers:children]#prod

配置SSH免密登录

ssh-keygen -f /root/.ssh/id_rsa -N''#生成密钥 保存在.ssh目录下 名字叫id_rsa 不设置密钥密码echo'192.168.80.181 node1'>>/etc/hosts#具体IP为客户端IP#把密钥传到被控制端主机foriinnode1dossh-copy-id$idone

验证

# 验证: 如果可以ping通所有节,证明配置文件、账戶、清单都没有问题(必做操做)ansible-inventory --graph#图形结构的形式展示主机和组之间的关系ansible all -mping
系统CentOS 7.9
192.168.80.183conctol3
192.168.80.180node1
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

中国建设银行网站石家庄网站建设

无需从头搭建!PyTorch-CUDA基础镜像助你秒启AI训练在深度学习项目启动的前72小时里,有多少开发者真正把时间花在了模型设计上?更多时候,

2026/06/30 12:19:00

电器网站建设网站建设规划

Excalidraw历史版本回溯功能详解:不怕误删修改在远程协作日益频繁的今天,一张草图可能承载着整个团队数小时的设计讨论成果。你是否经历过这样的场景:刚完成

2026/06/30 11:59:58

长安网站建设西安网站建设公司

一、LR 分析器模型LR 分析器是自底向上语法分析的一种高效实现,广泛应用于编译器构造中。其核心思想是从左到右扫描输入符号串,使用最右推导的逆过程进行归约(L

2026/06/30 12:41:32

免费建设网站闵行网站建设

SoundCloud音乐下载终极指南:3分钟掌握免费高效下载技巧【免费下载链接】scdlSoundcloud Music Downloader项目地址: https://gitcode.

2026/06/30 12:27:31

网站建设制作建设行业网站

Dify在法律文书自动生成中的实践探索在律所的某个加班深夜,一位年轻律师正反复核对一份民事起诉状中的法条引用——这已是本周第三次因格式不规范或条款过时被合伙人退回。类似场景在法律行业中屡

2026/06/30 14:09:39

免费建设网站国家建设部网站

还在为Zotero文献库中堆积如山的重复条目而头痛吗?当你从不同数据库导入文献时,同一篇文章经常被重复收录多次,这不仅浪费存储空间,还严重影响文

2026/06/30 10:14:49

北京网站建设网站建设学习

雷递网 雷建平 12月27日深之蓝海洋科技股份有限公司(简称:“深之蓝”)日前递交招股书,准备在科创板上市。深之蓝计划募资15亿元,

2026/06/30 10:25:20

专业网站建设网站建设教程

还在为音乐播放器的后端开发而苦恼吗?酷我音乐API Node.js版为你提供了一套完整的解决方案。基于Egg.js企业级框架构建,这个开源项目让音乐API开发变得前所未有的

2026/06/30 13:17:05

广州网站建设中小企业网站建设

科研实验室以太网POE温湿度监控系统设计方案一、方案设计背景与目标1. 设计背景科研实验室(如生物培养室、化学试剂存储室、电子元器件测试实验室等)对温湿度环境具有极高敏感性

2026/06/30 12:01:58

怎样建设网站东莞南城网站建设

教育创新:如何用预置镜像快速构建AI教学实验室作为一名计算机课程教授,你是否遇到过这样的困境:想让学生体验最前沿的物体识别技术,但学校机房没有G

2026/06/30 13:43:07