zoukankan      html  css  js  c++  java
  • 【每日进步】April 2012

    ------------------------------------------------- 2012/04/25 周三-----------------------------------------

    Linux:

    1. tar -zcvf *.tar.gz *得到的文件tar.gz是压缩(-z)和归档(-c)文件,不能追加文件

    如果希望追加,不要使用-z -j选项 即:tar -cvf *.tar.gz *

    2. 使用ssh提交单个命令时有时执行结束后不会自动退出:命令后面加上0</dev/null 1>/dev/null 2>/dev/null,保证ssh提交任务后退出

    3. 修改bash的行编辑模式为vi, 并对所有用户有效:修改/etc/bash.bashrc 添加set -o vi

    4. ubuntu11.10 有个bug,设定好的resolv.conf在重启后会自动被清空,试过使用rc2脚本修改该文件,重启后还是会被清空。现在的解决方法是sudo chattr +i /etc/resolv.conf 重启后不再被清空。

    5. chattr lsattr, 修改查看linux文件系统的文件属性

    6. 自定义bash的prompt,修改环境变量PS1。可使用的转意符号及可以用的颜色值见如下参考链接,目前使用的设置为:

    PS1="\[\e[1;31m\][\d \t]\[\e[1;32m\]\u\[\e[0m\]@\[\e[4;32m\]\h\[\e[0m\]\[\e[1;35m\]:\W\[\e[0m\]\$ \[\e[0;37m\]"

    参考:https://wiki.archlinux.org/index.php/Color_Bash_Prompt   http://www.linuxselfhelp.com/howtos/Bash-Prompt/Bash-Prompt-HOWTO-2.html  

    7. C里面查看CPU affinity,使用sched_getaffinity获得、CPU_ISSET检查,CPU_ISSET等宏需要在#include <sched.h>前定义如下宏:

    #define __USE_GNU

    然后使用sysconf(_SC_NPROCESSORS_CONF)获得系统cpu个数,循环使用CPU_ISSET检查。

    参考:http://www.chinaunix.net/jh/4/904906.html  

    8.  理解/proc/cpuinfo:如果cpu cores = siblings 表明超线程OFF,否则超线程是开启的,会出现多个逻辑CPU的physical 和 core id 是相同的。

    physical id 与 core id 未必是连续的值,

    使用如下命令查看以上信息:cat /proc/cpuinfo | egrep 'processor|model name|cache size|core|sibling|physical'

    参考: http://www.richweb.com/cpu_info   

    9. 在.bashrc中修改已存在的环境变量时,如PATH,使用PATH=。。。即可,但如果是添加新的环境变量需要使用export,如果使用前一种方法,得到的变量只对shell有效,echo 时也会正确显示,但并不会传递给子进程。如:

    在.bashrc 中添加 MYENV=~/xxxx, 在shell中输入echo $MYENV 会正确显示,但运行的命令不会继承。

    10.  目录的rwx权限含义与文件的不同,r表示是否可以list文件列表,w可修改目录中的文件/子目录,x能否进入该目录

    11. chattr,lsattr仅对ext2及以上的fs有效,其他文件系统如nfs,会出现lsattr: Inappropriate ioctl for device While reading flags on

    Torque, Maui:

    1. Resource Management System : OpenPBS(现在的torque前身), PBSPro, Loadleveler, SGE, etc.

    2.Maui is a scheduler, it makes decisions about where, when, and how to run jobs as specified by a set of configurable policies, priorities, and limits.  It makes and enforces its decisions by querying and controlling a resource management system such as OpenPBS, PBSPro, Loadleveler, SGE, etc.

    3. PBS 的queue与server的resources_(default, max, min, available, assigned)等属性

    4. 使用PBS提交了一个需要1节点2CPU的程序,提交后一直处于Q状态,一开始怀疑系统中资源不够用了,pbsnodes 查看,集群中有53节点处于free状态,调查后发现是权限不够,Maui的控制文件maui.cfg中的 USERCFG 控制用户的资源使用权限,我使用的用户MAXPROC=1,导致资源申请不到。

    5. Maui从3.2开始支持资源预留,setres showres使用这些命令需要相关权限

    SSH, SFTP, Windows:

    1. 需要在windows操作Linux服务器,使用SecureCRT + WInSCP 这两个软件试过,很好用

    Perl:

    1. 三种数据类型 对应标量、数组、hash

    2. 多维数组定义 my @arr = ([], []....); 第一次使用弄混了括号,结果报错

    3. 其他各种维度的数组,我是使用for循环一步一步生成的,未找到简单的方法:

    这种方式算是C中数据结构形式,Perl中有没有别的方式处理未知。

    for(my $i = 0; $i < 3; $i++)
    {
     my @tmpj;
     for(my $j = 0; $j < 3; $j++)
     {
      $tmpj[$j] = 0;
     }
     $total[$i] = [@tmpj];
    }
    

      

     

    4. 文件处理 open close

    5. 划分字符串 split 类似于strtok,不过强大多了

    6. 使用RE处理字符串问题、验证字符串是否为数字 =~ !~

    7. 自定义函数 sub 参数存放在$_中,结果返回可以使用return,也可以是最后一条指令的返回值(没试过)

    8. next if...;类似于C中的 if...continue;

    ------------------------------------------------- 2012/04/26 周四-----------------------------------------

    Linux,MPI:

    1. taskset 来做 processor affinity, 运行结果:

    $ mpirun -n 3 taskset -c 0 ./a.out : -n 2 taskset -c 1 ./a.out
    hostname[hadoop16], rank[2/5], processor affinity[1]
    hostname[hadoop16], rank[4/5], processor affinity[2]
    hostname[hadoop16], rank[3/5], processor affinity[2]
    hostname[hadoop16], rank[0/5], processor affinity[1]
    hostname[hadoop16], rank[1/5], processor affinity[1]
    以上结果运行在单个节点,两个CPU
    若需要在多个节点使用Processor affinity,在machinefile中可以重复设置节点,如每个节点两个CPU,可写为如下:
    hadoop3
    hadoop4
    hadoop3
    hadoop4

    运行命令:$ mpirun -machinefile mfile -n 2 taskset -c 0 ./a.out : -n 2 taskset -c 1 ./a.out
    hostname[hadoop3], rank[0/4], processor affinity[1]
    hostname[hadoop3], rank[2/4], processor affinity[2]//mpd按mfile顺序分配rank,所以hadoop3都是偶数rank
    hostname[hadoop4], rank[1/4], processor affinity[1]
    hostname[hadoop4], rank[3/4], processor affinity[2]

    2. numactl 用来做Memory/processor affinity,(没试过)

    3. env :run a program in a modified environment

    4. A Beowulf cluster is a computer cluster of what are normally identical, commodity-grade computers networked into a small local area network with libraries and programs installed which allow processing to be shared among them. One of the main differences between Beowulf and a Cluster of Workstations (COW) is that Beowulf behaves more like a single machine rather than many workstations. In most cases client nodes do not have keyboards or monitors, and are accessed only via remote login or possibly serial terminal

    ------------------------------------------------- 2012/04/27 周五-----------------------------------------

    NAMD,MPI:

    1. 安装时version选的mpi-linux, make时报错,找不到sfftw.h srfftw.h,看了下安装目录,有fftw.h rfftw.h,查看fftw的configure选项,添加--enable-float(不加这个生成的前缀是d) --enable-type-prefix, 重新编译安装,进namd目录make,搞定。

    2. Charm++ is a parallel object-oriented programming language based on C++ and developed in the Parallel Programming Laboratory at the University of Illinois.
    参考:http://en.wikipedia.org/wiki/Charm%2B%2B

     

     

     

     

  • 相关阅读:
    BZOJ_3171_[Tjoi2013]循环格_最小费用最大流
    BZOJ_1150_[CTSC2007]数据备份Backup_堆+贪心
    BZOJ_1576_[Usaco2009 Jan]安全路经Travel&&BZOJ_3694_最短路_树链剖分+线段树
    BZOJ_4802_欧拉函数_MR+pollard rho+欧拉函数
    BZOJ_3667_Rabin-Miller算法_Mille_Rabin+Pollard rho
    BZOJ_1584_[Usaco2009 Mar]Cleaning Up 打扫卫生_DP
    BZOJ_1229_[USACO2008 Nov]toy 玩具_三分+贪心
    BZOJ_2160_拉拉队排练_manacher
    [转载]Linux软件包及dpkgapt等方法
    服务器基础认知杂谈及一小点运维相关
  • 原文地址:https://www.cnblogs.com/D3Hunter/p/2536021.html
Copyright © 2011-2022 走看看