云服务器内容精选

  • 在本地Windows环境中调测HDFS程序 在开发环境中(例如IntelliJ IDEA中),分别选中以下两个工程运行程序: 选中HdfsExample.java,右键工程,选择“Run 'HdfsExample.main()'”运行应用工程。 选中ColocationExample.java,右键工程,选择“Run 'ColocationExample.main()'”运行应用工程。 在HDFS任务运行过程中禁止重启HDFS服务,否则可能会导致任务失败。 在运行Colocation工程时,HDFS的配置项fs.defaultFS不能配置为viewfs://ClusterX。
  • 查看调测结果 查看运行结果获取应用运行情况 HdfsExample Windows样例程序运行结果如下所示。 ... 1308 [main] INFO org.apache.hadoop.security.UserGroupInformation - Login successful for user hdfsDevelop using keytab file 1308 [main] INFO com.huawei.hadoop.security.LoginUtil - Login success!!!!!!!!!!!!!! 2040 [main] WARN org.apache.hadoop.hdfs.shortcircuit.DomainSocketFactory - The short-circuit local reads feature cannot be used because UNIX Domain sockets are not available on Windows. 3006 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to create path /user/hdfs-examples 3131 [main] WARN org.apache.hadoop.util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 3598 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to write. 4408 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to append. 5015 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - result is : hi, I am bigdata. It is successful if you can see me.I append this content. 5015 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to read. 5077 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete the file /user/hdfs-examples\test.txt 5186 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete path /user/hdfs-examples 5311 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to create path /user/hdfs-examples/hdfs_example_0 5311 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to create path /user/hdfs-examples/hdfs_example_1 5669 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to write. 5669 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to write. 7258 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to append. 7741 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to append. 7896 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - result is : hi, I am bigdata. It is successful if you can see me.I append this content. 7896 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to read. 7959 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete the file /user/hdfs-examples/hdfs_example_1\test.txt 8068 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete path /user/hdfs-examples/hdfs_example_1 8364 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - result is : hi, I am bigdata. It is successful if you can see me.I append this content. 8364 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to read. 8426 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete the file /user/hdfs-examples/hdfs_example_0\test.txt 8535 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete path /user/hdfs-examples/hdfs_example_0 ... 在Windows环境运行样例代码时可能会出现下面的异常,但是不影响业务: java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. ColocationExample Windows样例程序运行结果如下所示。 ... 945 [main] INFO org.apache.hadoop.security.UserGroupInformation - Login successful for user hdfsDeveloper using keytab file user.keytab 945 [main] INFO com.huawei.hadoop.security.LoginUtil - Login success!!!!!!!!!!!!!! 945 [main] INFO com.huawei.hadoop.security.LoginUtil - JaasConfiguration loginContextName=Client principal=hdfsDeveloper useTicketCache=false keytabFile=XXX\sample_project\src\hdfs-example-security\conf\user.keytab 946 [main] INFO com.huawei.hadoop.security.KerberosUtil - Get default realm successfully, the realm is : HADOOP.COM ... Create Group has finished. Put file is running... Put file has finished. Delete file is running... Delete file has finished. Delete Group is running... Delete Group has finished. 4946 [main-EventThread] INFO org.apache.zookeeper.ClientCnxn - EventThread shut down for connection: 0x440751cb41a4d415 4946 [main] INFO org.apache.zookeeper.ZooKeeper - Connection: 0x440751cb41a4d415 closed ... 查看HDFS日志获取应用运行情况 您可以查看HDFS的NameNode日志了解应用运行情况,并根据日志信息调整应用程序。
  • 查看调测结果 查看运行结果获取应用运行情况 HdfsExample Linux样例程序运行结果如下所示。 [root@192-168-32-144 client]#hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.HdfsExample WARNING: Use "yarn jar" to launch YARN applications. 17/10/26 19:11:44 INFO examples.HdfsExample: success to create path /user/hdfs-examples 17/10/26 19:11:44 INFO examples.HdfsExample: success to write. 17/10/26 19:11:45 INFO examples.HdfsExample: success to append. 17/10/26 19:11:45 INFO examples.HdfsExample: result is : hi, I am bigdata. It is successful if you can see me.I append this content. 17/10/26 19:11:45 INFO examples.HdfsExample: success to read. 17/10/26 19:11:45 INFO examples.HdfsExample: success to delete the file /user/hdfs-examples/test.txt 17/10/26 19:11:45 INFO examples.HdfsExample: success to delete path /user/hdfs-examples 17/10/26 19:11:45 INFO examples.HdfsExample: success to create path /user/hdfs-examples/hdfs_example_1 17/10/26 19:11:45 INFO examples.HdfsExample: success to create path /user/hdfs-examples/hdfs_example_0 17/10/26 19:11:45 INFO examples.HdfsExample: success to write. 17/10/26 19:11:45 INFO examples.HdfsExample: success to write. 17/10/26 19:11:46 INFO examples.HdfsExample: success to append. 17/10/26 19:11:46 INFO examples.HdfsExample: result is : hi, I am bigdata. It is successful if you can see me.I append this content. 17/10/26 19:11:46 INFO examples.HdfsExample: success to read. 17/10/26 19:11:46 INFO examples.HdfsExample: success to delete the file /user/hdfs-examples/hdfs_example_1/test.txt 17/10/26 19:11:46 INFO examples.HdfsExample: success to delete path /user/hdfs-examples/hdfs_example_1 17/10/26 19:11:46 INFO examples.HdfsExample: success to append. 17/10/26 19:11:46 INFO examples.HdfsExample: result is : hi, I am bigdata. It is successful if you can see me.I append this content. 17/10/26 19:11:46 INFO examples.HdfsExample: success to read. 17/10/26 19:11:46 INFO examples.HdfsExample: success to delete the file /user/hdfs-examples/hdfs_example_0/test.txt 17/10/26 19:11:46 INFO examples.HdfsExample: success to delete path /user/hdfs-examples/hdfs_example_0 ColocationExample Linux样例程序运行结果如下所示。 [root@192-168-32-144 client]#hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.ColocationExample WARNING: Use "yarn jar" to launch YARN applications. 17/10/26 19:12:38 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=xxx, built on 10/19/2017 04:21 GMT 17/10/26 19:12:38 INFO zookeeper.ZooKeeper: Client environment:host.name=192-168-32-144 17/10/26 19:12:38 INFO zookeeper.ZooKeeper: Client environment:java.version=1.8.0_144 17/10/26 19:12:38 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation 17/10/26 19:12:38 INFO zookeeper.ZooKeeper: Client environment:java.home=/opt/client/JDK/jdk1.8.0_144/jre ...... Create Group has finished. Put file is running... Put file has finished. Delete file is running... Delete file has finished. Delete Group is running... Delete Group has finished. 17/10/26 19:12:39 INFO zookeeper.ZooKeeper: Session: 0x13000074b7e4687f closed 17/10/26 19:12:39 INFO zookeeper.ClientCnxn: EventThread shut down for session: 0x13000074b7e4687f 17/10/26 19:12:39 INFO zookeeper.ZooKeeper: Session: 0x12000059699f69e1 closed 17/10/26 19:12:39 INFO zookeeper.ClientCnxn: EventThread shut down for session: 0x12000059699f69e1 查看HDFS日志获取应用运行情况 可以查看HDFS的namenode日志了解应用运行情况,并根据日志信息调整应用程序。
  • 未安装客户端时编译并运行程序 进入工程本地根目录,在Windows命令提示符窗口中执行下面命令进行打包。 mvn -s "{maven_setting_path}" clean package 上述打包命令中的{maven_setting_path}为本地Maven的“settings.xml”文件路径。 打包成功之后,在工程根目录的target子目录下获取打好的jar包。 将导出的Jar包上传至Linux运行环境的任意目录下,例如“/optclient”。 将工程中的“lib”文件夹和“conf”文件夹上传至和Jar包相同的Linux运行环境目录下,例如“/opt/client”(其中“lib”目录汇总包含了工程中依赖的所有的Jar包,“conf”目录包含运行jar包所需的集群相关配置文件,请参考准备运行环境)。 运行此样例代码需要设置运行用户,设置运行用户有两种方式,添加环境变量HADOOP_USER_NAME或者修改代码设置运行用户。若在没有修改代码的场景下,执行以下语句添加环境变量: export HADOOP_USER_NAME=test 用户可向管理员咨询运行用户。test在这里只是举例,若需运行Colocation相关操作的样例代码,则此用户需属supergroup用户组。 执行如下命令运行Jar包。 java -cp HDFSTest-XXX.jar:conf/:lib/* com.huawei.bigdata.hdfs.examples.HdfsExample java -cp HDFSTest-XXX.jar:conf/:lib/* com.huawei.bigdata.hdfs.examples.ColocationExample 在运行com.huawei.bigdata.hdfs.examples.ColocationExample:时,HDFS的配置项“fs.defaultFS”不能配置为“viewfs://ClusterX”。
  • 已安装客户端时编译并运行程序 进入样例工程本地根目录,在Windows命令提示符窗口中执行下面命令进行打包。 mvn -s "{maven_setting_path}" clean package 上述打包命令中的{maven_setting_path}为本地Maven的“settings.xml”文件路径。 打包成功之后,在工程根目录的target子目录下获取打好的jar包,例如“HDFSTest-XXX.jar”,jar包名称以实际打包结果为准。 将导出的Jar包上传至Linux客户端运行环境的任意目录下,例如“/opt/client”。 配置环境变量: cd /opt/client source bigdata_env 运行此样例代码需要设置运行用户,设置运行用户有两种方式,添加环境变量HADOOP_USER_NAME或者修改代码设置运行用户。若在没有修改代码的场景下,执行以下语句添加环境变量: export HADOOP_USER_NAME=test 用户可向管理员咨询运行用户。test在这里只是举例,若需运行Colocation相关操作的样例代码,则此用户需属supergroup用户组。 执行如下命令,运行Jar包。 hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.HdfsExample hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.ColocationExample 在运行com.huawei.bigdata.hdfs.examples.ColocationExample时,HDFS的配置项“fs.defaultFS”不能配置为“viewfs://ClusterX”。
  • 前提条件 已安装客户端时: 已安装HDFS客户端。 当客户端所在主机不是集群中的节点时,需要在客户端所在节点的hosts文件中设置主机名和IP地址映射。主机名和IP地址请保持一一对应。 未安装客户端时: Linux环境已安装JDK,版本号需要和IDEA导出Jar包使用的JDK版本一致。 当Linux环境所在主机不是集群中的节点时,需要在Linux环境所在节点的hosts文件中设置主机名和IP地址映射。主机名和IP地址请保持一一对应。
  • 未安装客户端时编译并运行程序 进入工程本地根目录,在Windows命令提示符窗口中执行下面命令进行打包。 mvn -s "{maven_setting_path}" clean package 上述打包命令中的{maven_setting_path}为本地Maven的“settings.xml”文件路径。 打包成功之后,在工程根目录的target子目录下获取打好的jar包。 将导出的Jar包上传至Linux运行环境的任意目录下,例如“/opt/client”。 将工程中的“lib”文件夹和“conf”文件夹上传至和Jar包相同的Linux运行环境目录下(其中“lib”目录汇总包含了工程中依赖的所有的Jar包,“conf”目录包含运行jar包所需的集群相关配置文件,请参考准备运行环境)。 执行如下命令运行Jar包。 java -cp HDFSTest-XXX.jar:conf/:lib/* com.huawei.bigdata.hdfs.examples.HdfsExample java -cp HDFSTest-XXX.jar:conf/:lib/* com.huawei.bigdata.hdfs.examples.ColocationExample 在运行“com.huawei.bigdata.hdfs.examples.ColocationExample”时,HDFS的配置项“fs.defaultFS”不能配置为“viewfs://ClusterX”。
  • 已安装客户端时编译并运行程序 进入样例工程本地根目录,在Windows命令提示符窗口中执行下面命令进行打包。 mvn -s "{maven_setting_path}" clean package “{maven_setting_path}”为本地Maven的“settings.xml”文件路径,例如“C:\Users\Developer\settings.xml”。 打包成功之后,在工程根目录的“target”子目录下获取打好的jar包,例如“HDFSTest-XXX.jar”,jar包名称以实际打包结果为准。 将导出的Jar包上传至集群客户端运行环境的任意目录下,例如“/opt/client”,然后在该目录下创建“conf”目录,将需要的配置文件复制至“conf”目录,具体操作请参考准备运行环境。 配置环境变量: cd /opt/client source bigdata_env 执行如下命令,运行Jar包。 hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.HdfsExample hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.ColocationExample 在运行com.huawei.bigdata.hdfs.examples.ColocationExample时,HDFS的配置项“fs.defaultFS”不能配置为“viewfs://ClusterX”。
  • 查看调测结果 查看运行结果获取应用运行情况 HdfsExample Linux样例程序运行结果如下所示。 0 [main] INFO org.apache.hadoop.security.UserGroupInformation - Login successful for user hdfsDevelop using keytab file user.keytab 1 [main] INFO com.huawei.hadoop.security.LoginUtil - Login success!!!!!!!!!!!!!! 568 [main] WARN org.apache.hadoop.util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 582 [main] WARN org.apache.hadoop.hdfs.shortcircuit.DomainSocketFactory - The short-circuit local reads feature cannot be used because libhadoop cannot be loaded. 793 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to create path /user/hdfs-examples 969 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to write. 1068 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to append. 1191 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - result is : hi, I am bigdata. It is successful if you can see me.I append this content. 1191 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to read. 1202 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete the file /user/hdfs-examples/test.txt 1210 [main] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete path /user/hdfs-examples 1223 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to create path /user/hdfs-examples/hdfs_example_0 1224 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to create path /user/hdfs-examples/hdfs_example_1 1261 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to write. 1264 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to write. 2807 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to append. 2810 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to append. 2861 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - result is : hi, I am bigdata. It is successful if you can see me.I append this content. 2861 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to read. 2866 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete the file /user/hdfs-examples/hdfs_example_0/test.txt 2874 [hdfs_example_0] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete path /user/hdfs-examples/hdfs_example_0 2874 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - result is : hi, I am bigdata. It is successful if you can see me.I append this content. 2874 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to read. 2879 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete the file /user/hdfs-examples/hdfs_example_1/test.txt 2885 [hdfs_example_1] INFO com.huawei.bigdata.hdfs.examples.HdfsExample - success to delete path /user/hdfs-examples/hdfs_example_1 ColocationExample Linux样例程序运行结果如下所示。 0 [main] INFO com.huawei.hadoop.security.LoginUtil - JaasConfiguration loginContextName=Client principal=hdfsDevelop useTicketCache=false keytabFile=/opt/hdfsDemo/conf/user.keytab 817 [main] INFO org.apache.hadoop.security.UserGroupInformation - Login successful for user hdfsDevelop using keytab file user.keytab 817 [main] INFO com.huawei.hadoop.security.LoginUtil - Login success!!!!!!!!!!!!!! 1380 [main] WARN org.apache.hadoop.util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable ... Create Group has finished. Put file is running... Put file has finished. Delete file is running... Delete file has finished. Delete Group is running... Delete Group has finished. ... 查看HDFS日志获取应用运行情况 您可以查看HDFS的namenode日志了解应用运行情况,并根据日志信息调整应用程序。
  • 前提条件 已安装客户端时: 已安装HDFS客户端。 当客户端所在主机不是集群中的节点时,需要在客户端所在节点的hosts文件中设置主机名和IP地址映射。主机名和IP地址请保持一一对应。 未安装客户端时: Linux环境已安装JDK,版本号需要和IDEA导出Jar包使用的JDK版本一致。 当Linux环境所在主机不是集群中的节点时,需要在Linux环境所在节点的hosts文件中设置主机名和IP地址映射。主机名和IP地址请保持一一对应。
  • 前提条件 已安装客户端时: 已安装HDFS客户端。 当客户端所在主机不是集群中的节点时,需要在客户端所在节点的hosts文件中设置主机名和IP地址映射。主机名和IP地址请保持一一对应。 未安装客户端时: Linux环境已安装JDK,版本号需要和IDEA导出Jar包使用的JDK版本一致。 当Linux环境所在主机不是集群中的节点时,需要在Linux环境所在节点的hosts文件中设置主机名和IP地址映射。主机名和IP地址请保持一一对应。
  • 已安装客户端时编译并运行程序 进入样例工程本地根目录,在Windows命令提示符窗口中执行下面命令进行打包。 mvn -s "{maven_setting_path}" clean package 上述打包命令中的{maven_setting_path}为本地Maven的“settings.xml”文件路径。 打包成功之后,在工程根目录的target子目录下获取打好的jar包,例如“HDFSTest-XXX.jar”,jar包名称以实际打包结果为准。 将导出的Jar包上传至Linux客户端运行环境的任意目录下,例如“/opt/client”。 配置环境变量: cd /opt/client source bigdata_env 运行此样例代码需要设置运行用户,设置运行用户有两种方式,添加环境变量HADOOP_USER_NAME或者修改代码设置运行用户。若在没有修改代码的场景下,执行以下语句添加环境变量: export HADOOP_USER_NAME=test 用户可向管理员咨询运行用户。test在这里只是举例,若需运行Colocation相关操作的样例代码,则此用户需属supergroup用户组。 执行如下命令,运行Jar包。 hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.HdfsExample hadoop jar HDFSTest-XXX.jar com.huawei.bigdata.hdfs.examples.ColocationExample 在运行com.huawei.bigdata.hdfs.examples.ColocationExample时,HDFS的配置项“fs.defaultFS”不能配置为“viewfs://ClusterX”。
  • 未安装客户端时编译并运行程序 进入工程本地根目录,在Windows命令提示符窗口中执行下面命令进行打包。 mvn -s "{maven_setting_path}" clean package 上述打包命令中的{maven_setting_path}为本地Maven的“settings.xml”文件路径。 打包成功之后,在工程根目录的target子目录下获取打好的jar包。 将导出的Jar包上传至Linux运行环境的任意目录下,例如“/optclient”。 将工程中的“lib”文件夹和“conf”文件夹上传至和Jar包相同的Linux运行环境目录下,例如“/opt/client”(其中“lib”目录汇总包含了工程中依赖的所有的Jar包,“conf”目录包含运行jar包所需的集群相关配置文件,请参考准备运行环境)。 运行此样例代码需要设置运行用户,设置运行用户有两种方式,添加环境变量HADOOP_USER_NAME或者修改代码设置运行用户。若在没有修改代码的场景下,执行以下语句添加环境变量: export HADOOP_USER_NAME=test 用户可向管理员咨询运行用户。test在这里只是举例,若需运行Colocation相关操作的样例代码,则此用户需属supergroup用户组。 执行如下命令运行Jar包。 java -cp HDFSTest-XXX.jar:conf/:lib/* com.huawei.bigdata.hdfs.examples.HdfsExample java -cp HDFSTest-XXX.jar:conf/:lib/* com.huawei.bigdata.hdfs.examples.ColocationExample 在运行com.huawei.bigdata.hdfs.examples.ColocationExample:时,HDFS的配置项“fs.defaultFS”不能配置为“viewfs://ClusterX”。
  • 操作步骤 查看运行结果获取应用运行情况 HdfsMain Linux样例程序安全集群运行结果如下所示: [root@node-master1dekG client]# hadoop jar hdfs-examples-1.0.jar com.huawei.bigdata.hdfs.examples.HdfsMain WARNING: Use "yarn jar" to launch YARN applications. 20/03/25 16:29:45 INFO security.UserGroupInformation: Login successful for user hdfsuser using keytab file user.keytab 20/03/25 16:29:45 INFO security.LoginUtil: Login success!!!!!!!!!!!!!! success to create path /user/hdfs-examples success to write. result is : hi, I am bigdata. It is successful if you can see me. success to read. success to delete the file /user/hdfs-examples/test.txt success to delete path /user/hdfs-examples success to create path /user/hdfs-examples StoragePolicy:FROZEN StoragePolicy:COLD StoragePolicy:WARM StoragePolicy:HOT StoragePolicy:ONE_SSD StoragePolicy:ALL_SSD StoragePolicy:LAZY_PERSIST succee to set Storage Policy path /user/hdfs-examples success to delete path /user/hdfs-examples HdfsMain Linux样例程序普通集群运行结果如下所示: [root@node-master2VknR client]# hadoop jar hdfs-examples-1.0.jar com.huawei.bigdata.hdfs.examples.HdfsMain WARNING: Use "yarn jar" to launch YARN applications. success to create path /user/hdfs-examplessuccess to write. result is : hi, I am bigdata. It is successful if you can see me. success to read. success to delete the file /user/hdfs-examples/test.txt success to delete path /user/hdfs-example ssuccess to create path /user/hdfs-examples StoragePolicy:FROZEN StoragePolicy:COLD StoragePolicy:WARM StoragePolicy:HOT StoragePolicy:ONE_SSD StoragePolicy:ALL_SSD StoragePolicy:LAZY_PERSIST succee to set Storage Policy path /user/hdfs-examples success to delete path /user/hdfs-examples 查看HDFS日志获取应用运行情况 您可以查看HDFS的namenode日志了解应用运行情况,并根据日志信息调整应用程序。
  • 操作步骤 执行mvn package生成jar包,在工程目录target目录下获取,比如:hdfs-examples-1.0.jar。 将导出的Jar包拷贝上传至Linux客户端运行环境的任意目录下,例如“/opt/client”,然后在该目录下创建“conf”目录,将“user.keytab” 和 "krb5.conf"拷贝至“conf”目录。可参考6 。 配置环境变量。 source /opt/client/bigdata_env 执行如下命令,运行Jar包。 hadoop jar hdfs-examples-1.0.jar com.huawei.bigdata.hdfs.examples.HdfsMain 运行命令时,需保持客户端“Yarn/config/hdfs-site.xml”中的kerberos相关信息和“HDFS/hadoop/etc/hadoop/hdfs-site.xml”中的kerberos相关信息一致。“hdfs-site.xml”中kerberos的配置mapred改为hdfs,需要修改的地方如图1所示。 图1 hdfs-site.xml