zookeeper、hadoop、hbase单机伪分布式环境搭建(虚拟机vmware)

zookeeper单机多实例
其实就是跑多个zk服务,以zkServer1为例,配置如下:其中192.168.29.128为虚拟机ip 很重要

dataDir=/virgil/zooserver/server1/data
dataLogDir=/virgil/zooserver/server1/logs 
clientPort=2181
server.1=192.168.29.128:2888:3888
server.2=192.168.29.128:2889:3889
server.3=192.168.29.128:2890:3890

其余实例只需要保证clientPort,dataDir,dataLogDir,不一样即可
hadoop关键配置
写在前面:配置时最好写具体的ip,不要用localhost或者127.0.0.1,不然本地机器访问不到虚拟机
core-site.xml配置

    
        hadoop.tmp.dir
        file:/virgil/hadoop/tmp
        Abase for other temporary directories.
    
    
        fs.defaultFS
        hdfs://192.168.29.128:9000/hbase
    

hdfs-site.xml配置

    
        dfs.replication
        1
    
    
        dfs.namenode.name.dir
        file:/virgil/hadoop/tmp/dfs/name
    
    
        dfs.datanode.data.dir
        file:/virgil/hadoop/tmp/dfs/data
    

hbase配置
hbase-site.xml配置

    
        hbase.cluster.distributed
        true
    
    
        hbase.master.info.port
        60010
    
    
        hbase.rootdir
        hdfs://192.168.29.128:9000/hbase
    

    
        hbase.zookeeper.property.dataDir
        /virgil/zooserver/data
    
    
        hbase.zookeeper.quorum
        192.168.29.128
    
    
        hbase.zookeeper.property.clientPort
        2181
    
    
        hbase.zookeeper.property.dataDir
        /virgil/zooserver/data
    

java API访问位于虚拟机中的hbase
依次启动zookeeper、hadoop、hbase后

        Configuration HBASE_CONFIG = new Configuration();

        HBASE_CONFIG.set("hbase.zookeeper.quorum", "192.168.29.128");

        HBASE_CONFIG.set("hbase.zookeeper.property.clientPort", "2181");

        HBaseConfiguration cfg = new HBaseConfiguration(HBASE_CONFIG);

        HBaseAdmin admin = new HBaseAdmin(cfg);

        System.out.println(admin.tableExists("tableName"));

你可能感兴趣的:(zookeeper、hadoop、hbase单机伪分布式环境搭建(虚拟机vmware))