三.3.1.1 3.1.2 3.1.3 ansible安装部署
ansible机上上传压缩包
修改主机名(三台都要)
[root@ecs-110f-0002 ~]# hostnamectl set-hostname ansible
[root@ecs-110f-0002 ~]# bash
[root@ansible ~]#
[root@ecs-110f-0003 ~]# hostnamectl set-hostname rabbix_server
[root@ecs-110f-0003 ~]# bash
[root@rabbix_server ~]#
[root@ecs-110f-0001 ~]# hostnamectl set-hostname rabbix_agent
[root@ecs-110f-0001 ~]# bash
[root@rabbix_agent ~]#
解压压缩包
[root@ansible ~]# tar -zxvf ansible.tar.gz -C /opt/ (安装包名字可能会变)
(可能需要先安装ansible 看能否访问vim /etc/ansible/hosts)
(安装时先要把centos的源删除)(后面做可以加上)
[root@ansible ~]# vim /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[ansible]
name=ansible
baseurl=file:///opt/ansible (看压缩完叫什么名,不一定是ansible)
gpgcheck=0
enabled=1
[root@ansible ~]# yum clean all
[root@ansible ~]# yum repolist
(若没有vim /etc/ansible/hosts先安装ansible)
[root@ansible ~]# yum install ansible -y
更改密码
[root@ansible ~]# passwd
[root@rabbix_server ~]# passwd
[root@rabbix_agent ~]# passwd
配置主机映射
[root@ansible ~]# vim /etc/hosts
[root@rabbix_server ~]# vim /etc/hosts
[root@rabbix_agent ~]# vim /etc/hosts
配置免密登录
[root@ansible ~]# ssh-keygen
[root@ansible ~]# ssh-copy-id ansible
[root@ansible ~]# ssh-copy-id rabbix_server
[root@ansible ~]# ssh-copy-id rabbix_agent
另外两台配置免密登录
[root@rabbix_server ~]# ssh-keygen
[root@rabbix_server ~]# ssh-copy-id ansible
[root@rabbix_server ~]# ssh-copy-id rabbix_server
[root@rabbix_server ~]# ssh-copy-id rabbix_agent
[root@rabbix_agent ~]# ssh-keygen
[root@rabbix_agent ~]# ssh-copy-id ansible
[root@rabbix_agent ~]# ssh-copy-id rabbix_server
[root@rabbix_agent ~]# ssh-copy-id rabbix_agent
关闭防火墙
[root@ansible ~]# setenforce 0
查看所含文件
[root@ansible ~]# vim /etc/ansible/hosts
(在最后面加上)
(验证)
- 点赞
- 收藏
- 关注作者
评论(0)