bin log
slow query log
分析工具
mysqldompslow
如果專案不用 go module,或是在專案外執行 godoc
那就是 gopath mode
godoc server 會從 gopath 去找src
-r : download recursive -np : don't ascend to the parent directory -N : don't retrieve files unless newer than local -E : add extension .html to html files (if they don't have) -p : download all necessary files for each page (css, js, images) -k : convert links to relative
注釋說明
詳細參考
http://c.biancheng.net/view/4035.html
package、const、variable、func 都支援註釋
只支援public (大寫開頭)的member 註釋輸出
註釋格式就是直接在member 上加上說明,
但是 func 的註釋要以 func名稱開頭
//PublicFunc
func PublicFunc(){
}
const(
//ConExample 是註釋範例
ConExample =10
)
var (
//VarExample是註釋範例
VarExample =10
)
const 內的 會顯示在 Constants 區段
var 內的 會顯示在 Variables 區段
建立範例 example
example_packageName_test.go
func exampleFuncName
func ExampleFuncName() {
logger.Info("hello, world.")
}
Bug 標示
這樣會顯示bug 標示
//BUG(rsc):
func BadFunc(){
}
ulimit -aH //顯示所有設定 hardulimit -aS //顯示所有設定 softcore file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 31204 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 (file descriptor) pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 31204 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
cat /proc/{pid}/limits
//example cat /proc/1888/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 31204 31204 processes
Max open files 1024 4096 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 31204 31204 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
//Max processes 是可開啟執行緒上限持cat /proc/xxxxx/stat
cat /proc/xxxxx/status
//顯示某 process file descriptor數量 lsof -p 28290 lsof -a -p 28290 or //列出 ls -l /proc/28290/fd | less //計算總數 ls -l /proc/28290/fd | wc -l
sysctl fs.file-nr
fs.file-nr //顯示已經分配的 fd 數量、可分配的 fd 數量、系統總 fd 數量
fs.file-max //系統所有 process 可使用的總 fd 數量
查看系統設定
sysctl fs.file-nr //輸出 fs.file-nr = 1020 0 70000 1. 1020 The number of allocated file handles. 2. 0 The number of unused-but-allocated file handles. 3. 70000 The system-wide maximum number of file handles. cat /proc/sys/fs/file-max 或是看上限設定 sysctl fs.file-max 臨時性修改 sysctl -w fs.file-max=102400 永久修改 sudo vim /etc/sysctl.conf fs.file-max = 70000 //這個數值對應於hard limit sysctl -p 使修改生效
fs.nr_open
查看 cat /proc/sys/fs/nr_open 或是 sysctl fs.nr_open 修改 sudo /etc/sysctl.conf nr_open=1000000
vi /etc/security/limits.conf * hard nofile 102400 //針對所有user,不包括root * soft nofile 102400 //針對所有user,不包括root httpd hard nofile 102400 //針對httpd這個user httpd soft nofile 102400 //針對httpd這個user root hard nofile 102400 //針對root root soft nofile 102400 //針對root
# /etc/security/limits.conf //設定值 // core - 限制内核文件的大小 date - 最大数据大小 fsize - 最大文件大小 memlock - 最大锁定内存地址空间 nofile - 打开文件的最大数目 rss - 最大持久设置大小 stack - 最大栈大小 cpu - 以分钟为单位的最多CPU时间 noproc - 进程的最大数目 as - 地址空间限制 maxlogins - 此用户允许登录的最大数目 # * 代表针对所有用户 * soft nofile 102400 * hard nofile 102400 * soft stack unlimited //開啟stack 無限制
# /etc/security/limits.conf * soft nproc 100 //不能太大 * hard nproc 100 //不能太大 # /etc/security/limits.conf * - nproc 100 * - nofile 102400
//Create the root user 1 nano /etc/my.cnf //centos7 comment the bind_address (好像不需要) 或是 bind_address 0.0.0.0 2 create user root //(yes, a new user because what exists is 'root@localhost' // which is local access only): CREATE USER 'root'@'%' IDENTIFIED BY '123'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; 3 restart sudo systemctl restart mysqld