logo logo
关于我们

技术分享

技术分享 windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

2019-10-22

 

1.首先打开虚拟机,查看虚拟机的ip地址

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

 

2.修改C:\Windows\System32\drivers\etc下的主机名与ip的映射文件

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

3.配置Map/reduce

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

配置成功后可以查看hdfs文件目录

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

4.修改、虚拟机的ip与主机名的映射文件

 windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

5启动hdfs,hbase服务

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

 

6.通过代码测试

 

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

 1 package dao; 2  3 import org.apache.hadoop.conf.Configuration; 4 import org.apache.hadoop.fs.FileSystem; 5 import org.apache.hadoop.fs.Path; 6 public class exit { 7     public static void main(String[] args){ 8         try{ 9             String fileName = "/user/hadoop/hadoopfile";10             Configuration  configuration = new Configuration();11            // conf.set("fs.defaultFS", "hdfs://192.168.189.137:9000");12             configuration.set("hbase.zookeeper.quorum", "zyt");13             configuration.set("hbase.zookeeper.property.clientPort", "2181");14             configuration.set("hbase.rootdir", "hdfs://zyt:9000/hbase");15 16             //设置响应时间17             configuration.set("hbase.client.pause", "50");18             configuration.set("hbase.rpc.timeout", "2000");19             configuration.set("hbase.client.operation.timeout", "3000");20             configuration.set("hbase.client.scanner.timeout.period", "10000");21 22             23             configuration.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");24             FileSystem fs = FileSystem.get( configuration);25             if(fs.exists(new Path(fileName))){26                 System.out.println("文件存在");27             }else{28                 System.out.println("文件不存在");29             }30  31         }catch (Exception e){32             e.printStackTrace();33         }34     }35 }

core-site.xml

 1 <?xml version="1.0" encoding="UTF-8"?> 2 <?xml-stylesheet type="text/xsl" ?> 3 <!-- 4   Licensed under the Apache License, Version 2.0 (the "License"); 5   you may not use this file except in compliance with the License. 6   You may obtain a copy of the License at 7  8     http://www.apache.org/licenses/LICENSE-2.0 9 10   Unless required by applicable law or agreed to in writing, software11   distributed under the License is distributed on an "AS IS" BASIS,12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13   See the License for the specific language governing permissions and14   limitations under the License. See accompanying LICENSE file.15 -->16 17 <!-- Put site-specific property overrides in this file. -->18 19 <configuration>20  <property>21         <name>hadoop.tmp.dir</name>22         <value>file:/usr/local/hadoop/tmp</value>23         <description>Abase for other temporary directories.</description>24     </property>25     <property>26         <name>fs.defaultFS</name>27         <value>hdfs://zyt:9000</value>28     </property>29 </configuration>

hdfs-site.xml

 1 <?xml version="1.0" encoding="UTF-8"?> 2 <?xml-stylesheet type="text/xsl" ?> 3 <!-- 4   Licensed under the Apache License, Version 2.0 (the "License"); 5   you may not use this file except in compliance with the License. 6   You may obtain a copy of the License at 7  8     http://www.apache.org/licenses/LICENSE-2.0 9 10   Unless required by applicable law or agreed to in writing, software11   distributed under the License is distributed on an "AS IS" BASIS,12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13   See the License for the specific language governing permissions and14   limitations under the License. See accompanying LICENSE file.15 -->16 17 <!-- Put site-specific property overrides in this file. -->18 19 <configuration>20 <property>21         <name>dfs.replication</name>22         <value>2</value>23     </property>24     <property>25         <name>dfs.namenode.name.dir</name>26         <value>file:/usr/local/hadoop/tmp/dfs/name</value>27     </property>28     <property>29         <name>dfs.datanode.data.dir</name>30         <value>file:/usr/local/hadoop/tmp/dfs/data</value>31     </property>32     <property>33         <name>dfs.permissions</name>34         <value>false</value>35     </property>36 </configuration>

 

 1 <?xml version="1.0" encoding="UTF-8"?> 2 <?xml-stylesheet type="text/xsl" ?> 3 <!-- 4   Licensed under the Apache License, Version 2.0 (the "License"); 5   you may not use this file except in compliance with the License. 6   You may obtain a copy of the License at 7  8     http://www.apache.org/licenses/LICENSE-2.0 9 10   Unless required by applicable law or agreed to in writing, software11   distributed under the License is distributed on an "AS IS" BASIS,12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13   See the License for the specific language governing permissions and14   limitations under the License. See accompanying LICENSE file.15 -->16 17 <!-- Put site-specific property overrides in this file. -->18 19 <configuration>20  <property>21         <name>hadoop.tmp.dir</name>22         <value>file:/usr/local/hadoop/tmp</value>23         <description>Abase for other temporary directories.</description>24     </property>25     <property>26         <name>fs.defaultFS</name>27         <value>hdfs://zyt:9000</value>28     </property>29 </configuration>

 

 

windows下eclipse实现操作虚拟机ubantu中的hdfs hbase

 

云祺备份软件,云祺容灾备份系统,虚拟机备份,数据库备份,文件备份,实时备份,勒索软件,美国,图书馆
  • 标签:
  • 云计算

您可能感兴趣的新闻 换一批

现在下载,可享30天免费试用

立即下载

请添加好友为您提供支持
jia7jia_7

请拨打电话
为您提供支持

400-9955-698