1.安装SSH服务
sudo apt-get install ssh
2.安装jdk7:
apt-get install openjdk-7-jdk
3.配置java:
nano /etc/profile
添加环境变量
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/lib:$JRE_HOME/lib:$PATH
生效:
source /etc/profile
4.安装Hadoop
4.1 获取Hadoop
wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
4.2 解压
mv hadoop-1.2.1.tar.gz /opt/
tar -zxvf hadoop-1.2.1.tar.gz
4.3 conf/下配置4个文件
详见官网:http://hadoop.apache.org/docs/r2.6.0/hadoop-project-dist/hadoop-common/SingleCluster.html
- hadoop-env.sh
ecport JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
- core-site.xml
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/hadoop</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/hadoop/name</value>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
- hdfs-site.xml
<property>
<name>dfs.data.dir</name>
<value>/hadoop/data</value>
</property>
- mapred-site.xml
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
- 最后添加到环境变量
nano /etc/profile
export HADOOP_HOME=/opt/hadoop-1.2.1
export PATH=$JAVA_HOME/lib:$HADOOP_HOME/bin:$JRE_HOME/lib:$PATH
source /etc/profile
5.运行Hadoop
5.1 格式化
hadoop namenode -format
5.2 启动
start-all.sh
注意会出现root@localhost's password:localhost:permission denied,please try again
解决方式一
sudo passwd然后,会输入新的密码,设置之后,再重新格式化一下namenode,最后执行start-all.sh
解决方式二
1.安装 open ssh:sudo apt-get install openssh-server
2.修改root密码:#sudo passwd root
3.辑配置文件,允许以 root 用户通过 ssh 登录:sudo vi /etc/ssh/sshd_config
找到:PermitRootLogin prohibit-password禁用
添加:PermitRootLogin yes
4.sudo service ssh restart
5.3 查看运行服务
> jps
5.4 查看文件
> hadoop fs -ls /
5.4 查看hdfs使用情况
> hadoop dfsadmin -report