修改配置文件 /usr/local/hadoop/etc/hadoop/core-site.xml
xml
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/usr/local/hadoop/tmp</value>
<description></description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>修改配置文件 /usr/local/hadoop/etc/hadoop/hdfs-site.xml
xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/hadoop/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop/tmp/dfs/data</value>
</property>
</configuration>namenode 格式化
shell
hdfs namenode -format启动hdfs 服务,在 $HADOOP_HOME/sbin 下执行 start-dfs.sh 或者执行 $HADOOP_HOME/sbin/start-dfs.sh
显示没有权限或者认证失败,需要ssh 免密连接,配置方式如下:
shell
ssh-keygen -t rsa
cd ~/.ssh && cat ./id_rsa.pub >> ./authorized_keyshadoop 相对路劲表示方法
- "." 表示 /user/[user_name]
- "~" 表示 /home/[user_name]
创建目录
shell
hdfs dfs -mkdir [path]上传到HDFS中
shell
hdfs dfs -put [源文件或路径] target_url执行hadoop 查找
shell
hdfs dfs -ls [target_url]下载 HDFS系统中的文件
shell
hdfs dfs -get source_path target_urlWeb 访问
停止hdfs 服务
在 $HADOOP_HOME/sbin 下执行 stop-dfs.sh
shell
$HADOOP_HOME/sbin/stop-dfs.sh