Kubernetes运行hive(五)

基于Kubernetes部署Spark:spark on kubernetes spark是一种基于内存的快速、通用、可扩展的的数据分析计算引擎。基于kubernetes的spark搭建 阅读详情

目的:

hive 可以基于hadoop mr或者Spark进行高层次的数据处理

前提:

安装之前先要保证hadoop的目录可以为root用户读写:

hadoop fs -chown root:root /

 

1: 构建镜像

下载依赖

mkdir -p hive/image-build

cd hive/image-build

wget http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz

wget http://mirror.bit.edu.cn/apache/hive/hive-2.3.3/apache-hive-2.3.3-bin.tar.gz

download mysql-connector-java-5.1.47.tar.gz

tar -zxvf mysql-connector-java-5.1.47.tar.gz

wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.9.1/hadoop-2.9.1.tar.gz

构建hive镜像

Dockerfile

FROM centos:7.5.1804

ADD jdk-8u181-linux-x64.tar.gz /opt

ADD hadoop-2.9.1.tar.gz /opt

ADD apache-hive-3.0.0-bin.tar.gz /opt

RUN yum install -y which && mv /opt/apache-hive-3.0.0-bin /opt/apache-hive-3.0.0

ADD mysql-connector-java-5.1.47.jar /opt/apache-hive-3.0.0/lib

ENV JAVA_HOME /opt/jdk1.8.0_181

ENV HADOOP_HOME /opt/hadoop-2.9.1

ENV HADOOP_CONF_DIR /opt/hadoop-2.9.1/etc/hadoop

ENV HIVE_HOME /opt/apache-hive-3.0.0

ENV PATH $JAVA_HOME/bin:$PATH

 

构建

docker build -t hive .

docker tag hive xxx.xxx.xxx.xxx:5000/hive

docker push xxx.xxx.xxx.xxx:5000/hive

 

2: 构建DBtool镜像

安装gradle 并编译DB tool

git clone https://github.com/chenlein/database-tools.git

cd database-tools/

unzip gradle-4.10.2-bin.zip

mkdir /opt/gradle

mv gradle-4.10.2 /opt/gradle/

edit build.gradle to remove dm driver

"compile group: 'dm', name: 'Dm7JdbcDriver', version: '7.1', classifier: 'jdk17-20170808'"

add in /etc/profile

export PATH=.:/opt/gradle/gradle-4.10.2/bin:$PATH

gradle --version

gradle build

ls build/distributions/database-tools-1.0-SNAPSHOT.tar

cp build/distributions/database-tools-1.0-SNAPSHOT.tar ./

DockerFile

FROM java:8
CMD ["mkdir", "-p", "/root/db_tools"]
WORKDIR /root/db_tools
ADD database-tools-1.0-SNAPSHOT.tar .
RUN ["chmod", "+x", "./database-tools-1.0-SNAPSHOT/bin/database-tools"]
CMD ["./database-tools-1.0-SNAPSHOT/bin/database-tools"]

编译镜像

docker build -t database-tools:1.0-SNAPSHOT .

docker tag database-tools:1.0-SNAPSHOT 172.2.2.11:5000/database-tools:1.0-SNAPSHOT

docker push 172.2.2.11:5000/database-tools:1.0-SNAPSHOT

 

3: 部署hive

1)部署local volume 用于hive部署的PVC

local-volumes.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: hive-data-1
  labels:
    type: local
    app: hive
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /home/hive/data1
  persistentVolumeReclaimPolicy: Recycle

2)部署mysql服务

mysql.yaml

apiVersion: v1
kind: Secret
metadata:
  name: hive-metadata-mysql-secret
  labels:
    app: hive-metadata-mysql
type: Opaque
data:
  mysql-root-password: RGFtZW5nQDc3Nw==
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hive-metadata-mysql
  name: hive-metadata-mysql
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: hive-metadata-mysql
  template:
    metadata:
      labels:
        app: hive-metadata-mysql
    spec:
      initContainers:
        - name: remove-lost-found
          image: busybox:1.29.2
          imagePullPolicy: IfNotPresent
          command: ["rm", "-rf", "/var/lib/mysql/lost+found"]
          volumeMounts:
            - name: data
              mountPath: /var/lib/mysql
      containers:
        - name: mysql
          image: mysql:5.7
          volumeMounts:
            - name: data
              mountPath: /var/lib/mysql
          ports:
            - containerPort: 3306
              protocol: TCP
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: hive-metadata-mysql-secret
                  key: mysql-root-password
      volumes:
        - name: data
          emptyDir: {}
