Author: jpuyy

  • 更改 mysql 慢查询时间阈值

    默认是 10s ,改为 200ms

    mysql> show global variables like 'long_query_time%';
    +-----------------+-----------+
    | Variable_name   | Value     |
    +-----------------+-----------+
    | long_query_time | 10.000000 |
    +-----------------+-----------+
    1 row in set (0.01 sec)
    
    mysql> set global long_query_time=0.2;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> show global variables like 'long_query_time%';
    +-----------------+----------+
    | Variable_name   | Value    |
    +-----------------+----------+
    | long_query_time | 0.200000 |
    +-----------------+----------+
    1 row in set (0.00 sec)
    
  • 防止在 slave 上执行sql 误操作

    防止在 slave 上执行sql 误操作最主要的还是知道自己执行的机器是否正确。

    要知道自己在哪台机器上

    select @@hostname

    查看 master status

    show master status\G

    查看 slave status (主库不应看到信息)

    show slave status

    查看 slave 有哪些 (从库不应看到信息)

    show slave hosts\G
  • rabbitmq从集群中拆除节点并初始化

    node1,node2,node3 想要拆掉 node3 做为单独和 node1,node2 相同配置的集群

    保存当前 definitions

    GET $host:15672/api/definitions 保存为 json文件

    node3 上执行

    rabbitmqctl stop_app

    node1上执行

    rabbitmqctl forget_cluster_node rabbit@node3

    node3 上删除 /var/lib/rabbitmq/mnesia 数据库下所有文件, 重启

    之后 node3 初始化

    rabbitmqctl add_user admin admin
    rabbitmqctl set_user_tags admin administrator
    rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

    登录到管理台导入json文件

  • macOS iCloud Drive path

    The path of iCloud Drive is

    ~/Library/Mobile\ Documents/com~apple~CloudDocs

    How to find this path
    Finder => View => Show Path Bar => Open iCloud Drive, in the bottom, right click, we can Copy “iCloud Drive” as Pathname

    We can create a symbolic link for the path

    ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs icloud

    Or an alias, cdi equals change directory to iCloud Drive

    alias cdi='cd ~/Library/Mobile\ Documents/com~apple~CloudDocs'
  • 2017读书清单

    目标30本书

    开始时间 技术书 非技术书 教学视频
    2017-03-10 人类简史
    2017-03-27 redis实战
    2017-04-28 Learning ELK stack
    2017-10-10 The go programming language
  • brew安装多版本 清理包和 img

    brew 安装多版本

    例子,当前 gradle 5.2.1 ,想将 4.10.2 装上,找到 formula 的 git 目录,切到对应 4.10.2 的 commit,安装,安装完之后再切回 master

    $ brew list gradle --versions
    gradle 5.2.1
    $ cd "$(brew --repo homebrew/core)"
    $ pwd
    /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
    $ git log master -- Formula/gradle.rb 
    ...
    commit 01e0511df2c37b052a9659797f3c09df3f20d533
    Author: Jerome Lapostolet 
    Date:   Thu Sep 20 08:51:53 2018 +0100
    
        gradle 4.10.2
    ...
    
    $ git checkout 01e0511df2c37b052a9659797f3c09df3f20d533
    Note: checking out '01e0511df2c37b052a9659797f3c09df3f20d533'.
    
    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.
    
    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:
    
      git checkout -b 
    
    HEAD is now at 01e0511df2 gradle 4.10.2
    $ HOMEBREW_NO_AUTO_UPDATE=1 brew install gradle
    Error: gradle 5.2.1 is already installed
    To install 4.10.2, first run `brew unlink gradle`.
    $ HOMEBREW_NO_AUTO_UPDATE=1 brew unlink gradle
    Unlinking /usr/local/Cellar/gradle/5.2.1... 1 symlinks removed
    $ HOMEBREW_NO_AUTO_UPDATE=1 brew install gradle
    ==> Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip
    ==> Downloading from https://downloads.gradle.org/distributions/gradle-4.10.2-all.zip
    ######################################################################## 100.0%
    🍺  /usr/local/Cellar/gradle/4.10.2: 203 files, 83.7MB, built in 5 minutes 56 seconds
    $ git checkout master
    
    $ brew list gradle --versions
    gradle 5.2.1 4.10.2
    
    

    之后可以用 brew swith gradle x.x.x 在不同版本之间切换
    helm 安装 v2.9.1 版本

    https://medium.com/@nehaguptag/installing-older-version-of-helm-downgrading-helm-8f3240592202
    wget https://raw.githubusercontent.com/Homebrew/homebrew-core/78d64252f30a12b6f4b3ce29686ab5e262eea812/Formula/kubernetes-helm.rb
    brew install kubernetes-helm.rb
    

    查看已经安装的包

    brew list

    选择要清理的包

    brew uninstall mariadb

    整体清理

    brew update && brew upgrade && brew cleanup
    
    ==> This operation has freed approximately 427.8M of disk space.
    brew cask cleanup

    https://brew.sh/ 搜索软件和版本

    检查当前 brew 的配置情况

    brew doctor                                                                                               master 187b0c8b0d
    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry or file an issue; just ignore this. Thanks!
    
    Warning: Some installed kegs have no formulae!
    This means they were either deleted or installed with `brew diy`.
    You should find replacements for the following formulae:
      python@2
      ab
      tuntap
      unrar
      sshpass
      php54
    
    Warning: Some installed formulae are deprecated or disabled.
    You should find replacements for the following formulae:
      dep
      docker-machine
      [email protected]
      sshfs
    
    Warning: Unbrewed dylibs were found in /usr/local/lib.
    If you didn't put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.
    
    Unexpected dylibs:
      /usr/local/lib/libD4P11_ICBC.dylib
      /usr/local/lib/libD4PinPad_ICBC.dylib
      /usr/local/lib/libD4Token_ICBC.dylib
      /usr/local/lib/libshuttle_p11v220.1.0.0.dylib
    
    Warning: You have unlinked kegs in your Cellar.
    Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
    those kegs to fail to run properly once built. Run `brew link` on these:
      tree
      pandoc
      docker
      python@2
      docker-machine
      ab
      markdown
      tuntap
      aria2
      geoip
      unixodbc
      unrar
      gd
      wireshark
      php54
    
    Warning: Some taps are not on the default git origin branch and may not receive
    updates. If this is a surprise to you, check out the default branch with:
      git -C $(brew --repo homebrew/core) checkout master
    
    Warning: Homebrew's "sbin" was not found in your PATH but you have installed
    formulae that put executables in /usr/local/sbin.
    Consider setting your PATH for example like so:
      echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc
    
    
    

    参考:
    https://www.cnblogs.com/BlackStorm/p/homebrew-install-old-versions-take-node-for-example.html