安全认证kerberos
kerberos认证
伪分布部署
完全分布式部署示例1
完全分布式部署示例2
官网信息
# 官网
https://hadoop.apache.org/
# 指定版本文档
https://hadoop.apache.org/docs/r3.3.6/
# 单机部署文档
https://hadoop.apache.org/docs/r3.3.6/hadoop-project-dist/hadoop-common/SingleCluster.html
# 集群部署文档
https://hadoop.apache.org/docs/r3.3.6/hadoop-project-dist/hadoop-common/ClusterSetup.html
hadoop访问界面
http://IP:9870
获取当前name节点的活动节点
用于获取Hadoop HA(高可用性)中NameNode服务状态的命令。用于检查NameNode服务的状态
hdfs haadmin -getServiceState <servicestate>
hdfs haadmin -getServiceState namenode1
相关操作命令
显示目录列表
bin/hdfs dfs -ls /
创建单机目录
bin/hdfs dfs -mkdir /a
创建多级目录
bin/hdfs dfs -mkdir -p /a/b/c
删除目录
bin/hdfs dfs -rm -r /a
上传文件
bin/hdfs dfs -put a.txt /
查看文件内容
bin/hdfs dfs -cat /a.txt
下载文件
bin/hdfs dfs -get /a.txt
删除文件
bin/hdfs dfs -rm /a.txt
Hadoop命令
hdfs dfs -mkdir /tmp 创建目录
hdfs dfs -mkdir -p /tmp/a/b/c/d 创建多级目录
hdfs dfs -rm -r /tmp/a/b 删除目录
hdfs dfs -ls / 查看目录内容
hadoop fs -ls /
hdfs dfs -ls -R /tmp 递归显示目录
hdfs dfs -put aa.txt /tmp 上传文件
hdfs dfs -rm /tmp/aa.txt 删除文件
hdfs dfs -mv /tmp/aa.txt /tmp/a 文件移动
hdfs dfs -cat /tmp/a/aa.txt 查看文件内容
hdfs dfs -get /tmp/aa.txt 下载文件
hdfs dfs -get /tmp/aa.txt bb.txt 下载文件并且改名字
hdfs dfs -chown aa:bb /tmp 修改目录所有者、所属组
hdfs dfs -chown -R root:supergroup /tmp 修改目录及文件所有者所属组
hdfs dfs -chmod -R 777 /tmp 修改目录权限
代码连接
public class test {
public static void main(String[] args) {
try {
Configuration configuration = new Configuration();
configuration.set("fs.defaultFS","hdfs://localhost:9000");
configuration.set("HADOOP_USER_NAME","root");
// System.setProperty("hadoop.home.dir", "/usr/hadoop");
// 获取文件系统
FileSystem fileSystem = FileSystem.get(configuration);
fileSystem.close();
log.info("连接成功");
} catch (Exception e) {
}
}
}