Hbase environment configuration of the remote connection

A few days ago, suddenly received a mandate, shall be accompanied by Hbase database, because no contact before, thinking that this is a common database connections, as later during operation, only to find that the pit is really a lot, man of few words said, directly on the code:

1. First view the remote server (I am a development library) version of Hbase connected to Hbase by Hbase shell command

View to version 1.2.0, in addition there are other ways to view, view /lib/*****.jar files can also be seen in the version number, the reason for this release is to depend on the phase pom.xml file inside correspondence, to avoid inconsistencies caused by the version number can not be connected

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-hadoop</artifactId>
            <version>2.5.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.2.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>guava</artifactId>
                    <groupId>com.google.guava</groupId>
                </exclusion>
            </exclusions>
        </dependency>

Add rely on good future, I began to write the test class:

private static String ip = "*.*.*.116,*.*.*.173,*.*.*.174";
public static void init() {
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.property.maxclientcnxns", "300");
        conf.set("hbase.ipc.client.socket.timeout.connect","1000");
        conf.set("zookeeper.session.timeout", "500");
        conf.set("hbase.regionserver.handler.count", "500");
        System.setProperty("hadoop.home.dir", "D:/Documents/Desktop/hadoop-common-2.6.0");
        conf.set("hbase.zookeeper.quorum",ip);
        try {
           conn = ConnectionFactory.createConnection(conf);
            //createTable(TABLE_NAME, FAMILY_NAMES);
             //getTablesList(conn);
            scan("students");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Here IP is the IP address of the cluster, configure itself, the configuration is complete, remember to also configure hadopp.hoop.dir in advance, although not used locally, but do not add will complain, consistent way and add JAVA_HOME way, need configuration path, after you configure this place, also need to configure the C: \ Windows \ System32 \ drivers \ etc \ hosts file,

Remember, the name of the red box and hsite.xml file to be consistent, otherwise an error could not find classpath = null, this configuration basically completed,

Finally, run the code

17:06:57.718 [main] DEBUG org.apache.hadoop.hbase.ipc.RpcClientImpl - Use SIMPLE authentication for service ClientService, sasl=false
17:06:57.735 [main] DEBUG org.apache.hadoop.hbase.ipc.RpcClientImpl - Connecting to worker3/*.*.*.176:60020
17:06:57.872 [hconnection-0x7770f470-shared--pool1-t1] DEBUG org.apache.hadoop.hbase.ipc.RpcClientImpl - Use SIMPLE authentication for service ClientService, sasl=false
17:06:57.873 [hconnection-0x7770f470-shared--pool1-t1] DEBUG org.apache.hadoop.hbase.ipc.RpcClientImpl - Connecting to worker2/*.*.*.175:60020
stu001	info:nme => tom
stu001_002	info:name => zhangtb
stu001_002_003	info:name => licy
stu002_001	info:name => weil

Remove the student information above is my pro-test, any questions, please leave a message communication

Published 23 original articles · won praise 7 · views 20000 +

Guess you like

Origin blog.csdn.net/ghd602338792/article/details/84975511