Blog

  • 追踪java 程序中的线程执行情况

    当我们希望观察java程序运行的堆栈情况,多次执行jstack,或者通过cpu 采用发现某个线程都在同一个函数函数.

    这可能是两种情况引起的:

    1. 在这个线程中,这个函数是高频函数.
    2. 线程当前阻塞在这个函数上.

    Linux中没有真正的线程,java线程是由进程来模拟实现的. 这种进程又称作:轻量级进程(LWP).

    因此可以通过strace -p 追踪其运行情况,来区分以上两种情况.

    但是通过ps -ef或者jps只能看到java程序的pid. 如果需要追踪线程,可以jstack查找线程的pid.

    线程第一个行中的 nid字段,就是该线程pid的16进制表示. 转化为10进制即可.

    例如下面,线程显示在执行io上,读数据相对这个操作是比重多的. 但是是频繁执行io,还是文件系统出现问题,卡在io上,这是无法区分. 就可以这样追踪一下.

    (more…)

  • rpm 与 yum 常用查询功能

    [TOC]

    例如查询ceph rados 命令的依赖包

    ldd /usr/bin/rados |awk '{print $3}'|grep '^/' |xargs -i  rpm -qf {}|xargs -i rpm -qi {} |grep ceph -B 10 -A 10
    

    rpm 查询

    rpm -qf 查询文件来源于那个package

    [root@localhost ~]# rpm -qf /usr/bin/rados
    ceph-common-10.2.10-0.el7.x86_64
    

    rpm -qi 查询rpm package 信息

    rpm -qi ceph-common
    Name        : ceph-common
    Epoch       : 1
    Version     : 10.2.10
    Release     : 0.el7
    Architecture: x86_64
    Install Date: Sat 23 May 2020 04:12:25 PM CST
    Group       : System Environment/Base
    Size        : 62321887
    License     : LGPL-2.1 and CC-BY-SA-1.0 and GPL-2.0 and BSL-1.0 and GPL-2.0-with-autoconf-exception and BSD-3-Clause and MIT
    Signature   : RSA/SHA1, Mon 13 Nov 2017 05:33:12 PM CST, Key ID d4a2e50be451e5b5
    Source RPM  : ceph-10.2.10-0.el7.src.rpm
    Build Date  : Wed 18 Oct 2017 11:04:07 PM CST
    Build Host  : c1bj.rdu2.centos.org
    Relocations : (not relocatable)
    Packager    : CBS <cbs@centos.org>
    Vendor      : CentOS
    URL         : http://ceph.com/
    Summary     : Ceph Common
    Description :
    Common utilities to mount and interact with a ceph storage cluster.
    Comprised of files that are common to Ceph clients and servers.
    

    rpm -qR 查询package 依赖

    [root@localhost ~]# rpm -qR ceph-common
    /bin/bash
    /bin/sh
    /bin/sh
    /bin/sh
    /bin/sh
    /usr/bin/env
    config(ceph-common) = 1:10.2.10-0.el7
    ld-linux-x86-64.so.2()(64bit)
    ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)
    libbabeltrace-ctf.so.1()(64bit)
    libbabeltrace.so.1()(64bit)
    libblkid.so.1()(64bit)
    libblkid.so.1(BLKID_1.0)(64bit)
    ...
    

    rpm -qa 查找所以

    [root@localhost ~]# rpm -qa |grep ceph
    centos-release-ceph-jewel-1.0-1.el7.centos.noarch
    libcephfs1-10.2.10-0.el7.x86_64
    python-cephfs-10.2.10-0.el7.x86_64
    ceph-common-10.2.10-0.el7.x86_64
    

    rpm -q

    [root@localhost ~]# rpm -q ceph-common
    ceph-common-10.2.10-0.el7.x86_64
    [root@localhost ~]# rpm -q ceph-common-10.2.10-0.el7.x86_64
    ceph-common-10.2.10-0.el7.x86_64
    [root@localhost ~]# rpm -q ceph-common-10.2.10-0.el7
    ceph-common-10.2.10-0.el7.x86_64
    

    yum 查询

    yum 查询软件可用版本

    [root@localhost ~]# yum list ceph-common --showduplicates
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.njupt.edu.cn
     * centos-qemu-ev: mirrors.ustc.edu.cn
     * extras: mirrors.dgut.edu.cn
     * updates: mirrors.dgut.edu.cn
    Installed Packages
    ceph-common.x86_64      1:10.2.10-0.el7  @centos-ceph-jewel
    Available Packages
    ceph-common.x86_64      1:10.2.5-4.el7   base
    ceph-common.x86_64      1:10.2.7-0.el7   centos-ceph-jewel
    ceph-common.x86_64      1:10.2.10-0.el7  centos-ceph-jewel
    

    yum 查询软件需要的依赖

    [root@localhost ~]#  yum deplist ceph-common
    
    Loaded plugins: fastestmirror
    Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
    Loading mirror speeds from cached hostfile
     * base: mirrors.njupt.edu.cn
     * centos-qemu-ev: mirrors.ustc.edu.cn
     * extras: mirrors.dgut.edu.cn
     * updates: mirrors.dgut.edu.cn
    package: ceph-common.x86_64 1:10.2.10-0.el7
      dependency: /bin/bash
       provider: bash.x86_64 4.2.46-34.el7
      dependency: /bin/sh
       provider: bash.x86_64 4.2.46-34.el7
      dependency: /usr/bin/env
       provider: coreutils.x86_64 8.22-24.el7_9.2
      dependency: ld-linux-x86-64.so.2()(64bit)
       provider: glibc.x86_64 2.17-324.el7_9
      dependency: ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)
       provider: glibc.x86_64 2.17-324.el7_9
    
  • 笔记_CPU缓存知识

    记录一下 cpu cache 相关内容

    (more…)

  • git merge,rebase,reset

    老分不清怎么用git merge 与 rebase 区别.
    撤回的时候使用git reset 又忘了具体参数.

    git log

    显示提交的详细信息

    commit 2ec3438b5c53932e928ec4284c5121acb86f2abb (HEAD -> mdfs-ng, origin/mdfs-ng)
    Author: #小辉辉 <xxxx.com>
    Date:   Tue Apr 17 17:30:22 2018 +0800
    
        clear : del unused code
    

    git log –pretty=oneline

    只显示commit id和提交的描述信息

    2ec3438b5c53932e928ec4284c5121acb86f2abb (HEAD -> mdfs-ng, origin/mdfs-ng) clear : del unused code
    8a78c5779328d2e48826b9203a50d596d508392f update : clear code by sonar
    

    git reflog

    可以查看所有分支的所有操作记录.包括已经删除commit记录

    2a84922 HEAD@{158}: checkout: moving from hui-comment to devel
    0d0b108 (master, hui-comment) HEAD@{159}: checkout: moving from master to hui-comment
    

    HEAD

    HEAD 意义
    HEAD 提交的最新版本
    HEAD^ 上一个版本
    HEAD^^ 上上个版本
    HEAD~100 往上100个版本
    HEAD@{index} 提交索引

    git reset

    git reset --hard HEAD@{2}
    

    git commit –amend

    修改已经提交的信息

    git rebase

    合并

    1. 合并1~3条提交
      git rebase -i HEAD~3
      
      pick dc44d6b 根据sonar修改FixedLenChunkFingerIndexDB
      pick 8a78c57 update : clear code by sonar
      pick 2ec3438 clear : del unused code
      
      #将pick改为squash或者s,之后保存并关闭文本编辑窗口即可
      pick dc44d6b 根据sonar修改FixedLenChunkFingerIndexDB
      s 8a78c57 update : clear code by sonar
      s 2ec3438 clear : del unused code
      
    2. 指名要合并的版本之前的版本号
      git rebase -i 0d0b108
      
    3. 遇到冲突需要使用
      git add .  
      git rebase --continue  
      
    4. 取消
      git rebase --abort
      

    Merging vs. Rebasing

    The first thing to understand about git rebase is that it solves the same problem as git merge.

    The Merge Option

    git checkout feature
    git merge master
    #Or, you can condense this to a one-liner:
    git merge master feature
    

    The Rebase Option

    git checkout feature
    git rebase master
    

    参考

    (Git)合并多个commit

    7. 用rebase合并
    Merging vs. Rebasing

  • outline accesskey format

    ss://base64(method:passwod)@server-address:port