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

南宁市创知电子科技有限公司 2026/09/09 19:04:21

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

网站建设协议网站建设项目

第一章:医疗AI诊断Agent模型融合的挑战与机遇在人工智能加速渗透医疗领域的背景下,多Agent系统在医学影像识别、辅助诊断和个性化治疗建议中的应用日益广泛。然而

2026/06/30 10:28:50

苏州网站建设app网站建设

MGeo在婚庆公司客户信息管理中的实用价值引言:婚庆行业客户数据治理的现实挑战在婚庆服务行业中,客户信息管理是业务运营的核心环节。每对新人从咨询、预订到婚礼执行࿰

2026/06/30 12:14:00

诸城网站建设马鞍山网站建设

智能家居DIY:用RAM模型给你的家装上"眼睛"想让你的智能家居系统像人类一样识别家庭成员和日常物品吗?RAM(Recognize Anyth

2026/06/30 10:30:20

如何建设网站官方网站建设

上拉电阻与信号完整性:从原理到实战的深度拆解你有没有遇到过这样的情况——电路明明没接错,代码也跑通了,但I²C总线就是时不时丢数据?或者按键输入

2026/06/30 14:15:39

网站建设策划市网站建设

在锁屏或长时间不操作时,导致VS Code SSH连接断开的主要原因是网络中的防火墙或路由器会关闭长时间空闲的连接。你可以通过配置“心跳包”和让后台进程独立运行这两种方法来解决。下面我将

2026/06/30 13:24:35

网站建设广告深圳外贸网站建设

背景与意义大数据旅游数据分析与推荐系统基于Django框架开发,结合大数据技术,旨在解决传统旅游行业信息过载、个性化服务不足等问题。通过整合海量旅游数据(如用

2026/06/30 13:05:04

苏州网站建设网站建设论文

界面新闻财经内容检查:Qwen3Guard-Gen-8B识别市场操纵言论在信息传播速度远超监管反应节奏的今天,一条看似普通的财经评论,可能正悄然撬动千万级资金

2026/06/30 13:24:35

贵阳网站建设网站建设计划书

硬盘隐藏区域及安全功能的访问与管理1. 硬盘SMART日志相关信息硬盘存在一些特定的SMART日志代码,不同代码代表不同的含义,如下表所示:| 代码 | 数量 | 其他信息 | 含义 || — | —

2026/06/30 11:33:26