目录
vim /etc/sysconfig/network-scripts/ifcfg-ens33
三.在ant151机器运行自动安装jdk脚本autoinstall.sh
设置标识在datas里面创建myid用于标识便于找到ant151这台机器
一.创建多台虚拟机
这里以四台虚拟机为例 ant151 / ant152 / ant153 / ant154
1.1查看虚拟机名称
[root@localhost ~]# hostname
1.2修改计算机名称
三台虚拟机修改名称
[root@localhost ~]# hostnamectl set-hostname ant151
[root@localhost ~]# hostnamectl set-hostname ant152
[root@localhost ~]# hostnamectl set-hostname ant153
[root@localhost ~]# hostnamectl set-hostname ant154
快速生效
[root@localhost ~]# bash
二.开始配置
2.1修改网络信息
vim /etc/sysconfig/network-scripts/ifcfg-ens33
按前面编号写入以下代码
4 BOOTPROTO=static
15 ONBOOT=yes
16 IPADDR=192.168.78.*
17 GATEWAY=192.168.78.2
18 NETMASK=255.255.255.0
19 DNS1=8.8.8.8
2.2重启网络服务
两种方法:
systemctl restart network.service
service network restart
关闭和禁用每台机的防火墙
[root@ant151 ~]# systemctl stop firewalld
[root@ant151 ~]# systemctl disable firewalld
2.3同步时间
同步时间的下面操作三台机都需要
安装ntpdate
[root@ant151 soft]# yum install -y ntpdate定时更新时间
[root@ant151 soft]# crontab -e每五分钟更新一次时间
*/5 * * * * /usr/sbin/ntpdate -u time.windows.com
启动定时任务
[root@ant151 soft]# service crond start
2.4设置集群中每台机器的/etc/hosts
[root@ant151 opt]# vim /etc/hosts
下面加入
IP地址 计算机名称
例如:
192.168.111.111 ant151
192.168.111.111 ant152
192.168.111.111 ant153
把hosts拷贝发送到每一台虚拟机
[root@ant151 opt]# scp /etc/hosts root@ant152:/etc/
[root@ant151 opt]# scp /etc/hosts root@ant153:/etc/
并且在windows界面c盘的system32目录下配置hosts文件
再次加入以下代码
192.168.111.111 ant151
192.168.111.111 ant152
192.168.111.111 ant153
2.5配置免密登陆
[root@ant151 ~]# ssh-keygen -t rsa -P ''
[root@ant151 ~]# cd .ssh/
把id_rsa.pub追加到au...下面
[root@ant151 .ssh]# cat id_rsa.pub >> ./authorized_keys
2.6将本机的公钥拷贝到要免密登陆的目标机器
[root@ant151 .ssh]# ssh-copy-id -i ./id_rsa.pub -p22 root@ant151
[root@ant151 .ssh]# ssh-copy-id -i ./id_rsa.pub -p22 root@ant152
[root@ant151 .ssh]# ssh-copy-id -i ./id_rsa.pub -p22 root@ant153
每一台机器都要执行
2.7 测试免密登陆是否成功
[root@ant151 .ssh]# ssh