find / -type f -size +500M -print0 | xargs -0 du -h
然后执行
echo "" > xxx.log
将空串写入文件
docker exec -it ${containerId} /bin/bash -c "wget https://arthas.aliyun.com/arthas-boot.jar && java -jar arthas-boot.jar"
Maven多模块工程打包指定模块工程执行如下命令:
mvn clean package -pl 指定模块工程名 -am
参数说明:
-am --also-make 同时构建所列模块的依赖模块;
-amd -also-make-dependents 同时构建依赖于所列模块的模块;
-pl --projects 构建制定的模块,模块间用逗号分隔;
-rf -resume-from 从指定的模块恢复反应堆。
// 暂存本地数据 git stash save -u "备注信息" // 查看暂存列表 git stash list // 恢复 git stash apply stash@{id} // 删除stash git stash drop stash@{id} // 查看 stash 的内容 git stash show git stash show stash@{id} git stash show -p
/** * 从请求体内取出数据,之后request里面就没有数据了,需要重新构造一个request * * @param serverHttpRequest * @return */ private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest) { //获取请求体 Flux<DataBuffer> body = serverHttpRequest.getBody(); StringBuilder sb = new StringBuilder(); body.subscribe(buffer -> { byte[] bytes = new byte[buffer.readableByteCount()]; buffer.read(bytes); DataBufferUtils.release(buffer); String bodyString = new String(bytes, StandardCharsets.UTF_8); sb.append(bodyString); }); return sb.toString(); }
docker container update --restart=always 容器名字
Redis配置文件修改(重要)
redis.conf 中daemonize=NO。非后台模式,如果为YES 会的导致 redis 无法启动,因为后台会导致docker无任务可做而退出。
启动命令
docker run --net=host --name redis --cpus=0.5 -m 256m -v /data/redis/redis.conf:/etc/redis.conf -v /data/redis/data:/data -d redis:alpine redis-server /etc/redis.conf --appendonly yes
cd /data/www/nginx/ // 限制cpu0.5 内存 最大128m docker run -itd --name nginx --cpus=0.5 -m 128m --memory-reservation=64m -v /data/crt:/data/crt -v $PWD/html:/etc/nginx/html -v $PWD/conf.d:/etc/nginx/conf.d -v $PWD/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/etc/nginx/logs --net=host nginx:alpine
安装包下载地址:
https://cloud.189.cn/web/share?code=Ff2aEvVfiqua(访问码:4b9b)
离线安装包下载地址
https://cloud.189.cn/web/share?code=B77zuqQrInu2(访问码:ct27)
yum提供了一种只下载安装包,但是不进行安装的方法:
yum install –downloadonly –downloaddir=/home/docker/dockerRpm docker rpm -ivh XXX.rpm --nodeps --force rpm -ivh container-selinux-2.21-2.gitba103ac.el7.noarch.rpm docker-ce-17.06.0.ce-1.el7.centos.x86_64.rpm --force --nodeps
//--nodeps 安装时不检查依赖关系
//--force 强制安装
// 开启服务
systemctl start docker
//开机自启docker服务 或 “chkconfig docker on” 命令
systemctl enable docker
修改DNS配置:
vi /etc/resolv.conf
添加:
nameserver 8.8.8.8
如果你之前安装过 docker,请先删掉
sudo yum remove docker docker-common docker-selinux docker-engine
安装一些依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
根据你的发行版下载repo文件:
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
把软件仓库地址替换为 TUNA:
sudo sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
最后安装:
sudo yum makecache fast sudo yum install docker-ce
安装固定版本:
yum install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.06.2.ce-1.el7.centos.x86_64.rpm
从根本解除nginx的限制,nginx默认request的header的那么中包含’_’时,会自动忽略掉。http部分中添加如下配置:underscores_in_headers on;(默认 underscores_in_headers 为off)
使用版本:7.8.0
docker pull kibana:7.8.0
配置文件的准备
mkdir -p /opt/elk7/kibana/config
vim /opt/elk7/kibana/config/kibana.yml
server.port: 5601 server.host: "0" elasticsearch.hosts: ["http://192.168.1.120:9200"] elasticsearch.username: "kibana_system" elasticsearch.password: "password" #i18n.locale: "en" i18n.locale: "zh-CN"
启动
docker run -itd --name=kib01 --restart=always -p 5601:5601 -v /opt/elk7/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml kibana:7.8.0
使用版本:7.8.0
docker pull elasticsearch:7.8.0
配置文件的准备
mkdir -p /home/elk7/es/config
vim /home/elk7/es/config/elasticsearch.yml
cluster.name: "docker-cluster" node.name: node-1 network.host: 0.0.0.0 http.port: 9200 cluster.initial_master_nodes: ["node-1"] http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization xpack.security.enabled: true xpack.security.transport.ssl.enabled: true
mkdir -p /home/elk7/es/data
chmod -R 777 /home/elk7/es/data
启动
docker run --name=es01 -itd -e ES_JAVA_OPT"-Xms1g -Xmx1g" -v /home/elk7/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/elk7/es/data/:/usr/share/elasticsearch/data/ -v /home/elk7/es/plugins:/usr/share/elasticsearch/plugins -p 9200:9200 -p 9300:9300 elasticsearch:7.8.0
可能出现的错误
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法1:
执行命令:
sysctl -w vm.max_map_count=262144
查看结果:
sysctl -a|grep vm.max_map_count
显示:
vm.max_map_count = 262144
上述方法修改之后,如果重启虚拟机将失效,所以:
解决办法:
在 /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
即可永久修改
解决办法2:
参考:Docker 部署 elasticsearch( ES开启了密码认证) - evescn - 博客园 (cnblogs.com)
# docker exec it es01 bash # elasticsearch-setup-passwords interactive Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user. You will be prompted to enter passwords as the process progresses. Please confirm that you would like to continue [y/N]y Enter password for [elastic]: Reenter password for [elastic]: Enter password for [apm_system]: Reenter password for [apm_system]: Enter password for [kibana_system]: Reenter password for [kibana_system]: Enter password for [logstash_system]: Reenter password for [logstash_system]: Enter password for [beats_system]: Reenter password for [beats_system]: Enter password for [remote_monitoring_user]: Reenter password for [remote_monitoring_user]: Changed password for user [apm_system] Changed password for user [kibana_system] Changed password for user [kibana] Changed password for user [logstash_system] Changed password for user [beats_system] Changed password for user [remote_monitoring_user] Changed password for user [elastic]
使用版本:7.8.0
docker pull logstash:7.8.0
配置文件
mkdir -p /opt/docker/logstash chmod 777 -R /opt/docker/logstash docker run -d --name logstash logstash:7.8.0 docker cp logstash:/usr/share/logstash/config ./config/ cd config/
编辑vim logstash.yml
pipeline.id: logstash-0 path.config: /usr/share/logstash/config/conf.d/*.conf path.logs: /usr/share/logstash/logs
在/opt/docker/logstash/config
目录下创建文件夹conf.d
mkdir conf.d && cd conf.d
新建或编辑vim logstash.conf
input { # 从文件读取日志信息 输送到控制台 file { path => "/logs/system/info/*.log" type => "system-info" start_position => "beginning" } file { path => "/logs/system/error/*.log" type => "system-error" start_position => "beginning" } } filter { json { source => "message" } } output { # 标准输出 # stdout {} # 输出进行格式化,采用Ruby库来解析日志 if[type]=="system-info"{ stdout { codec => rubydebug } elasticsearch { hosts => ["127.0.0.1:9200"] index => "system-info-%{+YYYY.MM.dd}" user => "logstash" password => "password" } } if[type]=="system-error"{ stdout { codec => rubydebug } elasticsearch { hosts => ["127.0.0.1:9200"] index => "system-error-%{+YYYY.MM.dd}" user => "logstash" password => "password" } } }
将日志输出目录授权一下
chmod 644 /logs/system/
启动
docker run -d \ --name=logstash \ --restart=always \ -p 5043:5044 \ -v /opt/docker/logstash/config:/usr/share/logstash/config \ -v /opt/docker/logstash/logs:/usr/share/logstash/logs \ -v /logs/system:/logs/system \ logstash:7.8.0
可能出现的错误情况
Encountered a retryable error. Will Retry with exponential backoff {:code=>403, :url=>"http://127.0.0.1:9200/_bulk"}
在kibana里面,重新建一个logstash用户可解决
TODO