k8s 部署 hive

7 篇文章 0 订阅

镜像:docker pull bde2020/hive-metastore-postgresql:2.3.0
docker pull bde2020/hive:latest

hive-mysql-dockerfile
# cat hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--><configuration>
<property><name>hive.metastore.uris</name><value>thrift://hive-metastore-svc:9083</value></property>
<property><name>datanucleus.autoCreateSchema</name><value>false</value></property>
<property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://mysql-svc:3306/metastore</value></property>
<property><name>javax.jdo.option.ConnectionDriverName</name><value>com.mysql.jdbc.Driver</value></property>
<property><name>javax.jdo.option.ConnectionPassword</name><value>123456</value></property>
<property><name>javax.jdo.option.ConnectionUserName</name><value>root</value></property>
</configuration>
FROM bde2020/hive:2.3.2-postgresql-metastore

COPY mysql-connector-java-5.1.47.jar /opt/hive/libs/
COPY hive-site.xml /opt/hive/conf

mysql-hive-metastore.yaml
apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    app: hive-mysql-metastore
  name: hive-mysql-metastore
spec:
  replicas: 1
  selector:
    app: hive-mysql-metastore
  template:
    metadata:
      labels:
        app: hive-mysql-metastore
    spec:
      containers:
        - name: hive-mysql-metastore
          image: docker-registry-node:5000/mysql:5.7.37
          ports:
          - containerPort: 3306
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "123456"
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: mysql-svc
  name: mysql-svc
spec:
  type: NodePort
  ports:
  - port: 3306
    targetPort: 3306
    nodePort: 32306
    name: mysql-port
  selector:
    app: hive-mysql-metastore
hive-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: hive-config
data:
  HIVE_SITE_CONF_javax_jdo_option_ConnectionURL: "jdbc:mysql://mysql-svc:3306/metastore"
  HIVE_SITE_CONF_javax_jdo_option_ConnectionDriverName: "com.mysql.jdbc.Driver"
  HIVE_SITE_CONF_javax_jdo_option_ConnectionUserName: "root"
  HIVE_SITE_CONF_javax_jdo_option_ConnectionPassword: "123456"
  HIVE_SITE_CONF_datanucleus_autoCreateSchema: "false"
  HIVE_SITE_CONF_hive_metastore_uris: "thrift://hive-metastore-svc:9083"
  HDFS_CONF_dfs_namenode_datanode_registration_ip___hostname___check: "false"
  
  CORE_CONF_fs_defaultFS: "hdfs://hadoop-hdfs-master:9000"
  CORE_CONF_hadoop_http_staticuser_user: "root"
  CORE_CONF_hadoop_proxyuser_hue_hosts: "*"
  CORE_CONF_hadoop_proxyuser_hue_groups: "*"
  
  HDFS_CONF_dfs_webhdfs_enabled: "true"
  HDFS_CONF_dfs_permissions_enabled: "false"
  
  YARN_CONF_yarn_log___aggregation___enable: "true"
  YARN_CONF_yarn_resourcemanager_recovery_enabled: "true"
  YARN_CONF_yarn_resourcemanager_store_class: "org.apache.hadoop.yarn.server.resourcemanager.recovery.FileSystemRMStateStore"
  YARN_CONF_yarn_resourcemanager_fs_state___store_uri: /rmstate
  YARN_CONF_yarn_nodemanager_remote___app___log___dir: /app-logs
  YARN_CONF_yarn_log_server_url: "http://historyserver:8188/applicationhistory/logs/"
  YARN_CONF_yarn_timeline___service_enabled: "true"
  YARN_CONF_yarn_timeline___service_generic___application___history_enabled: "true"
  YARN_CONF_yarn_resourcemanager_system___metrics___publisher_enabled: "true"
  YARN_CONF_yarn_resourcemanager_hostname: "hadoop-yarn-master"
  YARN_CONF_yarn_timeline___service_hostname: "historyserver"
  YARN_CONF_yarn_resourcemanager_address: "hadoop-yarn-master:8032"
  YARN_CONF_yarn_resourcemanager_scheduler_address: "hadoop-yarn-master:8030"
  YARN_CONF_yarn_resourcemanager_resource__tracker_address: "hadoop-yarn-master:8031"


