搭建hbase1.2.5徹底分佈式集羣

 

簡介java

有一段時間,沒寫博客了,由於公司開發分佈式調用鏈追蹤系統,用到hbase,在這裏記錄一下搭建過程node

一、集羣以下:

ip 主機名 角色
192.168.6.130 node1.jacky.com maser
192.168.6.131 node2.jacky.com slave
192.168.6.132 node3.jacky.com slave

二、文件以下:

[root@node1 software]# ll
總用量 464336
-rw-r--r--. 1 root root 214092195 9月  12 17:54 hadoop-2.7.3.tar.gz
-rw-r--r--. 1 root root 104584366 9月  14 14:08 hbase-1.2.5-bin.tar.gz
-rwxr-xr-x. 1 root root 140393310 9月  16 13:51 jdk-8u11-linux-x64.rpm
-rw-r--r--. 1 root root  16402010 10月 25 2016 zookeeper-3.4.5.tar.gz

說明:安裝hbase以前,須要安裝hadoop環境(hbase用到hadoop的hdfs),須要zookeeper環境,須要jdk環境linux

三、安裝hadoop、centos7.0環境配置

 3.一、修改3臺機器的hosts文件,配置ip和主機名映射

[root@node1 jacky]# vim /etc/hosts

在文件後面添加內容爲:web

192.168.6.130 node1.jacky.com
192.168.6.131 node2.jacky.com
192.168.6.132 node3.jacky.com

3.二、修改3臺機器hostname文件

在192.168.6.130機器中修改,修改hostname爲apache

[root@node1 jacky]# cat /etc/hostname 
node1.jacky.com

很顯然另外兩臺技術設置的主機名分別爲node2.jacky.com和node3.jacky.comvim

3.三、配置192.168.6.130能夠免密碼登陸192.168.6.131和192.168.6.132

步驟:centos

  • 生成公鑰和私鑰
  • 修改公鑰名稱爲authorized_keys
[root@node1 ~]# 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:pvR6iWfppGPSFZlAqP35/6DEtGTvaMY64otThWoBTuk root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|  .  o.          |
|.o  . .          |
|+. o . . o       |
| Eo o . +        |
|   o o..S.       |
|  o ..oO.o       |
| . . ..=*oo      |
|  ..o *=@+ .     |
|  .oo=+@+.o..    |
+----[SHA256]-----+
[root@node1 .ssh]# cp id_rsa.pub authorized_keys
[root@node1 .ssh]# chmod 777 authorized_keys #修改文件權限

說明:session

authorized_keys:存放遠程免密登陸的公鑰,主要經過這個文件記錄多臺機器的公鑰 
id_rsa : 生成的私鑰文件 
id_rsa.pub : 生成的公鑰文件 
know_hosts : 已知的主機公鑰清單 app

[root@node1 .ssh]# ssh-copy-id -i root@node1.jacky.com 到本身
[root@node1 .ssh]# ssh-copy-id -i root@node2.jacky.com 
[root@node1 .ssh]# ssh-copy-id -i root@node3.jacky.com 

3.四、配置hadoop的環境變量

[root@node1 software]# vim /etc/profiledom

# hadoop
export HADOOP_HOME=/usr/local/hadoop-2.7.3
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
export HADOOP_INSTALL=$HADOOP_HOME

輸入 source /etc/profile 使配置文件生效。

[root@node1 software]#  source /etc/profile

四、hadoop配置

 4.一、上傳hadoop文件

[root@node1 software]# ll
總用量 464336
-rw-r--r--. 1 root root 214092195 9月  12 17:54 hadoop-2.7.3.tar.gz
-rw-r--r--. 1 root root 104584366 9月  14 14:08 hbase-1.2.5-bin.tar.gz
-rwxr-xr-x. 1 root root 140393310 9月  16 13:51 jdk-8u11-linux-x64.rpm
-rw-r--r--. 1 root root  16402010 10月 25 2016 zookeeper-3.4.5.tar.gz
[root@node1 software]# pwd
/usr/software
[root@node1 software]#

說明:我把hadoop-2.7.3.tar.gz上傳到/usr/software

4.二、配置hadoop-env.sh文件

# The java implementation to use.
export JAVA_HOME=/usr/java/jdk1.8.0_11

4.三、配置yarn-env.sh文件

export JAVA_HOME=/usr/java/jdk1.8.0_11

