记录一次hadoop的安装配置,
版本号:Hadoop 2.7.3,
三台机器:test,home-test,hbase-test(主机名随便起,不过要先在/etc/hosts配置好)
创建一个hadoop账户,来安装hadoop,也可以直接使用root安装,配置好三台机器ssh无密码登陆,如下:
useradd hadoop;passwd hadoop;ssh-keygen -t rsa(直接回车,回车);cp -a ~/.ssh/id_rsa.pub authorized_keys;把authorized_keys传给其他两台机器,相同,在其他两台机器也这样做,确保从任何一台机器登陆其他两台都不需要密码!
安装hadoop之前,需要先把java环境配置好,直接解压jdk到/usr/local/lib,然后配置变量
~/.bashrc:
-
export JAVA_HOME=/usr/local/lib/jdk1.8.0_144
-
export JAVA_BIN=$JAVA_HOME/bin
-
export JAVA_LIB=$JAVA_HOME/lib
-
export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar
-
export PATH=$JAVA_BIN:$PATH
现在安装hadoop,直接解压hadoop的/usr/local/目录,开始配置变量:
-
# Hadoop Environment Variables
-
export HADOOP_HOME=/usr/local/hadoop
-
export HADOOP_INSTALL=$HADOOP_HOME
-
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=$HADOOP_HOME/sbin:$HADOOP_HOME/bin:$PATH
-
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
-
export LD_LIBRARY_PATH=$HADOOP_HOME/lib/native
开始配置
hdfs-site.xml:
-
<configuration>
-
<property>
-
<name>dfs.replication</name>
-
<value>2</value>
-
</property>
-
<property>
-
<name>dfs.namenode.name.dir</name>
-
<value>file:/usr/local/hadoop/tmp/dfs/name</value>
-
</property>
-
<property>
-
<name>dfs.datanode.data.dir</name>
-
<value>file:/usr/local/hadoop/tmp/dfs/data</value>
-
</property>
-
<property>
-
<name>dfs.datanode.address</name>
-
<value>0.0.0.0:50011</value>
-
</property>
-
<property>
-
<name>dfs.datanode.http.address</name>
-
<value>0.0.0.0:50076</value>
-
</property>
-
<property>
-
<name>dfs.datanode.ipc.address</name>
-
<value>0.0.0.0:50021</value>
-
</property>
-
</configuration>
core-site.xml
-
<configuration>
-
<property>
-
<name>hadoop.tmp.dir</name>
-
<value>file:/usr/local/hadoop/tmp</value>
-
<description>Abase for other temporary directories.</description>
-
</property>
-
<property>
-
<name>fs.defaultFS</name>
-
<value>hdfs://test:9000</value>
-
</property>
-
<property>
-
<name>ha.zookeeper.quorum</name>
-
<value>test:2181,home-test:2181,hbase-test:2181</value>
-
</property>
-
</configuration>
yarn-site.xml:
-
<configuration>
-
<property>
-
<name>yarn.resourcemanager.hostname</name>
-
<value>test</value>
-
</property>
-
<property>
-
<name>yarn.nodemanager.aux-services</name>
-
<value>mapreduce_shuffle</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.address</name>
-
<value>test:8032</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.scheduler.address</name>
-
<value>test:8030</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.resource-tracker.address</name>
-
<value>test:8031</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.admin.address</name>
-
<value>test:8033</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.webapp.address</name>
-
<value>test:8088</value>
-
</property>
-
</configuration>
mapred-site.xml
-
<configuration>
-
<property>
-
<name>mapreduce.framework.name</name>
-
<value>yarn</value>
-
<final>true</final>
-
</property>
-
<property>
-
<name>mapreduce.jobtracker.http.address</name>
-
<value>test:50030</value>
-
</property>
-
<property>
-
<name>mapreduce.jobhistory.address</name>
-
<value>test:10020</value>
-
</property>
-
<property>
-
<name>mapreduce.jobhistory.webapp.address</name>
-
<value>test:19888</value>
-
</property>
-
<property>
-
<name>mapred.job.tracker</name>
-
<value>http://test:9001</value>
-
</property>
-
</configuration>
slave文件加入两个datanode的主机名
以上配置好后,把整个hadoop目录拷贝到另外两台机器,现在准备配置zookeeper,
把zookeeper解压到/usr/local/zookeeper的配置文件
zoo.cfg:
-
# The number of milliseconds of each tick
-
tickTime=2000
-
# The number of ticks that the initial
-
# synchronization phase can take
-
initLimit=10
-
# The number of ticks that can pass between
-
# sending a request and getting an acknowledgement
-
syncLimit=5
-
# the directory where the snapshot is stored.
-
# do not use /tmp for storage, /tmp here is just
-
# example sakes.
-
dataDir=/opt/zookeeper/data
-
dataLogDir=/opt/zookeeper/logs
-
# the port at which the clients will connect
-
clientPort=2181
-
server.0=192.168.2.131:2888:3888
-
server.1=192.168.2.138:2888:3888
-
server.2=192.168.2.139:2888:3888
-
# the maximum number of client connections.
-
# increase this if you need to handle more clients
-
maxClientCnxns=60
-
#
-
# Be sure to read the maintenance section of the
-
# administrator guide before turning on autopurge.
-
#
-
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
-
#
-
# The number of snapshots to retain in dataDir
-
#autopurge.snapRetainCount=3
-
# Purge task interval in hours
-
# Set to "0" to disable auto purge feature
-
#autopurge.purgeInterval=1
分别在/opt目录创建data和logs目录:mkdir -p /opt/{data,logs}
并在data目录里面创建myid文件,填入当前机器的number,如当前机器是test,按照你的配置文件:server.0=192.168.2.131:2888:3888,直接在myid填入0
把zookeeper整个目录,拷贝到其他两台机器,主要要修改对应的myid号
紧接着,可以来弄hbase了,解压hbase到任意目录,修改配置
hbase-site.xml:
-
<configuration>
-
<!--HBase数据目录位置-->
-
<property>
-
<name>hbase.rootdir</name>
-
<value>hdfs://test:9000/hbase</value>
-
</property>
-
<!--启用分布式集群-->
-
<property>
-
<name>hbase.cluster.distributed</name>
-
<value>true</value>
-
</property>
-
<!--默认HMaster HTTP访问端口-->
-
<property>
-
<name>hbase.master.info.port</name>
-
<value>17010</value>
-
</property>
-
<!--默认HRegionServer HTTP访问端口-->
-
<property>
-
<name>hbase.regionserver.info.port</name>
-
<value>16030</value>
-
</property>
-
<!--不使用默认内置的,配置独立的ZK集群地址-->
-
<property>
-
<name>hbase.zookeeper.quorum</name>
-
<value>test,home-test</value>
-
</property>
-
<property>
-
<name>hbase.zookeeper.property.dataDir</name>
-
<value>/opt/zookeeper/data</value>
-
</property>
-
</configuration>
配置hbase的环境:
~/.bashrc
-
#Hbase Environment
-
HBASE_HOME=/opt/hbase-1.2.6
-
export PATH=$HBASE_HOME/bin:$PATH
hbase自带zookeeper,不适用自带的需要关闭它:
hbase-env.sh:
-
# Tell HBase whether it should manage it's own instance of Zookeeper or not.
-
export JAVA_HOME="/usr/local/lib/jdk1.8.0_144"
-
export HBASE_CLASSPATH=$HADOOP_HOME/etc/hadoop
-
export HBASE_MANAGES_ZK=false<---这个true的话,是使用hbase自带的zookeeper
拷贝整个hbase目录到另外两台机器,到这里基本该做的做完了,现在可以启动了,先启动zookeeper:
zkServer.sh start<---每一台都执行,然后zkServer.sh status看一下结果:
-
ZooKeeper JMX enabled by default
-
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
-
Mode: follower
-
-
ZooKeeper JMX enabled by default
-
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
-
Mode: leader
启动zookeeper成功,现在来启动hadoop:start-dfs.sh && start-yarn.sh,命令jps看一下结果:
-
Master(Namenode)上的:
-
1232 QuorumPeerMain
-
1608 SecondaryNameNode
-
1770 ResourceManager
-
8012 Jps
-
1407 NameNode
-
-
DataNode上的:
-
2275 QuorumPeerMain
-
2389 DataNode
-
4217 Jps
-
2506 NodeManager
可以看到正常启动,不错,现在开启hbase,命令start-hbase.sh,命令jps查看结果:
-
Master(NameNode)上的:
-
1232 QuorumPeerMain
-
3732 HMaster
-
1608 SecondaryNameNode
-
1770 ResourceManager
-
8012 Jps
-
1407 NameNode
-
-
DataNode上的:
-
2275 QuorumPeerMain
-
2389 DataNode
-
3159 HRegionServer
-
4217 Jps
-
2506 NodeManager
可以看到NameNode和DataNode个多了一个进程,HMaster和HRegionServer,表明hbase已经其启动了,一般来说,在master上启动,会把其他的节点也一起启动,如果其他节点没有启动成功,登陆其他节点,使用命令:hbase-daemon.sh start regionserver
到此,基本上配置好了,值得注意的是,上面hadoop配置完成后,需要先格式化hdfs,Master上执行:hdfs namenode -format
按照上面的配置会在/usr/local/hadoop/tmp生成name和data目录,
现在打开hbase shell验证一下hbase,还有按照上面的配置也可以直接通过web访问hbase,地址:
-
[hadoop@test ~]$ hbase shell
-
SLF4J: Class path contains multiple SLF4J bindings.
-
SLF4J: Found binding in [jar:file:/opt/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
-
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
-
SLF4J: See for an explanation.
-
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
-
HBase Shell; enter 'help' for list of supported commands.
-
Type "exit" to leave the HBase Shell
-
Version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017
-
-
hbase(main):001:0> status
-
1 active master, 0 backup masters, 2 servers, 0 dead, 1.0000 average load
-
-
hbase(main):002:0>
可以看到,没问题了,按照上面的配置,hbase的数据是在hdfs的/hbase上,查看一下:
-
[hadoop@test ~]$ hdfs dfs -lsr /
-
lsr: DEPRECATED: Please use 'ls -R' instead.
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:19 /hbase
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:19 /hbase/.tmp
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 15:19 /hbase/MasterProcWALs
-
-rw-r--r-- 2 hadoop supergroup 0 2017-08-11 15:19 /hbase/MasterProcWALs/state-00000000000000000017.log
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:19 /hbase/WALs
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 10:53 /hbase/WALs/hbase-test,16020,1502414543892
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 15:19 /hbase/WALs/hbase-test,16020,1502432350982
-
-rw-r--r-- 2 hadoop supergroup 83 2017-08-11 15:19 /hbase/WALs/hbase-test,16020,1502432350982/hbase-test%2C16020%2C1502432350982.default.1502435957318
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 17:02 /hbase/WALs/home-test,16020,1502334255452
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 17:18 /hbase/WALs/home-test,16020,1502356239257
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 15:19 /hbase/WALs/home-test,16020,1502432347782
-
-rw-r--r-- 2 hadoop supergroup 83 2017-08-11 15:19 /hbase/WALs/home-test,16020,1502432347782/home-test%2C16020%2C1502432347782..meta.1502435954818.meta
-
-rw-r--r-- 2 hadoop supergroup 83 2017-08-11 15:19 /hbase/WALs/home-test,16020,1502432347782/home-test%2C16020%2C1502432347782.default.1502435952957
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:25 /hbase/archive
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 14:24 /hbase/data/default
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data/hbase
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data/hbase/meta
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data/hbase/meta/.tabledesc
-
-rw-r--r-- 2 hadoop supergroup 398 2017-08-10 11:04 /hbase/data/hbase/meta/.tabledesc/.tableinfo.0000000001
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data/hbase/meta/.tmp
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:19 /hbase/data/hbase/meta/1588230740
-
-rw-r--r-- 2 hadoop supergroup 32 2017-08-10 11:04 /hbase/data/hbase/meta/1588230740/.regioninfo
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:26 /hbase/data/hbase/meta/1588230740/.tmp
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:26 /hbase/data/hbase/meta/1588230740/info
-
-rw-r--r-- 2 hadoop supergroup 5256 2017-08-11 14:26 /hbase/data/hbase/meta/1588230740/info/3fd729d52d074b0589519f6274e16d55
-
-rw-r--r-- 2 hadoop supergroup 7774 2017-08-11 14:19 /hbase/data/hbase/meta/1588230740/info/635a0727cf9f45bfaba3137b47ca7958
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:19 /hbase/data/hbase/meta/1588230740/recovered.edits
-
-rw-r--r-- 2 hadoop supergroup 0 2017-08-11 14:19 /hbase/data/hbase/meta/1588230740/recovered.edits/62.seqid
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data/hbase/namespace
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data/hbase/namespace/.tabledesc
-
-rw-r--r-- 2 hadoop supergroup 312 2017-08-10 11:04 /hbase/data/hbase/namespace/.tabledesc/.tableinfo.0000000001
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:04 /hbase/data/hbase/namespace/.tmp
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 17:10 /hbase/data/hbase/namespace/b89aee108e8c946ec1ef91e9ca9ff17a
-
-rw-r--r-- 2 hadoop supergroup 42 2017-08-10 11:04 /hbase/data/hbase/namespace/b89aee108e8c946ec1ef91e9ca9ff17a/.regioninfo
-
drwxr-xr-x - hadoop supergroup 0 2017-08-10 11:11 /hbase/data/hbase/namespace/b89aee108e8c946ec1ef91e9ca9ff17a/info
-
-rw-r--r-- 2 hadoop supergroup 4963 2017-08-10 11:11 /hbase/data/hbase/namespace/b89aee108e8c946ec1ef91e9ca9ff17a/info/a63013952e4749a5a44bcf6f15348e7c
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 14:19 /hbase/data/hbase/namespace/b89aee108e8c946ec1ef91e9ca9ff17a/recovered.edits
-
-rw-r--r-- 2 hadoop supergroup 0 2017-08-11 14:19 /hbase/data/hbase/namespace/b89aee108e8c946ec1ef91e9ca9ff17a/recovered.edits/26.seqid
-
-rw-r--r-- 2 hadoop supergroup 42 2017-08-10 11:04 /hbase/hbase.id
-
-rw-r--r-- 2 hadoop supergroup 7 2017-08-10 11:04 /hbase/hbase.version
-
drwxr-xr-x - hadoop supergroup 0 2017-08-11 15:30 /hbase/oldWALs
可以看到,有数据,没问题!
到此,也差不多了,可能有些小的细节没写清楚,以后慢慢补充吧,下一篇会是spark的集群!
阅读(2334) | 评论(0) | 转发(0) |