开发、运维操作实用技巧
目录
将本地镜像复制到远程机器,直接导入 docker,无中间文件
docker save edgexfoundry/device-s7:0.0.0-dev | gzip | ssh -C 192.168.123.35 docker load
将当前目录下所有的视频文件合并为一个 mp4
ffmpeg -f concat -safe 0 -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy output.mp4
Localtunnel under Apache Httpd
<VirtualHost *:80>
ServerName t.abc.cn
ServerAlias *.t.abc.cn
RewriteEngine On
ProxyPassMatch ^/(.*)$ http://localhost:3081/$1
ProxyPassReverse / http://localhost:3081/
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://localhost:3081%{REQUEST_URI} [P]
ProxyPreserveHost On
ProxyRequests On
</VirtualHost>
从 docker container 中获取配置,并打印需要的内容
docker exec -it zlmediakit cat /opt/media/conf/config.ini | grep secret| awk -F'=' '{print $2}'
FRP server config in nginx
server {
listen 80;
listen [::]:80;
root /var/www/html/t.abc.cn;
server_name .t.abc.cn;
location / {
proxy_pass http://localhost:8888;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Docker 私有 Registry 实操
0、增加新的 IP 地址解析
more /etc/hosts
121.1.1.251 hub.abc.cn
1、修改 docker 配置文件
more /etc/docker/daemon.json
{
"insecure-registries" : [ "0.0.0.0/0" ]
}
2、重启 docker
systemctl restart docker
3、拉取镜像 image
docker pull ...
远程连接 ssh 通过 socks5
1、启动 socks 服务,监听 9898
ssh -D 0.0.0.0:9898 1.1.1.1
2、连接 ssh 通过 socks
ssh -o "ProxyCommand=nc -X 5 -x 192.168.123.33:9898 %h %p" 121.1.1.68
Linux 下断点续传文件
rsync -av --partial --progress model_server.tar.gz gust@50.5.0.9:/tmp/
通过网络修改系统时间
sudo date -s "$(curl -H'Cache-Control:no-cache' -sI google.com | grep '^Date:' | cut -d' ' -f3-6)Z"
Ubuntu 自动连接 4G LTE 网卡
nmcli device connect cdc-wdm0
会产生一个 /etc/NetworkManager/system-connections/cdc-wdm0.nmconnection
文件,重启 NetworkManager
即可
systemctl restart NetworkManager
docker 一次性导出所有需要的 image
docker images --format "{{.Repository}}:{{.Tag}}" |grep hub > images.txt
image list
...
output=$(awk '{printf "%s ", $0}' images.txt)
docker save $output | gzip > all-images.tar.gz