节点 | 端口号 | 协议 | 使用 | 说明 |
zookeeper | 2181 | zkCli.sh -server zookeeper1:2181 | 客户端接入 | |
2888 | N/A | 集群内部通讯 | ||
3888 | N/A | 集群内部通讯 | ||
HDFS Namenode | 9000 | HDFS | hdfs dfs -ls hdfs://namenode1:9000/ | 客户端接入 |
50070 | HTTP | http://namenode1:50070/ | 集群监控 | |
HDFS SecondaryNamenode | 50090 | HTTP | http://namenode1:50090/ | secondary监控 |
HDFS Datanode | 50010 | N/A | 客户端接入/其他节点接入 | |
50020 | N/A | |||
50075 | HTTP | http://datanode1:50075/ | 节点监控 | |
HBase Master | 16000 | hbase-client-1.x.x.jar | RegionServer接入 | |
16010 | HTTP | http://namenode1:16010/ | 集群监控 | |
HBase RegionServer | 16020 | N/A | 客户端接入 | |
16030 | HTTP | http://datanode1:16030/ | 节点监控 |
HBase默认配置
发表于
分类于
hadoop
hbase-default.xml
默认配置中常用的的配置项:
配置项 | 说明 | 默认值 |
---|---|---|
hbase.tmp.dir |
本地文件系统上的临时目录。将此设置更改为指向比“/tmp”更持久的位置,因为在重新启动计算机时清除了“/tmp”目录。 | ${java.io.tmpdir}/hbase-${user.name} |
hbase.rootdir |
这个目录是region servers共享的目录。 | ${hbase.tmp.dir}/hbase |
hbase.cluster.distributed |
群集所处的模式。对于独立模式,可能的值为false,对于分布式模式,可能的值为true。 | false |
hbase.zookeeper.quorum |
使用逗号分隔的ZooKeeper集合中的服务器列表 | localhost |
zookeeper.recovery.retry.maxsleeptime |
在重试 zookeeper操作之前的最大睡眠时间(以毫秒为单位) | 60000 |
hbase.local.dir |
将本地文件系统上的目录用作本地存储。 | ${hbase.tmp.dir}/local/ |
hbase.master.port |
HBase Master应该绑定的端口。 | 16000 |
hbase.master.info.port |
HBase Master Web UI的端口。如果您不想运行UI实例,请将其设置为-1。 | 16010 |
hbase.master.info.bindAddress |
HBase Master Web UI的绑定地址 | 0.0.0.0 |
hbase.master.logcleaner.ttl |
WAL在归档({hbase.rootdir} / oldWALs)目录中保留多久,之后将由主线程清除。该值以毫秒为单位。 | 600000 |
hbase.master.procedurewalcleaner.ttl |
程序WAL将在归档目录中保留多久,之后将由主线程清除。该值以毫秒为单位。 | 604800000 |
hbase.master.fileSplitTimeout |
分割一个区域,在放弃尝试之前等待文件分割步骤需要多长时间。 | 600000 |
hbase.regionserver.port |
HBase RegionServer绑定的端口。 | 16020 |
hbase.regionserver.info.port |
HBase RegionServer Web UI的端口如果您不希望RegionServer UI运行,请将其设置为-1。 | 16030 |
hbase.regionserver.info.bindAddress |
HBase RegionServer Web UI的地址 | 0.0.0.0 |
hbase.regionserver.msginterval |
从RegionServer到Master的消息间隔(以毫秒为单位)。 | 3000 |
hbase.regionserver.regionSplitLimit |
限制区域数量,之后不再发生区域分割。这并不是硬性限制区域数量,而是作为区域服务商在一定限度之后停止分裂的指导方针。默认设置为1000。 | 1000 |
zookeeper.session.timeout |
ZooKeeper会话超时(以毫秒为单位)。它使用两种不同的方式。首先,这个值用于HBase用来连接到集合的ZK客户端。当它启动一个ZK服务器时它也被HBase使用 | 90000 |
zookeeper.znode.parent |
ZooKeeper中用于HBase的Root ZNode。所有配置了相对路径的HBase的ZooKeeper文件都会在这个节点下。 | /hbase |
zookeeper.znode.acl.parent |
Root ZNode用于访问控制列表。 | acl |
hbase.zookeeper.dns.interface |
ZooKeeper服务器应从中报告其IP地址的网络接口的名称。 | default |
hbase.zookeeper.peerport |
ZooKeeper同伴使用的端口进行彼此会话。 | 2888 |
hbase.zookeeper.leaderport |
ZooKeeper用于leader选举的端口。 | 3888 |
hbase.zookeeper.property.dataDir |
来自ZooKeeper的配置zoo.cfg的属性。快照存储的目录。 | ${hbase.tmp.dir}/zookeeper |
hbase.zookeeper.property.clientPort |
来自ZooKeeper的配置zoo.cfg的属性。客户端将连接的端口。 | 2181 |
hbase.zookeeper.property.maxClientCnxns |
来自ZooKeeper的配置zoo.cfg的属性。限制由IP地址标识的单个客户端的并发连接数量 | 300 |
hbase.column.max.version |
新的列族描述符将使用此值作为要保留的默认版本数。 | 1 |
参考链接
hbase shell常用命令
发表于
分类于
hadoop
通用命令
命令 | 说明 |
---|---|
status | 提供HBase的状态,例如,服务器的数量。 |
version | 提供正在使用HBase版本。 |
table_help | 表引用命令提供帮助。 |
whoami | 提供有关用户的信息。 |
数据定义
命令 | 说明 |
---|---|
create | 用于创建一个表。 |
list | 用于列出HBase的所有表。 |
disable | 用于禁用表。 |
is_disabled | 用于验证表是否被禁用。 |
enable | 用于启用一个表。 |
is_enabled | 用于验证表是否已启用。 |
describe | 用于提供了一个表的描述。 |
alter | 用于改变一个表。 |
exists | 用于验证表是否存在。 |
drop | 用于从HBase中删除表。 |
drop_all | 用于丢弃在命令中给出匹配“regex”的表。 |
数据操作语言
命令 | 说明 |
---|---|
put | 用于把指定列在指定的行中单元格的值在一个特定的表。 |
get | 用于取行或单元格的内容。 |
delete | 用于删除表中的单元格值。 |
deleteall | 用于删除给定行的所有单元格。 |
scan | 用于扫描并返回表数据。 |
count | 用于计数并返回表中的行的数目。 |
truncate | 用于禁用、删除和重新创建一个指定的表。清空表。 |
hbase单机版部署及简单测试
发表于
分类于
hadoop
在Centos7
上部署单机版hbase
下载安装包
解压
tar -zxvf hbase-2.2.4.bin.tar.gz
配置hbase-env.sh
部署JDK
,查看JAVA_HOME
路径。
[root@node1 hbase]# echo $JAVA_HOME
/usr/local/bin/jdk1.8.0_112
配置conf/hbase-env.sh
...
# 配置java路径
export JAVA_HOME=/usr/local/bin/jdk1.8.0_112
# 配置是否使用自身Zookeeper
export HBASE_MANAGES_ZK=true
...
编辑conf/hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///root/hbase/rootdir</value>
<description>The directory shared byregion servers.</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>file:///root/hbase/dfs</value>
</property>
<!-- hbase的端口 -->
<!-- <property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
<description>Property from ZooKeeper'sconfig zoo.cfg. The port at which the clients will connect.
</description>
</property> -->
<!-- 超时时间 -->
<!-- <property>
<name>zookeeper.session.timeout</name>
<value>120000</value>
</property> -->
<!-- zookeeper 集群配置。如果是集群,则添加其它的主机地址 -->
<!-- <property>
<name>hbase.zookeeper.quorum</name>
<value>localhost:2181</value>
</property> -->
<property>
<name>hbase.tmp.dir</name>
<value>/root/hbase/tmp</value>
</property>
<!-- <property>
<name>hbase.cluster.distributed</name>
<value>false</value>
</property> -->
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/root/hbase/datadir</value>
</property>
<property>
<name>zookeeper.znode.parent</name>
<value>/hbase</value>
</property>
</configuration>
启动
./bin/start-hbase.sh
Web UI
http://192.168.41.128:16010
进入shell命令行
./bin/hbase shell
简单测试
创建一个表,需要指明table name
和ColumnFamily name
hbase(main):002:0> create 'test', 'cf'
Created table test
Took 0.8251 seconds
=> Hbase::Table - test
确认
hbase(main):004:0> list 'test'
TABLE
test
1 row(s)
Took 0.0077 seconds
=> ["test"]
describe ‘test’
hbase(main):005:0> describe 'test'
Table test is ENABLED
test
COLUMN FAMILIES DESCRIPTION
{NAME => 'cf', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPL
ICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
1 row(s)
QUOTAS 0 row(s)
Took 0.2132 seconds
写入数据
hbase(main):003:0> put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0850 seconds
hbase(main):004:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0110 seconds
hbase(main):005:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0100 seconds
查看写入的数据
hbase(main):006:0> scan 'test'
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1586504678931, value=value1
row2 column=cf:b, timestamp=1586504712029, value=value2
row3 column=cf:c, timestamp=1586504717104, value=value3
3 row(s) in 0.0230 seconds
获取一行数据
hbase(main):007:0> get 'test', 'row1'
COLUMN CELL
cf:a timestamp=1586504678931, value=value1
1 row(s) in 0.0350 seconds
获取一个字段
hbase(main):007:0> get 'test', 'row1','cf:a'
COLUMN CELL
cf:a timestamp=1586504678931, value=value1
1 row(s) in 0.0350 seconds
返回一个字段的多个版本值
默认Hbase
列族最多保存一个版本的数据,可以通过下面命令修改,也可以使用HColumnDescriptor
:
alter 'test', NAME => 'cf', VERSIONS => 3
从HBase 0.98.2
开始,您可以通过在hbase-site.xml
中设置hbase.column.max.version
为所有新创建列保留的最大版本数指定一个全局默认值。
get 'test', 'row1', {COLUMN=>'cf:a',VERSIONS=>3}
禁用或者恢复表
hbase(main):008:0> disable 'test'
0 row(s) in 1.1820 seconds
hbase(main):009:0> enable 'test'
0 row(s) in 0.1770 seconds
添加一个列族
hbase(main):012:0> alter 'test',{NAME=>'haha'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.0149 seconds
hbase(main):014:0> alter 'test',NAME=>'hehe'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 1.9555 seconds
删除一个列族
hbase(main):009:0> alter 'test',{NAME=>'haha',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 1.9296 seconds
hbase(main):013:0> alter 'test','delete'=>'haha'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 1.8706 seconds
# 添加一个列族,同时删除一个列族
hbase(main):011:0> alter 'test', {NAME => 'hehe'}, {NAME => 'myInfo', METHOD => 'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 3.8260 seconds
清空表
hbase(main):013:0> truncate 'test'
Truncating 'test' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 3.6760 seconds
删除表
删除表或者修改表的配置前,需要禁用表
hbase(main):011:0> drop 'test'
0 row(s) in 0.1370 seconds
退出Shell
quit
或者 Ctrl+D
停止Hbase
./bin/stop-hbase.sh
springboot定时任务从配置文件中获取cron表达式
发表于
分类于
spring boot
@Scheduled
实现cron表达式从application.yml文件中获取
dbc:
cron: 0/5 * * * * ?
@Component
@EnableScheduling
public class CompareSchedule {
@Scheduled(cron = "${dbc.cron}")
public void schedule(){
System.out.println(1);
}
}
cron表达式含义
cron一共有7位,但是最后一位是年,可以留空,所以我们可以写6位:
- 第一位,表示秒,取值0-59
- 第二位,表示分,取值0-59
- 第三位,表示小时,取值0-23
- 第四位,日期天/日,取值1-31
- 第五位,日期月份,取值1-12
- 第六位,星期,取值1-7,星期一,星期二…,注:不是第1周,第二周的意思 另外:1表示星期天,2表示星期一。
- 第七位,年份,可以留空,取值1970-2099
cron中,还有一些特殊的符号,含义如下:
- (*)星号:可以理解为每的意思,每秒,每分,每天,每月,每年…
- (?)问号:问号只能出现在日期和星期这两个位置,表示这个位置的值不确定,每天3点执行,所以第六位星期的位置,我们是不需要关注的,就是不确定的值。同时:日期和星期是两个相互排斥的元素,通过问号来表明不指定值。比如,1月10日,比如是星期1,如果在星期的位置是另指定星期二,就前后冲突矛盾了。
- (-)减号:表达一个范围,如在小时字段中使用“10-12”,则表示从10到12点,即10,11,12
- (,)逗号:表达一个列表值,如在星期字段中使用“1,2,4”,则表示星期一,星期二,星期四
- (/)斜杠:如:x/y,x是开始值,y是步长,比如在第一位(秒) 0/15就是,从0秒开始,每15秒,最后就是0,15,30,45,60 另:*/y,等同于0/y
下面列举几个例子供大家来验证:
- 0 0 3 * * ? 每天3点执行
- 0 5 3 * * ? 每天3点5分执行
- 0 5 3 ? * * 每天3点5分执行,与上面作用相同
- 0 5/10 3 * * ? 每天3点的 5分,15分,25分,35分,45分,55分这几个时间点执行
- 0 10 3 ? * 1 每周星期天,3点10分 执行,注:1表示星期天
- 0 10 3 ? * 1 #3 每个月的第三个星期,星期天 执行,#号只能出现在星期的位置
测试文章加密,密码123456
发表于
分类于
test
Here's something encrypted, password is required to continue reading.