Skip to content

Instantly share code, notes, and snippets.

View Ivlyth's full-sized avatar
🎯
Focusing

Ivlyth Ivlyth

🎯
Focusing
View GitHub Profile
  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@Ivlyth
Ivlyth / gen-git-submodule-add-from-gitmodules.sh
Last active December 17, 2018 06:59
generate `git submodule add` from pre-exists .gitmodules file
cat .gitmodules | grep 'url =' | awk -F ' = ' '{print $2}' | awk -F'/' '{print "git submodule add " $1 "/" $2 " repos/" substr($2, 0, index($2, ".") - 1) }'
@Ivlyth
Ivlyth / delete_git_submodule.md
Created November 13, 2018 12:53 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@Ivlyth
Ivlyth / README.md
Last active July 2, 2020 07:13
zookeeper / kafka cluster 搭建及 kafka 集群加密认证, 客户端加密认证设置方法

zookeeper 与 kafka 集群设置教程, 作为教程, 下文描述的步骤是在 1台 服务器上部署 启动三个 zookeeper 和 kafka 服务以组成模拟集群, 多机上的注意事项会在相关位置说明

⚠️: 该教程完成于内网 10.0.81.9 这台 sensor 机器, 因此以下步骤中提到的 IP 10.0.81.9, 请在自己实验中更换为自己实验用机器的 IP 地址.
⚠️: 标记 FIXME 的均为在实际环境中需要注意的值(比如 ip, 端口, 文件路径), 其余值新增内容均为固定值

1. 创建必要的测试目录

mkdir -p /data/kafka-cluster-test/{kafka,zookeeper}-data-{1,2,3}
@Ivlyth
Ivlyth / text-highlight.txt
Created May 15, 2018 02:37
text-highlight
AAAv1BBBv2BBBCCCv3CCCDDDv4DDDAAA
0 5 10 13 18 21 26 29
0 2 4 4 6 6 8 8
rep AAA
0 2 7 10 15 18 23 26
rep AAA
@Ivlyth
Ivlyth / kafka-more-consumer-than-partition.py
Created May 9, 2018 09:00
more consumer than partition count in kafka. some older consumer will be replaced, and some new consumer cant consume from topic.
# -*- coding:utf8 -*-
"""
Author : Myth
Date : 2018/5/9
Email : email4myth at gmail.com
"""
import json
import os
import signal
@Ivlyth
Ivlyth / bro.crash.log.md
Last active April 1, 2018 02:39
bro crash log (source version tag: 2.5.1)

backtrace

#0  EventMgr::QueueEvent (this=0xc312c0 <mgr>, event=event@entry=0x7fffd806eaf0) at /root/myth/bro-2.5.1/src/Event.cc:90
#1  0x00000000005fe6b7 in QueueEvent (obj=0x0, mgr=0x0, aid=0, src=0, vl=0x7fffd8069840, h=..., this=<optimized out>) at /root/myth/bro-2.5.1/src/Event.h:88
#2  Reporter::DoLog (this=0xc92a10, prefix=prefix@entry=0x908d37 "error", event=..., out=0x7ffff640d1c0 <_IO_2_1_stderr_>, conn=conn@entry=0x0,
    addl=addl@entry=0x0, location=location@entry=true, time=time@entry=true, postfix=postfix@entry=0x0,
    fmt=fmt@entry=0x7ffff482bd70 "Kafka send failed: %s", ap=ap@entry=0x7fffe318eaf8) at /root/myth/bro-2.5.1/src/Reporter.cc:350
#3  0x00000000005fee9f in Reporter::Error (this=<optimized out>, fmt=fmt@entry=0x7ffff482bd70 "Kafka send failed: %s")
    at /root/myth/bro-2.5.1/src/Reporter.cc:76
@Ivlyth
Ivlyth / rsync_project.py
Created March 23, 2018 06:29
fabric rsync_project without interaction
from fabric.contrib.project import rsync_project as _rsync_project
import tempfile
import os
def rsync_project(*args, **kwargs):
temp_pri_key = tempfile.mktemp(prefix='prs-rsa-')
temp_pub_key = temp_pri_key + '.pub'
local('ssh-keygen -t rsa -b 2048 -C "rsync-project@fabric" -N "" -f "%s"' % temp_pri_key)
run("mkdir -p /root/.ssh")
put(File(open(temp_pub_key).read(), "tmp-id_rsa.pub"), '/root/.ssh/authorized_keys')
@Ivlyth
Ivlyth / mail-parser.py
Created January 11, 2018 11:37
email parser - extract mail content and attachment
# -*- coding:utf8 -*-
"""
Author : Myth
Date : 18/1/11
Email : email4myth at gmail.com
"""
import email
import email.header
import hashlib
@Ivlyth
Ivlyth / find_bro_analyzers.md
Created January 2, 2018 11:41
find all bro analyzers
grep --include "*.bro" -r -e "register_for_ports" * | grep register_for_ports | grep -v call | grep "::ANALYZER_" | awk -F 'ANALYZER_' '{print $2}' | awk -F ',' '{print $1}' | sort
# results 27. bro-2.5.1
AYIYA
DCE_RPC
DHCP
DNP3_TCP