搭建环境
- CentOS Linux release 7.4.1708 (Core)
- Hbase 2.3.4
一、伪分布式搭建
Hbase 自带web页面(重点是端口): http://192.168.75.138:16010/
0.配置免密登录
免密登录给本机和需要连接服务器都配置免密登录
* 生成私钥和公钥命令(在任意目录执行)
# ssh-keygen
# 出现下面的信息,按三次回车即可
----------------显示-------------------
[root@hbase-139 .ssh]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:HgHxi2cQ2vdxwN74vPuLMttGsDAK8RVb3KkOavT6XWs root@hbase-139
The key's randomart image is:
+---[RSA 2048]----+
| +..+o. . |
| .o +.oo.o |
| .oo.=..+. |
| . o+++=o. |
| o.+S=.= |
| ++..o + |
| . .. ... |
| . .ooEo |
| .. o*=oo. |
+----[SHA256]-----+
------------------执行完上面的命令,会在/root/.ssh目录下生成公钥和私钥----------------------
# cd /root/.ssh
* 输入要免密登录的服务器ip
# ssh-copy-id 192.168.75.139
* 输入yes,然后再输入连接服务器的密码
-----------------显示-----------------
[root@hbase-139 .ssh]# ssh-copy-id 192.168.75.139
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.75.139 (192.168.75.139)' can't be established.
ECDSA key fingerprint is SHA256:bdCj1PkE+gCBkoRq1pqA3IwNK0LqIY+eRyJmt1aooAk.
ECDSA key fingerprint is MD5:c8:4e:68:04:60:bd:50:ef:91:a2:5c:35:79:37:16:f9.
Are you sure you want to continue connecting (yes/no)? yes
/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@192.168.75.139's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.75.139'"
and check to make sure that only the key(s) you wanted were added.
------------------执行完上面的命令,会在连接的服务器/root/.ssh目录下生成authorized_keys文件-------------------------
------------------authorized_keys和公钥的内容一样-----
* 至此,可以直接登录到设置了免密登录的服务器,而不用输入密码
1.安装Hbase
# tar -zxvf hbase-2.3.4-bin.tar.gz
# cd hbase-2.3.4
2.hbase-env.sh
# vi conf/hbase-env.sh
--------------加入下面的配置------------------
export JAVA_HOME=/opt/jdk/jdk1.8.0_112
3.hbase-site.xml
# vi conf/hbase-site.xml
------------------选择1:如果不连接HDFS修改为true即可,其他默认-------------------
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
------------------选择2:如果连接HDFS-------------------
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!--
<property>
<name>hbase.tmp.dir</name>
<value>./tmp</value>
</property>
-->
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop-1:9000/hbase</value>
</property>
如果要连接HDFS请参考Hadoop伪分布式搭建: https://blog.youkuaiyun.com/Wen__Fei/article/details/116269138
4.ip映射
# vi /etc/hosts
192.168.75.138 hbase-1
192.168.75.139 hadoop-1
5.启动
# ./bin/start-hbase.sh
6.检查
如果没有连接HDFS可以忽略下面这个操作
* 如果一切正常,则HBase将在HDFS中创建其目录。(在hadoop根目录使用下面的命令)
# ./bin/hadoop fs -ls /hbase
ps:
经过上面的步骤,一个供测试使用的伪分布式就搭建起来了,可以使用Hbase shell对Hbase进行DDL等操作,也可以使用Java客户端连接Hbase,对Hbase进行操作。bye~