【Hadoop】集群配置要点

1.SSH免密码登录

1.1生成公钥,一直enter,直到完成

dream361@master:~$ ssh-keygen -t rsa

1.2传送公钥 

dream361@master:~$ scp /home/dream361/.ssh/id_rsa.pub /home/dream361/.ssh/authorized_keys

1.3传送到其他节点并生成~/.ssh/authorized_keys文件(因为authorized_keys的拼写失败了好多次,少写了'z')

如此即可免密码 

1.4同时主节点本身也是要免密码登录自己的,将公钥cat到自己的.ssh目录下生成authorized_keys文件

1.5 .ssh/authorized_keys 的权限为600  $ chmod 600 .ssh/authorized_keys

1.6 本机免密码登录 $ cat .ssh/id_rsa.pub >>.ssh/authorized_keys

2. /etc/hosts 主机名配置 (所有节点共用这个文件的内容 第三列代表用户名)

dream361@master:/$ cat /etc/hosts
127.0.0.1       localhost
192.168.5.4     master  dream361
192.168.5.5     slave1  dream361
192.168.5.6     slave2  dream361

配置完了 使用scp 传送到 从节点的/etc/hosts文件下

root@master:/home/dream361# scp /etc/hosts root@slave4:/etc/hosts

3.环境变量配置 JAVA_HOME、HADOOP_HOME、PATH

变量的设置位置可以是/etc/profile 或 ~/.bash_profile

我的是在/etc/profile

dream361@master:/$ cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

export JAVA_HOME=/usr/local/jdk
export HADOOP_HOME=/usr/local/hadoop
export PATH=$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#其他内容省略

4.主要的集群配置文件

/usr/local/hadoop/etc/hadoop/core-site.xml 、hdfs-site.xml等

4.1 core-site.xml

dream361@master:/$ cat /usr/local/hadoop/etc/hadoop/core-site.xml 
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
        <!-- namenode path-->
        <property>
                <name>fs.defaultFS</name>
                <value>hdfs://master:9000</value>
        </property>
        <!-- Hadoop Runtime TMP_DIR -->
        <property>
                <name>hadoop.tmp.dir</name>
                <value>/home/dream361/hadoopTmp</value>
        </property>
        <property>
                <name>io.file.buffer.size</name>
                <value>131702</value>
        </property>
</configuration>

4.2 hdfs-site.xml

dream361@master:/$ cat /usr/local/hadoop/etc/hadoop/hdfs-site.xml 
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
        <property>
                <name>dfs.namenode.secondary.http-address</name>
                <value>master:50090</value>
        </property>
        <!-- HDFS replication -->
        <property>
                <name>dfs.replication</name>
                <value>2</value>
        </property>
        <property>
                <name>dfs.namenode.name.dir</name>
                <value>file:/usr/local/hadoop/hdfs/name</value>
        </property>
        <property>
                <name>dfs.datanode.data.dir</name>
                <value>file:/usr/local/hadoop/hdfs/data</value>
        </property>
</configuration>

4.3设置 hadoop-env.sh中 JAVA_HOME变量

5.在一个主节点完成配置后,将jdk、hadoop传送到其他节点

我这里是直接传送目录、省去了压缩、解压过程。

传送jdk

root@master:/home/dream361# scp -r /usr/local/jdk root@slave3:/usr/local/jdk/

传送hadoop

root@master:/home/dream361# scp -r /usr/local/hadoop root@slave3:/usr/local/hadoop
原文地址:https://www.cnblogs.com/zhengwenqiang/p/6804603.html