Author: jpuyy

  • centos6下查看RAID信息

    到 LSI 下载

    8.07.14_MegaCLI.zip

    centos7

    http://sarepos.cpanel.net/centos/7/noarch/MegaCli-8.07.14-1.el7.centos.noarch.rpm

    安装

    MegaCli-8.07.14-1.noarch.rpm
    Lib_Utils-1.00-09.noarch.rpm

    默认在 /opt/MegaRAID/MegaCli 目录下
    命令使用:

    #/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL 查raid级别
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL 查raid卡信息
    #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL 查看硬盘信息
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll 查看电池信息
    #/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog -Dsply -aALL 查看raid卡日志
    #/opt/MegaRAID/MegaCli/MegaCli64 -adpCount 【显示适配器个数】
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpGetTime –aALL 【显示适配器时间】
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll 【显示所有适配器信息】
    #/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LALL -aAll 【显示所有逻辑磁盘组信息】
    #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll 【显示所有的物理信息】
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL |grep ‘Charger Status’ 【查看充电状态】
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL【显示BBU状态信息】
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuCapacityInfo -aALL【显示BBU容量信息】
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuDesignInfo -aALL 【显示BBU设计参数】
    #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuProperties -aALL 【显示当前BBU属性】
    #/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL 【显示Raid卡型号,Raid设置,Disk相关信息】

  • mkfifo+nc进行端口转发

    需求:

    服务器 A 装了 redis,监听 127.0.0.1 6379
    服务器 B 要做 A 的 slaveof

    但是 A 不能服务,那么在 A 上可以做一些操作把端口8888放出来,让 B 能做 slaveof A公网ip:8888做复制。

    首先

    mkfifo fifo

    然后通过管道,及 fifo 将两个 nc 连起来

    nc -l 8888 < fifo | nc 127.0.0.1 6379 > fifo

    最后在 B 上直接 slaveof A公网ip:8888 即可。

    以上测试(两个 redis 版本一致情况下)通过。

    参考:

    http://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html

  • php数组合并merge

    来自官方示例

    $array1 = array("color" => "red", 2, 4);
    $array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
    $result = array_merge($array1, $array2);
    print_r($result);
    

    数组中有的标记了下标,有的没有标记下标(索引)

    有下标的将会沿用下标,如果下标相同,则会覆盖
    没有下标的,将会从0开始索引
    值不会覆盖

    结果

    Array ( [color] => green [0] => 2 [1] => 4 [2] => a [3] => b [shape] => trapezoid [4] => 4 )
  • php array-intersect取两个数组交集

    http://php.net/manual/en/function.array-intersect.php#84286

    后面的数组与第一个数组比较,返回交集是一个数组,且下标是第一个数组的下标

    $array1 = array(2, 4, 6, 8, 10, 12);
    $array2 = array(1, 2, 3, 4, 5, 6);
    
    var_dump(array_intersect($array1, $array2));
    var_dump(array_intersect($array2, $array1));
    
    

    结果

    array(3) { [0]=> int(2) [1]=> int(4) [2]=> int(6) }
    array(3) { [1]=> int(2) [3]=> int(4) [5]=> int(6) }

  • git查看清理gitignore的文件

    查看可以清理的文件

    git clean -ndX

    确定好之后要清理运行

    git clean -fdX

    查看 clean 的 help

    $ git help clean
    
    git-clean - Remove untracked files from the working tree
    -n, --dry-run - Don't actually remove anything, just show what would be done. 测试查看哪些文件可以被删除。
    -d - Remove untracked directories in addition to untracked files. 同时清理目录
    -X - Remove only files ignored by git. 清理被 ignored 的文件
    

    参考:

    http://stackoverflow.com/questions/466764/show-ignored-files-in-git

  • git删除commit

    删除最近的一次 commit

    git reset --hard HEAD~1

    git rebase -i HEAD~1

    使用 git log 的时候看到的 sha1 的提交

    git reset --hard 

    如果不幸已经提交,则需要如下操作将提交还原

    git push origin HEAD --force

    将所有修改还原

    git reset --hard HEAD

    经过上面的操作, commit 被删掉了,你做的工作也废了

    如果你只是想要撤回提交,但并不想把工作废掉,可以使用 –soft

    git reset --soft HEAD~1

    我错删了一个文件并提交,现在需要将这次的提交恢复

    git revert c588349186b8dc3d074d64eca1408d2966a30cdc

    然后显示如下信息,我可以写下为什么要收回这次提交

    Revert "delete no use .vimrc"
    
    This reverts commit c588349186b8dc3d074d64eca1408d2966a30cdc.
    
    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    # On branch master
    # Your branch is ahead of 'origin/master' by 1 commit.
    #   (use "git push" to publish your local commits)
    #
    # Changes to be committed:
    #       new file:   ubuntu/home/jpuyy/.vimrc
    

    然后这就变成了一次新的提交,但是返回到了之前的版本.

    参考:
    http://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git