灌溉梦想,记录脚步

磁盘阵列技术-术语汇编

STP:IEEE Std 802.1D-1998定义,不能快速迁移。即使
是在点对点链路或边缘端口,也必须等待2倍的forward delay
的时间延迟,网络才能收敛。

RSTP:IEEE Std 802.1w定义,可以快速收敛,却存在以
下缺陷:
局域网内所有网桥共享一棵生成树,不能按vlan
阻塞冗余链路。

MSTP可以弥补这样缺陷,它允许不同vlan的流量
沿各自的路径分发,从而为冗余链路提供了更好的
负载分担机制。

MSTP:
Multiple Spanning Tree Protocol
多生成树协议
在规范IEEE Std 802.1s中第13节描述。
MSTP算法通过应用MSTP、STP或RSTP的桥任意互连的桥接网络,为分配给任一个特定VLAN的帧提供了简单而完备的连通性。
MSTP允许不同VLAN的数据从各自的路径分发。各条路径建立在由LAN和MST桥组成的MST域中的各个独立的多生成树实例的基础上。

svn库中添加、删除、提交文件的脚本

#!/bin/bash
COUNT=`svn status | grep '^?' |wc -l`
until [ $COUNT -lt "1" ]
do
CURRENT=`svn status | grep '^?' |awk {'print $2'} | head -$COUNT | tail -1`
echo "Do you want to add $CURRENT? (y/n): "
read ANS
if [ $ANS = "y" ]
then
svn add $CURRENT
echo "$CURRENT added to repository"
COUNT=`expr $COUNT – 1 `
elif [ $ANS = "n" ]
then
COUNT=`expr $COUNT – 1 `
fi
done

COUNT=`svn status | grep '^!' |wc -l`
until [ $COUNT -lt "1" ]
do
CURRENT=`svn status | grep '^!' |awk {'print $2'} | head -$COUNT | tail -1`
echo "Do you want to delete $CURRENT? (y/n): "
read ANS
if [ $ANS = "y" ]
then
svn delete $CURRENT
echo "$CURRENT added to repository"
COUNT=`expr $COUNT – 1 `
elif [ $ANS = "n" ]
then
COUNT=`expr $COUNT – 1 `
fi
done

echo "Enter a commit message: "
read MSG
svn commit -m "$MSG"

