VirtualBox6.0 搭建Ubuntu18.04集群环境

2019-01-01  本文已影响102人  大道至简非简

1、安装VirtualBox

https://www.virtualbox.org/
下载最新版6.0

image.png
安装启动。
image.png

2、下载Ubuntu18.04镜像

应为计划搭建hadoop集群,所以用server版本。
https://www.ubuntu.com/download/server

image.png

3、安装Ubuntu

image.png image.png
image.png image.png
image.png
image.png

启动安装。

image.png

选择下载的iso文件。


用户和密码都设置成为hadoop,一路安装即可。


image.png
image.png

4、配置主机

开启root账户

sudo passwd root
设置密码为hadoop

安装ssh服务

apt-get install openssh-server
设置允许超级管理员远程访问

# vi /etc/ssh/sshd_config
找到并用#注释掉这行:PermitRootLogin prohibit-password

新建一行 添加:PermitRootLogin yes

重启服务

# service ssh restart

设置网络桥接方式。

image.png

配置固定ip

/etc/netplan/50-cloud-init.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:   #配置的网卡名称
      dhcp4: no    #dhcp4关闭
      dhcp6: no    #dhcp6关闭
      addresses: [192.168.0.151/24]   #设置本机IP及掩码
      gateway4: 192.168.0.151   #设置网关
      nameservers:
          addresses: [114.114.114.114, 8.8.8.8]   #设置DNS

netplan apply 使配置生效。

配置hosts

/etc/hosts

#主机信息
192.168.0.151     hadoop01
192.168.0.152     hadoop02
192.168.0.153     hadoop03
192.168.0.154     hadoop04
192.168.0.155     hadoop05

配置hostname

sudo vi /etc/hostname

修改/etc/cloud/cloud.cfg

sudo vi/etc/cloud/cloud.cfg

preserve_hostname: true  #这里是将false改成true

修改最大线程数

vim /etc/security/limits.conf


root             soft         nofile      10240
root             hard       nofile      10240
root             soft       noproc      10240
root             hard       noproc      10240

设置时区

sudo tzselect 

sudo cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

设置ntp

sudo apt-get install ntp
service ntp start

安装jdk1.8

自带安装
apt install openjdk-8-jdk-headless
修改etc/profile

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOMR}/bin:$PATH

配置生效

source /etc/profile

5、复制主机

image.png

登录更改相关的hostname和ip地址即可。

6、集群间主机互信

生成密钥(主机全部执行一遍)

hadoop@hadoop01:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa): 
Created directory '/home/hadoop/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/hadoop/.ssh/id_rsa.
Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3QfoHhnfu/GwcJ0zKNWIYYq7cCQko6vZjdAP47lR1cA hadoop@hadoop01
The key's randomart image is:
+---[RSA 2048]----+
|     ..          |
|      Eo   .     |
|   o .. . oo.    |
|  . +.  .oo=ooo  |
| .  .. oS.=.ooo. |
| ...  o .. ....o.|
|..=  . o  ....=+.|
|.= O  o .   .o *o|
|o *.o  .      o .|
+----[SHA256]-----+

传给互信主机

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys hadoop01:/root/.ssh/authorized_keys
scp ~/.ssh/authorized_keys hadoop02:/root/.ssh/authorized_keys
scp ~/.ssh/authorized_keys hadoop03:/root/.ssh/authorized_keys
scp ~/.ssh/authorized_keys hadoop04:/root/.ssh/authorized_keys
scp ~/.ssh/authorized_keys hadoop05:/root/.ssh/authorized_keys

全文完。

上一篇下一篇

猜你喜欢

热点阅读