4.四、修改slaves文件,指定master的小弟,在master機器上,sbin目錄下只執行start-all.sh,可以啓動全部slave的DataNode和NodeManager

[root@node1 hadoop]# cat slaves 
node2.jacky.com
node3.jacky.com

4.五、修改hadoop核心配置文件core-site.xml

<configuration>
  <!--配置hadoop使用的文件系統,配置hadoop內置的文件系統-->
   <property>
        <name>fs.defaultFS</name>
        <value>hdfs://node1.jacky.com:9000</value>
    </property>
   <!--配置hadoop數據目錄-->
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/usr/local/hadoop-2.7.3/tmp</value>
    </property>
</configuration>

說明:目錄/usr/local/hadoop-2.7.3/tmp,是本身新建的

4.六、修改hdfs-site.xml文件

<configuration>
    <property>
      <name>dfs.namenode.secondary.http-address</name>
      <value>node1.jacky.com:50090</value>
    </property>
    <property>
      <name>dfs.replication</name>
      <value>3</value>
    </property>
    <property>
        <name>dfs.name.dir</name>
        <value>/usr/local/hadoop-2.7.3/hadoop/name</value>
    </property>
    <property>
        <name>dfs.data.dir</name>
        <value>/usr/local/hadoop-2.7.3/hadoop/data</value>
    </property>
    <property>
      <name>dfs.webhdfs.enabled</name>
      <value>true</value>
    </property>
</configuration>

4.七、修改mapred-site.xml文件

<configuration>
       <!--mapreduce配置在yarn集羣上跑-->
        <property>
        <name>mapreduce.framework.name</name>
                <value>yarn</value>
           </property>
          <property>
                  <name>mapreduce.jobhistory.address</name>
                  <value>node1.jacky.com:10020</value>
          </property>
          <property>
                <name>mapreduce.jobhistory.webapp.address</name>
                <value>node1.jacky.com:19888</value>
       </property>
</configuration>

4.八、修改yarn-site.xml文件

<configuration>  
        <property>  
               <name>yarn.nodemanager.aux-services</name>  
               <value>mapreduce_shuffle</value>  
        </property>  
        <property>                                                                  
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>  
               <value>org.apache.hadoop.mapred.ShuffleHandler</value>  
        </property> 
       <!--配置yarn的master--> 
        <property>  
               <name>yarn.resourcemanager.address</name>  
               <value>node1.jacky.com:8032</value>  
       </property>  
       <property>  
               <name>yarn.resourcemanager.scheduler.address</name>  
               <value>node1.jacky.com:8030</value>  
       </property>  
       <property>  
            <name>yarn.resourcemanager.resource-tracker.address</name>  
             <value>node1.jacky.com:8031</value>  
      </property>  
      <property>  
              <name>yarn.resourcemanager.admin.address</name>  
               <value>node1.jacky.com:8033</value>  
       </property>  
       <property>  
               <name>yarn.resourcemanager.webapp.address</name>  
               <value>node1.jacky.com:8088</value>  
       </property>  
</configuration>

4.九、而後把在master的配置拷貝到node2.jacky.com和node3.jacky.com節點上

[root@node1 hadoop-2.7.3]# scp -r hadoop-2.7.3 root@node2.jacky.com:/usr/local/
[root@node1 hadoop-2.7.3]# scp -r hadoop-2.7.3 root@node3.jacky.com:/usr/local/

五、啓動hadoop

5.一、格式化hadoop

[root@node1 hadoop-2.7.3]# hdfs namenode -format

5.二、啓動hadoop

[root@node1 sbin]# start-all.sh

5.三、用jps命令查看三臺機器上hadoop有沒起來

192.168.6.130

[root@node1 sbin]# jps
7969 QuorumPeerMain
25113 NameNode
25483 ResourceManager
73116 Jps
25311 SecondaryNameNode

192.168.6.131

[root@node2 jacky]# jps
43986 Jps
60437 DataNode
12855 QuorumPeerMain
60621 NodeManager

192.168.6.132

[root@node2 jacky]# jps
43986 Jps
60437 DataNode
12855 QuorumPeerMain
60621 NodeManager

5.四、界面查看驗證

http://192.168.6.130:8088/cluster/nodes

查看dataNode是否啓動

http://192.168.6.130:50070/

好了,到這裏,hadoop-2.7.3徹底分佈式集羣搭建成功了,接下來咱們將進入hbase搭建

 六、hbase徹底分佈式集羣搭建

