VMware搭建分布式集群基础环境

1.安装CentOS

在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.配置网络

CentOS系统安装完成后,可能会发现系统并未自动分配IP,外网也不不能连接,
这是因为没有激活网卡,编辑ifcfg_ens33文件激活

cd /etc/sysconfig/network-scripts/
vi ifcfg-ens33

在这里插入图片描述
ONBOOT=no 修改为 ONBOOT=yes 保存退出。
在这里插入图片描述
执行命令 service network restart重启网络服务。安装最小版,可能无法执行ifconfig命令,需要安装ifconfig 命令的依赖软件net-tools

yum install -y net-tools

在这里插入图片描述
可以看出,虚拟机已经自动获取了IP 192.168.5.128 ,已经可以连接外网了。(因笔者之前有设置过虚拟机的网关,所以此处自动获取的IP是“5.X”的,一般自动获取的IP是“1.X”的,即 “192.168.1.X”这样的IP)

3.配置静态IP

以上我们已经动态获取了虚拟机的IP,但动态IP可能会随着虚拟机的重启而发生变化,特别是存在多台虚拟机都动态获取IP时,不太利于我们的开发和测试,因此,统一配置静态IP是有必要的。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
配置虚拟机网卡文件ifcfg-ens33

cd /etc/sysconfig/network-scripts/
vi ifcfg-ens33

在这里插入图片描述
将BOOTPROTO=dhcp修改为BOOTPROTO=static,然后再添加指定的静态IP、网关等配置,修改后的整体配置如下所示:(笔者此处没有配置DNS解析地址,如有需要可再加一行DNS1=119.29.29.29进行配置)

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=47f26d69-2258-4ed9-b3df-56a6f50a8c35
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.5.101
NETMASK=255.255.255.0
GATEWAY=192.168.5.2

修改完成保存,然后执行命令 service network restart重启网络服务
在这里插入图片描述
可以看到,虚拟机IP已修改为指定的静态IP 192.168.5.101

4.克隆虚拟机

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5.调整测试

把克隆的虚拟机重命名,以方便操作(F2键)
在这里插入图片描述
把CentOS7-slave1、CentOS7-slave2这2台机器的IP分别修改为192.168.5.102、192.168.5.103
在这里插入图片描述
修改3台虚拟机的hostname,依次修改为s1、s2、s3(原来的hostname都是localhost.localdomain),使用命令 vi /etc/hostname依次修改3台虚拟机的hostname,并重启虚拟机
在这里插入图片描述
在这里插入图片描述
经测试,3台虚拟机192.168.5.101、192.168.5.102、192.168.5.103hostname已修改,网络互通,均可访问外网

6.问题总结

6.1.执行yum 命令出错

错误示例:

Loaded plugins: fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#56 - "Recv failure: Connection reset by peer"
 
 
 
 
 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:
     1. Contact the upstream for the repository and get them to fix the problem.
     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).
     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:
 
 
            yum-config-manager --disable <repoid>
 
 
     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:
 
 
            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
 
 
Cannot find a valid baseurl for repo: base/7/x86_64

解决方案:修改DNS客户机配置文件(国内DNS服务器系统地址:114.114.114.114;谷歌DNS服务器系统地址:8.8.8.8)

vi /etc/resolv.conf
#新增配置
nameserver 114.114.114.114

6.2.安装telnet(测试虚拟机网络互通)

(1)安装telnet

yum -y install  xinetd
yum -y install  telnet
yum -y install  telnet-server

(2)配置telnet

vi /etc/xinetd.d/telnet
#新增配置
service telnet         
{  
  flags = REUSE  
  socket_type = stream  
  wait = no  
  user = root  
  server =/usr/sbin/in.telnetd  
  log_on_failure += USERID  
  disable = no   
}

(3)设置开机启动

systemctl enable telnet.socket
systemctl enable xinetd

(4)测试验证

#查看TCP的23端口是否开启正常
netstat -tnl |grep 23
tcp6       0      0 :::23                   :::*                    LISTEN
#测试连接
telnet IP地址

(5)提示telnet无法连接 Connection refused,检查防火墙和celinux

#关闭selinux
vi /etc/sysconfig/selinux
SELINUX=enforcing 改为 SELINUX=disabled
#查看防火墙状态
systemctl status firewalld
systemctl status iptables
#关闭防火墙
systemctl disable firewalld
systemctl disable iptables

(6)telnet 登录linux报错Login incorrect(用户名和密码正确)
(1)方案一:修改/etc/pam.d/login

vi /etc/pam.d/login
#注释auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
#auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
#重启telnet服务
service xinetd restart
systemctl start telnet.socket

(2)方案二:执行tail /var/log/secure,查看登录日志。日志提示:access denied: tty ‘pts/0’ is not secure(接入被拒绝,tty pts/0是不安全的)

#查看登录日志
tail /var/log/secure
#编辑securetty配置
vi /etc/securetty
#新增配置
pts/0
#重启telnet
service xinetd restart
systemctl start telnet.socket
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值