Tom Li (李懿峰), biergaizi (比尔盖子)
gentoo-zh.|
|
My nickname doesn’t represent that I’m a fan of Bill Gates, it is a joke (高端黑?) |
$ echo -e "\033(0"
$ cat /dev/urandom
$ reset
<erno> hm. I’ve lost a machine… literally lost. it responds to ping, it works completely, I just can’t figure out where in my apartment it is.
If the computer has a PC Speaker.
beep -d 1 -r 100
<1> delay 1 second, repeat 100 times.
Then stand up and find out your machine!
|
|
It only works if you probe pcspkr.
|
The computer no longer respond mouse or keyboard input. But the kernel doesn’t panic.
SysRq let us talk to the kernel directly!
Hold Alt+SyqRq / Print Screen, then press
R |
unRaw |
Take control of keyboard back from X. |
E |
tErminate |
Send SIGTERM to all processes. |
I |
kIll |
Send SIGKILL to all processes. |
S |
Sync |
Sync the filesystems. |
U |
Unmount |
Mount the filesystems to read-only. |
B |
reBoot |
Reboot the computer. |
kernel.sysrq.echo r > /proc/sysrq-trigger.HPN-SSH is a high performance SSH/SCP patchset. It can improve the performance of SSH/SCP without redece the security.
For the best performance, both the server and the client should apply the patches.
|
|
Gentoo includes HPN by default. |
[ebuild R ] net-misc/openssh-6.6.1_p1 USE="X hpn pam tcpd -X509 -bindist -kerberos -ldap -ldns -libedit (-selinux) -skey -static" 0 kB
I have many servers to management.
$ whoami
biergaizi
$ ssh user-2122487@shared-host
$ ssh root@personal-server
$ ssh fedora@community-server
$ ssh my-server # biergaizi is the default username
Modify ~/.ssh/config with your favorite editor.
Host ps
HostName personal-server
User root
$ ssh ps
Sometimes, the machine you want to connect doesn’t have a public IP address, and/or was walled by the routers/firewalls. And you don’t have the permission to modify the port-forwarding settings. For example, the computers in your company/school.
You need a public server which is world accessable.
$ ssh -NfR proxy_port:private_server:walled_port user@public_server
$ ssh root@private_server -p proxy_port
The network is unstable, or the latency of your network is very high. e.g 3G network.
Mosh is a replacement for SSH. It’s more robust and responsive, especially over Wi-Fi, cellular, and long-distance links.
$ mosh user@server
$ mosh -ssh="ssh -p 8088" user@server
It even helped a user escape from an broken elevator. http://gopher.floodgap.com/gopher/gw.lite?gopher://sdf.org:70/0/users/irl/blog/2012-08-22-mosh-in-a-lift.md
GNU parallel is a shell tool for executing jobs in parallel using one or more computers. A job can be a single command or a small script that has to be run for each of the lines in the input. A job can also be a command that reads from a pipe. GNU parallel can then split the input and pipe it into commands in parallel.
$ time cat test | xz > test.xz1
141.51s user
0.98s system
99% cpu
2:22.64 total
$ time cat test | parallel --pipe --recend "" -k xz > test.xz2
131.26s user
8.55s system
632% cpu
22.115 total
|
|
6x faster! |
The memory allocator implementation in glibc
Pretty old and slow for heavy-load servers (often make too much fragment).
So, Google started a project called tcmalloc.
3x (?) faster.
But I’m not going to talk about tcmalloc.
Facebook started supporting jemalloc.
jemalloc first came into use as the FreeBSD libc allocator in 2005.
It’s much faster than tcmalloc.
echo "/usr/lib64/libjemalloc.so.1" > /etc/ld.so.preload
LD_PRELOAD="/usr/lib64/libjemalloc.so.1" mysql
Some programs depend on Cryptography.
$ cat /proc/sys/kernel/random/entropy_avail
150
# too bad!
If there isn’t enough entropy, kernel will be unable to provide random data by /dev/random, these programs will be very slow and waiting for the random data all the time.
|
|
Although haveged has a strong algorithm to generate more random data, but it should not be used to generate important private keys, etc.
|
Thanks!