工作中笔记

1 机器内存配置

临时配置

pssh -i -h hostlist.txt ‘sudo su - root -c “echo 2048000 > /proc/sys/vm/min_free_kbytes”’

永久配置

pssh -i -h hostlist.txt “sudo su - root -c ‘sed -i “s#vm.min_free_kbytes = 90112#vm.min_free_kbytes = 2048000#” /etc/sysctl.conf’”
sysctl -p

pssh -i -h hostlist.txt -t 0 “sudo su - root -c ‘echo vm.min_free_kbytes = 2048000 >> /etc/sysctl.conf’”
pssh -i -h hostlist.txt -t 0 “sudo su - root -c ‘sysctl -p’”
pssh -i -h hostlist.txt “cat /proc/sys/vm/min_free_kbytes” | grep 2048000 | wc -l
pssh -i -h hostlist.txt “cat /etc/sysctl.conf” | grep vm.min_free_kbytes

2 磁盘检查

pssh -i -h hostlist.txt df -m /opt/huawei/data[1234] | awk ‘$4 < 1419200{print}’

3 清理机器缓存

pssh -i -h minion_ip_engine.txt -t 0 “sudo su - root -c ‘sync; echo 3 > /proc/sys/vm/drop_caches’”

#替换命令
cat hostlist.txt | tr “\n” “,”

4 CPU

cat /proc/cpuinfo | grep name | cut -f0 -d: | uniq -c cpu逻辑个数
cat /proc/cpuinfo |grep “cores” 每个CPU核心数

5 sed

13 sed
    流编辑器,其实就是写好一些指令脚本,然后让一个文本流输入进来
    通过编辑器的命令修改之后转化为另一个文本流
    sed option 'script' file1 file2 ...             sed 参数  ‘脚本(/pattern/action)’ 待处理文件
    sed option -f scriptfile file1 file2 ...            sed 参数 –f ‘脚本文件’ 待处理文件
    sed -i ...-i表示将文本修改的内容重新写回去
        p,  print           打印
            sed '1p'      打印第一行
        a,  append          追加
            sed '3a aaa'  在第三行后面追加aaa
        i,  insert          插入
            sed '3i aaa'  在第三行前面插入aaa
        d,  delete          删除

        s,  substitution    替换
            符合什么内容就替换
            sed 's/123/789'123替换为789




        sed '行号+操作'
        sed '/匹配模式/操作'



        干掉 html的标签
        <html><head><title>Hello World</title></head>          
        <body>Welcome to the world of regexp!</body></html>

        sed ' s/<\w*>//g ; s###g' test.html

            将匹配 正则 <\w*>的字符串都替换为空字符串
            将匹配 正则 </\w*>的字符串都替换为空字符串  




sed -i 's/--queryFeHost=10.189.40.125/--queryFeHost=10.188.251.212/g' /opt/huawei/data2/instance_themes/run/qrwt.gflags
sed -i "s#--queryFeUrl=/lightning/SparkleSearchImage/query_fe/0#--queryFeUrl=/lightning/searchonline/image_query_fe/1.0.0#" /opt/huawei/data2/instance_themes/run/qrwt.gflags

sed -i "469c --tag_switch=0" /opt/huawei/data1/instance1/run/config.gflags

sed -i '$a* pe\t true ' /opt/huawei/data1/imgsrch_merger_RuleData/intervene_all_search_immerse_file.txt

6 atop

# 进入atop 文件目录
cd /var/log/atop

# 按时间排序文件
ls -1t
#显示如下
atop_20220614
dummy_after
dummy_before
daily.log
atop_20220613
atop_20220612
atop_20220611
atop_20220610
atop_20220609
atop_20220608
atop_20220607
atop_20220606

# 找对应时间的文件
atop -r atop_20220613

# 输入b,进入交互式界面

# 输入时间,如10:00
# 跳转到指定时间的界面

# 输入g, 按照cpu 排序,查看那个程序的cpu 占用率比较高



快捷键	说明
b	输入时间,格式为"12:23"(时:分)
t	前进 10s
T	后退 10s
g	按 CPU 使用率排序,默认排序方式
m	按内存使用率降序排列
d	按磁盘使用率降序排列
y	查看线程信息
j	查看 container 聚合信息
c	查看详细的 command line
l	定制化查看每个 CPU 核/每个磁盘/每个网卡的信息
f	展示全局指标中 fixed 的指标
Q	根据进程状态过滤,如 R|S|D|Z 等
I	按照 PID 进行搜索(注:大写的 i)

原文链接:https://blog.csdn.net/ByteDanceTech/article/details/122007542

# 7 
netsh interface portproxy add v4tov4 listenaddress=172.16.0.253 listenport=20000 connectaddress=127.0.0.1 connectport=10001
export http_proxy=http://172.16.0.253:20000
export https_proxy=http://172.16.0.253:20000

# 8 端口映射
ssh -L 192.192.100.44:9902:127.0.0.1:9902 root@localhost

# 9 launch.json

```c
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "envoy",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/bazel-bin/envoy",
      "args": [
        "-c",
        // "${workspaceFolder}/config/waf.yaml"
        // "${workspaceFolder}/config/web_socker.yaml"
        "${workspaceFolder}/config/xds.yaml"
      ],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "sourceFileMap": {
        "/root/.cache/bazel/_bazel_root/44290b59dab7a3ce9c46b1b308b992bb/execroot/envoy_filters": "${workspaceFolder}"
      },
      "setupCommands": [
        {
          "description": "为 gdb 启用整齐打印",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        },
        {
          "description": "将反汇编风格设置为 Intel",
          "text": "-gdb-set disassembly-flavor intel",
          "ignoreFailures": true
        }
      ]
    },
    {
      "name": "C/C++ Runner: Debug Session",
      "type": "cppdbg",
      "request": "launch",
      "args": [],
      "stopAtEntry": false,
      "externalConsole": false,
      "cwd": "/root/envoy-filters/filters/source/extensions/filters/http/strong_global_ratelimit",
      "program": "/root/envoy-filters/filters/source/extensions/filters/http/strong_global_ratelimit/build/Debug/outDebug",
      "MIMode": "gdb",
      "miDebuggerPath": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }
  ]
}

你可能感兴趣的:(linux,运维,服务器)