Notes

Linux 相关

1、 修改Linux最大文件句柄数,修改文件 /etc/sysctl.conf 将参数 fs.file-max=100000 默认未修改的情况应该是 65535. 修改之后我们需要 sysctl -p /etc/sysctl.conf 执行 (root用户执行),可以查看配置是否在内核运行环境中是否生效 cat /proc/sys/fs/file-max 关于 Linux 操作系统 proc 目录的相关解释可以参考这篇文章: https://en.wikipedia.org/wiki/Procfs

2. ssh 执行远程命令 e.g ssh [email protected] “cd /home/user01 && tar xvf somefile.tar.gz”

3. Tmux using hjkl to navigate panes. edit ~/.tmux.conf

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

4. Arch Linux 中使用fcitx5 和Rime 切换中文简体和繁体
在输入是,使用ctrl + ` 进行切换选择

4. RSA 相关

openssl 生成pkcs1 密钥

 openssl genrsa -out private.pem 4096

Java 无法正常加载pkcs1 格式的私钥,需要转换成pkcs8格式,使用命令:

openssl pkcs8 -topk8 -inform PEM -in private.pem -outform pem -nocrypt -out pkcs8.pem

从私钥中生成公钥(pkcs8格式):

openssl rsa -in private.pem -pubout -out public.pem

5. 编译OPENSSL 0.9.8k 出错解决: 错误如下:

md5-x86_64.s: Assembler messages:
md5-x86_64.s:41: Error: 0xd76aa478 out range of signed 32bit displacement

解决方案:

make clean
./config --shared no-asm --prefix=/usr/local

详情参考StackOverflow: https://stackoverflow.com/questions/14574622/openssl-building-errors-in-centos-6-02-64-bit-os

6. Why dart use underscore instead of access modifier keywords like public or private?

https://github.com/dart-lang/sdk/issues/33383

7. How to reconsume RocketMQ Message when consumption failed?

  • Cluster consumption pattern The consumer business logic code returns Action.ReconsumerLater, NULL, or throws an exception, if a message failed to be consumed, it will retry for up to 16 times, after that, the message would be descarded.
  • Broadcast consumption pattern The broadcaset consumption still ensures that a message is consumered at least once, but no resend option is provided.

Reference: https://rocketmq.apache.org/docs/faq/

8. Linux 使用文件句柄数统计

cat /proc/sys/fs/file-nr

/*
man proc 查找对应解释
*/
/proc/sys/fs/file-nr
              This (read-only) file contains three numbers: the number of allocated file handles (i.e., the number of files presently opened); the number of free file handles; and the maximum  number  of
              file  handles  (i.e.,  the  same value as /proc/sys/fs/file-max).  If the number of allocated file handles is close to the maximum, you should consider increasing the maximum.  Before Linux
              2.6, the kernel allocated file handles dynamically, but it didn't free them again.  Instead the free file handles were kept in a list for reallocation; the "free file handles"  value  indi‐
              cates  the size of that list.  A large number of free file handles indicates that there was a past peak in the usage of open file handles.  Since Linux 2.6, the kernel does deallocate freed
              file handles, and the "free file handles" value is always zero.