西维蜀黍

【Linux】命令 - echo

Usage

# Print a text message. Note: quotes are optional:
$ echo "Hello World"

# Print a message with environment variables:
$ echo "My path is $PATH"

# Append a message to the file:
$ echo "Hello World" >> file.txt

# Enable interpretation of backslash escapes (special characters):
$ echo -e "Column 1\tColumn 2"
  ...


【Distributed System】高可用(High-availability)

High availability

High availability (HA) is a characteristic of a system which aims to ensure an agreed level of operational performance, usually uptime, for a higher than normal period.

Modernization has resulted in an increased reliance on these systems. For example, hospitals and data centers require high availability of their systems to perform routine daily activities. Availability refers to the ability of the user community to obtain a service or good, access the system, whether to submit new work, update or alter existing work, or collect the results of previous work. If a user cannot access the system, it is – from the user’s point of view – unavailable.

Generally, the term downtime is used to refer to periods when a system is unavailable.

  ...


【Cache System】缓存更新策略

Update Cache Design Pattern

  • Cache aside Pattern
  • Read through Pattern
  • Write through Pattern
  • Write Back/ Write Behind Pattern
  ...


【Engineering】Code Review

  ...


【MySQL】MySQL 性能优化

EXPLAIN 你的 SELECT 查询

使用 EXPLAIN 关键字可以让你知道MySQL是如何处理你的SQL语句的。这可以帮你分析你的查询语句或是表结构的性能瓶颈。

EXPLAIN 的查询结果还会告诉你你的索引主键被如何利用的,你的数据表是如何被搜索和排序的……等等,等等。

  ...


【Performance】网络调优

Misc

查看一下网络带宽使用情况,在Linux下,你可以使用iftop, iptraf, ntop, tcpdump这些命令来查看

测试TCP的RTT时间

$ ping aaa.com
PING aaa.com (10.1.2.3) 56(84) bytes of data.
64 bytes from 10.1.2.3: icmp_seq=1 ttl=61 time=0.104 ms
64 bytes from 10.1.2.3: icmp_seq=2 ttl=61 time=0.097 ms
64 bytes from 10.1.2.3: icmp_seq=3 ttl=61 time=0.103 ms
64 bytes from 10.1.2.3: icmp_seq=4 ttl=61 time=0.116 ms
64 bytes from 10.1.2.3: icmp_seq=5 ttl=61 time=0.086 ms
64 bytes from 10.1.2.3: icmp_seq=6 ttl=61 time=0.101 ms
64 bytes from 10.1.2.3: icmp_seq=7 ttl=61 time=0.086 ms
64 bytes from 10.1.2.3: icmp_seq=8 ttl=61 time=0.095 ms
64 bytes from 10.1.2.3: icmp_seq=9 ttl=61 time=0.091 ms
64 bytes from 10.1.2.3: icmp_seq=10 ttl=61 time=0.092 ms

输出显示每个包的往返时间(round trip time,RTT)并总结各种统计信息。由于时间戳是由ping命令自己计量的,其中包括获取时间戳到处理网络 I/O 的整个 CPU 代码路径执行时间。

  ...


【Linux】Vim

模式切换

  • iInsert 模式,按 ESC 回到 Normal 模式
  ...


【Linux】Shell - Bash 常用快捷键、命令和工具包

常用快捷键

编辑命令

  • 使用 Ctrl-R 而不是上下光标键来查找历史命令。

  • 使用 Ctrl-W 来删除最后一个单词

  • 使用 Ctrl-U 来删除一行

  • Ctrl + a :移到命令行首

  • Ctrl + e :移到命令行尾

  • Command + K:清空当前 session

  • Alt + f :按单词前移(右向) - 并不行(macOS下用Esc + F

  • Alt + b :按单词后移(左向) - 并不行(macOS下用Esc + B

  • Ctrl + u :从光标处删除至命令行首 - macOS下OK

  • Ctrl + k :从光标处删除至命令行尾 - macOS下OK

  • Ctrl + w :从光标处删除至字首 - macOS下OK

  • Alt + d :从光标处删除至字尾

  ...


【Linux】命令 - find

find 命令

Linux find 命令用来在指定目录下查找文件。任何位于参数之前的字符串都将被视为欲查找的目录名。如果使用该命令时,不设置任何参数,则 find 命令将在当前目录下查找子目录与文件。并且将查找到的子目录和文件全部进行显示。

$ find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
$ find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
  ...


【Linux】SSH 配置文件(.ssh/config)

Records

  • user’s configuration file (~/.ssh/config)
  • sstem-wide configuration file (/etc/ssh/ssh_config)

参数含义

  • %L 本地主机名的第一个组件
  • %l 本地主机名(包括域名)
  • %h 远程主机名(命令行输入)
  • %n 远程原始主机名
  • %p 远程主机端口
  • %r 远程登录用户名
  • %u 本地 ssh 正在使用的用户名
  • %i 本地 ssh 正在使用 uid
  • %C 值为 %l%h%p%r 的 hash

通配符

  • * - Matches zero or more characters. For example, Host * matches all hosts, while 192.168.0.* matches hosts in the 192.168.0.0/24 subnet.
  • ? - Matches exactly one character. The pattern, Host 10.10.0.? matches all hosts in 10.10.0.[0-9] range.
  • ! - When used at the start of a pattern, it negates the match. For example, Host 10.10.0.* !10.10.0.5 matches any host in the 10.10.0.0/24 subnet except 10.10.0.5.
  ...