首頁 > 軟體

Hadoop部署的基礎設施操作詳解

2023-02-25 06:04:31

官網導讀

hadoop.apache.org/docs/r2.6.5…

  • 支援最好的平臺:GNU/Linux

  • 依賴的軟體:

    • Java™ must be installed. Recommended Java versions are described at HadoopJavaVersions.Hadoop基於Java開發,Java的行動性好
    • ssh must be installed and sshd must be running to use the Hadoop scripts that manage remote Hadoop daemons.
  • 部署模式:

    • Local (Standalone) Mode 單機模式,主要用於debug
    • Pseudo-Distributed Mode 偽分散式,單節點多角色
    • Fully-Distributed Mode 完全分散式,多節點多角色

基礎設施

作業系統、環境、網路、必須軟體

  • 設定IP及主機名
  • 關閉防火牆&selinux
  • 設定hosts對映
  • 時間同步
  • 安裝jdk
  • 設定SSH免祕鑰

設定IP及主機名

可以正常聯網檢視IP

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.118  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::3db1:f589:4820:5457  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:18:10:17  txqueuelen 1000  (Ethernet)
        RX packets 462062  bytes 670399544 (639.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 166351  bytes 11096211 (10.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 84  bytes 13940 (13.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 13940 (13.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:5a:69:e1  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
// 設定
DEVICE=eth0
#HWADDR=00:0C:29:42:15:C2
TYPE=Ethernet
ONBOOT=yes
NM_TROLLED=yes
BOOTPROTO=static
IPADDR=192.168.150.11
NETMASK=255.255.255.0
GATEWAY=192.168.150.2
DNS1=223.5.5.5
DNS2=114.114.114.114

修改組態檔設定主機名

[root@localhost ~]# vi /etc/sysconfig/network
// 設定主機名並儲存退出
HOSTNAME=node01

關閉防火牆&selinux

//關閉防火牆
[root@localhost ~]# systemctl stop firewalld
//關閉開機啟動防火牆
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# 
[root@localhost ~]# vi /etc/selinux/config
//將組態檔中的SELINUX設定為disabled
SELINUX=disabled

設定hosts對映

增加對映關係,因為在現在搭建環境的時候,一般會做解耦,不會再軟體組態檔中寫ip地址,主要使用主機名,就和dns解析一樣,避免ip改變時要修改很多組態檔

[root@localhost ~]# vi /etc/hosts
// 增加對映關係
192.168.0.118 node01
192.168.0.119 node02

時間同步

所有節點時間需同步一致,不然未來做心跳的時候會有問題

[root@localhost ~]# date
Fri Dec 30 22:23:45 CST 2022
// 安裝ntp
[root@localhost ~]# yum install ntp -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Package ntp-4.2.6p5-29.el7.centos.2.x86_64 already installed and latest version
Nothing to do
[root@localhost ~]# vi /etc/ntp.conf
// 增加設定
server ntp1.aliyun.com
// 啟動ntpd
[root@localhost ~]# systemctl start ntpd.service
// 設定開機啟動ntpd
[root@localhost ~]# systemctl enable ntpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
[root@localhost ~]# 

安裝jdk

設定環境變數的時候要記得設定兩次,一次在安裝jdk的時候設定,一次在搭建Hadoop的時候設定

去官網下載jdk,最好是rpm包,然後上傳到伺服器節點中(使用jdk壓縮包解壓安裝需要做很多其他的設定)

這裡使用過windows下載,通過scp命令上傳到118節點中

F:workspacedemo>scp C:Users43866Downloadsjdk-8u351-linux-x64.rpm root@192.168.0.118:/usr/jdk
root@192.168.0.118's password: 
jdk-8u351-linux-aarch64.rpm                                                                                           100%   59MB  70.1MB/s   00:00     
F:workspacedemo> 

在118節點中使用命令安裝jdk

[root@node01 jdk]# rpm -i jdk-8u351-linux-x64.rpm 
warning: jdk-8u351-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Unpacking JAR files...
        tools.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
        rt.jar...
        jsse.jar...
        charsets.jar...
        localedata.jar...
[root@node01 jdk]# 

設定JAVA_HOME環境變數

[root@node01 default]# vi /etc/profile
// 追加環境變數並儲存檔案
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin

設定SSH免祕鑰

想要使用Hadoop指令碼就必須設定ssh免密

1、檢查是否已設定ssh免密

[root@node01 default]# ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:rDsunaro1f5LyKkEeNohXfDD9oEglNXtviD/JZtA1dw.
ECDSA key fingerprint is MD5:51:38:8d:fc:e4:d2:c7:ce:66:09:c8:f2:e6:9e:a7:f2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
root@localhost's password: 

通過ssh localhost命令檢查發現需要輸入密碼,說明還未設定ssh免密,而且還可以自動生成.ssh檔案,這個檔案要建立的話比較麻煩

2、生成祕鑰和公鑰

如果118節點想免密登入到118節點(自己):

118節點就要生成公鑰和祕鑰,且將公鑰放到 ~/.ssh/authorized_keys中

[root@node01 .ssh]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
Generating public/private dsa key pair.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
SHA256:GHhKB7GeoYYlNPWJpCZ+VoABUyIgDbdYrjjyAdgui1k root@node01
The key's randomart image is:
+---[DSA 1024]----+
|@BB+o.           |
|=X=.++.          |
|*o=.=++          |
|=B +.* o         |
|B.Eo+ . S        |
|oOo.             |
|+ .              |
|                 |
|                 |
+----[SHA256]-----+
[root@node01 .ssh]# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[root@node01 .ssh]# 
[root@node01 .ssh]# ssh 192.168.0.118
Last login: Sat Dec 31 13:52:49 2022 from 192.168.0.117
[root@node01 ~]#

結論

119節點包含了118節點的公鑰,118就可以免密登入

以上就是Hadoop部署的基礎設施操作詳解的詳細內容,更多關於Hadoop部署基礎操作的資料請關注it145.com其它相關文章!


IT145.com E-mail:sddin#qq.com