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

合肥欧派水泥预制品厂 2026/09/09 18:25:03

一、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
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

东莞手机网站建设烟台网站建设

Tone.js音频缓冲管理终极指南:高效加载与释放大型音频文件的完整教程【免费下载链接】Tone.jsA Web Audio framework for making interacti

2026/06/30 11:58:58

深圳网站建设公司品牌网站建设公司

第一章:Open-AutoGLM 睡眠质量分析Open-AutoGLM 是一款基于开源大语言模型的智能健康分析工具,专为睡眠质量评估与干预建议设计。它通过整合可穿戴设备采集

2026/06/30 12:36:32

网站建设模板寿光网站建设

文章目录**摘要****第一章:MQ消息对账的核心概念解析****1.1 “MQ消息对账”的定义与核心目标****1.2 为何需要消息对账:挑战与驱动力****1.3 典型

2026/06/30 13:51:37

长沙网站建设公司黄石网站建设

快速体验打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容:创建一个基于AI的Git辅助工具,能够自动生成有意义的提交信息

2026/06/30 12:27:31

渭南网站建设公司网站建设的

还在为AI应用需要云端联网而烦恼吗?谷歌最新开源的Gemma 3 270M模型彻底改变了这一现状。这款仅有2.7亿参数的轻量级AI模型,能在普通手机上实现秒级启动ÿ

2026/06/30 14:07:08

网站建设中建设网站教程

企业级AI定制服务新思路:基于lora-scripts构建私有化模型在品牌竞争日益激烈的今天,一家设计公司接到了一个紧急需求:为某科技客户打造一套“赛博朋克&

2026/06/30 10:48:22

中山网站建设专业网站建设公司

一、关键词基于协同过滤的动漫个性化推荐系统,动漫协同过滤个性化推荐平台,协同过滤动漫推荐平台二、作品包含源码+数据库+全套环境和工具资源+本地部署教

2026/06/30 10:57:22

合川网站建设长春网站建设

Ubuntu系统实用技巧大揭秘1. 文件与文件夹操作1.1 添加注释在Ubuntu系统中,任何文件或文件夹都可以添加注释。操作步骤如下:1. 右键单击文件或文件夹。2. 从弹出菜单中选择“属性”。3.

2026/06/30 14:17:39

电器网站建设东莞南城网站建设

Qwen3-VL轻量化部署:智能推理引擎重塑多模态应用新体验【免费下载链接】Qwen3-VL-4B-Instruct-FP8项目地址: https://ai.gitcode.com/hf

2026/06/30 11:18:25