链接:https://pan.baidu.com/s/1wzbCiDxP7H5G_llwjSS3Rw?pwd=wgal
提取码:wgal
zookeeper-3.4.6.tar
注意:上传文件位置为 /export/server目录
cd /export/server
tar xvf /export/server/zookeeper-3.4.6.tar.gz
mv zookeeper-3.4.6 zookeeper
echo 'export ZOOKEEPER_HOME=/export/server/zookeeper' >> /etc/profile
echo 'export PATH=$PATH:$ZOOKEEPER_HOME/bin' >> /etc/profile
# 刷新环境变量
source /etc/profile
mkdir -p /export/data/zkdata
echo 1 > /export/data/zkdata/myid
# 注意:!!!!!!!!!
# 注意:!!!!!!!!!
# 注意:!!!!!!!!!
# 搭建集群时,还需要在创建完node2虚拟机上执行
echo 2 > /export/data/zkdata/myid
# 搭建集群时,还需要在创建完node3虚拟机上执行
echo 3 > /export/data/zkdata/myid
# 将环境变量重命名为zoo.cfg
mv /export/server/zookeeper/conf/zoo_sample.cfg /export/server/zookeeper/conf/zoo.cfg
# 替换其中的内容
sed -i "s#^dataDir.*#dataDir=/export/data/zkdata#" /export/server/zookeeper/conf/zoo.cfg
# 将host和port信息写入配置文件中
echo 'server.1=192.168.88.161:2888:3888' >> /export/server/zookeeper/conf/zoo.cfg
echo 'server.2=192.168.88.162:2888:3888' >> /export/server/zookeeper/conf/zoo.cfg
echo 'server.3=192.168.88.163:2888:3888' >> /export/server/zookeeper/conf/zoo.cfg
# 启动
zkServer.sh start
# 停止
zkServer.sh stop
# 查看状态
zkServer.sh status
## 注意启动时需要三台机器都执行启动服务
jps
正常启动会有: QuorumPeerMain 服务
在node1的机器上配置完成后,需要将node1中的zookeeper目录复制到node2和node3的对应目录下,同时需要将基础环境配置步骤在node2和node3上重新执行一遍
可以使用分发脚本进行数据分发,分发脚本编写和使用规则参考另一篇文章
https://blog.csdn.net/m0_49620121/article/details/135432995?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22135432995%22%2C%22source%22%3A%22m0_49620121%22%7D
链接:https://pan.baidu.com/s/1Wd4WIOmDxIyJ-4nfA4mtvA?pwd=4ddz
提取码:4ddz
上传目录为: /export/server
cd /export/server
tar zxvf /export/server/hadoop-3.3.0-Centos7-64-with-snappy.tar.gz
echo 'export HADOOP_HOME=/export/server/hadoop-3.3.0' >> /etc/profile
echo 'export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin' >> /etc/profile
# 刷新环境变量
source /etc/profile
进入配置文件目录下
cd /export/server/hadoop-3.3.0/etc/hadoop
export JAVA_HOME=/export/server/jdk1.8.0_241
#文件最后添加
export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root
<configuration>
<property>
<name>fs.defaultFSname>
<value>hdfs://node1:8020value>
property>
<property>
<name>hadoop.tmp.dirname>
<value>/export/data/hadoop-3.3.0value>
property>
<property>
<name>hadoop.http.staticuser.username>
<value>rootvalue>
property>
<property>
<name>hadoop.proxyuser.root.hostsname>
<value>*value>
property>
<property>
<name>hadoop.proxyuser.root.groupsname>
<value>*value>
property>
configuration>
<configuration>
<property>
<name>dfs.namenode.secondary.http-addressname>
<value>node2:9868value>
property>
<property>
<name>dfs.replicationname>
<value>2value>
property>
configuration>
<configuration>
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
<property>
<name>mapreduce.jobhistory.addressname>
<value>node1:10020value>
property>
<property>
<name>mapreduce.jobhistory.webapp.addressname>
<value>node1:19888value>
property>
<property>
<name>yarn.app.mapreduce.am.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
<property>
<name>mapreduce.map.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
<property>
<name>mapreduce.reduce.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
configuration>
<configuration>
<property>
<name>yarn.resourcemanager.hostnamename>
<value>node1value>
property>
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
<property>
<name>yarn.nodemanager.pmem-check-enabledname>
<value>falsevalue>
property>
<property>
<name>yarn.nodemanager.vmem-check-enabledname>
<value>falsevalue>
property>
<property>
<name>yarn.log-aggregation-enablename>
<value>truevalue>
property>
<property>
<name>yarn.log.server.urlname>
<value>http://node1:19888/jobhistory/logsvalue>
property>
<property>
<name>yarn.log-aggregation.retain-secondsname>
<value>604800value>
property>
configuration>
192.168.88.161
192.168.88.162
192.168.88.163
需要将node1中的Hadoop文件复制到node2和node3的对应位置
# 使用数据分发脚本分发hadoop-3.3.0目录
xsync /export/server/hadoop-3.3.0
# 使用数据分发脚本分发环境变量文件
xsync /etc/profile
注意: 初始化操作必须在node1中执行
hdfs namenode -format
# 整体服务启动/关闭服务
start-all.sh
# 整体服务服务关闭
stop-all.sh
# 启动JobHistoryServer
mapred --daemon historyserver
# 单独启动hdfs
start-dfs.sh
# 单独关闭hdfs
stop-dfs.sh
# 单独启动yarn
start-yarn.sh
# 单独关闭yarn
stop-yarn.sh
# 单独启动hdfs服务的单个组件
hdfs --daemon start namenode/datanode/secondarynamenode
# 单独关闭hdfs服务的单个组件
hdfs --daemon stop namenode/datanode/secondarynamenode
# 单独启动yarn服务的单个组件
yarn --daemon start resourcemanager/nodemanager
# 单独关闭yarn服务的单个组件
yarn --daemon stop resourcemanager/nodemanager
如果想在Windows电脑上使用web登陆9870的HDFS管理界面,需要配置本地映射
位于Windows的C:\Windows\System32\drivers\etc\hosts
192.168.88.161 node1.onepandas.cn node1
192.168.88.162 node2.onepandas.cn node2
192.168.88.163 node3.onepandas.cn node3
hdfs结构管理界面url:http://192.168.88.161:9870/node1:9870
yarn Web UI管理界面:http://192.168.88.161:8088/node1:8088
链接:https://pan.baidu.com/s/1E83wjgzrc4AUKrOEUk0xIA?pwd=t8z5
提取码:t8z5
上传位置: /export/server
cd /export/server/
tar zxvf /export/server/apache-hive-3.1.2-bin.tar.gz
mv apache-hive-3.1.2-bin/ ./hive3.1.2
rm -rf /export/server/hive3.1.2/lib/guava-19.0.jar
cp /export/server/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar /export/server/hive3.1.2/lib/
echo 'export HIVE_HOME=/export/server/hive3.1.2' >> /etc/profile
echo 'export PATH=$PATH:$HIVE_HOME/bin:$HIVE_HOME/sbin' >> /etc/profile
# 刷新环境变量
source /etc/profile
# 切换到配置文件目录
cd /export/server/hive3.1.2/conf
# 拷贝配置文件并重命名
cp hive-env.sh.template ./hive-env.sh
# 将配置信息写入配置文件
echo 'export HADOOP_HOME=/export/server/hadoop-3.3.0' >> /export/server/hive3.1.2/conf/hive-env.sh
echo 'export HIVE_CONF_DIR=/export/server/hive3.1.2/conf' >> /export/server/hive3.1.2/conf/hive-env.sh
echo 'export HIVE_AUX_JARS_PATH=/export/server/hive3.1.2/lib' >> /export/server/hive3.1.2/conf/hive-env.sh
<configuration>
<!-- 存储元数据mysql相关配置 -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node1:3306/hive3?createDatabaseIfNotExist=true&useSSL=false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<!-- H2S运行绑定host -->
<property>
<name>hive.server2.thrift.bind.host</name>
<value>node1</value>
</property>
<!-- 远程模式部署metastore metastore地址 -->
<property>
<name>hive.metastore.uris</name>
<value>thrift://node1:9083</value>
</property>
<!-- 关闭元数据存储授权 -->
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
</configuration>
注意:驱动上传到
/export/server/apache-hive-3.1.2-bin/lib/
目录下
链接:https://pan.baidu.com/s/1w3L9jRO_moT7gmUjAAyhpg?pwd=t0wo
提取码:t0wo
mysql-connector-java-5.1.40.jar
schematool -initSchema -dbType mysql -verbos
#初始化成功会在mysql中创建74张表
hadoop fs -mkdir /tmp
hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -chmod g+w /tmp
hadoop fs -chmod g+w /user/hive/warehouse
# 启动metastore服务
#前台启动 关闭ctrl+c
#前台启动开启debug日志
/export/server/hive3.1.2/bin/hive --service metastore --hiveconf hive.root.logger=DEBUG,console
#后台启动 进程挂起 关闭使用jps+ kill -9(先使用jps获取runjar的id在kill +9 id号)
nohup /export/server/hive3.1.2/bin/hive --service metastore &
# 启动hiveserver2服务
nohup /export/server/hive/bin/hive --service hiveserver2 &
#注意 启动hiveserver2需要一定的时间 不要启动之后立即beeline连接 可能连接不上
先用lsof -i:10000 查看hiveserver2有没有启动
启动beeline
输入:!connect jdbc:hive2://node1:10000
到此 Zookeeper/Hadoop/Hive 基础环境搭建完毕
有问题欢迎指出!!!