搭建hadoop_之 创建3个虚拟机配置好网络
(创建3个虚拟机,1个作为主服务器,二个作为从节点)
一、安装虚拟机
Windwos:VMware Workstation Pro
MAC:VMware Fusion
安装:
** 创建空虚拟机
** 安装虚拟机时的资源规划
Linux版本:Centos 6.8 或 CentOS 7.2 1611内核
内存:
linux01:
内存:4G
CPU:1个 2core
linux02:
内存:2G
CPU:1个 1core
linux03
内存:2G
CPU:1个 1core
** 虚拟机网络设置
** $ su - root
输入密码
** # vi /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.216.20
NETMASK=255.255.255.0
GATEWAY=192.168.216.2
DNS1=192.168.216.2
DNS2=8.8.8.8
BOOTPROTO=static
ONBOOT=yes
** 重启网卡服务
CentOS6.8: # service network restart
CentOS7.2: # systemctl restart network.service
** CRT远程连接Linux
** 禁用SELinux
** Selinux:linux安全管理工具
** # vi /etc/sysconfig/selinux
** 编辑改动如下:
SELINUX:disable
** 禁用防火墙
** CentOS 6.8
iptables
# service iptables stop
# chkconfig iptables off
** CentOS 7.2
# systemctl stop firewalld.service
# systemctl disable firewalld.service
** ping外网测试
** visudo
在如下加上这么一句话:
······················· ![]()
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATIAAAA1CAYAAADCtGfJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAxESURBVHhe7Z1rmuogDIbPntyOi+leuhaXMuvw8HFroEmgHdHi5Mf7jDYFciPFFp1/Pz8/z3///hmGYczLVQrZbXk8oYvnsTxvnTLD+Bru63z5fVuejyvo/JlCdn+uUlHSgjljoCtQlB/LjZVpnG1nTIQVsvM0CxlR9L4+nsutU6bhA+Ym5s/6vLMywTFWyFiZ8SVYITtPs5A554YJhFVUVXg0mUKalPf157neK/mZQuacuT7CR8/HmuS35+KK5b64Qteeohvar4uzEatHuoJkx4tIMuie+sl0+KzVTtNFRbCvTkzq8yhb3EUr6NF/8UKss/60f7VPJlZafhQ4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rey1sCe0P25dg/QkwVuwv0zFxEbeiDYj5Utm+70+zvUXwTa2f7JctN/L5JOfa/uTHU4H9yba1zm85tmKMoj/zezpnKl/v80xAix+QdGki2HfAhpwveLMfwMEqHxu6gUVZM4hQPhQwFLTdrmKqdA0rS/0hwUNxTAWCLZRwBIIQ/2Z98UXfVhBS2zimH6fSKYwfd3X7X0RwOuBXD7R2vl/eBrHPbFfoc+eXM/Z5ZH9msh/IsQ7EFVm2fZ8Tuu0naPiF870f77Q/Nfa+LuMoxFaLEfSk5x/Isxb8iqwjX0QE+7ptIPmCApQ72IGBQsLujdBkCjEh8tW4nhBssVJkdR84J06ETS9ypU1y384diw7pAm3i+EWCF04u7fE6uCvtoXbEBrHP7O+USJvc49sdtA9oukjndMLmCTdey5+9ucbR8gsdn37SaLU7g2a7R4tt1Y7mC+1D8ydt10F3/Lr7VOw7YoOT6YUsd4gBYyHokSnAGZuhjCFU6RpO1jIar91f/FYUgkCD4X+OGMedD7pWk2QsuSChrwqM0WqXXoNd4Jg+Cx/yuh+2D2i60HNoMnUiToTTtp9D98t20Stz9aQ/NZq+FmLb8tkZWQeH49fkVfYtz/+39Oj57unJYQAAAABJRU5ErkJggg==)
admin ALL=(ALL) NOPASSWD: ALL
** 修改主机名
CentOS 6.8:
$ sudo vi /etc/sysconfig/network
································![]()
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKEAAABLCAYAAAAYjudSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAnCSURBVHhe7ZtNjBxHFYDnyBHJF44cuEWBw1xCzpE4gFAOyAc0Fy578YUrJ0ZckIhA9i2IkAi1LEAckIyyBhI5xGZsLz+RA4ll2RYRQRsvrNcYS4v2B+lRr+q96ld/PT273Ts9u69Wn7en/rve1zU9vePRvXv3oInNzU3Y3d214PHoWzdh9L2/K0PExAZjdPXq1U7Avk4ClfA0ISTc29s7FiqhcjRUQmXpqITK0lEJlaWj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PaPzu09dtJNGQJ3UNuepgdrHUNyjgoCeldt5iOLWHmEYRfhFaBK0hY/GqVe81jYFCCOsGfAk2/C/150bGIhHL3CXZuXBdTX+5a/hypzPcV9W3fJcS54nk4qXCtCmvdlNf0Q3VWW8JccLjMCkpX7jhcqJqShKZP2Tf3aevU92BWAs6n+vhFiGpi+uU+SvMssPhOmLknpHPnt8tgnnMkDPozZb5u3A7h8xN5p1dCU5ZQCq5cGPtduXq3SL8a3yChDQaVBX1igGlHkMfczgaLAsHt8LecO0L9WUFEPgZElodzotcBJQnFriXbxzLl+rbtzTnw+XMenx+vGZ+faKs7oSyTeYj8Kr7Pb5KQjnkc6jPYVaJdw7WL8krzLNDZTijry/ZtJKQ+g3WM2yF8fiLv7Elor8r59ymepK85EnK5/+YKBQd3KoHf9UpBypURve2Esr5s30JCd6Hht8TlX1xwLfSeMJPnAuBP2iywlwqPTZ16caO6lnkSCknseA31M8H088yVFcgGJHOx1SwoYXAO7sNVMDc5VjSufjou5plF9btT9OzK1JPfIsav8YcizJfQ1THtizJRH7kvgPI88beYhyMvVSkg+Ck1bEfzirAyNkooLqxk3qnQtq4sLzwnzJ2j7afph9oOX8IzRq8BWQZNP1RHJRwYKmHHkGvFpBKmqIQdQ64Vk0qYcuokbIFKODBUwo4h14pJJUxRCTuGXCsmlTBFJewYcq2YVMIUlbBjyLViUglTVMKOIdeKSSVMwYCcRXJr0QnkWjGphErvkGvF1E7CNfhiBfDyNYCXvrsG5zDvuTV4/sJapq6iRJBrxdRGwnMXLsJnn6Pjr6zDS0bGl6t1eJ7yFKURcq2Y2u2EinIMyLViUgmV3iHXikklVHqHXCsmlVDpHXKtmFRCpXfItWJSCZXeIdeKSSVU+mUE/weRnGkuf6h3PgAAAABJRU5ErkJggg==)
CentOS 7.2:
$ sudo vi /etc/hostname
** 修改ip与主机名的映射关系
$ sudo vi /etc/hosts
192.168.216.20 linux01
192.168.216.21 linux02
192.168.216.22 linux03
** 安装JDK
**下载jdk1.8
不能直接用wget http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.tar.gz 因为这样下来的包 是有问题的
方法1,浏览器下载 上传到服务器
方法2. 浏览器下载的时候复制 下载链接 这个时候再用wget url地址
这个时候会有个一个文件
重命名:mv 当前文件 jdk-1.8.tar.gz
** 解压 tar -zxf jdk-1.8.tar.gz
** 配置环境变量 vim /etc/profile
#JAVA_HOME
JAVA_HOME=/home/admin/modules/jdk1.8.0_121
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
** 删除OpenJDK(CentOS 自带的JAVA环境)
rpm -qa|grep java 找到系统自带的java
依次删除他们
** source刚才配置好的系统环境变量文件
$ source /etc/profile
** 验证
$ java -version
如果报错如下: 则yum install glibc.i686 可以解决
** 克隆
将linux01,克隆出linux02,linux03
** 先关闭虚拟机
** 完成克隆
** 修改后两台机器的网络配置
** 主机名
$ sudo vi /etc/sysconfig/network
** 网卡MAC地址
$ sudo vi /etc/udev/rules.d/70-persistent-net.rules
** 修改固定IP地址 和对应的mac地址
$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
** 重启机器(注意,克隆出来的两台机器都要配置)(如果不重启,网络会报错Connection activation failed: The connection is not for this device.)
** 使用CRT连接3台机器,测试
** 配置SSH无秘钥访问(如下操作,需要在3台机器中分别执行)
** 生成密钥
$ ssh-keygen -t rsa
** 分发公钥
$ ssh-copy-id linux01; ssh-copy-id linux02; ssh-copy-id linux03;
** ssh访问测试
ssh linux01
ssh linux02
ssh linux03
** 关闭后两台机器的界面
CentOS6:
$ sudo vi /etc/inittab
CentOS7:
$ sudo systemctl set-default multi-user.target
** 安装VMTool
** 配置时间服务器
** 检查时区
$ date -R
** 检查软件包 NTP服务器【Network Time Protocol(NTP)】是用来使计算机时间同步化的一种协议
如果ntp工具不存在,则需要使用yum安装
$ sudo rpm -qa | grep ntp
如果不存在则安装:
$ sudo yum -y install ntp
** 如果时区不是+0800东八区区时的话,需要手动纠正
$ sudo rm -rf /etc/localtime
$ sudo ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
** 先以网络时间为标准,纠正集群的时间服务器的时间
$ sudo ntpdate pool.ntp.org
** 修改ntp配置文件(只修改主服务器的时间配置,其他的向主服务器同步时间即可)
$ sudo vi /etc/ntp.conf
修改为如下:
#允许192.168.216.x网段上的所有机器和当前这台机器进行实践同步
restrict 192.168.216.0 mask 255.255.255.0 nomodify notrap
#当该节点丢失网络连接,依然可以作为时间服务器为集群其他节点提供时间同步服务
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
** 重启ntp服务
CentOS6:
$ sudo chkconfig ntpd on
$ sudo service ntpd restart
CentOS7:
$ sudo systemctl enable ntpd.service
$ sudo systemctl restart ntpd.service
** 使用从节点,手动同步时间(后面两台机器都要操作)
$ sudo ntpdate linux01
** 设置时间同步任务
# crontab -e 编辑时间任务
(尖叫提示:上面的#号代表root用户,下边的#号代表shell注释)
# .------------------------------------------minute(0~59)
# | .----------------------------------------hours(0~23)
# | | .--------------------------------------day of month(1~31)
# | | | .------------------------------------month(1~12)
# | | | | .----------------------------------day of week(0~6)
# | | | | | .--------------------------------command
# | | | | | |
# | | | | | |
*/10 * * * * /usr/sbin/ntpdate linux01
# crontab -l 查看时间任务
** 重启定时任务
CentOS6:
# service crond restart
CentOS7:
# systemctl restart crond.service
** 虚拟定期备份,一定要做!!!!!
先关机:
$ sudo shutdown -h now
按照时间新建文件夹,将已经安装完成的3台虚拟机,备份到该文件夹中。