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

网站建设营销推广实训总结网站制作建设公司

网站建设营销推广实训总结,网站制作建设公司,南庄建网站服务,营销型网站设计工资Ansible是Python开发的自动化运维工具,集合了众多运维工具(Puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置,批量程序部署、批量运行命令等功能。 特点: 1)部署简单&#xff…

Ansible是Python开发的自动化运维工具,集合了众多运维工具(Puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置,批量程序部署、批量运行命令等功能。

特点:

1)部署简单;

2)默认使用ssh进行管理,基于Python里的paramiko模块开发;

3)管理端和被管理端不需要启动服务;

4)配置简单、功能强大、拓展性强;

5)能playbook剧本进行多任务的编排;

 

实验准备:

三台机器:一台管理、两台被管理。

主机IP地址备注信息
管理机Master192.168.17.104
被管理机1192.168.17.105
被管理机2192.168.17.106

实验过程:

1)在管理机上安装ansible,被管理机上必须打开ssh服务。

yum install -y epel-release
yum install ansible[root@localhost ~]# ansible --version
ansible 2.9.27config file = /etc/ansible/ansible.cfgconfigured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']ansible python module location = /usr/lib/python2.7/site-packages/ansibleexecutable location = /usr/bin/ansiblepython version = 2.7.5 (default, Jun 20 2023, 11:36:40) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

 2)实现master对agent的免密登录,只有master上做。(如果这步不做的话,则在后面操作agent时候要加上-k参数传密码,或者在主机清单里传密码。)

ssh-keygenssh-copy-id -i 192.168.17.105
ssh-copy-id -i 192.168.17.106

3)在master上定义主机组,并测试连接性。

 说明:inventory:财产清单,库存等。

在hosts清单中添加两个机器IP地址。

[root@localhost ansible]# tail -3 hosts
[group1]
192.168.17.105
192.168.17.106
[root@localhost ansible]# ansible all -m ping
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

说明:all是所有机器。-m是module的意思,ping是模块。

[root@localhost ansible]# ansible group1 -m ping
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

服务器分组:

ansible通过一个主机清单功能来实现服务器分组。

Ansible的默认主机清单配置文件为/etc/ansible/hosts

 另外,如果服务器比较多的情况下,也可以写:

[nginx]
apache[1:10].aaa.com
nginx[a:z].aaa.com
10.1.1.[11:15]
[root@localhost ansible]# tail -2 hosts
[group1]
192.168.17.[105:106]

然后再用ping模块测试:

[root@localhost ansible]# ansible group1 -m ping
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

再看一个例子:

[nginx]
10.1.1.13:2222

表示的是10.1.1.13这台机器,但是端口是2222端口。

[root@localhost ansible]# tail -3 hosts
[group1]
192.168.17.105
192.168.17.106:2222
[root@localhost ansible]# ansible group1 -m ping
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

别名的写法:

定义10.1.1.12:2222 这台服务器的别名nginx1。

nginx1 ansible_ssh_hosts=10.1.1.13 ansible_ssh_port=2222

没有做免密登录的服务器可以指定用户名和密码

nginx1 ansible_ssh_host=10.1.1.13 ansible_ssh_port=2222 ansible_ssh_user=root ansible_ssh_pass="123456"
nginx2 ansible_ssh_host=10.1.1.12# /etc/ansible/hosts
[nginx]
nginx1
nginx2

说明:密码最好是一个加密字符串。

[root@localhost ansible]# tail -6 hosts
nginx1 ansible_ssh_host=192.168.17.106 ansible_ssh_port=2222 ansible_ssh_user=root ansible_ssh_pass="1q2w3e4r"## db-[99:101]-node.example.com
[group1]
192.168.17.105
nginx1

 别名的测试。

[root@localhost ansible]# ansible group1 -m ping
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
nginx1 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

小结:

主机清单的作用:服务器分组。主机清单就是服务器分组。

主机清单的常见功能:

1)可以通过IP范围来分,主机名的名称来分;

2)如果ssh端口不是22,可以传入新端口;

3)没有做免密登录,可以传密码。

不论是哪种环境(免密或不免密,端口是否22),请最终将两台被管理机器加入到group1组即可。

http://www.yayakq.cn/news/907598/

相关文章:

  • 免费试用网站 源码印象笔记wordpress同步
  • 南通网站建设公司排名富国基金公司网站
  • nft制作网站私密浏览器在线看
  • 网站群 建设 方案怎么做百度网站验证码
  • 西安网站建设中企建站wordpress 公式
  • asp网站程序优点北京网下载
  • 网站建设需要资料网站设计总结
  • 提升型企业网络营销网站青海省教育厅门户网站登录
  • 网站301检测北京网站开发品牌
  • 网站开发语言数据库有几种开发个网站多少钱
  • server2008部署网站西安市建设网站
  • 模板免费网站建设江门电商网站设计培训
  • 免费域名网站推荐什么是网络营销直播
  • 运动网站模板名词解释 网站内容
  • 模板网站平台农产品交易平台
  • 公司注册的流程与步骤无锡网站关键词优化软件咨询
  • 厦门建设厅查询网站首页怎样登网站
  • 加强网站硬件建设方案网站建设教程信赖湖南岚鸿点 赞
  • 网站备案 地域制作网站网页
  • php装修网站源码无锡手机网站制作
  • 如何做网商商城的网站wordpress+仿简书模板
  • 深圳 网站设计师 招聘手机上可以创建网站吗
  • 太仓智能网站开发网络建设概述
  • 网站推介方案前端设计除了做网站还能做什么
  • 如何制作一个自己的网站?网站卖东西怎么做
  • 免费做公益网站物流网站的建设实训
  • 大型网站制作平台手机网站怎么做推广
  • 网站建设方法氵金手指排名27阳谷网站建设费用
  • 网站的建设时间表饰品电子商务网站的建设
  • 易企秀网站怎么做轮播图凡科做网站多少钱