메뉴 건너뛰기

Cloudera, BigData, Semantic IoT, Hadoop, NoSQL

Cloudera CDH/CDP 및 Hadoop EcoSystem, Semantic IoT등의 개발/운영 기술을 정리합니다. gooper@gooper.com로 문의 주세요.


import org.apache.spark.SparkContext
import org.apache.spark.streaming.StreamingContext
import org.apache.spark.streaming.Seconds

object StreamingLogsMB {
  def main(args: Array[String]) {
    if (args.length < 2) {

      System.err.println("Usage: stubs.StreamingLogsMB <hostname> <port>")
      System.exit(1)
    }

    // get hostname and port of data source from application arguments
    val hostname = args(0)
    val port = args(1).toInt

    // Create a Spark Context
    val sc = new SparkContext()

    // Set log level to ERROR to avoid distracting extra output
    sc.setLogLevel("ERROR")

    // Configure the Streaming Context with a 1 second batch duration
    val ssc = new StreamingContext(sc,Seconds(1))

    // Create a DStream of log data from the server and port specified
    val logs = ssc.socketTextStream(hostname,port)

    ssc.checkpoint("logcheckpt")

    logs.countByWindow(Seconds(5), Seconds(2)).print

    ssc.start()
    ssc.awaitTermination()
  }
}

번호 제목 날짜 조회 수
247 beeline으로 접근시 "User: gooper is not allowed to impersonate anonymous (state=08S01,code=0)"가 발생하면서 "No current connection"이 발생하는 경우 조치 2018.04.15 2478
246 Cloudera Manager 5.x설치시 embedded postgresql를 사용하는 경우의 관리정보 2018.04.13 1600
245 jupyter, zeppelin, rstudio를 이용하여 spark cluster에 job를 실행시키기 위한 정보 2018.04.13 5102
244 Cloudera Manager web UI의 언어를 한글에서 영문으로 변경하기 2018.04.03 2364
243 Impala daemon기동시 "Could not create temporary timezone file"오류 발생시 조치사항 2018.03.29 2359
242 각 서버에 설치되는 cloudera서비스 프로그램 목록(CDH 5.14.0의 경우) 2018.03.29 1811
241 Cloudera설치중 실패로 여러번 설치하는 과정에 "Running in non-interactive mode, and data appears to exist in Storage Directory /dfs/nn. Not formatting." 오류가 발생시 조치하는 방법 2018.03.29 2211
240 Cloudera설치중에 "Error, CM server guid updated"오류 발생시 조치방법 2018.03.29 1171
239 Cloudera가 사용하는 서비스별 포트 2018.03.29 2070
238 Cloudera가 사용하는 서비스별 디렉토리 2018.03.29 1911
237 cloudera-scm-agent 설정파일 위치및 재시작 명령문 2018.03.29 2448
236 Components of the Impala Server 2018.03.21 1789
235 HDFS Balancer설정및 수행 2018.03.21 1681
234 hadoop 클러스터 실행 스크립트 정리 2018.03.20 3162
233 HA(Namenode, ResourceManager, Kerberos) 및 보안(Zookeeper, Hadoop) 2018.03.16 1222
232 update 샘플 2018.03.12 2993
» Scala에서 countByWindow를 이용하기(예제) 2018.03.08 2595
230 Scala를 이용한 Streaming예제 2018.03.08 2233
229 scala application 샘플소스(SparkSession이용) 2018.03.07 2275
228 spark-submit 실행시 "java.lang.OutOfMemoryError: Java heap space"발생시 조치사항 2018.02.01 1869
위로