How To Create A Cluster Testbed Using CentOS 5 Vir

  A. Overview
  This guide attempts to provide a Xen based test environment where you can practice setting up a two node cluster (cluster setup itself is not discussed here – I'm merely giving you what you need to set it up).
  XEN can host two type of guest systems para-virtualized and fully-virtualized:
  for para-virtualized guests you require the Red Hat Enterprise Linux 5 installation tree available over NFS, FTP or HTTP.
  for fully-virtualized guest installations you will require DVD or CD-ROM distribution media or a bootable .iso file and a network accessible installation tree
  For details, please refer to the RHEL5 Virtualization Manual.
  I'll be using para-virtualized guests here in my setup. There will be three systems involved here:
  node00 – physical system
  virtual IPs: 192.168.222.1 (public1 vlan)
  192.168.100.1 (private1 vlan)
  node01 – para-virtualized guest 1
  virtual IPs: 192.168.222.10 (public1 vlan)
  192.168.100.10 (private1 vlan)
  node02 – para-virtualized guest 1
  virtual IPs: 192.168.222.20 (public1 vlan)
  192.168.100.20 (private1 vlan)
  B. What I used
  an HP Blade bl25p machine with 4G of RAM (this is actually an AMD64 blade machine). A machine with decent amount of RAM and processing speed should do.
  Centos i386 5 update 1 www.centos.org DVD ISO downloaded HTTP, NFS and FTP installation sources were created from this iso. Also, the yum repository that can be used by host and guest systems will be generated from the centos iso image.
  logical volumes hosting the guests and the "virtual luns" via iscsi (you can also use disk partitions – please refer to the virtualization guide for details).
  1. My LVM setup
  The following is my LVM configuration. The lvLUN0* entries are the ones I used for iSCSI setup and will be shared by the two virtual guest systems.
  lvs
  LV VG Attr LSize origin Snap% Move Log Copy%
  lvLUN01 Virtual00VG -wi-ao 50.00G
  lvLUN02 Virtual00VG -wi-ao 50.00G
  lvNODE01 Virtual00VG -wi-ao 30.00G
  lvNODE02 Virtual00VG -wi-ao 30.00G
  lvNODE03 Virtual00VG -wi-ao 15.00G
  lvsys00 vg00 -wi-ao 512.00M
  lvsys01 vg00 -wi-ao 8.00G
  lvsys02 vg00 -wi-ao 8.00G
  lvsys03 vg00 -wi-ao 512.00M
  lvsys04 vg00 -wi-ao 128.00M
  lvsys05 vg00 -wi-ao 1.00G
  lvsys06 vg00 -wi-ao 256.00M
  C. Host Preparation
  I'm assuming that you know how to install CentOS or other RHEL based distributions and that you are familiar with rpm installation. Since I do a lot of setup for test/dev environments at work, I already have an installation server making it easy to do a network based install via PXE. The kickstart file for node00 is provided below. You can do a local media install (you have the ISO so you can burn it to a DVD) and just refer to the kickstart file for some of the configuration. The list of packages I used is in the %packages section of node00's kickstart file. You can install them manually using yum, like:
  # will list centos installation groups
  yum grouplist
  # will install Virtualization group
  yum groupinstall Virtualization
  1. ks file and installation
  1.a kickstart file I use for the host (node00)
  You'll have to modify the following to suit your setup.
  ## START node00_ks.cfg
  #modify for your own settings
  install
  nfs –server=remote_server –dir=/path/to/CENTOS5U1/i386
  lang en_US.UTF-8
  keyboard us
  skipx
  reboot
  network –device eth2 –bootproto static –ip a.b.c.1 –netmask 255.255.255.0 –gateway a.b.c.2 –nameserver x.y.z.n –hostname node00.example.com
  # grub and root password is a1s2d3f4g5
  rootpw –iscrypted $1$3CXK2$CG9WlX2PuPpp7nxYMQGwP0
  firewall –disabled
  authconfig –enableshadow
  selinux –disabled
  timezone Asia/Singapore
  bootloader –location=mbr –driveorder=cciss/c0d0 –append="rhgb quiet" –md5pass=$1$3CXK2$CG9WlX2PuPpp7nxYMQGwP0
  clearpart –all –initlabel –drives=cciss/c0d0
  part /boot –fstype ext3 –size=100 –ondisk=cciss/c0d0
  part pv.100000 –size=100 –grow –ondisk=cciss/c0d0 –asprimary
  volgroup vg00 –pesize=32768 pv.100000
  logvol /tmp –fstype ext3 –name=lvsys05 –vgname=vg00 –size=1024
  logvol /opt –fstype ext3 –name=lvsys04 –vgname=vg00 –size=128
  logvol /var –fstype ext3 –name=lvsys03 –vgname=vg00 –size=512
  logvol /usr –fstype ext3 –name=lvsys02 –vgname=vg00 –size=8192
  logvol swap –fstype swap –name=lvsys01 –vgname=vg00 –size=8192
  logvol /home –fstype ext3 –name=lvsys06 –vgname=vg00 –size=256
  logvol / –fstype ext3 –name=lvsys00 –vgname=vg00 –size=512
  %packages
  @development-libs
  @editors
  @system-tools
  @text-internet
  @x-software-development
  @virtualization
  @dns-server
  @core
  @base
  @ftp-server
  @network-server
  @legacy-software-development
  @base-x
  @web-server
  @printing
  @server-cfg
  @sql-server
  @admin-tools
  @development-tools
  lsscsi
  createrepo
  audit
  net-snmp-utils
  iptraf
  tftp
  lynx
  mesa-libGLU-devel
  kexec-tools
  bridge-utils
  device-mapper-multipath
  vnc-server
  xorg-x11-server-Xnest
  xorg-x11-server-Xvfb
  imake
  openmotif
  -vim-enhanced
  -zisofs-tools
  -zsh
  -bluez-hcidump
  -sysreport
  ## END of node00_ks.cfg
  2. Host configuration
  Setting up an HTTP, NFS and FTP installation server:
  2.a web server
  #/etc/httpd/conf.d/centos5u1.conf
  Alias /centos5u1 /var/ftp/pub/centos5u1
  
  Options Indexes FollowSymLinks MultiViews
  IndexOptions FancyIndexing
  Order deny,allow
  Deny from all
  Allow from 127.0.0.1 ::1 all
  
  Then start the httpd service and make sure it does during startup:
  service httpd start
  chkconfig httpd on
  2.b NFS server
  Edit /etc/exports and put the following into it:
  # /etc/exports
  /var/ftp/pub/centos5u1 192.168*(ro)
  service nfs start
  chkconfig nfs on
  2.c FTP server
  Since we already have the source in /var/ftp/pub/centos5u1, all that is needed is to start vsftpd:
  service vsftpd start
  chkconfig vsftpd on
  2.d YUM repository
  For this setup, I only use a local yum repository from the Centos DVD ISO I downloaded. First, I loopback mount it in /var/ftp/pub/centos5u1/i386/:
  cd /var/ftp/pub/centos5u1/
  mkdir temp
  mount -o loop CentOS-5.1-i386-bin-DVD.iso temp
  cp -pr temp i386
  umount temp
  createrepo -g i386
  (i386/repodata/ will then be updated.)
  For RHEL5, it's different:
  createrepo -g repodata/comps-rhel5-server-core.xml Server
  You need to do this inside the i386 directory (after loopback mounting and copying the whole directory structure).
  2.d.1 the yum repo configuration:
  I renamed the default repo files in /etc/yum.repos.d/ to *-repo (instead of *.repo) to disable them. I then created this file:
  #/etc/yum.repos.d/CentOS5.repo
  [centos5-Server]
  name=CentOS5 Server
  baseurl=http://node00/centos5u1/i386
  enabled=1
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  node00 needs to be defined in /etc/hosts for the above file to work. or just replace node00 with its IP address.
  2.e VNC server
  You won't be needing a vnc connection if you have local console access to the physical machine. All you need to do is switch into gui mode:
  telinit 5
  and open a gui terminal (like gnome-terminal or kde konsole). But since I do everything remotely, I use vncserver and vncviewer to do gui based stuff.
  2.e.1 run vncserver:
  This will bringvup a vncserver in node00 that is accessible via "vncviewer" at node00:1 (assuming node00 is resolveable from your vncviewer host).
  vncserver
  You will require a password to access your desktops.
  Password:
  Verify:
  xauth: creating new authority file /root/.Xauthority
  New 'node00.example.com:1 (root)' desktop is node00.example.com:1
  Creating default startup script /root/.vnc/xstartup
  Starting applications specified in /root/.vnc/xstartup
  Log file is /root/.vnc/node00.example.com:1.log
  How To Create A Cluster Testbed Using CentOS 5 Virtualization And iSCSI – Page 2
  How To Create A Cluster Testbed Using CentOS 5 Virtualization And iSCSI – Page 3
  next
  How To Create A Cluster Testbed Using CentOS 5 Virtualization And iSCSI – Page 2
  Copyright ? 2008 roderick tapang

身份证号码的结构和表示形式

  1、号码的结构
  公民身份号码是特征组合码,由十七位数字本体码和一位校
  验码组成。排列顺序从左至右依次为:六位数字地址码,八位数
  字出生日期码,三位数字顺序码和一位数字校验码。
  2、地址码
  表示编码对象常住户口所在县(市、旗、区)的行政区划代码,
  按GB/T2260的规定执行。
  3、出生日期码
  表示编码对象出生的年、月、日,按GB/T7408的规定执行,
  年、月、日代码之间不用分隔符。
  4、顺序码
  表示在同一地址码所标识的区域范围内,对同年、同月、同
  日出生的人编定的顺序号,顺序码的奇数分配给男性,偶数分配
  给女性。
  5、校验码
  (1)十七位数字本体码加权求和公式
  S = Ai * Wi, i = 2, … , 18
  Y = mod(S, 11)
  i: 表示号码字符从右至左包括校验码字符在内的位置序号
  Ai:表示第i位置上的身份证号码字符值
  Wi:表示第i位置上的加权因子
  i: 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
  Wi: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
  (2)校验码字符值的计算
  Y: 0 1 2 3 4 5 6 7 8 9 10
  校验码: 1 0 X 9 8 7 6 5 4 3 2
  四、举例如下:
  北京市朝阳区: 11010519491231002X
  广东省汕头市: 440524188001010014

Memcached的管理

  在以前写过了"搭建nginx + python + django +memcached+ mysql +fastcgi 环境"一文,有不少朋友问我关于memcached的管理的问题,比如查看memcached的运行情况等等,我们知道目前memcached没有直观的工具来查看整个运行情况,不过我们可以通过系统级--shell命令。
  1、数据存储(假设key为dbasky.net,value为88888)
  printf "set dbasky.net 0 0 5\r\n88888\r\n" | nc 127.0.0.1 11211
  STORED
  2、数据取回(假设key为dbasky.net)
  printf "get dbasky.net\r\n" | nc 127.0.0.1 11211
  VALUE dbasky.net 0 5
  88888
  END
  3、数值增加1(假设key为dbasky.net,并且value为正整数)
  printf "incr dbasky.net 1\r\n" | nc 127.0.0.1 11211
  88889
  4、数值减少3(假设key为dbasky.net,并且value为正整数)
  printf "decr dbasky.net 3\r\n" | nc 127.0.0.1 11211
  88886
  5、数据删除(假设key为dbasky.net)
  printf "delete dbasky.net\r\n" | nc 127.0.0.1 11211
  DeleteD
  6、查看Memcached状态
  [root@app3 ~]# printf "stats\r\n" | nc 127.0.0.1 11211
  STAT pid 20272
  STAT uptime 927901
  STAT time 1256541017
  STAT version 1.2.8
  STAT pointer_size 64
  STAT rusage_user 72323.142211
  STAT rusage_system 270758.303481
  STAT curr_items 2255461
  STAT total_items 2237096141
  STAT bytes 3865876133
  STAT curr_connections 156
  STAT total_connections 2662892830
  STAT connection_structures 2975
  STAT cmd_flush 0
  STAT cmd_get 7155551459
  STAT cmd_set 2237096141
  STAT get_hits 6275571127
  STAT get_misses 879980332
  STAT evictions 21174550
  STAT bytes_read 5936788593022
  STAT bytes_written 12278494693042
  STAT limit_maxbytes 4294967296
  STAT threads 9
  STAT accepting_conns 1
  STAT listen_disabled_num 0
  END
  7、模拟top命令,查看Memcached状态:
  watch "printf 'stats\r\n' | nc 127.0.0.1 11211"
  或者
  watch "echo stats | nc 127.0.0.1 11211"
  [root@app3 ~]# watch "printf 'stats\r\n' | nc 127.0.0.1 11211"
  Every 2.0s: printf 'stats\r\n' | nc 127.0.0.1 11211 Mon Oct 26 16:11:26 2009
  STAT pid 20272
  STAT uptime 927970
  STAT time 1256541086
  STAT version 1.2.8
  STAT pointer_size 64
  STAT rusage_user 72327.750510
  STAT rusage_system 270774.932953
  STAT curr_items 2255435
  STAT total_items 2237240981
  STAT bytes 3865771193
  STAT curr_connections 269
  STAT total_connections 2663066932
  STAT connection_structures 2975
  STAT cmd_flush 0
  STAT cmd_get 7156031867
  STAT cmd_set 2237240981
  STAT get_hits 6275980308
  STAT get_misses 880051559
  STAT evictions 21177694
  STAT bytes_read 5937174840056
  STAT bytes_written 12279303680177
  STAT limit_maxbytes 4294967296
  STAT threads 9
  STAT accepting_conns 1
  STAT listen_disabled_num 0
  END
  下面解释下各项的含意:
  uptime 是memcached运行的秒数,cmd_get是查询缓存的次数。这两个数据相除一下就能得到平均每秒请求缓存的次数,cmd_set 就是设置key=>value的次数。整个memcached是个大hash,用cmd_get没有找到的内容,就会调用一下cmd_set写进缓存里。紧跟着是get_hits,就是缓存命中的次数。缓存命中率 = get_hits/cmd_get *100%。get_misses的数字加上get_hits应该等于cmd_get。而total_itemscurr_items表示现在在缓存中的键值对个数,在图上total_items == cmd_set == get_misses,不过当可用最大内存用光时,memcached就会删掉一些内容,上面的等式就不成立了。

关于操作系统的“偏见”

  操作系统则是身为一个 IT 人员最容易有偏见的人, 只是我也很清楚我不是基本教义派, 因为我在去年之前还是大量的使用 Windows 做为我最主要的 Desktop.
  只是我现在并不是投向 Linux, 而是因为为了贪图一个 17 寸的萤幕使用 MacBook Pro, 在此之前, 我并不认为 Linux 即使在某方面比 Windows 在效能上占优势, 但扣除之外并没有那么绝对, 而且用了 GUI, 谁赢谁输更是各有立场.
  不否认的我现在的 Server 环境就顾问面是: 10% Windows, 15% Red Hat, 20% Ubuntu, 30% CentOS, 20% FreeBSD, 5% SuSE 但若是计算在我手上建议的 Server 的话, 目前是 50% FreeBSD, 40% CentOS, 10% SuSE, 且这 SuSE 与 CentOS 还是受限于环境, 而自己偷偷的喜欢 FreeBSD 是不争的事实.
  当然并不是我真的很讨厌 Microsoft, 就像是我说 Windows 可能是除了 Mac OSX 外, 比很多 Linux GUI 都来得实用, 但就 Server 而言, GUI 本身就是个原罪, 毕竟要处理这些 Handle, 花掉 10%~30% 的资源是跑不掉的, 更何况 Windows 从来不喜欢文字介面.
  就像是 Linux 很多设定要写成 GUI 或 Web UI, 大概只有写出常用的, 也就是文字设定可能的 30%~40%, 说不定还更低, 更何况 Windows 更不希望你去调整 Kernel, 也不太可能去做 Kernel Source Compiler.
  如同我今天看到 "聚沙成塔" 这本书, 作者也承认虽然 80% 以上的软体靠 Binary 就很够, 但有些还是要重新编译才能达到最佳化, 单单这部份我的确会比较信任 Open Source 的原因, 而不是免费或商用与否.
  而的确我现使用较多的 OS 是 FreeBSD 与 CentOS, 其中也是因为很多实体主机商提供的 CentOS 都是基础的, 且很合适初学者管理.
  当然若是选择了 Linux-based, 很多东西是不言而喻, 但我还是不会有任何 "较为积极正面的态度" 主张使用者的 Desktop 使用非 Windows 的, 只是经过这一年多 Mac 的经验, 我的确会明示或暗示 Mac OS 用起来真的比 Windows 好, 但我现在还没有正式在任何一台常用的桌机装任何的 Linux GUI 来长期使用.
  而就 TCO (Total Cost of Ownership) 的观点来看, 我的确也认为到底是 Windows 好还是 Unix 好, 目前的观点与经验是: "看产业", 若不是看产业, 更是看 "目前的架构", 变化的成本有时会是无法负担或必要或获得更好的情型下就不要变, 除非有些产业明鲜的使用 Windows 好或 Unix 好, 但这些都并不构成绝对因素.
  只是身为一个顾问本来就应该有跨系统或多系统管理的经验, 不能偏废, 但事实上就市场而言似乎都是 "全部只用Winows" 的顾问占 40%, "部份Windows部份Unix 的顾问占 60%, 所以相对的 Windows 的布署反而是 Windows 60%, Unix 40%, 因为有些人是太习惯使用 Windows 而对 Unix 有莫名的恐惧到直接拒绝反而是最麻烦的.
  当然经验论是决定一个人的价值, 但或许更多的经验也是增加自己的价值, 若要成为一个有本质的 IT 顾问, 我不认为该偏任何 OS 是真的, …
  但我也是因为在网络服务方面容易都只遇到 Unix 的机会较高阿, …