企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
![bigdata](https://img.kancloud.cn/e5/99/e5990d45c6572ac922966eecb6c1db86_1068x699.png) # 一、关闭防火墙开机自启 ```shell systemctl disable firewalld ``` # 二、`[克隆机重设]`设定主机名 ```shell echo "hadoop01" >/etc/hostname ``` ```shell echo "hadoop02" >/etc/hostname ``` ```shell echo "hadoop03" >/etc/hostname ``` # 三、配置<u>*hosts*</u>文件 ```shell echo "192.168.8.101 hadoop01" >>/etc/hosts echo "192.168.8.102 hadoop02" >>/etc/hosts echo "192.168.8.103 hadoop03" >>/etc/hosts ``` # 四、`[克隆机重设]`固定IP地址 ```shell vi /etc/sysconfig/network-scripts/ifcfg-ens33 ``` ①、将`BOOTPROTO`=`dhcp`修改为`BOOTPROTO`=`static` 。 ②、将`ONBOOT`=`no`修改为`ONBOOT`=`yes` 。 ```shell echo "IPADDR=192.168.8.101" >>/etc/sysconfig/network-scripts/ifcfg-ens33 echo "NETMASK=255.255.255.0" >>/etc/sysconfig/network-scripts/ifcfg-ens33 echo "GATEWAY=192.168.8.1" >>/etc/sysconfig/network-scripts/ifcfg-ens33 echo "DNS1=192.168.8.1" >>/etc/sysconfig/network-scripts/ifcfg-ens33 ``` # 五、配置<u>*Java*</u> ①、解压 — ②、改名 — ③、删源 ```shell tar -zxvf jdk-8u231-linux-x64.tar.gz -C /opt/ \ && mv /opt/jdk1.8.0_231 /opt/java \ && rm -rf jdk-8u231-linux-x64.tar.gz ``` ①、添加`JAVA_HOME` — ②、配置`PATH` — ③、配置生效 ```shell echo "export JAVA_HOME=/opt/java" >>/etc/profile \ && echo "export PATH=\$PATH:\$JAVA_HOME/bin" >>/etc/profile \ && source /etc/profile ``` # 六、简配<u>*Hadoop*</u> ①、解压 — ②、改名 — ③、删源 ```bash tar -zxvf hadoop-2.7.5.tar.gz -C /opt/ \ && mv /opt/hadoop-2.7.5 /opt/hadoop \ && rm -rf hadoop-2.7.5.tar.gz ``` ①、添加`HADOOP_HOME` — ②、配置`PATH` — ③、配置生效 ```shell echo "export HADOOP_HOME=/opt/hadoop" >>/etc/profile \ && echo "export PATH=\$PATH:\$HADOOP_HOME/bin:\$HADOOP_HOME/sbin" >>/etc/profile \ && source /etc/profile ``` # 七、配置SSH免密(操作前重启) ```shell ssh-keygen -t rsa ``` > .ssh # 权限为`700` ```shell ssh-copy-id hadoop01 ``` > authorized_keys # 权限为`600` 通过SSH执行命令环境变量失效问题 解决(一):在执行命令前,先执行 `source /etc/profile` 。 解决(二):环境变量配置在 `/etc/bashrc` 文件中。 # 八、`[克隆机重设]`同步时间 ```shell rpm -qa | grep ntp # 查询是否安装了ntp服务 ``` [ntp-4.2.6p5-29.el7.centos.x86_64.rpm](http://mirror.centos.org/centos/7/os/x86_64/Packages/ntp-4.2.6p5-29.el7.centos.x86_64.rpm) 依赖 ①、[autogen-libopts-5.18-5.el7.x86_64.rpm](http://mirror.centos.org/centos/7/os/x86_64/Packages/autogen-libopts-5.18-5.el7.x86_64.rpm)和②、[ntpdate-4.2.6p5-29.el7.centos.x86_64.rpm](http://mirror.centos.org/centos/7/os/x86_64/Packages/ntpdate-4.2.6p5-29.el7.centos.x86_64.rpm) ```shell # 安装软件 rpm -ivh ntpdate-4.2.6p5-29.el7.centos.x86_64.rpm rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm rpm -ivh ntp-4.2.6p5-29.el7.centos.x86_64.rpm ``` ```shell vi /etc/ntp.conf ``` 放开注释 ``` # Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap ``` 改后结果 ``` # Hosts on local network are less restricted. restrict 192.168.8.0 mask 255.255.255.0 nomodify notrap ``` > IP地址192.168.8.1-192.168.8.254,默认网关255.255.255.0的服务器都可以使用NTP服务器同步时间。 注释掉 ``` # 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 ``` 改后结果 ```shell # 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 server 127.127.1.0 fudge 127.127.1.0 stratum 10 ``` > 当服务器与公用的时间服务器失去联系时以本地时间为客户端提供时间服务 ```shell vi /etc/sysconfig/ntpd ``` 添加一行,同步硬件时钟 ``` SYNC_HWCLOCK=yes ``` ```shell systemctl start ntpd # 启动服务 systemctl enable ntpd # 开机自启 ``` 定时任务(主节点不用操作,从节点操作) ```shell crontab -e ``` 每隔10分钟同步一次时间 ``` */10 * * * * /usr/sbin/ntpdate hadoop01 ``` ```shell date -s "2010-05-05 12:12:12" ``` # 九、配置<u>*Hadoop*</u> ![configfile](https://img.kancloud.cn/6b/b9/6bb920c88d93280c553dc54325c9b59a_1128x833.png) ### hadoop-env.sh ```shell vi /opt/hadoop/etc/hadoop/hadoop-env.sh ``` ```shell export JAVA_HOME=/opt/java ``` ### core-site.xml ```shell vi /opt/hadoop/etc/hadoop/core-site.xml ``` ```xml <property> <name>fs.defaultFS</name> <value>hdfs://hadoop01:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/opt/hadoop/data/tmp</value> </property> ``` ### hdfs-site.xml ```shell vi /opt/hadoop/etc/hadoop/hdfs-site.xml ``` ```xml <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.namenode.secondary.http-address</name> <value>hadoop02:50090</value> </property> ``` ### yarn-env.sh ```shell vi /opt/hadoop/etc/hadoop/yarn-env.sh ``` ```shell export JAVA_HOME=/opt/java ``` ### yarn-site.xml ```shell vi /opt/hadoop/etc/hadoop/yarn-site.xml ``` ```xml <property> <name>yarn.resourcemanager.hostname</name> <value>hadoop01</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> ``` ### mapred-env.sh ```shell vi /opt/hadoop/etc/hadoop/mapred-env.sh ``` ```shell export JAVA_HOME=/opt/java ``` ### mapred-site.xml.template ```shell cp /opt/hadoop/etc/hadoop/mapred-site.xml.template /opt/hadoop/etc/hadoop/mapred-site.xml vi /opt/hadoop/etc/hadoop/mapred-site.xml ``` ```xml <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> ``` ### slaves ```shell echo "hadoop01" >/opt/hadoop/etc/hadoop/slaves echo "hadoop02" >>/opt/hadoop/etc/hadoop/slaves echo "hadoop03" >>/opt/hadoop/etc/hadoop/slaves ``` ##### 普通复制 ```shell cp -r source destination ``` ##### 远程复制 source和destination都可以是远程主机 ```shell scp -r source destination ``` ```shell scp -r root@hadoop01:/root/test root@hadoop03:/root ``` ##### 归档拷贝 source和destination只能有一个是远程主机 ```shell rsync -av source destination ``` ```shell rsync -av -r root@hadoop01:/root/test /root/ ```