前面已经完成Zookeeper和HDFS的安装,本文会详细介绍Hbase的安装步骤。以及安装过程中遇到问题的汇总。
系列文章:
Hadoop集群(一) Zookeeper搭建
Hadoop集群(二) HDFS搭建
Hadoop集群(四) Hadoop升级
下面开始Hbase的安装。
Hbase的服务器规划
192.168.67.101 c6701 --Master + regionserver 192.168.67.102 c6702 --Master(standby)+regionserver 192.168.67.103 c6703 --regionserver
—在c6701上安装Hbase
1. 创建hbase用户,及创建相关目录
su - root useradd hbase echo "hbase:hbase" | chpasswd mkdir -p /data/zookeeper mkdir -p /data/hbase/tmp mkdir -p /data/hbase/logs chown -R hbase:hbase /data/hbase chown -R a+rx /home/hdfs <<<<<<<<<<<<<让hadoop目录,其他人可以用读和执行--很重要hbase需要访问
2. 解压软件
su - hbase cd /tmp/software tar -zxvf hbase-1.1.3.tar.gz -C /home/hbase/
3. 设置hbase-site.xml的参数
[hbase@c6701 conf]$ more hbase-site.xml <configuration> <property> <name>hbase.tmp.dir</name> <value>/data/hbase/tmp</value> </property> <property> <name>hbase.rootdir</name> <value>hdfs://ns/hbase</value> <<<<<<<<<<<<<<<<<这里要注意,ns是namenode的名字,Hbase可以访问很多HDFS,在这里标注namenode,才是指定访问这个namenode,实际在hdfs看到是/hbase的目录,不会看到ns的。 </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.master</name> <value>60000</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>c6701,c6702,c6703</value> </property> <property> <name>hbase.zookeeper.property.clientPort</name> <value>2181</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/data/zookeeper</value> </property> </configuration>
4. 设置hbase-env.sh的参数
[hbase@c6701 conf]$ cat hbase-env.sh |grep -v "^#" export JAVA_HOME=/usr/local/jdk1.8.0_144 export HBASE_CLASSPATH=$HADOOP_HOME/etc/hadoop/ export HBASE_HEAPSIZE=500M export HBASE_OPTS="-XX:+UseConcMarkSweepGC" export HBASE_REGIONSERVER_OPTS="-Xmx1g -Xms400m -Xmn128m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70" export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -Xmx1g -Xms400m -XX:PermSize=128m -XX:MaxPermSize=128m" export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m" export HBASE_LOG_DIR=/data/hbase/logs export HBASE_PID_DIR=/data/hbase/hadoopPidDir export HBASE_MANAGES_ZK=true export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HBASE_HOME/lib/:/usr/lib64/ export HBASE_LIBRARY_PATH=$HBASE_LIBRARY_PATH:$HBASE_HOME/lib/:/usr/lib64/
5. 注意一下内存设置,由于是测试环境,设置过大,导致内存不足,无法启动问题
export HBASE_REGIONSERVER_OPTS="-Xmx1g -Xms400m -Xmn128m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70" export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -Xmx1g -Xms400m -XX:PermSize=128m -XX:MaxPermSize=128m"
内存不足的错误
[hbase@c6701 bin]$ ./hbase-daemon.sh start master starting master, logging to /data/hbase/logs/hbase-hbase-master-c6701.python279.org.out Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006c5330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory. # An error report file with more information is saved as: # /home/hbase/hbase-1.1.3/bin/hs_err_pid7507.log
6. 增加hadoop的参数到/etc/profile中,后面hbase运行,需要知道hadoop_home
export JAVA_HOME=/usr/local/jdk1.8.0_144 export JRE_HOME=/usr/local/jdk1.8.0_144/jre export PATH=$JAVA_HOME/bin:$PATH:/home/hbase/hbase-1.1.3/bin export HADOOP_HOME=/home/hdfs/hadoop-2.6.0-EDH-0u2 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=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib:$HADOOP_COMMON_LIB_NATIVE_DIR"
—安装c6702的hbase
7. 创建hbase用户
ssh c6702 "useradd hbase;echo "hbase:hbase" | chpasswd"
8. 为hbase用户ssh免密
ssh-copy-id hbase@c6702
9. 拷贝软件,创建目录,解压软件
scp -r /tmp/software/hbase-1.1.3.tar.gz root@c6702:/tmp/software/. ssh c6702 "chmod 777 /tmp/software/*;mkdir -p /data/zookeeper;mkdir -p /data/hbase/tmp;mkdir -p /data/hbase/logs;chown -R hbase:hbase /data/hbase" ssh c6702 "chmod -R a+rx /home/hdfs" ssh hbase@c6702 "tar -zxvf /tmp/software/hbase-1.1.3.tar.gz -C /home/hbase"
10.复制配置文件
scp -r /etc/profile root@c6702:/etc/profile scp -r /home/hbase/hbase-1.1.3/conf/hbase-site.xml hbase@c6702:/home/hbase/hbase-1.1.3/conf/. scp -r /home/hbase/hbase-1.1.3/conf/hbase-env.sh hbase@c6702:/home/hbase/hbase-1.1.3/conf/.
—安装c6703的hbase
8. 创建hbase用户
ssh c6703 "useradd hbase;echo "hbase:hbase" | chpasswd"
9. 为hbase用户ssh免密
ssh-copy-id hbase@c6703
10. 拷贝软件,创建目录,解压软件
scp -r /tmp/software/hbase-1.1.3.tar.gz root@c6703:/tmp/software/. ssh c6703 "chmod 777 /tmp/software/*;mkdir -p /data/zookeeper;mkdir -p /data/hbase/tmp;mkdir -p /data/hbase/logs;chown -R hbase:hbase /data/hbase" ssh c6703 "chmod -R a+rx /home/hdfs" ssh hbase@c6703 "tar -zxvf /tmp/software/hbase-1.1.3.tar.gz -C /home/hbase"
11. 复制配置文件
scp -r /etc/profile root@c6703:/etc/profile scp -r /home/hbase/hbase-1.1.3/conf/hbase-site.xml hbase@c6703:/home/hbase/hbase-1.1.3/conf/. scp -r /home/hbase/hbase-1.1.3/conf/hbase-env.sh hbase@c6703:/home/hbase/hbase-1.1.3/conf/.
12. 启动Hbase master(在c6701和c6702)
hbase-daemon.sh start master ssh -t -q c6702 sudo su -l hbase -c "/usr/local/hadoop/hbase-release/bin/hbase-daemon.sh/ start/ master"
13. 启动Hbase regionserver(在c6701和c6702和c6703)
hbase-daemon.sh start regionserver ssh -t -q c6702 sudo su -l hbase -c "/usr/local/hadoop/hbase-release/bin/hbase-daemon.sh/ start/ regionserver" ssh -t -q c6703 sudo su -l hbase -c "/usr/local/hadoop/hbase-release/bin/hbase-daemon.sh/ start/ regionserver"
HBASE安装过程,问题汇总
1. 首先Hbase-site.xml设置错误,ns是namenode的名字,Hbase可以访问很多HDFS,在这里标注namenode,才是指定访问这个namenode,实际在hdfs看到是/hbase的目录,不会看到ns的。
<name>hbase.rootdir</name> <value>hdfs://ns/hbase</value> <<<<<<<<<<<<<<<<<这里要注意
2.通过hbase访问hdfs遇到问题,虽然也可以对hdfs操作,但是有warning
[root@c6701 home]# su - hbase $ hdfs dfs -mkdir /hbase $ hdfs dfs -ls / Found 1 items drwxrwx--- - hdfs hadoop 0 2017-10-25 10:18 /hbase 权限不对,需要hbase是owner才可以让hbase正常访问hdfs路径 $ hadoop fs -chown hbase:hbase /hbase $ hdfs dfs -ls / Found 1 items drwxrwx--- - hbase hbase 0 2017-10-25 10:18 /hbase 已经修改成功 [hbase@c6701 ~]$ hdfs dfs -ls /hbase/test 17/09/27 07:45:59 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
最后注释掉/etc/profile中的CLASSPATH=解决的这个问题
export JAVA_HOME=/usr/local/jdk1.8.0_144 export JRE_HOME=/usr/local/jdk1.8.0_144/jre #export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$PATH:/home/hbase/hbase-1.1.3/bin
3. 启动Hbase的时候,还遇到权限问题,无法找到hadoop。首先通过hbase用户检查hadoop访问权限
su - hbase /home/hdfs/hadoop-2.6.0-EDH-0u2/bin/hadoop version
如果权限有问题,需要增加hbase执行hadoop文件的权限
4. 启动过程中,遇到错误,是由于/home/hbase/hbase-1.1.3/lib/原有的一些jar包版本与hadoop不同,进而影响,删除即可。hbase会从hadoop中读取jar包
[hbase@c6702 ~]$ hbase-daemon.sh start regionserver starting regionserver, logging to /data/hbase/logs/hbase-hbase-regionserver-c6702.python279.org.out Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/hbase/hbase-1.1.3/lib/kylin-jdbc-1.5.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hbase/hbase-1.1.3/lib/kylin-job-1.5.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hbase/hbase-1.1.3/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hdfs/hadoop-2.6.0-EDH-0u2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
至此Zookeeper+HDFS+Hbase安装全部完成,前面还是比较顺利的,但是在Hbase安装的过程中,由于与Hadoop的衔接上,出现一些问题,耗费一些时间分析解决。
后续会继续测试,hadoop升级的过程。
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/196179.html