Author: jpuyy

  • macOS 屏幕相关

    1. mission control => 触发角 => 启用屏幕保护程序 or 将显示器置入睡眠状态
    2. 安全性与隐私 => 进入睡眠或开始屏幕保护程序 立即 要求输入密码

    接下来使用触发角就可以立即锁屏了

    新版 mac 使用 ctrl + command + q

    Question: how to quick switch between mirror and extended display in macOS
    切换 mirror 和 扩展模式: command + F1
    If you need to temporarily see your Dock or your open windows on both displays, Command-F1 lets you accomplish this. It’s a shortcut to the System Preferences > Displays > Arrangement > Mirror Displays command.

  • bee 自动运行 go 项目

    当源代码有过修改之后,自动 build 重启

    ~/go/bin/bee run logan
    
  • kafka修改 topic retention

    查看所有的 topic

    bin/kafka-topics.sh --list --zookeeper localhost:2181
    

    修改为 60s

    
    # bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-name provider-service --entity-type topics --add-config retention.ms=60000
    

    查看

    # bin/kafka-configs.sh --zookeeper localhost:2181 --describe --entity-name provider-service --entity-type topics
    Configs for topics:provider-service are retention.ms=60000
    
  • bash countdown

    输入 countdown + 秒数,就开始倒计时了

    gnu date

    function countdown(){  
        local now=$(date +%s)
        local end=$((now + $1))
        while (( now < end )); do   
            printf "%s\r" "$(date -u -d @$((end - now)) +%T)"  
            sleep 0.25  
            now=$(date +%s)
        done  
        echo
    }
    

    osx date

    function countdown(){  
        echo $2
        local now=$(date +%s)
        local end=$((now + $1))
        while (( now < end )); do   
            printf "%s\r" "$(date -u -j -f %s $((end - now)) +%T)"  
            sleep 0.25  
            now=$(date +%s)
        done
    }
    

    参考:https://superuser.com/questions/850368/osx-bash-command-line-countdown-timer?answertab=votes#tab-top

  • elasticsearch 笔记

    查看索引

    http://127.0.0.1:9200/_cat/indices

    查看节点

    http://10.18.19.93:9200/_nodes

    查看 mappings

    http://10.18.19.70:9200/_mappings

    查看健康状态

    _cluster/health

    每个 index 状态

    _cluster/health?level=indices

    删除 index

    curl -XDELETE 1.2.3.4:9200/notification_msgcount_logs-2019.24

    按存储大小排序

    curl -XGET 'http://127.0.0.1:9200/_cat/indices/_all?v&s=store.size'  
    
    

    查看未分配 shard 的原因
    GET _cluster/allocation/explain?pretty

    FORBIDDEN/12/index read-only 报错
    es磁盘已满而无法索引更多文档,则elasticsearch将切换为只读。它确保了只读查询的可用性。

    blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];: [cluster_block_exception] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
    进行 index 的删除的同时。Elasticsearch不会自动切换回来,可以使用如下方法切换回正常模式:

    PUT _settings
    {
    “index.blocks.read_only_allow_delete”: “false”
    }

    # 检查

    GET _settings

  • docker image 迁移

    要迁移 docker image 有三个方法

    1.拿到 docker repo, Dockerfile 重新 build

    docker build .

    2.通过 docker registry

     docker pull image

    3.打包后通过文件迁移

    保存一个 tar 文件

    docker save -o fedora-latest.tar fedora:latest 

    把文件传输到目标机器

    docker load -i path to image tar file