yum remove java* libreoffice* -ynode
systemctl stop firewalld.servicelinux
systemctl disable firewalld.servicebash
編輯文件/etc/selinux/configdom
SELINUX=enforcing 改成 SELINUX= disabledssh
輸入命令,ssh-keygen -t rsa ,生成key,一直回車,/root就會生成.ssh文件夾ide
接下來執行如下命令oop
cd ~/.ssh/ this
cat id_rsa.pub >> authorized_keysspa
chmod 644 ~/.ssh/authorized_keys
chmod 744 ~/.ssh/
systemctl enable sshd.service
scp -rp authorized_keys 客戶端IP:/root/.ssh/
(scp沒有.ssh目錄,使用客戶端ssh鏈接一下服務端即生成該文件夾)
三臺hadoop集羣:
192.168.159.151 master
192.168.159.152 slave1
192.168.159.153 slave2
修改主機名hostname(客戶端服務端均修改)
[root@master ~]# cat /etc/sysconfig/network(永久修改)
# Created by anaconda
NETWORKING=yes
HOSTNAME=master
hostnamectl set-hostname [主機名]
例 :hostnamectl set-hostname master
修改/etc/hosts
格式爲:
[root@slave1 /]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.159.151 master
192.168.159.152 slave1
192.168.159.153 slave2
解壓包:
cd /usr/local/src/;rz -yb 上傳hadoop-1.2.1-bin.tar.gz和jdk-6u45-linux-x64.bin
tar zxvf hadoop-1.2.1-bin.tar.gz;./jdk-6u45-linux-x64.bin
拷貝到各節點:
scp -rp jdk1.6.0_45 slave1:/usr/local/src/
cd /usr/local/src/jdk1.6.0_45/bin;./java
vi ~/.bashrc
加入JAVA的環境變量:
export JAVA_HOME=/usr/local/src/jdk1.6.0_45
export CLASSPATH=.:CLASSPATH:JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
source ~/.bashrc
hadoop安裝:
cd /usr/local/src/hadoop-1.2.1
mkdir tmp(存放臨時文件,core-site.xml 配置文件指定其pwd路徑)
cd /usr/local/src/hadoop-1.2.1/conf
修改masters,slaves文件:
[root@master conf]# cat masters
master
[root@master conf]# cat slaves
slave1
slave2
[root@master conf]# cat hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>
[root@master conf]# cat core-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/src/hadoop-1.2.1/tmp</value>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://192.168.159.151:9000</value>
</property>
</configuration>
[root@master conf]# cat hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>
[root@master conf]# cat mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>http://192.168.159.151:9001</value>
</property>
</configuration>
在hadoop-env.sh加入一行JAVA_HOME的環境變量:
export JAVA_HOME=/usr/local/src/jdk1.6.0_45
master執行:
而後將服務端的hadoop-1.2.1目錄scp到各客戶端:
scp -rp /usr/local/src/hadoop-1.2.1 slave1:/usr/local/src/
cd /usr/local/src/hadoop-1.2.1/bin
格式化namenode:
./hadoop namenode -format
啓動各節點:
./start-all.sh
設置開機自動啓動hadoop各節點,和生成hadoop啓動命令的環境變量:
cat /root/.bashrc
export JAVA_HOME=/usr/local/src/jdk1.6.0_45
export HADOOP_HOME=/usr/local/src/hadoop-1.2.1
#export PATH=.:$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH
$PATH換成如今定義的環境變量便可, : 用來分隔環境變量
export PATH=$PATH:$JAVA_HOME/bin:/usr/local/src/hadoop-1.2.1/bin
cat .bash_profile
在.bash_profile裏面追加一行:
export HADOOP_HOME_WARN_SUPPRESS=1
啓動Hadoop時報了一個警告信息,個人系統是CentOS,安裝的Hadoop版本是hadoop1.2.1,具體警告信息以下:
bin/start-all.sh Warning: $HADOOP_HOME is deprecated.
網上的說法是由於Hadoop自己對HADOOP_HOME作了判斷,具體在bin/hadoop和bin/hadoop-config.sh裏。在hadoop-config.sh裏有以下的配置:
if [ "$HADOOP_HOME_WARN_SUPPRESS" = "" ] && [ "$HADOOP_HOME" != "" ]; then echo "Warning: \$HADOOP_HOME is deprecated." 1>&2 echo 1>&2fi
2. 在當前用戶目錄下的 .bash_profile 裏增長一個環境變量:
export HADOOP_HOME_WARN_SUPPRESS=1 注:修改完 .bash_profile 後須要執行 source 操做使其生效
master查看啓動的節點
[root@master hadoop-1.2.1]# jps
5676 Jps
3237 JobTracker
3158 SecondaryNameNode
2994 NameNode
slave查看啓動的節點:
[root@slave1 ~]# jps
2673 DataNode
3346 Jps
2757 TaskTracker
查看hdfs
./hadoop fs -ls /
上傳文件
./hadoop fs -put /etc/passwd /
查看上傳的文件
./hadoop fs -cat /passwd