6.一、上傳到文件到/usr/software目錄下,解壓到/usr/local目錄下

[root@node2 software]# ll
總用量 327232
-rw-r--r--. 1 root root 214092195 9月  12 17:54 hadoop-2.7.3.tar.gz
-rw-r--r--. 1 root root 104584366 9月  14 15:59 hbase-1.2.5-bin.tar.gz
-rw-r--r--. 1 root root  16402010 10月 25 2016 zookeeper-3.4.5.tar.gz
[root@node2 software]# pwd
/usr/software
[root@node2 software]# tar -xvzf hbase-1.2.5-bin.tar.gz -C /usr/local/

6.二、配置hbase環境變量vim /etc/profile

#hbase
export HBASE_HOME=/usr/local/hbase-1.2.5 export PATH=$HBASE_HOME/bin:$PATH

執行 source /etc/profile,讓配置生效

6.三、建立目錄tmp

[root@node2 hbase-1.2.5]# /usr/local/hbase-1.2.5/tmp

6.四、配置hbase-env.sh

export JAVA_HOME=/usr/java/jdk1.8.0_11

# Extra Java CLASSPATH elements.  Optional.
export HBASE_CLASSPATH=/usr/local/hadoop-2.7.3/etc/hadoop

# Tell HBase whether it should manage it's own instance of Zookeeper or not.
export HBASE_MANAGES_ZK=false 默認是true

6.五、配置hbase-site.xml

<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://node1.jacky.com:9000/hbase</value>
    </property>
    <property>
        <name>hbase.master</name>
        <value>node1.jacky.com</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.tmp.dir</name>
        <value>/usr/local/hbase-1.2.5/tmp</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>node1.jacky.com,node2.jacky.com,node3.jacky.com</value>
    </property>
    <property>
        <name>hbase.zoopkeeper.property.dataDir</name>
        <value>/usr/local/zookeeper-3.4.5/data</value>
    </property>
    <property>
        <name>zookeeper.session.timeout</name>
        <value>60000000</value>
    </property>
    <property>
        <name>dfs.support.append</name>
        <value>true</value>
    </property>
</configuration>

6.六、配置regionservers,其實就是配置master的小弟

node2.jacky.com
node3.jacky.com

6.七、用scp 命令把配置好的hbase程序分發到各個機器上

scp  hbase-1.2.5 root@node2.jacky.com:/usr/local
scp  hbase-1.2.5 root@node3.jacky.com:/usr/local

七、啓動hbase,只須要在master機器上執行

[root@node1 bin]# ./start-hbase.sh 
node3.jacky.com: starting zookeeper, logging to /usr/local/hbase-1.2.5/bin/../logs/hbase-root-zookeeper-node3.jacky.com.out
node2.jacky.com: starting zookeeper, logging to /usr/local/hbase-1.2.5/bin/../logs/hbase-root-zookeeper-node2.jacky.com.out
node1.jacky.com: starting zookeeper, logging to /usr/local/hbase-1.2.5/bin/../logs/hbase-root-zookeeper-node1.jacky.com.out
starting master, logging to /usr/local/hbase-1.2.5/logs/hbase-jacky-master-node1.jacky.com.out
node2.jacky.com: starting regionserver, logging to /usr/local/hbase-1.2.5/bin/../logs/hbase-root-regionserver-node2.jacky.com.out
node3.jacky.com: starting regionserver, logging to /usr/local/hbase-1.2.5/bin/../logs/hbase-root-regionserver-node3.jacky.com.out
node2.jacky.com: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
node2.jacky.com: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
[root@node1 bin]# 

 7.一、經過jps查看hbase進程

192.168.6.130

[root@node1 bin]# jps
7969 QuorumPeerMain
74560 HMaster
25113 NameNode
25483 ResourceManager
25311 SecondaryNameNode
75006 Jps

192.168.131

[root@node2 local]# jps
60437 DataNode
12855 QuorumPeerMain
47227 HRegionServer
60621 NodeManager
47902 Jps

192.168.6.132

[root@node2 local]# jps
60437 DataNode
12855 QuorumPeerMain
47227 HRegionServer
60621 NodeManager
47902 Jps

7.二、經過打開頁面驗證

 

 到這裏hbase徹底分佈式集羣就搭建完成了

歡迎關注

相關文章
相關標籤/搜索