系列文章目录
第一章 大数据学习入门之HBase的使用
文章目录
一、HBase是什么?
HBase是一个开源的、分布式的、版本化的NoSQL数据库,它构建于Hadoop之上,提供大规模数据存储和实时读写访问。以下是一些关于HBase的详细介绍:
基于Hadoop:HBase是Apache Hadoop生态系统的一部分,它直接运行在Hadoop Distributed File System (HDFS) 之上,利用HDFS来存储数据。
列式存储:与传统的关系型数据库不同,HBase采用面向列的存储方式,这意味着同一列的数据会被存储在一起,这种结构特别适合于处理大量的稀疏数据。
可伸缩性:HBase设计之初就考虑到了水平可伸缩性,能够通过添加更多的服务器来应对不断增长的数据量和访问压力。
随机访问与修改:HBase支持对数据的随机访问和修改,这使得它在需要快速查找和更新数据的应用中非常有用。
高可靠性:作为分布式系统,HBase提供了数据的高可靠性保障,即使个别服务器出现故障,整个系统仍能正常工作。
海量数据存储:HBase能够处理PB级别的数据量,适用于数据量巨大的场景。
版本控制:HBase还具有版本化的特性,可以保存同一数据单元的多个版本,这对于跟踪数据变更历史非常有价值。
适用场景:由于其特性,HBase非常适合于需要实时读写大数据的应用场景,如日志分析、社交媒体数据存储等。
社区支持:作为一个Apache项目,HBase拥有活跃的社区和持续的开发支持,不断有新功能和优化加入。
综上所述,HBase以其独特的列式存储模式、高可靠性、易扩展性和海量数据处理能力,在大数据存储解决方案中占有重要地位。对于需要处理大规模非结构化或半结构化数据的企业来说,HBase是一个值得考虑的选择。
IP地址 | 主机名 |
---|---|
192.168.24.10 | node1 |
192.168.24.20 | node2 |
192.168.24.30 | node3 |
二、基本配置。
1配置hosts映射。
vim /etc/hosts
把下面的内容添加到上面的文本中
192.168.24.10 node1
192.168.24.20 node2
192.168.24.30 node3
2.关闭防火墙。
systemctl stop firewalld.service //关闭防火墙
systemctl disable firewalld.service //开机自动关闭防火墙
3.配置ssh免密登陆。
1.生成密钥对。
[root@node1 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:l+RqMv79hB9RI0oIwim7THE0Vd23t1qfNXBdXCARCs4 root@node1
The key's randomart image is:
+---[RSA 2048]----+
| o+oo.o. .+o.oo|
| o +o + o..... o|
| = E + ..o.o|
| o + o +.oo|
| o . S = . o..|
| o o . . +.|
| o o . o o =|
| . + . o o ..|
| ... ..o |
+----[SHA256]-----+
2.将生成的密钥对传至另外的服务器
[root@node1 ~]# ssh-copy-id root@node1 //传至node1服务器
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node1's password: // 密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@node1'"
and check to make sure that only the key(s) you wanted were added.
[root@node1 ~]# ssh-copy-id root@node2 //传至node2服务器
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node1's password: // 密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@node1'"
and check to make sure that only the key(s) you wanted were added.
[root@node1 ~]# ssh-copy-id root@node3 //传至node3服务器
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node1's password: // 密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@node1'"
and check to make sure that only the key(s) you wanted were added.
三、配置HBase并启动集群。
1.用Xftp上传压缩包。
2.解压压缩包并指定目录。
tar -zxvf hbase-1.3.1-bin.tar.gz -C /opt/ //解压到/opt目录
3.配置HBase的环境变量。
vim /etc/profile
把下面的内容添加到上面文本中
export HBASE_HOME=/opt/hbase-1.3.1
export PATH=$HBASE_HOME/bin:$PATH
使环境变量生效
source /etc/profile
4.修改配置文件。
1.切换到HBase的配置文件目录。
cd /opt/hbase-1.3.1/conf/
2.修改hbase文件。
vim hbase-env.sh
把下面的配置文件添加到上面的文本中
export JAVA_HOME=/opt/jdk1.8.0_111
export HBASE_MANAGES_ZK=false
3.编辑hbase-site.xml,这个是hbase的主配置文件。
vim hbase-site.xml
把下面的内容添加到文本中
<property>
<name>hbase.rootdir</name>
<value>hdfs://node1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>node1,node2,node3</value>
</property>
<property>
<name>hbase.temp.dir</name>
<value>/opt/data/hbase/temp</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/data/zookeeper/</value>
</property>
</configuration>
4.编辑regionservers文件,删除里面的内容,并添加node2,node3.
vim regionservers
把下面内容添加到上面文本中
node2
node3
node2,node3跟上面的配置是一样的
四、启动集群。
start-hbase.sh //只需要在node1上启动
1.查看进程。
node1的集群
node2的集群
node3的集群
如果在node1上启动集群在node2,nade3上没有启动,就在node2,node3
分别使配置环境变量文件生效,再次启动
source /etc/profile
总结
以上就是今天要讲的内容,本文仅仅简单介绍了HBase的使用。