美文网首页
运维杂事

运维杂事

作者: 六弦极品 | 来源:发表于2017-09-27 16:32 被阅读0次

    统计排序: sort | uniq

    awk '{print $1}' support_access_ssl.log |sort |uniq -c |sort -n
    

    查看网卡mac码

    # cat /sys/class/net/eth0/address
    

    ps查看进程cpu使用率,内存使用情况

    # ps -p 21603 -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid'
      PID COMMAND         COMMAND                     %CPU   RSZ    VSZ STIME USER       UID
    21603 java            /usr/local/services/java/bi  147 3355808 27326272 15:01 wwwuser 502             
    
    备注:rsz 实际使用内存3.3G    vsz 虚拟分配内存:27.3G
    

    centos 域名解析命令

    dig @114.114.114.114 www.baidu.com
    

    centos查找命令yum安装包

    yum whatprovides */lspci
    yum provides */nload
    

    获取系统版本

    rpm -q --queryformat '%{VERSION}-%{RELEASE}' centos-release
    uname -a
    cat /etc/redhat-release
    

    windows server 添加路由

    route add 192.168.0.0 mask 255.255.0.0 192.168.1.254 -p
    

    centos 添加静态路由

    ip route add 54.182.4.0/24 via 192.168.0.5
    ip route add 23.22.87.48 via 192.168.0.5
    

    SVN 版本库迁移

    1、导出: svnadmin dump oldRepository > dumpfile
    2、新建版本库: svnadmin create newRepostitory
    3、导入: svnadmin load newRepository < dumpfile
    

    硬件概念 :
    ① 物理CPU
    实际Server中插槽上的CPU个数
    物理cpu数量,可以数不重复的 physical id 有几个

    ② 逻辑CPU
    Linux用户对 /proc/cpuinfo 这个文件肯定不陌生. 它是用来存储cpu硬件信息的信息内容分别列出了processor 0 – n 的规格。这里需要注意,如果你认为n就是真实的cpu数的话, 就大错特错了,一般情况,我们认为一颗cpu可以有多核,加上intel的超线程技术(HT), 可以在逻辑上再分一倍数量的cpu core出来
    逻辑CPU数量=物理cpu数量 x cpu cores 这个规格值 x 2(如果支持并开启ht)
    备注一下:Linux下top查看的CPU也是逻辑CPU个数

    ③ CPU核数
    一块CPU上面能处理数据的芯片组的数量、比如现在的i5 760,是双核心四线程的CPU、而 i5 2250 是四核心四线程的CPU,一般来说,物理CPU个数×每颗核数就应该等于逻辑CPU的个数,如果不相等的话,则表示服务器的CPU支持超线程技术

    查看CPU信息:
    当我们 cat /proc/cpuinfo 时、具有相同core id的CPU是同一个core的超线程,具有相同physical id的CPU是同一个物理CPU封装的线程或核心

    下面举例说明
    ① 查看物理CPU的个数

    #cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l  
     2  
    

    ② 查看逻辑CPU的个数

    #cat /proc/cpuinfo |grep "processor"|wc -l  
     24  
    

    ③ 查看CPU是几核

    #cat /proc/cpuinfo |grep "cores"|uniq  
     6   
    

    这里应该是2个Cpu,每个Cpu有6个core,应该是Intel的CPU,支持超线程,所以显示24

    windows server 2008 查看SN码:

    wmic bios get serialnumber
    

    centos系统:

    查看服务器型号:dmidecode | grep 'Product Name'
    查看主板的序列号:dmidecode |grep 'Serial Number'
    查看系统序列号(SN码):dmidecode -s system-serial-number
    查看内存信息:dmidecode -t memory
    查看OEM信息:dmidecode -t 11
    

    查看网卡流量

    iftop -nN -i eth2
    

    lofs 命令:

    查看哪些进程在操作某个文件
    lsof   /filepath/file
    列出某个用户打开的文件信息
    lsof  -u username
    备注: -u 选项,u其实是user的缩写
    列出某个程序所打开的文件信息
    lsof -c MySQL
    

    iostat命令:磁盘io状态

    $ iostat -d -x -m 1 3
    Linux 2.6.32-573.3.1.el6.x86_64 (KX-M27-SupportMail-183)    09/28/2017  _x86_64_    (32 CPU)
    
    Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
    sda               0.24    86.21    1.64   23.15     0.12     0.43    45.59     0.06    2.34    2.72    2.31   1.57   3.88
    
    Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
    sda               0.00     0.00    0.00    1.00     0.00     0.00     8.00     0.01    6.00    0.00    6.00   6.00   0.60
    
    Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
    sda               0.00     0.00    0.00    2.00     0.00     0.01     8.00     0.01    4.00    0.00    4.00   4.00   0.80
    
    rrqm/s: 每秒进行 merge 的读操作数目。即 delta(rmerge)/s
    wrqm/s: 每秒进行 merge 的写操作数目。即 delta(wmerge)/s
    r/s: 每秒完成的读 I/O 设备次数。即 delta(rio)/s
    w/s: 每秒完成的写 I/O 设备次数。即 delta(wio)/s
    rsec/s: 每秒读扇区数。即 delta(rsect)/s
    wsec/s: 每秒写扇区数。即 delta(wsect)/s
    rkB/s: 每秒读K字节数。是 rsect/s 的一半,因为每扇区大小为512字节。(需要计算)
    wkB/s: 每秒写K字节数。是 wsect/s 的一半。(需要计算)
    avgrq-sz: 平均每次设备I/O操作的数据大小 (扇区)。delta(rsect+wsect)/delta(rio+wio)
    avgqu-sz: 平均I/O队列长度。即 delta(aveq)/s/1000 (因为aveq的单位为毫秒)。
    await: 平均每次设备I/O操作的等待时间 (毫秒)。即 delta(ruse+wuse)/delta(rio+wio)
    svctm: 平均每次设备I/O操作的服务时间 (毫秒)。即 delta(use)/delta(rio+wio)
    %util: 一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的。即 delta(use)/s/1000 (因为use的单位为毫秒)
    如果 %util 接近 100%,说明产生的I/O请求太多,I/O系统已经满负荷,该磁盘
    可能存在瓶颈。
    idle小于70% IO压力就较大了,一般读取速度有较多的wait.
    同时可以结合vmstat 查看查看b参数(等待资源的进程数)和wa参数(IO等待所占用的CPU时间的百分比,高过30%时IO压力高)
    

    查看是虚拟机还是物理机:

    $ sudo dmidecode -s system-product-name
    PowerEdge R720
    
    $ sudo dmidecode -s system-product-name
    Standard PC (i440FX + PIIX, 1996)
    
    $ sudo dmidecode -s system-product-name
    VMware Virtual Platform
    

    删除多个文件,文件名中包含空格或其他特殊字符:

    find /data/www/faryaa/api/logs/label/ -maxdepth 1 -mtime +33 -type f -print0 |xargs -0 ls -l
    find /data/www/faryaa/api/logs/label/ -maxdepth 1 -mtime +33 -type f -print0 |xargs -0 rm -f
    

    http://lidao.blog.51cto.com/3388056/1915449

    安装mysqlnd驱动
    编译php时,修改以下几个项参数即可, 如果使用mysqlnd,并不需要预先安装mysql

    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    

    查看php编译参数:

    php -r "phpinfo();" | grep configure  或 php -i |more
    

    批量删除大量文件

    空目录:/home/wwwuser/test/blank/  
    $ find 2014/201404 -type f |wc -l
    350006
    $ time rsync --delete-befor -d /home/wwwuser/test/blank/ /data/ebay/2014/201404/
    real    0m9.485s
    user    0m0.499s
    sys     0m8.066s
    
    $ find 2014/ -type f |wc -l
    4636134
    $ time rsync --delete-befor -d /home/wwwuser/test/blank/ /data/ebay/2014/
    real    6m5.550s
    user    0m8.524s
    sys     2m9.601s
    

    硬盘同步进度:

    $ omreport storage pdisk controller=0 |grep Progress
    Progress                        : Not Applicable
    Progress                        : Not Applicable
    Progress                        : Not Applicable
    Progress                        : 97% Complete
    
    

    查看dell 关闭 numa

    yum install numactl  perl  -y
    numactl  --hardware
    

    已关闭截图:

    $ numactl --hardware
    available: 1 nodes (0)
    node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    node 0 size: 65442 MB
    node 0 free: 899 MB
    node distances:
    node   0 
      0:  10 
    $ free -h
                 total       used       free     shared    buffers     cached
    Mem:           62G        62G       885M       1.6M       146M        26G
    -/+ buffers/cache:        35G        27G
    Swap:          62G        18M        62G
    

    未关闭截图:

    $ numactl --hardware
    available: 2 nodes (0-1)
    node 0 cpus: 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
    node 0 size: 32722 MB
    node 0 free: 182 MB
    node 1 cpus: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31
    node 1 size: 32768 MB
    node 1 free: 1904 MB
    node distances:
    node   0   1 
      0:  10  20 
      1:  20  10 
    [liuzhousheng@KX-M27-SupportMail-183 ~]$ free -h
                 total       used       free     shared    buffers     cached
    Mem:           62G        60G       2.1G       2.5M       1.9G        25G
    -/+ buffers/cache:        33G        29G
    Swap:          31G         0B        31G
    
    

    进程启动时间运行时间

    for i in `ps aux |grep "auto_message.php" |grep -v grep |awk '{print $2}'`;do ps -eo pid,lstart,etime |grep $i ;done
    

    压缩:

    tar.xz格式
    
    方式一:利用已经打包好的tar文件,直接用压缩命令:
    压缩:xz [原文件名].tar
    解压:unxz [原文件名].tar.xz
    
    方式二:一次性打包并压缩、解压并解包
    打包并压缩: tar -Jcvf [目标文件名].tar.xz [原文件名/目录名]
    解压并解包: tar -Jxvf [原文件名].tar.xz
    注:大写J代表用xz算法来压缩/解压。
    
    $ dd if=/dev/zero of=tmp.1G bs=10M count=100
    $ tar -Jcvf tmp.1G.xz tmp.1G
    
    $ du -sh ./*
    124K    ./php-error.log
    1001M   ./tmp.1G
    152K    ./tmp.1G.xz
    

    相关文章

      网友评论

          本文标题:运维杂事

          本文链接:https://www.haomeiwen.com/subject/ujuuextx.html