---
kind: Service
apiVersion: v1
metadata:
  labels:
    app: hive-metadata-mysql
  name: hive-metadata-mysql-service
spec:
  ports:
    - name: tcp
      port: 3306
      targetPort: 3306
  selector:
    app: hive-metadata-mysql
  type: NodePort

3)部署hive配置

hive-config.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: hive-custom-config-cm
  labels:
    app: hive
data:
  bootstrap.sh: |-
    #!/bin/bash
    set -x
    cd /root/bootstrap
    # Apply custom config file context
    for cfg in ./*; do
      if [[ ! "$cfg" =~ bootstrap.sh ]]; then
        echo $cfg
        cat $cfg
        cat $cfg > $HIVE_HOME/conf/${cfg##*/}
      fi
    done
    # Replace hive metadata password
    sed -i 's/${HIVE_METADATA_PASSWORD}/'$HIVE_METADATA_PASSWORD'/g' `grep '${HIVE_METADATA_PASSWORD}' -rl $HIVE_HOME/conf`
    # initSchema
    echo "step 1"
    #if [[ ! -e $HADOOP_CONF_DIR/hive-metastore-initialization.out ]]; then
      echo "step 2"
      $HADOOP_HOME/bin/hadoop fs -mkdir -p hdfs://172.2.2.11:9000/tmp
      $HADOOP_HOME/bin/hadoop fs -mkdir -p hdfs://172.2.2.11:9000/user/hive/warehouse
      $HADOOP_HOME/bin/hadoop fs -chmod g+w hdfs://172.2.2.11:9000/tmp
      $HADOOP_HOME/bin/hadoop fs -chmod g+w hdfs://172.2.2.11:9000/user/hive/warehouse
      $HIVE_HOME/bin/schematool -dbType mysql -initSchema --verbose &> $HADOOP_CONF_DIR/hive-metastore-initialization.out
    #fi
    echo "step 3"
    $HIVE_HOME/bin/hiveserver2 &
    $HIVE_HOME/bin/hive --service metastore &
    cp $HIVE_HOME/conf/hive-env.sh.template $HIVE_HOME/conf/hive-env.sh && echo "export HADOOP_CLIENT_OPTS=\"-Xmx512m -XX:MaxPermSize=1024m \$HADOOP_CLIENT_OPTS\"" >> $HIVE_HOME/conf/hive-env.sh
    # keep running
    sleep infinity

hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    <configuration>
      <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>hive</value>
      </property>
      <property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>${HIVE_METADATA_PASSWORD}</value>
      </property>
      <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://hive-metadata-mysql-service:3306/metastore?createDatabaseIfNotExist=true&useSSL=false</value>
      </property>
      <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
      </property>
      <property>
        <name>system:java.io.tmpdir</name>
        <value>/tmp</value>
      </property>
      <property>
        <name>system:user.name</name>
        <value>hive</value>
      </property>
      <property>
        <name>hive.server2.authentication</name>
        <value>NOSASL</value>
      </property>
      <property>
        <name>hive.metastore.schema.verification</name>
        <value>false</value>
      </property>
      <property>
        <name>datanucleus.fixedDatastore</name>
        <value>false</value>
      </property>
      <property>
        <name>datanucleus.autoCreateSchema</name>
        <value>true</value>
      </property>
      <property>
        <name>datanucleus.autoCreateTables</name>
        <value>true</value>
      </property>
      <property>
        <name>datanucleus.autoCreateColumns</name>
        <value>true</value>
      </property>
      <property>
        <name>datanucleus.schema.autoCreateAll</name>
        <value>true</value>
        <description>creates necessary schema on a startup if one doesn't exist. set this to false, after creating it once</description>
      </property>
    </configuration>

4)部署hive

hive-deploy.yaml


apiVersion: v1
kind: ConfigMap
metadata:
  name: hive-metastore-database
  labels:
    app: hive
data:
  execute.sql: |-
    -- create database
    CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    -- create user and grant authorization
    GRANT ALL ON metastore.* TO 'hive'@'%' IDENTIFIED BY '${IDENTIFIED}';
---
apiVersion: v1
kind: Secret
metadata:
  name: hive-metastore-secret
  labels:
    app: hive
