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配置
<property> <name>hadoop.tmp.dir</name> <value>file:/virgil/hadoop/tmp</value> <description>Abase for other temporary directories.</description> </property> <property> <name>fs.defaultFS</name> <value>hdfs://192.168.29.128:9000/hbase</value> </property>
hdfs-site.xml配置
<property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:/virgil/hadoop/tmp/dfs/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:/virgil/hadoop/tmp/dfs/data</value> </property>
hbase配置
hbase-site.xml配置
<property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.master.info.port</name> <value>60010</value> </property> <property> <name>hbase.rootdir</name> <value>hdfs://192.168.29.128:9000/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/virgil/zooserver/data</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>192.168.29.128</value> </property> <property> <name>hbase.zookeeper.property.clientPort</name> <value>2181</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/virgil/zooserver/data</value> </property>
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"));
相关推荐
eternityzzy 2020-07-19
鲸鱼写程序 2020-06-08
strongyoung 2020-06-04
WeiHHH 2020-05-30
飞鸿踏雪0 2020-06-12
changjiang 2020-11-16
minerd 2020-10-28
WeiHHH 2020-09-23
Aleks 2020-08-19
WeiHHH 2020-08-17
飞鸿踏雪0 2020-07-26
tomli 2020-07-26
deyu 2020-07-21
strongyoung 2020-07-19
Elmo 2020-07-19
飞鸿踏雪0 2020-07-09
飞鸿踏雪0 2020-07-04