TANKENQI.cn

July 3, 2024

Hbase 集群部署

database5.5 min to read

1 设置主机名与 IP 映射关系(所有节点)

vi /etc/hosts10.101.240.41 hbase010.101.240.42 hbase110.101.240.43 hbase210.101.240.44 hbase3

2 配置节点间免密(所有节点)

# 生成密钥ssh-keygen -t rsa# 拷贝公钥至目标机器ssh-copy-id -i ~/.ssh/id_rsa.pub 用户@远端ip

3 配置 JDK 环境(所有节点)

vim ~/.bashrc# Javaexport JAVA_HOME=/mnt/oge/jdk/export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATHexport PATH=$PATH:$JAVA_HOME/binsource ~/.bashrc

4 部署hadoop

mkdir -p /mnt/storage/hadoop_data
export JAVA_HOME=/mnt/oge/jdk
<configuration>   <property>      <name>fs.default.name</name>      <value>hdfs://hbase0:9000</value>    </property>    <property>       <name>hadoop.tmp.dir</name>       <value>/mnt/oge/hadoop_data</value>   </property></configuration>
<configuration>   <property>		<name>dfs.replication</name>		<value>2</value>   </property>   <property>		<name>dfs.namenode.name.dir</name>		<value>/mnt/oge/hadoop_data/dfs/name</value>   </property>   <property>		<name>dfs.datanode.data.dir</name>		<value>/mnt/oge/hadoop_data/dfs/data</value>   </property></configuration>
hbase0hbase1hbase2hbase3
<configuration><!-- Site specific YARN configuration properties --><property>    <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>    <value>org.apache.mapred.ShuffleHandler</value></property><property>    <name>yarn.resourcemanager.address</name>    <value>hbase0:8032</value></property><property>    <name>yarn.resourcemanager.scheduler.address</name>    <value>hbase0:8030</value></property><property>    <name>yarn.resourcemanager.resource-tracker.address</name>    <value>hbase0:8031</value></property><property>    <name>yarn.resourcemanager.admin.address</name>    <value>hbase0:8033</value></property><property>    <name>yarn.resourcemanager.webapp.address</name>    <value>hbase0:8088</value></property></configuration>
<configuration><property>	<name>mapred.job.tracker</name>	<value>hbase0:9001</value></property><property>    <name>mapreduce.jobhistory.address</name>    <value>hbase0:10020</value></property><property>    <name>mapreduce.jobhistory.webapp.address</name>    <value>hbase0:19888</value></property></configuration>
scp -r /mnt/oge/hadoop-2.7.3 root@其他节点:/mnt/oge/
vim ~/.bashrc# hadoopexport HADOOP_HOME=/mnt/oge/hadoop-2.7.3export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbinexport HADOOP_LOG_DIR=/mnt/oge/hadoop-2.7.3/logsexport YARN_LOG_DIR=$HADOOP_LOG_DIRexport HADOOP_PREFIX=/mnt/oge/hadoop-2.7.3/source ~/.bashrc
# 进入hadoop/bincd /mnt/oge/hadoop-2.7.3/bin# 格式化./hadoop namenode -format
# 进入hadoop/sbincd /mnt/oge/hadoop-2.7.3/sbin# 启动./start-all.sh

执行命令后,输入yes,可能会有些慢,耐心等待

[root@hbase0 sbin]# jps35504 NameNode35640 DataNode36299 NodeManager36397 Jps35981 ResourceManager35837 SecondaryNameNode

浏览器打开 hbase0_ip:8088 即可看到 hadoop的 YARN ResourceManager 管理界面

浏览器打开 hbase0_ip:50070 即可看到 hadoop的 hdfs 管理界面

5 部署zookeeper(奇数个节点)

dataDir=/mnt/oge/zookeeper-3.4.13/dataserver.1=hbase0:2888:3888server.2=hbase1:2888:3888server.3=hbase2:2888:3888
mkdir /mnt/oge/zookeeper-3.4.13/datacd /mnt/oge/zookeeper-3.4.13/dataecho 1 >> myid

在第1台机器里面填写的内容: 1 在第2台机器里面填写的内容: 2 在第3台机器里面填写的内容: 3

这个我们后面把 zookeeper 目录复制到其他机器上时再统一修改

scp -r /mnt/oge/zookeeper-3.4.13 root@其他节点:/mnt/oge
vim ~/.bashrc# zookeeperexport ZOOKEEPER_HOME=/mnt/oge/zookeeper-3.4.13export PATH=$ZOOKEEPER_HOME/bin:$PATHsource ~/.bashrc

分别在每台机器上运行zkServer.sh start命令

需要关闭防火墙

cd /mnt/oge/zookeeper-3.4.13/bin./zkServer.sh start

6 部署Hbase

export JAVA_HOME=/mnt/oge/jdk
<configuration><property>    <name>hbase.rootdir</name>    <value>hdfs://hbase0:9000/hbase</value></property><property>    <name>hbase.cluster.distributed</name>    <value>true</value></property><property>    <name>hbase.zookeeper.quorum</name>    <value>hbase0,hbase1,hbase2</value></property><property>    <name>hbase.zookeeper.property.dataDir</name>    <value>/mnt/oge/zookeeper-3.4.13/data</value></property><property>    <name>hbase.master</name>    <value>hdfs://hbase0:60000</value></property><property>    <name>hbase.client.keyvalue.maxsize</name>    <value>514672800</value></property><property>   <name>hbase.server.keyvalue.maxsize</name>   <value>544572800</value></property></configuration>
hbase0hbase1hbase2hbase3
scp -r /mnt/oge/hbase-1.4.13 root@其他节点:/mnt/ogescp -r /mnt/oge/hbase-1.4.13 root@hbase1:/mnt/oge
vim ~/.bashrc# hbaseexport HBASE_HOME=/mnt/oge/hbase-1.4.13export PATH=$HBASE_HOME/bin:$PATHsource ~/.bashrc
cd /mnt/oge/hbase-1.4.13/bin./start-hbase.sh