1.修改文件/etc/hostname里的值即可,修改成功后用hostname命令查看当前主机名是否设置成功。
[root@masternode centos]# cat /etc/hosts
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.3 slavenode1.novalocal slavenode1
10.10.10.4 masternode.novalocal masternode
10.10.10.5 slavenode2.novalocal slavenode2
10.10.10.6 slavenode3.novalocal slavenode3
修改hostname
vi /etc/sysconfig/network
Hostname=masternode1
1) 首先在主机器上核对ssh是否安装
[root@masternode ~]# rpm -qa |grep ssh
libssh2-1.4.2-1.el6.x86_64
openssh-5.3p1-104.el6_6.1.x86_64
openssh-server-5.3p1-104.el6_6.1.x86_64
openssh-clients-5.3p1-104.el6_6.1.x86_64
2) 生产密钥
[root@masternode ~]# cd .ssh/
[root@masternode .ssh]# ls
authorized_keys
[root@masternode .ssh]# cd /
[root@masternode /]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/opt/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /opt/.ssh/id_rsa.
Your public key has been saved in /opt/.ssh/id_rsa.pub.
The key fingerprint is:
e8:3d:75:11:0b:6a:a9:f5:39:e5:04:71:2e:94:21:94 root@masternode.novalocal
The key's randomart image is:
+--[ RSA 2048]----+
| .o.*+o |
| E=.= o |
| = . * |
| = . * . |
| o S = o |
| . . . o |
| . o |
| . |
| |
+-----------------+
[root@masternode /]# cd
[root@masternode ~]# cd .ssh/
[root@masternode .ssh]# ls
authorized_keys id_rsa id_rsa.pub 生产的密钥
[root@masternode .ssh]# cat id_rsa.pub >> authorized_keys
3)把密钥传输到其他节点机器上
(1)用ssh-copy-id命令将公钥传送到远程主机上(这里以Slave1node3为例)。
[root@masternode ~]# ssh-copy-id root@slavenode3
(2)如果在用命令ssh-copy-id时发现找不到该命令“ssh-copy-id:Command not found”,则可能是ssh服务的版本太低的原因,比如若你的机器是Redhat系统就可能该问题,解决办法是:手动复制本地的pubkey内容到远程服务器,命令如下:
cat ~/.ssh/id_rsa.pub | ssh root@slavenode3 'cat >> ~/.ssh/authorized_keys'
该命令等价于下面两个命令:
①在本地机器上执行:scp ~/.ssh/id_rsa.pub root@slavenode3:/~
②到远程机器上执行:cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
[root@masternode .ssh]# scp authorized_keys root@125.208.30.89:/opt/.ssh
The authenticity of host '125.208.30.89(125.208.30.89)' can't be established.
RSA key fingerprint is e3:97:c0:29:e4:fa:0d:41:31:6e:df:fe:0c:6b:c7:08.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '125.208.30.89' (RSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
lost connection
[root@masternode .ssh]# vi authorized_keys
cat id_rsa.pub >> authorized_keysd_rsa.pub
[root@masternode .ssh]# scp .ssh/authorized_keys root@mslavenode1:~/.ssh/
[root@masternode .ssh]# scp .ssh/authorized_keys root@slavenode2:~/.ssh/
[root@masternode .ssh]# scp .ssh/authorized_keys root@slavenode3:~/.ssh/
[root@masternode centos]# scp /etc/hosts root@10.10.10.5:/etc/hosts
hosts 100% 332 0.3KB/s 00:00
[root@masternode centos]# scp /etc/hosts root@10.10.10.3:/etc/hosts
hosts 100% 332 0.3KB/s 00:00
[root@masternode centos]# scp /etc/hosts root@10.10.10.6:/etc/hosts
1)解压java软件包
cd /usr/java/
tar -xvf jdk-7u79-linux-x64.tar.gz
chown -R hadoop:hadoop jdk-7u79
2)编辑环境变量
编辑"/etc/profile"文件,在后面添加Java的"JAVA_HOME"、"CLASSPATH"以及"PATH"内容如下:
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_79
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#export JAVA_LIBRARY_PATH='/opt/hadoop/hadoop-2.7.2/lib/native'
export PATH=$PATH:$JAVA_HOME/bin
#set hadoop path
export HADOOP_HOME=/opt/hadoop/hadoop-2.7.2
#export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
#export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib:$HADOOP_COMMON_LIB_NATIVE_DIR"
export PATH=$PATH:$HADOOP_HOME/bin
#set hive
export HIVE_HOME=/opt/hadoop/hive-2.0.0
export PATH=$PATH:$HIVE_HOME/bin
#set zookeeper
export ZOOKEEPER_HOME=/opt/hadoop/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf
#set hbase
export HBASE_HOME=/opt/hadoop/hbase-1.1.5
export PATH=$PATH:$HBASE_HOME/bin
#set scala
export SCALA_HOME=/opt/hadoop/scala
export PATH=$PATH:$SCALA_HOME/bin
#set spark
export SPARK_HOME=/opt/hadoop/spark
export PATH=$PATH:$SPARK_HOME/bin
3)使配置生效
保存并退出,执行下面命令使其配置立即生效。
source /etc/profile 或 . /etc/profile
vi ~/.bash_profile
export JAVA_HOME=/usr/java/jdk1.7.0_79/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
#set hadoop path
export HADOOP_HOME=/opt/hadoop/hadoop-2.7.2
export PATH=$PATH:$HADOOP_HOME/bin
Source ~/.bash_profile
4)验证安装成功
配置完毕并生效后,用下面命令判断是否成功。
[root@masternode java]#