Skip to content

Instantly share code, notes, and snippets.

@JoshuaChi
JoshuaChi / multi-process
Created January 2, 2016 09:35
Shell Multi Process
#!/bin/bash
set -m # Enable Job Control
WORKSPACE="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )"
for i in `seq 8`; do # start 8 jobs in parallel(e.g. 8 cores)
//sh example.sh
done
@JoshuaChi
JoshuaChi / gist:82acf99323dfd49af7929c0c218fe4ff
Created December 31, 2016 07:55 — forked from kaiwren/gist:1283905
Steve Yegge's SOA post
From: https://raw.github.com/gist/933cc4f7df97d553ed89/24386c6a79bb4b31fb818b70b34c5eab7f12e1ff/gistfile1.txt
Stevey's Google Platforms Rant
I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.
I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various effort
@JoshuaChi
JoshuaChi / RoundRobinBalancer.java
Created April 9, 2017 08:17
Zookeeper::RoundRobinBalancer
public class RoundRobinBalancer implements Balancer {
private CuratorFramework zkClient;
public RoundRobinBalancer(CuratorFramework zkClient){
this.zkClient = zkClient;
}
@Override
public String select() throws Exception {
@JoshuaChi
JoshuaChi / LeastConnectionBalancer.java
Created April 9, 2017 08:18
Zookeeper::LeastConnectionBalancer
public class LeastConnectionBalancer implements Balancer {
private CuratorFramework zkClient;
public LeastConnectionBalancer(CuratorFramework zkClient){
this.zkClient = zkClient;
}
@Override
public String select() throws Exception {
@JoshuaChi
JoshuaChi / consist_hash.java
Created June 1, 2017 14:20 — forked from bcambel/consist_hash.java
Consistent Hash Java implementation
import java.util.Collection;
import java.util.SortedMap;
import java.util.TreeMap;
public class ConsistentHash<T> {
private final HashFunction hashFunction;
private final int numberOfReplicas;
private final SortedMap<Integer, T> circle = new TreeMap<Integer, T>();
@JoshuaChi
JoshuaChi / postgres-cheatsheet.md
Created August 23, 2017 09:17 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@JoshuaChi
JoshuaChi / npm.taobao.sh
Last active December 22, 2017 03:29 — forked from 52cik/npm.taobao.sh
npm 淘宝镜像配置
npm set registry https://registry.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set chromedriver_cdnurl http://cdn.npm.taobao.org/dist/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl http://cdn.npm.taobao.org/dist/operadriver # operadriver 二进制包镜像
npm set phantomjs_cdnurl http://cdn.npm.taobao.org/dist/phantomjs # phantomjs 二进制包镜像
npm set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass # node-sass 二进制包镜像
npm set electron_mirror http://cdn.npm.taobao.org/dist/electron/ # electron 二进制包镜像
npm set selenium_cdnurl=http://npm.taobao.org/mirrors/selenium
TASK [kubernetes/master : Backup old certs and keys] *******************************************
task path: /home/centos/kubespray/roles/kubernetes/master/tasks/kubeadm-certificate.yml:2
Thursday 14 March 2019 06:05:10 +0000 (0:00:01.655) 0:06:23.774 ********
TASK [kubernetes/master : Remove old certs and keys] *******************************************
task path: /home/centos/kubespray/roles/kubernetes/master/tasks/kubeadm-certificate.yml:16
Thursday 14 March 2019 06:05:10 +0000 (0:00:00.245) 0:06:24.019 ********
TASK [kubernetes/master : Generate new certs and keys] *****************************************
task path: /home/centos/kubespray/roles/kubernetes/master/tasks/kubeadm-certificate.yml:28
PLAY [all] *************************************************************************************
TASK [set_fact] ********************************************************************************
Thursday 14 March 2019 07:04:49 +0000 (0:00:00.240) 0:00:00.240 ********
ok: [ip-172-16-0-157.cn-northwest-1.compute.internal]
ok: [ip-172-16-0-231.cn-northwest-1.compute.internal]
ok: [ip-172-16-0-32.cn-northwest-1.compute.internal]
TASK [Storing commands output] *****************************************************************
Thursday 14 March 2019 07:04:49 +0000 (0:00:00.388) 0:00:00.628 ********

kafka 集群安全认证配置

本文主要介绍下 kafka 0.10.0 版如何实现sasl/plain认证机制及权限控制

kafka安全机制

kakfa 的安全机制主要分为两部分:

  • 身份认证(Authentication): 对客户端的身份进行认证
  • 权限控制(Authorization): 对topic级别的权限进行控制

kafka 身份认证

kafka 目前支持 SSL,SASL(Kerberos),SASL(PLAIN) 三种认证机制。