6.4 Java Version

  • 보안 관점에서는 최신 JDK 1.8 버전을 사용하는 것을 권장함
  • G1 collector 를 사용한다면 JDK 1.7 u51이상인지 확인 필요

6.5 Hardware and OS

  • Active reader, writer 버퍼링 하기 위한 충분한 메모리 필요.
  • 디스크 처리량이 중요함.
  • flush 동작 구성에 따라 더 좋은 디스크의 이점이 있을 수도 있고 없을 수도 있음.
  • flush 를 자주한다면 RPM이 높은 SAS 디스크가 더 좋을 수도 있음.

OS

  • 리눅스, 솔라리스에서 정상 동작, 윈도우는 지원하지 않음
  • 중요한 OS 레벨 configuration
    • File descriptor limits
      • (파티션 개수) * ( 파티션 사이즈 / 세그먼트 사이즈) 이상 필요로 함.
    • socket buffer size

Disk and Filesystem

  • 여러개의 디스크를 사용하고 카프카 데이터에 사용되는 드라이브를 타 응용프로그램 로그 또는 OS 파일 시스템과 공유하지 않는 것이 중요.
  • replication 기능을 가지고 있기 때문에 RAID에서 제공하는 redundancy를 응용프로그램 수준에서 제공가능함.
  • 그러나 몇가지 단점이 있음
    • 디스크 간의 로드 불균형
      • RAID는 더 낮은 수준에서 균형을 유지함.
      • 디스크 오류허용 능력

Application vs. OS Flush Management

  • 카프카는 데이터가 flush 되었다는 것을 알리기 위해 fsync를 호출함.
    • fsync 참고 내용
      • 물리적인 디스크에 반영하고 반환하므로 함수가 끝났고 반환값이 -1이 아니면 실제 디스크에 쓰여졌다는 것을 보장함
      • 버퍼 내용 뿐만 아니라 변경한 파일 속성 등의 메타 데이터도 반영함.
      • 참고 url : http://ehclub.co.kr/1322
  • 카프카는 실패한 노드의 데이터는 복제본에서 복구 되므로 데이터를 디스크에 동기화 할 필요가 없음

  • 응용프로그램 단에서 fsync 를 비활성화 하는 것을 권장함. 이것은 OS와 카프카에서 수행되는 백그라운드 플러시에 의존하는 것을 의미함.

Understanding Linux OS Flush Behavior

  • Pdflush 가 기록되는 데이터의 속도를 따라갈 수 없으면 결국 쓰기 프로세스가 쓰기에서 지연을 방지해서 데이터 축적을 늦추게 됨
  • pdflush
    • 리눅스 2.6 커널에 있는 시스템 버퍼에 쌓여 있는 내용을 디스크로 기록하는 데몬
    • 참고 url : http://pinocc.tistory.com/3

Filesystem Selection

  • ext4, xfs 를 가장 많이 사용함

General Filesystem Notes

  • 리눅스에서 데이터 디렉토리에 사용되는 파일시스템의 경우 마운트시에 다음 옵션을 사용

    • noatime : 파일을 읽을 때 파일의 atime (최종 엑세스시간) 속성의 갱신을 사용 불가능하게 함.

      • fstab 에서 noatime 설정 사용예제
      /dev/sda7          /chroot          ext2          defaults,noatime          1  2
      

XFS Notes

  • largeio
    • stat 호출에 의해 보고된 기본 I/O 크기에 영향을 줌
  • nobarrier
    • 배터리 백업 캐시가 있는 기본 장치의 경우, 플러시를 비활성화하여 약간의 성능을 향상 시킬 수 있음.

EXT4 Notes

  • data=writeback
  • Disabling journaling
    • 저널링이란?
      • 스토리지에 데이터를 저장하기 전에 Journal 영역에 데이터의 변경 이력을 저장하고, 스토리지에 데이터 변경 내역을 저장하는 것
      • 장점 : 파일에 대한 변경여부를 가장 정확하게 유지할 수 있음
      • 단점 : 저널 영역에 대한 추가적인 디스크 접근이 많음
      • data integrity 면에서는 최고이나 performance 면에서는 최선이 아님.
      • 참고 url
  • commit=num_secs
    • ext4가 메타 데이터 저널에 commit 하는 빈도 설정
    • 이 값을 높이면 처리량이 향상됨
  • nobh
    • data=writeback 모드를 사용할 때, 추가적으로 ordering guarantees를 설정함.
  • delalloc
    • Delayed allocation(지연된 할당)
    • 파일 시스템이 물리적 쓰기가 발생할 때 까지 블록 할당을 방지함.

