簡介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
[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
在192.168.6.130機器中修改,修改hostname爲apache
[root@node1 jacky]# cat /etc/hostname
node1.jacky.com
很顯然另外兩臺技術設置的主機名分別爲node2.jacky.com和node3.jacky.comvim
步驟:centos
[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
[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
[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
# The java implementation to use. export JAVA_HOME=/usr/java/jdk1.8.0_11
export JAVA_HOME=/usr/java/jdk1.8.0_11
[root@node1 hadoop]# cat slaves
node2.jacky.com
node3.jacky.com
<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,是本身新建的
<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>
<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>
<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>
[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/
5.一、格式化hadoop
[root@node1 hadoop-2.7.3]# hdfs namenode -format
[root@node1 sbin]# start-all.sh
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
http://192.168.6.130:8088/cluster/nodes
查看dataNode是否啓動
http://192.168.6.130:50070/
好了,到這裏,hadoop-2.7.3徹底分佈式集羣搭建成功了,接下來咱們將進入hbase搭建
[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/
#hbase
export HBASE_HOME=/usr/local/hbase-1.2.5 export PATH=$HBASE_HOME/bin:$PATH
執行 source /etc/profile,讓配置生效
[root@node2 hbase-1.2.5]# /usr/local/hbase-1.2.5/tmp
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
<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>
node2.jacky.com
node3.jacky.com
scp hbase-1.2.5 root@node2.jacky.com:/usr/local scp hbase-1.2.5 root@node3.jacky.com:/usr/local
[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]#
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
到這裏hbase徹底分佈式集羣就搭建完成了
歡迎關注