type: Opaque
data:
  database-dba-password: RGFtZW5nQDc3Nw==
  database-user-password: RGFtZW5nQDc3Nw==
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hive
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: hive
  template:
    metadata:
      labels:
        app: hive
    spec:
      nodeName: k8s-node-01
      initContainers:
        - name: init-dababase
          image:  172.2.2.11:5000/database-tools:1.0-SNAPSHOT
          env:
            - name: DRIVER_NAME
              value: "com.mysql.jdbc.Driver"
            - name: URL
              value: "jdbc:mysql://hive-metadata-mysql-service:3306/mysql?useUnicode=true&characterEncoding=utf8&useSSL=false"
            - name: USERNAME
              value: "root"
            - name: PASSWORD
              valueFrom:
                secretKeyRef:
                  name: hive-metastore-secret
                  key: database-dba-password
            - name: IDENTIFIED
              valueFrom:
                secretKeyRef:
                  name: hive-metastore-secret
                  key: database-user-password
          volumeMounts:
            - name: init-dababase-volume
              mountPath: /root/db_tools/script
      containers:
        - name: hive
          image: 172.2.2.11:5000/hive
          command: ["bash", "-c", "cp /root/bootstrap/bootstrap.sh /tmp/ && chmod +x /tmp/bootstrap.sh && /tmp/bootstrap.sh"]
          ports:
            - containerPort: 10000
            - containerPort: 10002
            - containerPort: 9083
          env:
            - name: HADOOP_CONF_DIR
              value: /opt/hadoop-2.9.1/etc/hadoop
            - name: HIVE_METADATA_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: hive-metastore-secret
                  key: database-user-password
          volumeMounts:
            - name: hadoop-config-volume
              mountPath: /etc/hadoop
            - name: hive-custom-config-volume
              mountPath: /root/bootstrap
          readinessProbe:
            initialDelaySeconds: 20
            periodSeconds: 5
            tcpSocket:
              port: 10000
      volumes:
        - name: hadoop-config-volume
          persistentVolumeClaim:
            claimName: hive-data
        - name: hive-custom-config-volume
          configMap:
            name: hive-custom-config-cm
        - name: init-dababase-volume
          configMap:
            name: hive-metastore-database
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: hive-data
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Gi
---
kind: Service
apiVersion: v1
metadata:
  labels:
    app: hive
  name: hive-service
spec:
  ports:
    - port: 10000
      targetPort: 10000
      name: thrift
    - port: 10002
      targetPort: 10002
      name: webui
    - port: 9083
      targetPort: 9083
      name: metastore
  selector:
    app: hive
  type: NodePort

4: 查看部署结果

Pod

kubectl get pods | grep hive

service

kubectl get svc | grep hive-service

 

5:运行

kubectl exec -it hive-xxxxx bash

 

 

 

 

 

 

 

 

 

K8s 环境下. DataGrip连接 kerberos认证的hive hive kerberos datargip 阅读详情

相关推荐

在Kubernetes环境下使用DataGrip连接支持Kerberos认证的Hive编程

在本文中,我们讨论了如何在Kubernetes环境下使用DataGrip连接支持Kerberos认证的Hive集群,并进行Hive编程。此外,我们还提供了一个简单的Hive脚本示例,以帮助您开始使用DataGrip进行Hive编程。希望本文对您有所帮助!在本文中,我们将探讨如何在Kubernetes环境下使用DataGrip连接到一个支持Kerberos认证的Hive集群,并进行Hive编程。下载和安装JetBrains DataGrip,这是一款强大的数据库开发和管理工具,它提供了与Hive的连接支持。

BitSlinger的博客 645

【云原生】Hive on k8s 环境部署

Hive是基于Hadoop的一个数据仓库(Data Aarehouse,简称数仓、DW),可以将结构化的数据文件映射为一张数据库表,并提供类SQL查询功能。是用于存储、分析、报告的数据系统。大数据Hadoop之——数据仓库HiveHive 架构Hive 客户端架构。

匠人精神,持之以恒! 2889

数字IC时序约束实战:深入解析clock_uncertainty的设置策略与后端影响

本文深入探讨数字IC设计中clock_uncertainty的设置策略及其对后端实现的影响。通过分析时钟不确定度的组成(包括clock_skew、clock_jitter和margin),并结合实际项目经验,详细介绍了在不同设计阶段(综合、布局布线、签核)的动态调整方法。文章还提供了工程化处理参数来源、跨时钟域特殊处理以及优化时序收敛的实用技巧,帮助工程师提升数字IC设计的可靠性和性能。

weixin_29284657的博客 227

k8s中部署hive,包括客户端及服务端

推送好之后,在cube studio平台上,新建一个pipeline,使用自定义镜像模板,填写镜像为ccr.ccs.tencentyun.com/cube-studio/hadoop-hive:v3.3.2-3.1.3,debug,检查目录对不对,检查环境变量是否正确,在命令行输入hive命令,看是否能正常执行。环境变量写在/etc/profile更好,因为~/.bashrc是临时的,重启一下pod就复原了,但/etc/profile是全局的,避免一直要重复设置。登录ui界面,可以验证是否成功。

