hbase ,windows 写Java程序
来源:互联网 发布:口红保质期 知乎 编辑:程序博客网 时间:2024/05/16 05:36
最近换工作了。
新工作做点笔记。
大数据平台
同事基于 http://www.aboutyun.com/thread-9075-1-1.html 配的
在 Windows 写 hbase Java 需要修改几个点。
1.需要 修改windows C:\Windows\System32\drivers\etc 下的hosts 这个是为了能找到服务器,不过你可以直接在下面的 hbase-site.xml
添加了
ip1 主机名1
ip2 主机名2
ip3 主机名3
2. 增加了hadoop home ,这个是要hadoop 运行程序 winutils.exe 这个是同事下载的,网上应该有很多。
System.setProperty("hadoop.home.dir", "D:/workSoftware/hadoop-2.4.1/hadoop-2.4.1/");
基本上 配置一下hbase-site.xml 文件就可以运行代码了
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- /** * * Licensed to the Apache Software Foundation (ASF) under one *
or more contributor license agreements. See the NOTICE file * distributed
with this work for additional information * regarding copyright ownership.
The ASF licenses this file * to you under the Apache License, Version 2.0
(the * "License"); you may not use this file except in compliance * with
the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0
* * Unless required by applicable law or agreed to in writing, software *
distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the
License for the specific language governing permissions and * limitations
under the License. */ -->
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://test11/hbase</value>
</property>
<property>
<name>hbase.client.write.buffer</name>
<value>2097152</value>
</property>
<property>
<name>hbase.client.pause</name>
<value>100</value>
</property>
<property>
<name>hbase.client.retries.number</name>
<value>35</value>
</property>
<property>
<name>hbase.client.scanner.caching</name>
<value>100</value>
</property>
<property>
<name>hbase.client.keyvalue.maxsize</name>
<value>10485760</value>
</property>
<property>
<name>hbase.rpc.timeout</name>
<value>60000</value>
</property>
<property>
<name>hbase.snapshot.enabled</name>
<value>true</value>
</property>
<property>
<name>hbase.security.authentication</name>
<value>simple</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>60000</value>
</property>
<property>
<name>zookeeper.znode.parent</name>
<value>/hbase</value>
</property>
<property>
<name>zookeeper.znode.rootserver</name>
<value>root-region-server</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>test11,test13,test12</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<!-- 解决使用maven构建hbase环境:No FileSystem for scheme: hdfs-->
<property>
<name>fs.hdfs.impl</name>
<value>org.apache.hadoop.hdfs.DistributedFileSystem</value>
</property>
</configuration>
然后做了一个简单的性能测试。个人以前写hive和mapreduce的。
不知道这个性能怎么
1千万行记录 用时 141s
主要代码
开启了100个线程
for (int i = 0; i < threads.length; i++) {
threads[i] = new ImportThread();
threads[i].start();
}
等全部线程结束
for(int j=0;j< threads.length;j++)
{
try {
(threads[j]).join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
线程程序
@Override
public void run() {
try {
HbaseUtils.insert(HbaseProps.TABLE_NAME,HbaseProps.SIZE/HbaseProps.THREAD_NUM,String.valueOf(this.getId()));
System.out.println(this.getName()+"insert into table success !!!");
} catch (IOException e) {
e.printStackTrace();
}
}
主机情况
- hbase ,windows 写Java程序
- 自己写java程序运行windows系统上的应用
- 第一个java hbase程序
- Windows 下Eclipse运行HBase程序
- java 写的spark 控制hbase
- c#写windows服务程序
- 使用ATL写Windows程序
- c#写windows服务程序
- c#写windows服务程序
- c#写windows服务程序
- 使用API写Windows程序
- 用API写windows程序
- 写一个Windows Forms程序
- c写windows窗体程序
- c++写windows服务程序
- java 多线程 写程序
- JAVA写串口程序
- 第一次写java程序
- VS2010产品秘钥
- [3.0]数组的创建及原理初探
- Excel导出到文件工具
- RN填坑-----tabBarIOS的icon和selectedIcon设置后无效
- 北航上机复试13真题
- hbase ,windows 写Java程序
- 从分支clone代码
- 一个hello world的编译原理
- 有关动/静态库的制作
- 电商商品模型的设计
- LeetCode总结,二叉树各种类型问题小结
- 绘图神器 —— Graphviz 绘制数据结构相关图形
- spring mvc接收数组mybatis 接收批量删除代码
- JQuery的Promise详解