6.6 Monitoring

  • 서버와 클라이언트 모두 메트릭 리포팅을 위해 Yammer Metrics를 사용함.
  • 사용가능한 메트릭을 확인하는 방법은 jconsole 을 실행하고 실행중인 카프카 클라이언트나 서버를 가리킴.
  • 측정항목

Common monitoring metrics for producer/consumer/connect/streams

Common Per-broker metrics for producer/consumer/connect/streams

Producer monitoring

New consumer monitoring

Consumer Group Metrics

Consumer Fetch Metrics

Topic-level Fetch Metrics

Stream Monitoring

  • 2가지 측정레벨

    • debug : 모든 메트릭 기록
    • info : 스레드 수준 메트릭 기록
    metrics.recording.level="info"
    

Thread Metrics

Task Metrics

Processor Node Metrics

State Store Metrics

Others

  • 서버
    • GC 시간 및 기타 통계, CPU 사용율, I/O 서비스 시간 등과 같은 다양한 서버 통계를 모니터링 하는 것이 좋음.
  • 클라이언트
    • 메시지/바이트 속도, 요청 비율/크기/시간 및 consumer 측면에서 모든 파티션 간의 메시지 지연 및 분당 페이지 요청 속도를 모니터링 하는 것이 좋음

Audit

  • 데이터 전달의 정확성 확인

6.7 ZooKeeper

Stable version

  • 안정적인 버전 : 3.4

Operationalizing ZooKeeper

  • Redundancy in the physical/hardware/network layout

    • 동일 랙에 배치하지 말 것
  • I/O segregation

    • ZooKeeper 스냅샷은 트랜잭션 로그와 별도의 디스크 크룹에 기록해야 함.
  • Application segregation

    • 별도 서버로 ZooKeeper 를 독립적으로 실행해야 함.
  • Use care with virtualization

  • ZooKeeper configuration

    • 충분한 힙메모리 공간확보
  • Monitoring

    • JMX, 4 lw command
  • Don't overbuild the cluster

7. SECURITY

7.1 Security Overview

  • SSL 또는 SASL (Simple Authentication and Security Layer)를 사용하여 클라이언트, 기타 브로커 및 도구에 해단 연결 인증 지원
    • 지원하는 SASL 메커니즘
      • SASL/GSSAPI (Kerberos) - starting at version 0.9.0.0
      • SASL/PLAIN - starting at version 0.10.0.0
      • SASL/SCRAM-SHA-256 and SASL/SCRAM-SHA-512 - starting at version 0.10.2.0
  • 브로커에서 ZooKeeper로 연결인증
  • 브로커와 클라이언트 간, 브로커 간 또는 SSL을 사용하는 브로거와 도구간에 전송되는 데이터의 암호화
  • 클라이언트의 읽기 / 쓰기 작업 권한 부여
  • 권한부여가 가능하며 외부 인증 서비스와의 통합을 지원

7.2 Encryption and Authenticatoin using SSL

Generate SSL key and certificate for each Kafka broker

  • 클러스터의 각 시스템에 대한 키와 인증서 생성
  • 자바의 keytool 유틸리티를 사용
keytool -keystore server.keystore.jks -alias localhost -validity {validity} -genkey
  • keytool 에서 2개의 매개변수 지정
    • keystore : 인증서를 저장하는 키
    • vallidity : 인증서 유효기간(일)
  • hostname 확인
ssl.endpoint.identification.algorithm = HTTPS
  • 생성된 인증서 확인
keytool -list -v -keystore server.keystore.jks

Creating your own CA

Signing the certificate

Configuring Kafka Brokers

  • Borkers는 여러 포트에서 연결을 listening 하고 있음.
  • server.properties 에서 listeneres 설정
