MySQL Administration Memo

Database Backup

  1. Command Used to back up a database in Linux

mysqldump -u root -p edusoho > edusoho.sql

  1. MySQL Directory Layout

If install from rpm package, the .lib .h and all other type of files are placed by rpm into the corresponding directories

If install by uncompressing a tar, the mysql directory layout will be preserved.

  1. MySQL Command

mysql > show processlist;

mysql > show status;

Software Engineering Study Notes

Productivity v.s. Complexity

Over engineering happens when the productivity gained does not worth the effort of work and the complexity added into the system.

Memory Safety

A concern in software development that aims to avoid software bugs that cause security vulnerability dealing with random-memory-access, such as buffer overflows and dangling pointers.

Type Safety

Type safety is the extent to which a programming language discourages or prevents type errors.

Linux Tool Note

  1. TCP/UDP Connection Test
    nc -zv 25331

  2. Show all process
    ps aux | less

  3. Uncompress gzip file
    tar -zxvf {file.tar.gz}

  4. List all hardware information

  5. Grep Multiple Patterns
    grep -E '123|abc' filename

  6. Show CPU Information
    cat /proc/cpuinfo

  7. Check if a Process Exist
    ps -ef | grep deplearning

  8. Server Benchmark
    ab -c 1000 -n 50000 http://localhost:8080/

  9. 查看系统日志

tail -f /var/log/syslog

  1. 查看文件夹大小
    du -hs /path/to/directory

Java Multi-threading

How to Write Multi-threading Code ?

The multi-threading programming of Java is achieved through the use of Thread object.
1. Declare a class to be the subclass of Thread class and overrides its run method.
2. Declare a class and implement the Runnable interface, then implement the run method. (Recommended)

The create of a new thread requires that a Thread object to be created with a Runnable object given as the first argument. To start running a new thread, a thread.start() method is provided. Also, thread.join() method is provided to synchronize states between different threads.


Static class members are shared by all threads (atomic w/r). Keyword: Synchronized is provided to ensure the all threads execute certain methods sequentially.

Class method members (as well as local variables in the method definition) is independent for each threads.

Start a Docker Container with Multiple Bash Command Execution

Start a docker container and launch multiple background process (service) through docker run is impossible. The reason is that docker run does not support multiple command given as docker run argument. Multiple command execution is only viable through /bin/bash -c "command1; command2". However, a container is by design exited whenever the /bin/bash process is finished. Because of this mechanism, all service launching command like "python" must not ended with a daemon decorator "&", such as /bin/bash -c "python & python &" (In this case, the /bin/bash process finishes so that the container then exited").

Theoretically, a command such as /bin/bash -c "python & python" should bypass this problem since /bin/bash process got stuck with the process running in the foreground (within the container)", but this proved to be wrong in practice due to unknown reasons".

It is worth to mention that commands such as /bin/bash -c "python; python" will keep the container running, but the launch of will prevent from launching forever (because of the ; decorator).

1. /bin/bash -c "command1; command2" is rarely useful
2. docker run xxx /bin/bash -c "command" can be replaced by docker run xxx command
3. Multiple services should be split into different containers/images (container and service should maintain 1-on-1 mapping)


Tensorflow(TF)项目的Python3版本安装文件的官方打包只有python 3.4版本的,如果想要将TF安装到Python3.5上,请不要使用官方提供的pip安装方式。


  1. 将官方wheel安装包下载到本地: wget
  2. 重命名wheel安装文件: mv ~/username/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl ~/username/tensorflow-0.8.0-cp35-cp35m-linux_x86_64.whl
  3. 使用pip从命令行手动安装wheel: pip install ~/username/tensorflow-0.8.0-cp35-cp35m-linux_x86_64.whl


  1. GPU版TF的安装除了上述步骤外,还需要提前确认用于计算的GPU(显卡)是否有CUDA Compute Capability 3.0以上的运算能力,具体档位和显卡型号对应表请查阅下面的链接: CUDA Compute Capability 官方链接
  2. CUDA Driver的安装, CUDA Driver包含在CUDA Toolkit里,请直接安装CUDA Toolkit; 请参照Nvida官方的文档, 如果安装环境以前装过非官方的Nvida显卡驱动,需要手动卸载。CUDA Driver Instructions 官方链接。CUDA Toolkit (含Driver和工具)的安装请使用Standalone安装方式(即从runfile离线安装)
  3. Cudnn (GPU运算库)的安装:官方下载需要注册和审核,这里给出一个临时下载地址:Cudnn Library 百度网盘链接下载解压候使用如下命令安装Cudnn文件
tar xvzf cudnn-7.0-linux-x64-v4.0-prod.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo cp cuda/lib64/libcudnn* /usr/lib/x86_64-linux-gnu/
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn*


  1. Miscellaneous Problems:
    a. Cannot find CUDA (for example): sudo ldconfig /usr/local/cuda/lib64
    (Update the cache file of linker targets so that linker can find shared libraries)
    b. Cannot Open CUDNN cudnn.xx. (for example): sudo ldconfig /usr/local/cuda/lib64

  2. 常用命令:
    lspci | grep -i nvidia
    nvidia-smi -L 显示GPU硬件信息
    nvidia-smi -a 显示GPU使用情况
    nvidia-smi 显示GPU综合情况(含Current Running GPU Process)

  3. GPU编号
    nvidia-smi -L 命令显示的GPU编号不一定是GPU运算库配置文件里所需要的编号, 配置文件有时需要按GPU个数编号如0, 1, 2。
    nvidia-smi -L 命令显示出来的GPU编号可以从4, 5, 6这些开始
    nvidia-smi -a 显示GPU使用情况