前景提要 部署安装 Hive3.1.2 数据仓库、Zookeeper3.5.7
系统环境 三台 Centos7 系统的主机
一台 master 节点,两台 slave 节点,分别为 slave1、slave2
Hadoop 完全分布式集群
所需安装包 apache-hive-3.1.2-bin.tar.gz
1 https ://downloads.apache.org/hive/hive-3 .1 .2 /apache-hive-3 .1 .2 -bin.tar.gz
apache-zookeeper-3.5.7-bin.tar.gz
1 https ://archive.apache.org/dist/zookeeper/zookeeper-3 .5 .7 /apache-zookeeper-3 .5 .7 -bin.tar.gz
所需 jar 包 mysql-connector-java-8.0.28.jar
1 https ://repo1.maven.org/maven2/mysql/mysql-connector-java/8 .0 .28 /mysql-connector-java-8 .0 .28 .jar
1、安装 Hive 1)解压 Hive 压缩包 1 2 3 4 5 6 7 8 9 10 11 12 13 [root@master ~]cd /tdsgpo [root@master tdsgpo]sudo tar -zxvf apache-hive-3.1.2-bin.tar.gz [root@master tdsgpo]sudo mv apache-hive-3.1.2-bin /tdsgpo/hive-3.1.2 [root@master tdsgpo]sudo chmod -R 777 /tdsgpo/hive-3.1.2 [root@master tdsgpo]hdfs dfs -mkdir /tmp [root@master tdsgpo]hdfs dfs -mkdir -p /user/hive/warehouse [root@master tdsgpo]hdfs dfs -chmod g+w /tmp [root@master tdsgpo]hdfs dfs -chmod g+w /user/hive/warehouse [root@master tdsgpo]sudo cp /tdsgpo/mysql-connector-java-8.0.28.jar /tdsgpo/hive-3.1.2/lib/
2)配置 hive-site.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [root@master tdsgpo]cd /tdsgpo/hive-3.1.2/conf/ [root@master tdsgpo]vim hive-site.xml <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true </value> <description>JDBC connect string for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>123456</value> <description>password to use against metastore database</description> </property> </configuration>
3)配置 Hive 与 MySQL 链接 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [root@master tdsgpo]sudo su - mysql -c '/tdsgpo/mysql-8.0.26/bin/mysqld_safe --user=mysql &' [root@master tdsgpo]mysql -uroot -p123456 mysql > create database hive; mysql > create user 'hive' @'%' identified by '123456' ; mysql > GRANT ALL PRIVILEGES on *.* to 'hive' @'%' ; mysql > flush privileges; mysql > exit [root@master tdsgpo]rm -rf /tdsgpo/hive-3.1.2/lib/guava-19.0.jar [root@master tdsgpo]cp /tdsgpo/hadoop-3.2.1/share/hadoop/common/lib/guava-27.0-jre.jar /tdsgpo/hive-3.1.2/lib/ [root@master tdsgpo]sudo su - root -c '/tdsgpo/hive-3.1.2/bin/schematool -initSchema -dbType mysql' [root@master tdsgpo]mysql -uroot -p123456 [root@master tdsgpo]use hive; [root@master tdsgpo]show tables; AUX_TABLE BUCKETING_CCLS CDS CCLUMNS_VS CCMPACTICN_QUEUE ....
4)启动 Hive 命令 1 2 [root@master tdsgpo]cd /softwares/hive-3.1.2 [root@master tdsgpo]bin/hive
2、安装Zookeeper 1)解压文件 1 2 3 4 5 6 7 8 9 10 11 12 [root@master ~]cd /tdsgpo [root@master tdsgpo]tar -xzvf apache-zookeeper-3.5.7-bin.tar.gz [root@master tdsgpo]mv apache-zookeeper-3.5.7-bin /tdsgpo/zookeeper3.5.7 [root@master tdsgpo]mkdir /tdsgpo/zookeeper3.5.7/data [root@master tdsgpo]mkdir /tdsgpo/zookeeper3.5.7/dataLog [root@master data]cd /tdsgpo/zookeeper3.5.7/data [root@master data]vim myid 1
2)修改配置文件 zoo.cfg 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [root@master data]cd /tdsgpo/zookeeper3.5.7/conf [root@master conf]cp zoo_sample.cfg zoo.cfg [root@master conf]vim zoo.cfg admin.commandURL=/commands autopurge.purgeInterval=24 quorum.cnxn.threads.size=20 admin.serverPort=18080 admin.idleTimeout=30000 quorum.auth.enableSasl=false autopurge.snapRetainCount=30 admin.enableServer=false dataDir=/tdsgpo/zookeeper3.5.7/data dataLogDir=/tdsgpo/zookeeper3.5.7/dataLog server.1=master:2888:3888 server.2=slave1:2888:3888 server.3=slave2:2888:3888
3)配置 zookeeper-env.sh 1 2 3 4 5 6 [root@master conf]vim zookeeper-env.sh ZOO_LOG_DIR=/tdsgpo/zookeeper-3.5.7/logs ZOO_LOG4J_PROP=/tdsgpo/zookeeper-3.5.7/logs ZK_SERVER_HEAP=512 ZK_CLIENT_HEAP=256
4)分发 Zookeeper 文件夹到其他两台从节点的 /tdsgpo 文件夹 1 2 3 4 5 [root@master conf]scp -r /tdsgpo/zookeeper-3.5.7 slave1:/tdsgpo/ [root@master conf]scp -r /tdsgpo/zookeeper-3.5.7 slave2:/tdsgpo/chmod 777 -R /tdsgpo/zookeeper-3.5.7
5)启动 Zookeeper 集群 1 2 3 4 5 6 [root@master ~]cd /tdsgpo/zookeeper-3.5.7/bin [root@master bin]./zkServer.sh start [root@master bin]./zkServer.sh status
下篇文章我们讲解在 Hadoop 完全分布式集群里面搭建 IDEA 代码编辑器以及集成 Spark、Flink。