listeners=PLAINTEXT://host.name:port,SSL://host.name:port
  • borker 에서 SSL config 설정
            ssl.keystore.location=/var/private/ssl/kafka.server.keystore.jks
            ssl.keystore.password=test1234
            ssl.key.password=test1234
            ssl.truststore.location=/var/private/ssl/kafka.server.truststore.jks
            ssl.truststore.password=test1234
  • SSL 관련 추가선택 사항
    • ssl.client.auth=none
    • ssl.chiper.suites
    • ssl.enabled.protocols
    • ssl.keystore.type=JKS
    • ssl.truststore.type=JKS
    • ssl.secure.random.implementation=SHA1PRNG
  • broker 간에 SSL 통신을 하기 위한 설정 (기본값은 PLAINTEXT )
ecurity.inter.broker.protocol = SSL
  • broker 간에 SSL 통신 확인
    • server.log 에서 확인 가능
    • with addresses: PLAINTEXT -> EndPoint(192.168.64.1,9092,PLAINTEXT),SSL -> EndPoint(192.168.64.1,9093,SSL)
      

Congfiguring Kafka Clinents

  • 브로커에서 클라이언트 인증이 필요하지 않는 경우의 구성 예
            security.protocol=SSL
            ssl.truststore.location=/var/private/ssl/kafka.client.truststore.jks
            ssl.truststore.password=test1234
  • 클라이언트 인증이 필요한 경우의 구성 예
            ssl.keystore.location = / var / private / ssl / kafka.client.keystore.jks 
            ssl.keystore.password = test1234 
            ssl.key.password = test1234
  • 브로커 구성에 따라 필요한 기타 구성 설정
    • ssl.provider
    • ssl.ciper.suites
    • ssl.enabled.protocols
    • ssl.truststore.type=JKS
    • ssl.keystore.type=JKS
  • 콘솔에서 producer/comsumer 사용 시 client ssl 사용 예
            kafka-console-producer.sh --broker-list localhost:9093 --topic test --producer.config client-ssl.properties
            kafka-console-consumer.sh --bootstrap-server localhost:9093 --topic test --consumer.config client-ssl.properties

7.3 Authentication using SASL

JAAS Configuration

7.4 Authorization and ACLs

{"version": 1, 
 "acls": [ 
    { 
      "principals": ["user:alice”, "group:kafka-devs"], 
      "permissionType": "ALLOW", 
      "operations": [ "READ", "WRITE" ], 
      "hosts": [ "host1", "host2" ] 
    }, 
   { 
     "principal": ["user:bob”, "user:*"] ,
     "permissionType": "ALLOW", 
     "operations": [ "READ" ], 
     "hosts": [ "*" ] 
   }, 
   { 
     "principal": "user:bob”, 
     "permissionType": "DENY", 
     "operations": [ "READ" ], 
     "hosts": [ "host1", "host2" ] 
   } 
 ] 
}

Command Line Interface

Examples

  • Adding Acls
bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:Bob --allow-principal User:Alice --allow-host 198.51.100.0 --allow-host 198.51.100.1 --operation Read --operation Write --topic Test-topic
  • Removing Acls
bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --remove --allow-principal User:Bob --allow-principal User:Alice --allow-host 198.51.100.0 --allow-host 198.51.100.1 --operation Read --operation Write --topic Test-topic
  • List Acls
bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --list --topic Test-topic
  • Adding or removing a principal as producer or consumer
bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:Bob --producer --topic Test-topic

7.5 Incorporating Security Feature in a Running Cluster

  • http://kafka.apache.org/documentation/#security_rolling_upgrade
  • 실행 중인 클러스터에 보안 기능 통합 절차
    • 추가 보안 포트를 열기위해서는 클러스터 노드를 점진적으로 바운스 (재부팅)함.
    • PLAINTEXT 포트 대신 보안된 포트를 사용해서 클라이언트 재시작
    • 브로커 간 브로커 보안을 활성화하기 위해 필요한 경우 클러스터를 점진적으로 바운스(재부팅)함.
    • PLAINTEXT 포트를 닫기 위한 최종 incremental 바운스 (재부팅)

7.6 ZooKeeper Authentication

7.6.1 New clusters

7.6.2 Migrating clusters

./bin/zookeeper-security-migration --zookeeper.acl=secure --zookeeper.connect=localhost:2181

7.6.3 Migrating the ZooKeeper ensemble

results matching ""

    No results matching ""