1流纹,打開虛擬機(jī)畔师,su - 畔咧,輸入密碼茎芭,切換root用戶
2,切換到Hadoop的sbin目錄下(2.X版本)
cd /opt/hadoop/hadoop-2.6.0/sbin
3誓沸,啟動(dòng)Hadoop
start-all.sh
4梅桩,jps檢查進(jìn)程(2.X版本,五個(gè))
5拜隧,確定Hadoop成功啟動(dòng)后宿百,輸入下面的命令
root@ubuntu:/opt/hadoop/hadoop-2.6.0# bin/hadoop fs -ls hdfs://localhost:9000/
這句話的意思是趁仙,查看hdfs系統(tǒng)的文件有哪些,現(xiàn)在可以看到垦页,只有系統(tǒng)文件夾雀费,沒有上傳文件。
hadoop的命令的格式就是這樣的痊焊,bin/hadoop fs - (命令) hdfs://hdphost:9000/(hdphost主機(jī)名)
6盏袄,輸入路徑input path,必須是/user/root/in但是原本不存在薄啥,所以要先創(chuàng)建
root@ubuntu:/opt/hadoop/hadoop-2.6.0# # bin/hadoop fs -mkdir hdfs://ubuntu:9000/user/
root@ubuntu:/opt/hadoop/hadoop-2.6.0# # bin/hadoop fs -mkdir hdfs://ubuntu:9000/user/root
root@ubuntu:/opt/hadoop/hadoop-2.6.0# # bin/hadoop fs -mkdir hdfs://ubuntu:9000/user/root/in
創(chuàng)建了輸入文件夾辕羽,也要?jiǎng)?chuàng)建輸出文件夾,輸出文件夾每次都不能相同垄惧,所以刁愿,創(chuàng)建之前,先查看一下到逊,然后在創(chuàng)建
root@ubuntu:/opt/hadoop/hadoop-2.6.0# # bin/hadoop fs -mkdir hdfs://ubuntu:9000/user/root/out
7酌毡,準(zhǔn)備工作做完了,現(xiàn)在開始正式上傳蕾管,-put命令
root@ubuntu:/opt/hadoop/hadoop-2.6.0# bin/hadoop fs -put /mnt/hgfs/E/lcx/ hdfs://ubuntu:9000/user/root/in
這里的/mnt/hgfs/E/lcx/是本地的E盤下的文件,前提是菩暗,先把本地的E盤和虛擬機(jī)共享一下掰曾。
8,用-ls查看一下停团,發(fā)現(xiàn)已經(jīng)上傳成功了旷坦。
root@ubuntu:/opt/hadoop/hadoop-2.6.0# bin/hadoop fs -ls hdfs://ubuntu:9000/user/root/in
9,查看
hadoop fs -cat /user/root/in/lcx | head