Blog

  • vim cd 和 lcd

    cd 意思为 global current directory
    lcd 意思为 local current directory

    在打开的 vim 进程中,使用 :cd 可以指定全局的目录,这样方便的使用 :edit , :Explore 来查找编辑文件。

    但是在日常使用多窗口和多 tab 时是去其他目录查阅资料,这时使用全局目录切来切去很麻烦,可使用 lcd 对当前窗口指定一个工作目录。

    查看当前目录使用 :pwd 命令

    更多

    :help cd
    :help lcd
    
  • mysqldump ignore table

    mysqldump 忽略一些表

    --ignore-table=name   Do not dump the specified table. To specify more than one
                          table to ignore, use the directive multiple times, once
                          for each table.  Each table must be specified with both
                          database and table names, e.g.,
                         --ignore-table=database.table
    

    例子

    mysqldump -u dw -p dw --ignore-table=dw.raw_tracking --ignore-table=dw.raw_access > dump_without_tracking_access.sql
  • openssl shell 检验 ssl 证书过期时间

    语法如下

    site=www.youqiantu.com
    echo | openssl s_client -servername $site -connect $site:443 2>/dev/null | openssl x509 -noout -dates
    

    添加很多域名的 check

    #!/bin/bash
    
    domains='
    sentry.google.com
    console.google.com
    www.google.com
    m.google.com
    api.google.com
    '
    
    for domain in $domains
    do
      check_result=$(echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -dates | grep After)
      echo "$domain\t $check_result" | awk -F"\t" '{sub(/^ /,"",$2);printf "%-40s%s\n",$1,$2}'
    done
    

    对于自己签发的证书

    openssl x509 -enddate -noout -in apiserver.pem 
    notAfter=Mar  5 13:23:40 2018 GMT
    

    或者通过第三方工具检查
    https://www.ssllabs.com/ssltest/analyze.html
    https://whatsmychaincert.com/?jpuyy.com

    证书信息 certificate/intermediate/root ca

    openssl x509 -in example.com.crt -text -noout
    

    key 信息

    openssl rsa -in example.com.key -check 
    

    检查 p12 证书过期时间
    https://stackoverflow.com/questions/28373771/how-to-determine-ssl-cert-expire-date-from-the-cert-file-itself-p12/28374749

    You can use openssl to extract the certificate from the .p12 file to a .pem file using the following command:
    
    openssl pkcs12 -in certificate.p12 -out certificate.pem -nodes
    Then, you can extract the expiration date from the certificate in the .pem file using the following command:
    
    cat certificate.pem | openssl x509 -noout -enddate
    
  • cassandra 操作记录

    查看状态

    bin/nodetool status

    查看所有的 keyspaces

    DESCRIBE KEYSPACES
    

    查看网络状态

    bin/nodetool netstats

    查看 gossipinfo

    bin/nodetool gossipinfo

    修改 replication factor 之后进行 repair

    bin/nodetool repair

    踢除一个活的节点

    bin/nodetool decommision

    导出一个 keyspace 的结构

    cqlsh -e "DESC KEYSPACE test" > db_schema_test.cql;

    导出所有 keyspace 的结构

    cqlsh -e "DESC SCHEMA" > db_schema.cql

    导出表至 csv 文件

    COPY table_name ( column , ... )
    TO  'file_name' | STDOUT 
    WITH option = 'value' AND ...

    当需要维护一个结点时

    cd /opt/platform/cassandra/
    bin/nodetool drain
    # stop
    pgrep -u ops -f cassandra | xargs kill -9

    # start
    nohup ./bin/cassandra &

    变更后 Check
    /opt/platform/cassandra/bin/nodetool status
    关注

    Status – U (up) or D (down)
    Indicates whether the node is functioning or not.

    State – N (normal), L (leaving), J (joining), M (moving)
    The state of the node in relation to the cluster.

  • less 查找忽略大小写

    平时使用

    cat config.json | less

    如果有大小区分的时候搜索时不太方便

    现在只使用小写搜索

    cat config.json | less -i
  • mysqldump 加 where 条件

    导出表,时间大于 2017-05-17

    mysqldump -u root -p dw tracking --where 'stm > 2017-05-17' > dw.tracking.2017-05-17.sql