命令速查
按场景分组,实验时对着敲就能把环境跑起来。
集群启停
start-dfs.shstart-yarn.shstart-all.shstop-dfs.sh && stop-yarn.shjpshdfs dfsadmin -reporthdfs dfsadmin -safemode get / leavehdfs haadmin -getServiceState nn1
hdfs haadmin -failover nn1 nn2ZooKeeper
zkServer.sh start / stopzkServer.sh statuszkCli.sh -server hadoop1:2181HDFS 常用
hdfs dfs -ls -h /
hdfs dfs -mkdir -p /data/inputhdfs dfs -put w.txt /data/input/
hdfs dfs -get /data/input/w.txt ./hdfs dfs -cat /data/input/w.txt
hdfs dfs -du -h /datahdfs dfs -chmod -R 777 /data
hdfs dfs -chown -R hadoop:hadoop /datahdfs dfs -rm -r /data/input
hdfs dfs -expungehdfs fsck / -files -blocks -locations
hdfs fsck / -list-corruptfileblocksMapReduce
hadoop jar wc.jar com.demo.WcDriver /wc/input /wc/outputhdfs dfs -cat /wc/output/part-r-00000mapreduce.map.memory.mb=2048
mapreduce.reduce.memory.mb=4096
mapreduce.job.reduces=4
mapreduce.map.output.compress=trueHive
hive
hive -e "show databases;"
schematool -initSchema -dbType mysqlCREATE DATABASE school;
USE school;
SHOW TABLES;
DESC FORMATTED student_info;
SELECT count(*) FROM student_info;ADD JAR /user/hadoop/jars/myudf.jar;
CREATE TEMPORARY FUNCTION my_lower AS 'com.demo.MyLowerUDF';sqoop import --connect jdbc:mysql://hadoop1:3306/nev --username root --password 123456 --table weather --hive-import --hive-database ods --hive-table weather_ods -m 1HBase
start-hbase.sh / stop-hbase.shhbase shellcreate 'student', 'info'
put 'student','1001','info:name','张三'
get 'student','1001'
scan 'student'
count 'student'
disable 'student' && drop 'student'sqlline.py hadoop1:2181Spark
$SPARK_HOME/sbin/start-all.shspark-submit --master yarn --class com.demo.Wc wc.jar hdfs:///input hdfs:///outmap / flatMap / filter / reduceByKey / groupByKey / join
count / collect / first / take / reduce / saveAsTextFile