hive-metastore-statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: hive-metastore
  name: hive-metastore  
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hive-metastore
  serviceName: "hive-metastore"  
  template:
    metadata:
      labels:
        app: hive-metastore
    spec:
      containers:
      - image: docker-registry-node:5000/hive-mysql-metastore:v1
        name: hive-metastore
        ports:
            - containerPort: 9083
        ### 启动后执行
        lifecycle:
          postStart:
            exec:
              command: ["/bin/bash", "-c", "/opt/hive/bin/hive --service metastore &"]
        envFrom:
        - configMapRef:
            name: hive-config
        env:
          - name: "TZ"
            value: "Asia/Shanghai"
          - name: "SERVICE_PRECONDITION"
            value: "hadoop-hdfs-master:50070 mysql-svc:3306"
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hive-metastore
  name: hive-metastore-svc
spec:
  type: NodePort
  ports:
  - port: 9083
    targetPort: 9083
    nodePort: 31083
    name: hive-metastore-port
  selector:
    app: hive-metastore

hive-service-statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: hive-service
  name: hive-service  
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hive-service
  serviceName: "hive-service"  
  template:
    metadata:
      labels:
        app: hive-service
    spec:
      containers:
      - image: docker-registry-node:5000/hive:latest
        name: hive-service
        envFrom:
        - configMapRef:
            name: hive-config
        env:
          - name: "TZ"
            value: "Asia/Shanghai"
          - name: "SERVICE_PRECONDITION"
            value: "hive-metastore-svc:9083"
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hive-service
  name: hive-service-svc
spec:
  type: NodePort
  ports:
  - port: 10000
    nodePort: 32000
    name: service-port
  selector:
    app: hive-service

初始化元数据

注意:hive-metastore pod 不自动初始化元数据。创建mysql元数据库metastore,再执行 schematool -dbType mysql -initSchema

root@hive-metastore-0:/opt/hive/bin# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:mysql://mysql-svc:3306/metastore
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
Tue May 24 15:55:07 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException : Unknown database 'metastore'
SQL Error code: 1049
Use --verbose for detailed stacktrace.
*** schemaTool failed ***
root@hive-metastore-0:/opt/hive/bin# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:mysql://mysql-svc:3306/metastore
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
Tue May 24 15:55:53 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Tue May 24 15:55:53 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Initialization script completed
Tue May 24 15:55:55 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
schemaTool completed

在这里插入图片描述

# kubectl  exec -it hive-server-0 -- hive
Error from server (NotFound): pods "hive-server-0" not found
-bash-4.2# kubectl  exec -it hive-service-0 -- hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in file:/opt/hive/conf/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> show databases;
OK
default
Time taken: 1.02 seconds, Fetched: 1 row(s)
hive>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你好!要在 Kubernetes 上部署 Hadoop,您可以按照以下步骤进行操作: 1. 首先,您需要为 Kubernetes 集群配置存储(例如,使用 Persistent Volumes)和网络(例如,使用 Service 或 Ingress)。这将确保在 Hadoop 集群中的不同组件之间进行通信并持久存储数据。 2. 接下来,您需要创建 Hadoop 的配置文件。这包括 core-site.xml、hdfs-site.xml、mapred-site.xml 和 yarn-site.xml 等文件。这些文件将指定 Hadoop 集群的各种属性和参数。 3. 使用 Kubernetes 的 ConfigMap 和 Secret,将 Hadoop 的配置文件和敏感信息(如认证密钥)转化为 Kubernetes 对象。这样,您的配置将与集群一起管理,并且可以轻松更新和部署。 4. 创建 Hadoop 的 Master 组件。这包括 HDFS 的 NameNode、YARN 的 ResourceManager 和 MapReduce 的 JobHistoryServer。您可以使用 Kubernetes 的 Deployment 或 StatefulSet 来创建这些组件,并使用适当的资源请求和限制来配置它们。 5. 创建 Hadoop 的 Worker 组件。这包括 HDFS 的 DataNode、YARN 的 NodeManager 和 MapReduce 的 TaskTracker。您可以根据需求扩展这些组件,并使用适当的资源请求和限制来配置它们。 6. 部署其他 Hadoop 组件,如Hive、Spark或其他工具,以便与 Hadoop 集群进行交互和数据处理。 这只是一个简单的概述,您还需要了解主从节点配置、数据复制和故障恢复等更多细节。此外,根据您的具体需求,还可能需要进行一些其他的配置和调整。 希望这些信息对您有所帮助!如有任何进一步的问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值