小白白的博客 2178

OpenAI,从推出更强大的Sora 2模型展开探索与未来发展前景+部署方法大全+文末邀请码*12

摘要 OpenAI推出的Sora 2是第二代AI视频生成模型,在多模态内容生成领域实现重大突破。文末足足有12个邀请码,速来速享!!!

aqfcca的博客 2248

E4A蓝牙APP开发实战:从零到一构建简易物联网控制终端

本文详细介绍了使用E4A(易安卓)开发蓝牙APP的实战教程,从零开始构建简易物联网控制终端。通过E4A的中文编程环境和内置蓝牙组件,开发者可以快速实现智能家居控制、创客项目遥控等功能。文章涵盖硬件准备、开发环境搭建、核心代码解析及典型应用场景,特别适合零Java基础的电子爱好者入门蓝牙APP开发。

weixin_42715608的博客 474

Kubernetes与大数据之五:在Kubernetes运行hive

一、前言 hive可以基于hadoop mr或者Spark进行高层次的数据处理。 安装之前先保证hadoop的目录可以为root用户读写: hadoop fs -chown  root:root / 转载自https://blog.youkuaiyun.com/cloudvtech   二、构建镜像 2.1 下载依赖 mkdir -p hive/image-build cd hive/i...

cloudvtech的博客 4632

LinuxCNC---在PC端显示开发板LinuxCNC界面

  今天在调试开发板时,执行开发板上的linuxcnc指令,总是出现如下报错 LINUXCNC - 2.9.0~pre0 application-specific initialization failed: couldn't connect to display "192.168.137.3:1" Error in startup script: invalid command name "image" while executing "image create photo -file $f/$i

中华田园巨龙 3469

在Kubernetes上部署Hive

在Kubernetes上部署Hive 思路: 以上一篇文章部署的Hadoop为基础,共享Hadoop集群的配置文件,安装Hadoop但不启动任何Hadoop进程 启动容器时进行Metadata数据库初始化,启动hiveserver2和metastore 1、环境介绍 [root@master-0 ~]# kubectl get nodes -o wi...

迷途的攻城狮 6652

逆变器专题(3)-锁相环-PLL

锁相环作为并网逆变器的第一道门户,其锁相的精度将直接影响逆变器是否并网成功,若锁相精度较差,则会直接导致系统的功率因数下降,产生无功等等。在有关文献中指出,提高PLL带宽可以准确且快速进行锁相,而当电网电压含有谐波时,可适当降低带宽抵制谐波的干扰。成为变化量,而如果两者旋转速度达到一致时,所在的交轴分量。ki很大,即带宽很大时,稳定裕度不够,锁相环锁不住。为交流量,当频率锁定而相位没有锁定时,即。,即控制环前馈,可实现将锁相速度的加快。控为0,则可实现系统完美锁相。mod,取余,可减少存储空间。

cyc19980105的博客 6181

Linux平台CCS安装配置完整示例

手把手讲解在Linux系统中完成CCS安装与环境配置的全过程,涵盖关键步骤与常见问题解决,是查找ccs安装教程时不可多得的实战指南。

weixin_42601134的博客 514

如何在 K8s 上运行 Spark & Hive?

引 言随着 Kubernetes 越来越成熟,使用者越来越多,大数据应用上云的需求也越来越迫切。原有的大数据资源管理器 Yarn 很难做到所有应用资源统一控制,完全隔离,带来的主机应用和大数据计算应用互相抢占资源,由此导致的计算任务时间可能经常性抖动,多租户应用互相影响。而在 Kubernetes 上,此类问题天然解决。所有的应用都以 Pod 形式在 Kubernetes...

LinkTime_Cloud的博客 3110

微信小程序 - 解决微信支付报错 requestPayment:fail no permission 原因分析及排查处理(支付失败出错,无法唤起支付弹框面板,微信支付API报错请求付款:失败无权限)

微信小程序,微信支付,支付报错,errMsg: "requestPayment:fail no permission",支付失败,支付权限没问题,微信小程序支付报错,检查了appid正确依旧不行,微信小程序支付异常,苹果ios手机,安卓手机,开发者工具模拟器,最新解决教程,小程序wx.requestPayment报错/无响应,小程序支付 requestPaym,微信小程序认证,真机运行,小程序微信支付提示错误,微信小程序里使用微信支付错误提示,微信小程序支付异常,微信支付弹框拉不起来,小程序支付api,都检

🏆 前端领域优质创作者 1万+

flink on k8s 访问hive hadoop

flink on k8s 访问hive hadoop

