Author: jpuyy

  • nmap 探测局域网有没有 dhcp server

    家里有时候会有多个 dhcp server,探测 dhcpserver 把没用的关掉

    nmap --script broadcast-dhcp-discover
    Starting Nmap 6.40 ( http://nmap.org ) at 2019-11-17 16:43 CST
    Pre-scan script results:
    | broadcast-dhcp-discover:
    |   IP Offered: 192.168.1.60
    |   DHCP Message Type: DHCPOFFER
    |   Server Identifier: 192.168.1.123
    |   IP Address Lease Time: 0 days, 0:02:00
    |   Renewal Time Value: 0 days, 0:01:00
    |   Rebinding Time Value: 0 days, 0:01:45
    |   Subnet Mask: 255.255.255.0
    |   Broadcast Address: 192.168.1.255
    |   Router: 192.168.1.123
    |   Domain Name Server: 192.168.1.123
    |_  Domain Name: lan
    WARNING: No targets were specified, so 0 hosts scanned.
    Nmap done: 0 IP addresses (0 hosts up) scanned in 3.37 seconds
    
  • macOS 初始化及必装软件

    Langurage & Region-设置为英文 (Only)

    Dock 设置到左侧, Automatically hide and show the Dock
    remove unneed applications in Dock
    取消勾选 Show recent applications in Dock
    minimize window using: Scale effect

    Keyboard -> input sources 五笔
    Keyboard -> shortcuts -> switch select previous input source using command + space ( remove spotlight shortcuts )
    Keyboard -> Key Repeat(Fast), Delay Until Repeat(Short)
    Modifier Keys Caps Lock 改为 Control
    添加启动台快捷键 F4

    The Unarchiver
    kindle
    The Clock # App Store

    默认使用 zsh

    env | grep SHELL
    

    https://support.apple.com/en-us/HT208050?from=timeline&isappinstalled=0

    open terminal, type `git`, hint

    xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
    

    brew

    open https://brew.sh/
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    

    如果安装包都是 up-to-date,可以先执行, 不用每次 check, 节省时间

    export HOMEBREW_NO_AUTO_UPDATE=1

    brew install wget
    brew install jq
    brew install yq
    brew install cmake
    brew install llvm

    ·> brew install python3
    Warning: No available formula with the name “python3”.
    ·> rm -fr $(brew –repo homebrew/core)
    brew install python3

    brew install google-cloud-sdk
    gcloud components install kubectl
    gcloud components install gke-gcloud-auth-plugin

    遇到

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    

    解决

    xcode-select --install
    

    brew install openssl
    brew install mysql-client
    brew install grep
    brew install mtr # sudo /usr/local/sbin/mtr baidu.com
    brew install oath-toolkit # sudo chown ${USER}:wheel /usr/local/lib/security
    brew install iperf
    brew install fping
    brew install tflint
    brew install maven
    brew install openjdk
    brew install ansible
    brew install nvm
    brew install nmap

    brew install kubectx
    brew install fzf # https://github.com/junegunn/fzf

    brew install yarn
    brew install gradle
    brew install gnu-sed
    brew install tree
    brew install github/gh/gh
    brew install terraform
    brew install shellcheck
    brew install shfmt
    brew install hey
    brew install coreutils
    brew install brotli
    brew install kubernetes-helm
    brew install sbt
    brew install gawk
    brew install watch
    brew install yamllint
    brew install inetutils # PATH=”/usr/local/opt/inetutils/libexec/gnubin:$PATH”
    brew install redis

    # nodejs
    brew install npm

    brew install keepassxc # https://keepassxc.org/

    brew install go2shell

    brew install cisco-proximity

    golang https://jpuyy.com/?p=8411

    https://ohmyz.sh/

    application 开发组件
    https://www.jetbrains.com/toolbox-app/ 下载 webstorm goland pycharm intelij, 登录账号, 设置自动更新,添加 shell scripts 命令到 /usr/local/bin
    brew install vault
    brew install terragrunt
    brew install git-crypt
    brew install aliyun-cli
    brew install groovysdk
    brew install pre-commit
    brew install wireshark –cask
    brew install fortio

    brew install graphviz
    https://gpgtools.org/
    https://istio.io/docs/setup/getting-started

    kubectl 插件
    https://krew.sigs.k8s.io/docs/user-guide/setup/install/

    启用 locate updatedb

    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
    

    docker 安装
    https://hub.docker.com/editions/community/docker-ce-desktop-mac/

    logitech options
    https://support.logi.com/hc/zh-cn/articles/360025297893

    Apple Music => account => Sign In

    分屏 rectangle https://rectangleapp.com/

    vscode https://code.visualstudio.com/

    postman https://www.postman.com/downloads/?utm_source=postman-home

    2022-01-13 更换新电脑 MacBook Pro (14-inch, 2021) Apple M1 Max 更新

    2023-03 Intel Mac 更换 MacBook Pro 13-inch, M2, 2022

    Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
    Please create a new installation in /opt/homebrew using one of the
    “Alternative Installs” from:
    https://docs.brew.sh/Installation
    You can migrate your previously installed formula list with:
    brew bundle dump
    重新安装 brew
    brew 将会安装到 /opt/homebrew/bin/brew
    可以清理 /usr/local/Cellar 下的无用文件

  • windows11 Powershell WSL2 配置开发环境

    安装 windows terminal

    https://docs.microsoft.com/zh-cn/windows/wsl/install

    安装 CentOS ( Microsoft Store )

    root 登入,安装必备软件包

    yum update
    cat /etc/redhat-release
    yum install git vim curl
    

    WSL 和 windows 文件交换在 /mnt 目录下

    mkidr /mnt/c/Users/jpuyy/git
    ln -s /mnt/c/Users/jpuyy/{Downloads,git,OneDrive} ~/
    

    作为项目目录

    yum install -y zsh
    

    安装 oh-my-zsh

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    

    遇到 raw.githubusercontent.com 被污染,临时解决

    echo 'nameserver 8.8.8.8' > /etc/resolv.conf
    

    安装 kubectx
    https://github.com/ahmetb/kubectx/releases

    安装 winget
    https://github.com/microsoft/winget-cli/releases 下载二进制包

    安装 keepassxc
    winget install keepassxc

    重启 wsl 虚拟机, 进入 PowerShell

     wsl --shutdown
    

    然后新开窗口启动

    从原来的 wsl 升级到 wsl2

    PS C:\Users\yangy> wsl -l -v
    NAME STATE VERSION
    * CentOS Running 1

    wsl –set-version CentOS 2
    PS C:\Users\yangy> wsl –set-version CentOS 2
    正在进行转换,这可能需要几分钟时间…
    有关与 WSL 2 的主要区别的信息,请访问 https://aka.ms/wsl2
    请启用虚拟机平台 Windows 功能并确保在 BIOS 中启用虚拟化。
    有关信息,请访问 https://aka.ms/wsl2-install

    ## powershell
    PS C:\Users\yangy> wsl –list –online
    以下是可安装的有效分发的列表。
    请使用“wsl –install -d <分发>”安装。

    NAME FRIENDLY NAME
    Ubuntu Ubuntu
    Debian Debian GNU/Linux
    kali-linux Kali Linux Rolling
    openSUSE-42 openSUSE Leap 42
    SLES-12 SUSE Linux Enterprise Server v12
    Ubuntu-16.04 Ubuntu 16.04 LTS
    Ubuntu-18.04 Ubuntu 18.04 LTS
    Ubuntu-20.04 Ubuntu 20.04 LTS

    winget install oh-my-posh
    winget install aria2

  • 判断 zookeeper 健康状态

    echo stat | nc localhost 2181 | grep Mode
    You will get the response if the node is acting as a leader:

    Mode: leader
    If it is a follower, you will see:

    Mode: follower
    Alternatively, you can use the zkServer.sh located in /opt/zookeeper/bin:

    ./zkServer.sh status

    [root@misc010-prod ~]# echo mntr |nc  10.16.1.60 2181
    zk_version	3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
    zk_avg_latency	0
    zk_max_latency	2
    zk_min_latency	0
    zk_packets_received	36275
    zk_packets_sent	36274
    zk_num_alive_connections	2
    zk_outstanding_requests	0
    zk_server_state	leader
    zk_znode_count	488
    zk_watch_count	3
    zk_ephemerals_count	4
    zk_approximate_data_size	40646
    zk_open_file_descriptor_count	33
    zk_max_file_descriptor_count	65536
    zk_followers	2
    zk_synced_followers	2
    zk_pending_syncs	0
    
    [root@misc010-prod ~]# echo mntr |nc  10.16.1.21 2181
    zk_version	3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
    zk_avg_latency	0
    zk_max_latency	10
    zk_min_latency	0
    zk_packets_received	685
    zk_packets_sent	686
    zk_num_alive_connections	1
    zk_outstanding_requests	0
    zk_server_state	follower
    zk_znode_count	488
    zk_watch_count	0
    zk_ephemerals_count	4
    zk_approximate_data_size	40646
    zk_open_file_descriptor_count	30
    zk_max_file_descriptor_count	1048576
    [root@misc010-prod ~]# echo mntr |nc  10.16.1.22 2181
    zk_version	3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
    zk_avg_latency	0
    zk_max_latency	13
    zk_min_latency	0
    zk_packets_received	73614
    zk_packets_sent	73622
    zk_num_alive_connections	3
    zk_outstanding_requests	0
    zk_server_state	follower
    zk_znode_count	488
    zk_watch_count	37
    zk_ephemerals_count	4
    zk_approximate_data_size	40646
    zk_open_file_descriptor_count	32
    zk_max_file_descriptor_count	1048576
    
    

    在 leader 输出中
    zk_followers 2
    zk_synced_followers 2
    zk_pending_syncs 0
    表示 zk 正常

  • kafka 查看 group id 和 offset

    查看所有 group id

     bin/kafka-consumer-groups.sh --bootstrap-server broker1:9092 --list
    

    描述具体的 group id

     bin/kafka-consumer-groups.sh --bootstrap-server broker1:9092 --describe --group test-consumer-group
    
  • Padavan 定时任务

    每天重启路由器,每周升级

    30 3 * * * reboot
    # Upgrade every sunday
    00 2 0 * * rm -f /tmp/up.sh; wget https://opt.cn2qq.com/opt-script/up.sh -P /tmp/; sh -x /tmp/up.sh