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

上海思丽文化传媒有限公司 2026/09/09 18:12:25

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

海口网站建设山西网站建设

还在为B站缓存的m4s格式视频无法在其他设备播放而烦恼吗?这些看似普通的视频文件其实被B站的数字内容保护机制锁定,导致只能在特定环境下使用。今天,我将为你揭秘

2026/06/30 10:51:22

商业网站建设北京高端网站建设

博主介绍:✌️码农一枚 ,专注于大学生项目实战开发、讲解和毕业🚢文撰写修改等。全栈领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等

2026/06/30 10:06:18

中山网站建设西安专业网站建设

在智能电视普及的今天,大屏上网已成为家庭娱乐的重要组成部分。然而传统浏览器在电视设备上的糟糕体验——操作不便、加载缓慢、界面混乱——严重影响了用户的使用感受。TV-Bro作为专为电视设备

2026/06/30 11:22:55

网站建设与管理网站建设技术

GoatCounter无cookie访客跟踪:终极隐私保护方案技术揭秘【免费下载链接】goatcounterEasy web analytics. No tracking of pers

2026/06/30 11:21:55

网站建设高端建设行业网站

在无线音频的世界里,一场静默却深刻的革命正在进行。它,就是LE Audio。这不仅仅是一次技术迭代,而是从底层重新定义声音如何被创造、传输和体验的范式转移。其

2026/06/30 13:52:38

鄂州网站建设建设官方网站

Geist字体完全指南:彻底解决开发者的字体选择难题【免费下载链接】geist-font项目地址: https://gitcode.com/gh_mirrors/ge/geist-fon

2026/06/30 09:57:17

外贸网站建设网站建设软件

大文件传输系统解决方案作为公司技术负责人,针对大文件传输需求,我将从技术选型、架构设计和实现方案等方面进行全面分析。需求分析我们的核心需求可以总结为:支持超大

2026/06/30 14:13:09

万州网站建设荆门网站建设

文章目录具体实现截图主要技术与实现手段系统设计与实现的思路系统设计方法java类核心代码部分展示结论源码lw获取/同行可拿货,招校园代理 :文章底部获取博主联系方式!具体实

2026/06/30 13:02:34

网站建设教程鞍山网站建设

实现高可靠性的USB功能应用,是嵌入式开发中常见却极具挑战性的任务。硬件设计中的电源完整性、信号完整性问题,常常成为系统不稳定的根本原因;而软件层面的协议处理

2026/06/30 13:21:35

网站建设模板摄影网站建设

Conda环境克隆快速复制TensorFlow开发配置在深度学习项目中,最让人头疼的往往不是模型调参,而是“为什么你的代码在我机器上跑不通”。这种经典的“在我这儿没问题”困

2026/06/30 10:24:20