hbase连接linux开发过程
最近近公司被安排做hbase开发,太久没做今天记录下过程
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
public class getHbaseConfiguration {
private static Configuration conf = null;
public getHbaseConfiguration()
{
}
//这里必须预先处理化不然不然可能会出现未初始化conf就开始使用的问题
static
{
if(null == conf)
{
conf = HBaseConfiguration.create();
Path path = new Path("hbase-site.xml");
conf.addResource(path);
}
// return conf;
}
public void createTable(String tableName) throws IOException
{
HBaseAdmin admin = new HBaseAdmin(conf);
if(admin.tableExists(tableName))
{
System.out.println("Exists tables");
}
HTableDescriptor hTabeDescriptor = new HTableDescriptor("tableName");
hTabeDescriptor.addFamily(new HColumnDescriptor("cf1"));
admin.createTable(hTabeDescriptor);
}
public static void main(String[] args) {
//new getHbaseConfiguration().getInstance();
try {
new getHbaseConfiguration().createTable("test_1");
} catch (IOException e) {
e.printStackTrace();
}
}
}
被初始化的conf要求,可以从集群中hbase目录下conf拷贝,记得集群先hbase shell ---list测试集群可用否
<?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://CDHProject1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/home/hadoop/bigdata/softs/hbase-1.0.0-cdh5.5.5/data/tmp</value>
</property>
<!-- zookeeper- -->
<property>
<name>hbase.zookeeper.quorum</name>
<value>CDHProject1,CDHProject2,CDHProject3</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>
hbase连接linux开发过程的更多相关文章
- xshell连接linux,切换焦点,自动执行ctrl+c
这几天发现 xshell 连接 linux 的时候,无缘无故的执行了 ctrl+c,导致 执行界面 终端,比方说 ,hbase shell 执行窗口命令 ,每次切换 窗口焦点之后,就终止了.百度后 发 ...
- Windows远程连接Linux
目录 xrdp方式 vnc方式 xrdp方式 ----------------------------------------------------------------------------- ...
- 1、linux网络服务实验 用PuTTY连接Linux
这个是大三下学期的Linux网络服务配置详解时,感觉老师上得简单,就整理下,岭南师范学院师弟妹有福,如果是蔡老师交的话,可以拿来预习,复习. 一.用PuTTY连接Linux ①.装有redhat系统的 ...
- 第2章 Linux系统安装(3)_SSH连接Linux工具:SecureCRT和WinSCP
4. SSH连接Linux工具 4.1 Linux网卡配置 (1)临时配置: ifconfig eth0 192.168.32.100 //给eth0网卡指定IP,写在ROM里的,关机会丢失. (2) ...
- hbase连接操作
hbase连接操作 package com.test; import java.io.IOException; import org.apache.hadoop.conf.Configuration; ...
- xmanager远程桌面连接Linux
远程桌面连接Linux,两种工具:vnc.xmanager xmanager使用参考如下,暂未整理: Xmanager连接Centos的远程桌面 | 大爱 http://lovesoo.org/xma ...
- ssh连接linux服务器只显示-bash-4.1#不显示路径解决方法
ssh连接linux服务器只显示-bash-4.1#不显示路径时,我们只需要修改 ~/.bash_profile文件,如果不存在这个文件,那么新建一个,增加内容 export PS1='[\u@\ ...
- windows远程连接Linux(Ubuntu)的方法
需要做的工作: 1.在Linux(Ubuntu)端安装.设置好SSH 2.下载putty,并通过putty的SSH连接登录Linux 一 .如何在Linux(Ubuntu)端安装.设置好SSH,获取I ...
- 记一次VNC远程连接Linux问题解决记录(5900端口测试、KDE桌面安装)
最近几天,到一个项目上安装Linux部署环境.由于服务器在机房,而进机房又比较麻烦,于是选择VNC远程连接Linux就显得自然而然了.以前也用过VNC,而且还经常使用,由于各个项目环境不太一样,这次也 ...
随机推荐
- day 62 Django基础之jQuery操作cookie
Django基础之jQuery操作cookie jquery之cookie操作 定义:让网站服务器把少量数据储存到客户端的硬盘或内存,从客户端的硬盘读取数据的一种技术: 下载与引入:jquery. ...
- CentOS升级GDB
需要先安装ncurses-devel和texinfo 如果不安装ncurses-devel,编译会出错 如果不安装texinfo或者版本太低,安装会出错 1.yum install -y ncurse ...
- 4_4.springboot之Web开发登录和拦截器
1.登录处理 1).禁用模板引擎的缓存 # 禁用缓存 spring.thymeleaf.cache=false 2).页面修改完用ctrl+f9:重新编译: LoginController @Cont ...
- 11_springmvc之RESTful支持
一.理解RESTful RESTful架构,就是一种互联网软件架构.它结构清晰.符合标准.易于理解.扩展方便,所以正得到越来越多网站的采用. RESTful(即Representational Sta ...
- 2019-6-23-天河2-程序-version-GLIBCXX_3.4.21-not-found-解决方法
title author date CreateTime categories 天河2 程序 version GLIBCXX_3.4.21 not found 解决方法 lindexi 2019-06 ...
- uoj37 主旋律
题意:一个班级n个人,如果a爱b,那么a->b一条有向边.问有多少种删边集合使得图仍然强联通? n<=15. 标程: #include<cstdio> #include&l ...
- LoadRunner函数的介绍
LoadRunner函数的介绍 LoadRunner函数 一:通用函数 LoadRunner的通用函数以lr为前缀,可以在任何协议中使用.可以如下分类: 信息相关的函数: lr_error_messa ...
- HDU - 6128
题意略: 题解:二次剩余板子题 //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pragma GCC optimize(4) //#pra ...
- ElasticSearch _bulk批量处理报错The bulk request must be terminated by a newline
在JSON数据最后回车换行,代码中可以
- 01.visual studio 2017添加菜单
创建项目 文件--新建项目 如果新建项目 左侧没有扩展菜单,请安装即可 添加菜单 右键--添加新项 菜单设置 菜单设置文件: MyCommandPackage.vsct <Buttons> ...