cat /etc/os-release | grep "^ID=" | awk -F= '{print $2}' | tr -d [:punct:]
cat /etc/os-release | grep "VERSION_ID=" | awk -F= '{print $2}' | tr -d [:punct:]
系统信息 查看内核信息 uname -r 查看 CPU 信息 cat /proc/cpuinfo 查看内存使用情况 lscpu free -h cat /proc/meminfo 查看系统运行时间 uptime who -b # 最近一次启动时间 dos2unix file :set ff=unix
find / -size +500M 找出最大文件
du -h --max-depth=1 /XXX 查看某个目录下 每个文件的大小.
查找大量小文件的目录
# 查看哪些目录下文件数量最多(需要在/vdb1分区内执行)
cd /vdb1
for dir in */; do echo -n "$dir: "; find "$dir" -type f | wc -l; done
# 清理30天前的临时文件(请确认路径正确性)
find /vdb1/tmp -type f -mtime +30 -delete
# 清理旧日志(谨慎操作,确保不影响系统运行)
find /vdb1/var/log -name "*.log.*" -type f -delete
# 清理无用的镜像和卷
docker system prune -a
一键清理所有无效资源(推荐)
docker image prune -a
docker system prune
docker ps -a --filter "status=exited"
docker system prune -f --volumes
docker system prune --volumes
docker images -f "dangling=true"
docker images | grep aeon | awk '{print $3}' | xargs docker rmi -f
建立用户
mkdir -p /data/pos-work
groupadd posgroup
useradd -g posgroup pos -d /data/pos-work
passwd pos
密码: Pos&Dev&2025
这是目录权限
chown -R pos:posgroup /data/pos-work
sudo visudo -c && echo "pos ALL=(ALL:ALL) ALL" | tee -a /etc/sudoers && echo "pos ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers
生成49位随机数
cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 49;echo
docker cp [本地文件/目录路径] [容器名或容器ID]:[容器内目标路径]
firewall-cmd --zone=public --add-port=9999/tcp --permanent firewall-cmd --reload sudo systemctl start firewalld sudo systemctl stop firewalld sudo systemctl disable firewalld
timeout 10 bash -c "</dev/tcp/192.168.0.1/8080" 2>/dev/null && echo "通" || echo "不通"
nc -v 192.168.0.1 8080
telnet 192.168.0.1 8080
主要用于诊断网络连接问题: tracepath [目标主机/IP]
traceroute [目标主机/IP]
curl -H "http://39.103.177.212:30082/tools/libcrypto.so.10 " -so "fastdeploy-linux"
curl -so /lib64/libssl.so.10 http://39.103.177.212:30082/tools/libssl.so.10
curl -so /lib64/libcrypto.so.10 http://39.103.177.212:30082/tools/libcrypto.so.10
tracepath
网卡详情
ifconfig -a
对于window: ipconfig -a
DHCP 拿到的详细信息(DNS、domain、router 等)
ipconfig getpacket en0 # en0 通常是 Wi-Fi,有线可能是 en1
查询域名解析
nslookup 域名
nslookup itor.westlakeerp.com 8.8.8.8
路由追踪前 10 跳
traceroute -n -m 10 域名
对应 Windows 的 tracert -d -h 10
这里是关于数据库技术的内容...
分配权限
GRANT SELECT, INSERT,UPDATE,DELETE,CREATE,INDEX,ALTER,CREATE VIEW,SHOW VIEW ON reportdb.* TO roc;
查看所有连接
select * from information_schema.processlist;
kill id值
会话状态
SELECT * FROM information_schema.SESSION_STATUS;
根据ip看连接
SELECT LEFT(HOST, INSTR(HOST, ':')-1) client_ip, COUNT(*) cnt FROM information_schema.processlist GROUP BY client_ip ORDER BY cnt DESC;
设置超时时间:
单位:微秒
SET ob_query_timeout=20000000;
60秒
set global ob_query_timeout=60000000;
120秒
set global ob_query_timeout=120000000;
300秒
set global ob_query_timeout=3000000000;
查看
SHOW VARIABLES LIKE 'ob_query_timeout';
kubectl rollout restart deploy -n roc-uat roc-goods
kubectl -n roc-uat scale deployment roc-goods --replicas=1
kubectl -n roc-uat set image deployment roc-goods roc-goods=版本号
kubectl -n roc-uat logs -f --tail --n 200 roc-goods
kubectl -n roc-uat logs -f --tail 200 roc-goods
kubectl -n roc-uat get pods |grep Evicted | awk '{print $1}' | xargs kubectl -n roc-uat delete pod 删除大量evicted的pod
docker cp ab5593917446:/home/admin/logs/supervisor/error.log ./ 从容器中复制文件到本地
kubectl cp <namespace>/<pod>:<root_dir>/<parent_dir>/<file_name> ./<file_name> 从 pod 容器复制文件到本地
kubectl cp ./<file_name> <namespace>/<pod>:/<root_dir>/<parent_dir>/<file_name> 从本地复制到 pod 容器
批量删除这些标签为none的镜像
docker rmi $(docker images -f "dangling=true" -q)
docker rmi -f $(docker images -f "dangling=true" -q)
kubectl -n pos-uat exec -it pos-pay-68f6497f55-kpqvj -- curl http://roc-card-api.roc-uat:80/ocm-valuecard-webin/rest?method=efuture.ocm.info.main.auth
{"timestamp":"2025-08-29T02:29:07.782+00:00","status":405,"error":"Method Not Allowed","message":"","path":"/ocm-valuecard-webin/rest"}[root@cce-ec-test-nodepool-61711-akhzj ~]#
echo 'alias kb="kubectl"' >> ~/.bashrc && source ~/.bashrc
kubectl -n pos-uat delete pod pos-order-5b58966559-5f5sp --grace-period=0 --force --wait=false
批量生成需要重启的pod命令
kubectl get pods -n roc-uat -o=jsonpath='{range .items[*]}{"kubectl rollout restart deploy -n roc-uat "}{.metadata.labels.app}{"\n"}' > pod-restart.log
kubectl get pods -n wms-prod -o=jsonpath='{range .items[*]}{"kubectl rollout restart deploy -n wms-prod "}{.metadata.labels.app}{"\n"}'
kb -n pos-prod top pod --sort-by=memory
kb -n pos-pbs top pod --sort-by=memory
kb -n pos-prod top pod --sort-by=memory | tail -n +2 | sort -k3 -h
kubectl -n roc-uat exec -it msc-datalink-7455d5b9bf-gfwkm -- timeout 10 bash -c "/dev/null && echo "通" || echo "不通"
kubectl -n pos-prod get cm conf-env-center -o jsonpath='{.data.CONFIG_SKYWALKING_ENABLE}'
kubectl -n pos-prod patch configmap conf-env-center -p '{"data":{"CONFIG_SKYWALKING_ENABLE":"true"}}'
server {
listen 9999;
server_name localhost;
charset utf-8;
location ~ / {
proxy_next_upstream http_503 http_500 http_502 http_404 error timeout invalid_header;
expires -1;
proxy_pass http://192.168.0.1;
}
}
server {
listen 9092;
server_name localhost;
location ~ /nacos {
proxy_next_upstream http_503 http_500 http_502 http_404 error timeout invalid_header;
expires -1;
proxy_pass http://192.168.0.1;
}
}
server {
listen 9093;
server_name localhost;
location ~ /xxl-job-admin {
proxy_next_upstream http_503 http_500 http_502 http_404 error timeout invalid_header;
expires -1;
proxy_pass http://192.168.0.1;
}
}
server {
listen 6901;
server_name localhost;
location ~ / {
proxy_next_upstream http_503 http_500 http_502 http_404 error timeout invalid_header;
expires -1;
proxy_pass http://192.168.0.1;
}
}
server {
listen 7298;
server_name localhost;
location ~ /rocketmq {
proxy_next_upstream http_503 http_500 http_502 http_404 error timeout invalid_header;
expires -1;
proxy_pass http://192.168.0.1;
}
}
server {
listen 9192;
server_name localhost;
location / {
root /data/sftp;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset utf-8;
}
}
这里是关于数据库技术的内容...
4N11294&
418#48r5