hadoop2.8.4+hbase2.1.0+zookeeper3.4.12+scala2.12.6+spark-2.3.1集群配置,按流程配置保证能用

要点(配置流程以及文件下载)

1、 hbase和hadoop要选择能够支持的匹配版本,否则会有很多坑。可到官网查看,目前选择hadoop2.8.4、hbase2.1.0(jdk1.8+)、zookeeper3.4.12。
2、 关闭防火墙,否则也是无尽的坑,iptables千万不要yum –y remove,会关联删除很多东西。

Step 1 Centos创建系统用户

vmware配置三台centos7,安装流程就不赘述了。

分别创建用户hadoop,密码123456
adduser hadoop
passwd hadoop
123456
关闭防火墙,centos7防火墙是firewalld
systemctl stop firewalld.service 停止firewalld
systemctl disable firewalld.service 禁止firewall开机启动
firewall-cmd –state 查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

Step 2 修改hosts配置文件

192.168.199.250 master
192.168.199.251 slave1
192.168.199.252 slave2

Step 3 安装并配置JDK

jdk配置,主从机分别执行
vim /etc/profile.d/jdk-1.8.sh

export JAVA_HOME=/opt/java/jdk1.8.0_181
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

source /etc/profile

Step 4 主从互信登录

无密码登录,主从机分别执行
ssh-keygen -t rsa -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
测试本机无密码登录
ssh localhost

无密码登录,主机无密码登录从机
cat ~/.ssh/id_rsa.pub | ssh hadoop@slave1 ‘cat - >> ~/.ssh/authorized_keys’
cat ~/.ssh/id_rsa.pub | ssh hadoop@slave2 ‘cat - >> ~/.ssh/authorized_keys’
测试主机无密码登录从机
ssh hadoop@slave1
exit
ssh hadoop@slave2
exit

无密码登录,从机无密码登录主机
cat ~/.ssh/id_rsa.pub | ssh hadoop@master ‘cat - >> ~/.ssh/authorized_keys’
测试从机无密码登录主机
ssh hadoop@master
exit

Step 5 hadoop集群配置

下载并解压hadoop、hbase、zookeeper 解压到/home/hadoop
Hadoop集群安装配置(只配置主机,复制到从机),修改配置文件:hadoop-env.sh、core-site.xml、hdfs-site.xml、mapred-site.xml、yarn-site.xml、slaves,下载附件
复制到从机
scp -r /home/hadoop/hadoop slave1:/home/hadoop
scp -r /home/hadoop/hadoop slave2:/home/hadoop

主从机分别执行hadoop环境变量配置
vim /etc/profile.d/hadoop.sh

export HADOOP_HOME=/home/hadoop/hadoop
export PATH=$HADOOP_HOME/bin:$PATH
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/Hadoop

source /etc/profile

从主机启动hadoop集群
格式化namenode,仅第一次启动服务执行
~/hadoop/bin/hadoop namenode -format clusterName
测试启动hadoop
sbin/start-all.sh
查看进程
jps
4866 NodeManager
4370 NameNode
4899 Jps
4648 SecondaryNameNode
4779 ResourceManager
4460 DataNode

Step 6 Zookeeper配置

ZooKeeper安装配置(只配置主机,复制到从机)
cd ~/zookeeper/conf
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
dataDir=/home/hadoop/zookeeper/data
server.1=192.168.199.250:2888:3888
server.2=192.168.199.251:2888:3888
server.3=192.168.199.252:2888:3888

复制到从机
scp -r /home/hadoop/zookeeper slave1:/home/hadoop
scp -r /home/hadoop/zookeeper slave2:/home/hadoop
主从机分别新建myid文件,注意这个文件每个服务器上不一样,master写入1,slave1写入2,slave2写入3,复制后要修改
mkdir /home/hadoop/zookeeper/data
echo “1” > /home/hadoop/zookeeper/data/myid

主从机zookeeper环境变量配置
vim /etc/profile.d/zookeeper.sh

export ZOOKEEPER_HOME=/home/hadoop/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

source /etc/profile

禁用selinux
vim /etc/selinux/config
SELINUX=disabled

Step 7 HBase集群安装配置

HBase集群安装配置文件:hbase-env.sh、hbase-site.xml、regionservers,下载附件
复制到从机
scp -r /home/hadoop/hbase slave1:/home/hadoop
scp -r /home/hadoop/hbase slave2:/home/hadoop
主机hbase环境变量配置
vim /etc/profile.d/hbase.sh

export HBASE_HOME=/home/hadoop/hbase
export PATH=$PATH:$HBASE_HOME/bin

source /etc/profile
可能会出现java.lang.NoClassDefFoundError: org/apache/htrace/SamplerBuilder的错误,解决方法:复制如下jar
cp ~/hbase/lib/htrace-core-3.1.0-incubating.jar ~/hbase/lib

step 8 scala环境配置

下载安装scala,操作流程类似JDK,主从机分别配置环境
vim /etc/profile.d/scala.sh

export SCALA_HOME=/opt/scala/scala-2.12.6
export PATH=.:${JAVA_HOME}/bin:${SCALA_HOME}/bin:$PATH

source /etc/profile

step 9 spark集群配置

操作流程类似hadoop,下载并解压spark
vim /etc/profile.d/spark.sh

export  SPARK_HOME=/home/hadoop/spark
export PATH=.:${JAVA_HOME}/bin:${SCALA_HOME}/bin:${SPARK_HOME}/bin:$PATH

source /etc/profile

~spark/conf/spark-env.sh配置,没有文件复制spark-env.sh.template

export SCALA_HOME=/opt/scala/scala-2.12.6
export JAVA_HOME=/opt/java/jdk1.8.0_181
export HADOOP_HOME=/home/hadoop/hadoop
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop  
export SPARK_HOME=/home/hadoop/spark
export SPARK_MASTER_IP=master
export SPARK_EXECUTOR_MEMORY=4G

~spark/conf/slaves配置,没有文件复制slaves.template

slave1
slave2

配置复制到从机
scp -r /home/hadoop/spark slave1:/home/hadoop
scp -r /home/hadoop/spark slave2:/home/hadoop

step 10 集群启动执行

每个服务器均需执行
~/zookeeper/bin/zkServer.sh start
仅master主机执行
~/hadoop/sbin/start-all.sh
~/hbase/bin/start-hbase.sh
~/spark/sbin/start-all.sh
停止服务

~/spark/sbin/stop-all.sh
~/hbase/bin/stop-hbase.sh
~/hadoop/sbin/stop-all.sh
~/zookeeper/bin/zkServer.sh stop

测试
hbase/bin/hbase shell
list
status

web ui 访问
Hadoop http://192.168.199.250:8088/
Spark http://192.168.199.250:8080/
Hbase http://192.168.199.250:16010/

你可能感兴趣的:(JAVA技术,其他,架构设计)