An apple a day keeps the doctor away !

0%

此篇文章被加密,需要输入密码查看
阅读全文 »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@OpenWrt:~# cat /etc/config/dockerd 

config globals 'globals'
option log_level 'warn'
option auto_start '1'
option alt_config_file '/etc/docker/daemon.json'
option data_root '/mnt/mmcblk2p4/docker/'
option bip '172.31.0.1/24'
option iptables 'true'

config dockerman 'dockerman'
option socket_path '/var/run/docker.sock'
option status_path '/tmp/.docker_action_status'
option debug 'false'
option debug_path '/tmp/.docker_debug'
option remote_endpoint '0'
list ac_allowed_interface 'br-lan'

使用以下命令限制docker的日志大小与日志数量

1
--log-driver=json-file --log-opt max-size=1m --log-opt max-file=1

连接es

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main

import (
"context"
"fmt"

"github.com/olivere/elastic"
)

var client *elastic.Client
var host = "http://x.x.x.x:29200/"

func init() {
fmt.Println("开始初始化")

var err error

// 不添加elastic.SetSniff(false)会导致连不上
client, err = elastic.NewClient(elastic.SetSniff(false), elastic.SetURL(host))
if err != nil {
panic(err)
}

info, _, err := client.Ping(host).Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("version %s\n", info.Version.Number)
fmt.Println("初始化完成,连接成功")
}
阅读全文 »

查看文件前5行

head -n 5 /tmp/tmpfile

查看文件后5行

tail -n 5 /tmp/tmpfile

从100行开始,显示200行,即显示100-299行

cat filename | tail -n +100 | head -n 200

显示100行到300行

cat filename | head -n 300 | tail -n +100

显示最后1000行

tail -n 1000

阅读全文 »