tianhouquan的专栏 3571

全覆盖路径规划开源项目Clean-robot-turtlebot3原理及流程概括总结

本系列文章主要介绍全覆盖路径规划开源项目Clean-robot-turtlebot3的相关内容,包含如下四篇文章,分别介绍了开源项目Clean-robot-turtlebot3流程的概括总结、ROS坐标系常用坐标及其变换、Clean-robot-turtlebot3关键函数解析等内容。

慕羽★的博客 6102

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

《云原生时代:Hive数据仓库的容器化改造与K8s部署》

管理元数据(如表结构)。:提供JDBC/ODBC接口供客户端查询。执行引擎:依赖MapReduce、Tez或Spark。在云原生环境中,Hive需适配容器化以支持动态扩缩容和微服务架构。容器化改造的核心是解耦状态(如元数据)和无状态组件(如查询服务)。Hive的容器化改造和K8s部署显著提升了云原生环境下的敏捷性和资源效率。通过解耦状态、使用K8s原生对象,企业能实现弹性伸缩和故障恢复。部署后,平均查询性能可提升30%-50%。

kkshdgxcjsd的博客 1163

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Hadoop、Hive On k8s

HDFS、Hive整合后,on k8s 运行

地球人是我哈的博客 1696

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Kubernetes运行大数据组件-运行hive

通过k8s运行hive服务

小森饭的博客 712

大数据容器化-基于Kubernetes(k8s)构建spark运行环境

Apache Spark 在大数据处理与分析领域,Apache Spark无疑占据着重要地位。它的特点是基于内存计算,支持各类资源管理平台,其中以YARN最为常见,同时又与Hadoop平台集成,在集群节点以HDFS作为分布式文件存储系统。 我们可以先看一下搭建一个常见的Apache Spark大数据平台需要哪些步骤: 安装Hadoop集群 配置HDFS 配置YARN 安装Spark 配置Spark与YARN集成 事实上如果参阅官方文档,还有更多细节检查与配置,有过大数据相关领域从业经验的人都知道,要搭建

学亮编程手记 2828

Flink 1.10 正式发布!——与Blink集成完成,集成Hive,K8S

Apache Flink社区宣布Flink 1.10.0正式发布!本次Release版本修复1.2K个问题,对Flink作业的整体性能和稳定性做了重大改进,同时增加了对K8S,Pytho...

大数据流动 173

k8s hue+hdfs+hive实验环境部署

开启minikube minikube start #开启minikube nohup minikube dashboard 1>>dashboard.log 2>>dashboard.err & #后台运行仪表盘 nohup kubectl proxy --port=80 --address='0.0.0.0' --accept-hosts='^.*' > /dev/null 2>&1 & #后台运行代理映射到外网 访问 http://k8s/

欢迎来到别往的博客 2032

Flink 2.2 容器化与K8s:Hive批流一体+SQL接入OpenAI

在大数据工程实践中,计算引擎的部署形态与数据链路架构直接决定平台的弹性与效率。Flink 作为主流分布式处理引擎,其容器化改造已成为从传统运维走向云原生的关键一步。通过将 Standalone 集群迁移到 Docker 与 Kubernetes,借助声明式资源调度和自动故障恢复,能够显著提升作业稳定性与资源利用率。在此基础上,利用 HiveCatalog 统一元数据管理,可实现 Hive 离线批处理与实时流计算的批流一体,配合分区提交与文件合并策略解决小文件问题。更进一步,将 OpenAI 推理封装为 Fl

weixin_29042035的博客 235

【spark on kubernetes】spark operator访问hdfs,hive

前一篇部署了spark operator,这边介绍spark访问hdfs,hive数据 一. 编写代码 Java代码,访问hdfs及访问hive package com.seagate.client.zyspark; import java.io.File; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import

你的博客 1万+

Flink 2.2 从本地 Standalone 到 Docker/Kubernetes,把 Hive 批流打通,并在 SQL 里接入 OpenAI 推理

Flink集群部署模式与优化实践 Flink集群包含Client、JobManager和TaskManager等核心角色,支持Session和Application两种部署模式。Session模式适合资源共享,而Application模式提供更好的隔离性。在Java版本选择上,Flink 2.0+推荐Java 17,但需注意模块化带来的反射问题。 部署方式包括: Standalone:快速启动但资源管理原始,支持ZooKeeper实现HA Docker:通过容器化实现环境复制,建议使用Compose管理依赖

hello.reader 1435
上一篇: Kubernetes的Spark运行Terasort(四)
下一篇: Kubernetes 运行flink(六)
CodeAsWind
博客等级 码龄12年 40粉丝 126原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值