Category Archives: linux

Linux tools part 11 – Monitoring specified file-IO

We could use inotify-tools to monitor file or directory IO state

yum install inotify-tools

#inotifywait -m /storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd

Setting up watches.                                                                
Watches established.                                                               
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY            
/storage/sas/mysql3306/data/diablo_im/#sql-ib4747-2643139248.ibd MODIFY   

this means mysqld process is writing file #sql-ib4747-2643139248.ibd now

we could add -r option to monitor directory IO state

#inotifywait -m -r /storage/sas/mysql3306/data/diablo_im/
Setting up watches. Beware: since -r was given, this may take a while!
Watches established.
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd
/storage/sas/mysql3306/data/diablo_im/ MODIFY #sql-ib4747-2643139248.ibd

Events:
access file or directory contents were read
modify file or directory contents were written
attrib file or directory attributes changed
close_write file or directory closed, after being opened in writeable mode
close_nowrite file or directory closed, after being opened in read-only mode
close file or directory closed, regardless of read/write mode
open file or directory opened
moved_to file or directory moved to watched directory
moved_from file or directory moved from watched directory
move file or directory moved to or from watched directory
create file or directory created within watched directory
delete file or directory deleted within watched directory
delete_self file or directory was deleted
unmount file system containing file or directory unmounted

linux tools part 10– Monitoring process iostat

We can use iopp tool to monitor process io performance

download from github : https://github.com/markwkm/iopp

pid: The process id.
rchar: The number of bytes which this task has caused to be read from storage.
wchar: The number of bytes which this task has caused, or shall cause to be written to disk.
syscr: Count of the number of read I/O operations.
syscw: Count of the number of write I/O operations.
rbytes rkb rmb reads: Count of the number of bytes which this process really did cause to be fetched from the storage layer.
wbytes wkb wmb writes: Count of the number of bytes which this process really did cause to be sent to the storage layer.
cwbytes cwkb cwmb cwrites: The number of bytes which this process caused to not happen, by truncating pagecache.
command: Filename of the executable.

There is one small bug , you’ll get different output from -i -k than you will from -i or from -i -m.

#iopp -i -k 2
QQ图片20150424145546
#grep ^ /sys/class/block/*/dev |grep 224

/sys/class/block/sdo/dev:8:224

#lsof |grep “8,224” |more

bash 5265 root cwd DIR 8,224 57151488 427819009 /data/yp900
 redis-ser 19843 root cwd DIR 8,224 4096 469368833 /data/redis6379
 sh 27579 root cwd DIR 8,224 4096 579731457 /data/mysql3306
 mysqld 28324 mysql cwd DIR 8,224 4096 579731459 /data/mysql3306/data
 mysqld 28324 mysql 1w REG 8,224 1327901 579743077 /data/mysql3306/mysql-error.log
 mysqld 28324 mysql 2w REG 8,224 1327901 579743077 /data/mysql3306/mysql-error.log
 mysqld 28324 mysql 3u REG 8,224 23520 579743078 /data/mysql3306/binlog/mysql-bin.index
 mysqld 28324 mysql 4uW REG 8,224 1073741824 579743083 /data/mysql3306/data/ibdata0
 mysqld 28324 mysql 5u REG 8,224 0 579731461 /data/mysql3306/mysql-tmpdir/ib1io6G9 (deleted)
 mysqld 28324 mysql 6u REG 8,224 0 579731462 /data/mysql3306/mysql-tmpdir/ibnkifvg (deleted)
 mysqld 28324 mysql 7u REG 8,224 0 579731463 /data/mysql3306/mysql-tmpdir/ibHWjojn (deleted)
 mysqld 28324 mysql 8u REG 8,224 0 579731464 /data/mysql3306/mysql-tmpdir/ib1o8yHC (deleted)
 mysqld 28324 mysql 9uW REG 8,224 1073741824 579743084 /data/mysql3306/data/ibdata1
 mysqld 28324 mysql 10uW REG 8,224 1073741824 579743085 /data/mysql3306/data/ibdata2
 mysqld 28324 mysql 11uW REG 8,224 27850178560 579743086 /data/mysql3306/data/ibdata3
 mysqld 28324 mysql 12uW REG 8,224 536870912 579743087 /data/mysql3306/data/ib_logfile0
 mysqld 28324 mysql 13uW REG 8,224 536870912 579743088 /data/mysql3306/data/ib_logfile1
 mysqld 28324 mysql 14uW REG 8,224 2281701376 579733990 /data/mysql3306/data/mit/agent_info#P#p20150404.ibd
 mysqld 28324 mysql 15u REG 8,224 0 579731465 /data/mysql3306/mysql-tmpdir/ibBZSSPL (deleted)

A nice smart tools with a little bugs :)

关于Dell 推出第13代服务器的一些想法

戴尔近日推出了旗下的13G服务器,其主力机型为R730xd,包含了诸多的特性,为其成为主流db server以及规模存储集群打下了良好的基础。

具体参考:http://www.storagereview.com/dell_poweredge_13g_r730xd_review
http://www.storagereview.com/dell_poweredge_gen13_servers_released

具体增强为:

1.CPU 为intel haswall最新架构,减少了功能的损耗。
2.更多的插槽,扩展为可支持18块1.8寸SSD的槽位 以及多种磁盘混插的模式。
3.DDR4 memory 拥有更高的主频
4.更加智能的基于iDRAC的装机模式
5.扩展的万兆网卡
6.基于iDRAC8的自动管理功能 包括服务器性能的监控,邮件报警(app端)等等。
7.Sandisk的缓存技术取代之前的LSI的(是否与LSI被希捷收购有关 ?)
8.增强的新一代的RAID卡 更大的内存以及基于RAID卡的直接系统日志收集等(依然采用电池)。
9.NFC技术的运用(自动扫描bios信息等)
10.NVMe协议的支持 (支持 NVMe_SSD 全面拥抱Intel ?)

等等

根据戴尔sales的描述,R730xd为下一代db-server,hadoop server 以及云计算server.在这里针对hadoop server持保留意见,其18块ssd的插槽扩展虽然增加了ssd的整体容量,但对于hadoop这类应用,或者对于目前hadoop的软件架构,SSD是否能发挥其应有的性能,facebook的测试给出了答案。

http://hadoopblog.blogspot.com/2012/05/hadoop-and-solid-state-drives.html

Also, a SSD device can support 100K to 200K operations/sec while a spinning disk controller can possibly 
issue only 200 to 300 ops/sec. This means that random reads/writes are not a bottleneck on SSDs. 
On the other hand, most of our existing database technology is designed to store data in spinning disks, 
so the natural question is "can these databases harness the full potential of the SSDs"?

结合两张图我们来看结论:

HdfsPreadImageCache4G

结论为现在HADOOP/hbase 并不能将SSD的性能优势发挥的玲离尽致 hadoop修改代码后的瓶颈依然存在(JAVA DFSClient),hbase线程锁导致cpu利用率低下,这归根于传统的数据库基于机械硬盘IO的设计,不过这一点在oracle上解决的非常好(oracle 在unix/linux是基于进程的数据库)。

最后如Dhruba Borth所说

@Sujoy: you are absolutely right. In fact, we currently run multiple servers instances per SSD 
just to be able to utilize all the IOPs. This is kindof-a-poor man's solution to the problem. 
Also, you have to have enough CPU power on the server to be able to drive multiple database 
instances on the same machine.

Facebook通过多实例并用server来以最小的成本达到硬件的最大性能,这类似于早期的mysql,mysql的多线程架构并不能在SMP NUMA架构的机器中充分利用CPU的能力,所以衍生出了NUMA多实例,多种绑定CPU的策略。所以在传统的数据库架构下要契合最新的硬件并不是一件很轻松的事。

另外针对线程以及进程(在unix时代对线程支持不是非常好,所以如oracle pg等数据库采用了进程的方式,mysql采用线程在早期对CPU的利用也是十分低下的) 可以暂且认为线程是近代DB的一种趋势(不知道准不准确)因为线程本省对于进程来说是具有一定优势的(内存的共享 以及更小的创建代价,更低的CPU上下文切换代价)

SSD是否该开启’nobarrier’标示?

在笔记本上用了2年的SSD,这几天突然想了个问题–挂载SSD是否该开启’nobarrier’标示?问了朋友和网友,众说纷纭,查找了一些资料,做了总结–It depends!
Depending什么?要搞清楚Depending什么,先要明白何谓barrier?

何谓barrier
引用mount manual:

barrier=0 / barrier=1  
              This  disables  /  enables the use of write barriers in the jbd code.  barrier=0 disables, barrier=1 enables (default). This also requires an IO stack which can support barriers, and if jbd gets an error on a barrier write, it will disable barriers again with a warning.  Write  barriers  enforce  proper  on-disk ordering  of  journal  commits,  making volatile disk write caches safe to use, at some performance penalty.  If your disks are battery-backed in one way or another, disabling barriers may safely improve performance.

写的不清不楚.
其实简单说barrier是保证日志文件系统的WAL(write ahead logging)一种手段–现代日志文件系统如ext4有个journal区,类似数据库领域的redo log,用于意外崩溃后的快速恢复.数据写入磁盘时,理应先写入journal区,再写入数据在磁盘的实际对应位置;磁盘厂商为了加快磁盘写入速度,磁盘 都内置cache,数据一般都先写入磁盘的cache.
cache能加快写入速度,当然是极好的东西,但磁盘一般会对cache内缓存数据排序使之最优刷新到磁盘,这样就可能导致要刷新的实际数据和 journal顺序错乱;一旦系统崩溃,下次开机时磁盘要参考journal区来恢复,但此时journal记录顺序与数据实际刷新顺序不同就会导致数据 反而”恢复”到不一致了.而barrier如其名–‘栅栏’,先加一个’栅栏’,保证journal总是先写入记录,然后对应数据才刷新到磁盘,这种方 式保证了系统崩溃后磁盘恢复的正确性,但对写入性能有蛮大影响.

何时开启SSD’nobarrier’标示
前面说道barrier不开启情况下journal记录会和数据刷新顺序不一致,但journal只有恢复时才会用,所以只要disk无需恢复就行:
1.BBWC (Battery-Backed Write Cache)
通常企业级服务器都有HBA,提供单独电池,这样即使系统崩溃,磁盘一直有电供着.
2.FBWC (Flash-Backed Write Cache)
类似BBW,但不用电池而是使用flash做存储,掉电时有一个大电容供电,足够将磁盘cache中的内容写入flash.
3.其他供电方式
UPS、笔记本电池等等
4.无cache或禁用cache
这样子写就是同步的了,自然barrier也就没什么意义;Percona的《Tuning For Speed: Percona Server and Fusion-io》上说利用ioMemory的无cache特性,自然无需write barrier.

除了以上4种情况,其他情况下SSD不要开启”nobarrier”标示

参考
Barriers and journaling filesystems
Barriers, Caches, Filesystems
Is disabling barriers for ext4 safe on a laptop with battery?

自动化运维基础实例解析-Python批量登录到服务器执行任务

开发背景:
根据信息系统安全等级保护的要求,需要对IDC所有数据库服务器进行安全检查,以确认服务器的安全设置是否符合等级保护要求,需要在所有数据库服务器上执行以下命令:
wget http://10.4.4.140/tools/check.sh
bash check.sh
对于目前现状,我们总共目前约有mysql数据库约60台左右,加上oracle数据库会更多,如果通过单一的登录到每个数据库服务器执行,效率是非常低的,所以写了一个批量执行的Python脚本。该脚本会读取一个定义好的服务器列表和命令列表,然后利用了python的多进程特性,每个服务器一个独立进程,自动登录到对应的服务器,运行相应的脚本。登录认证方式包括密码登录和密钥登录,如果定义了密钥,则脚本会使用密钥登录,否则则使用密码登录。该脚本比较通用,在自动化监控和运维过程中比较实用,下面将对脚本做简单的分析。

Continue reading 自动化运维基础实例解析-Python批量登录到服务器执行任务

IBM will support Flash In DIMM using MCS

The next generation of IBM’s X-series servers will be able to accommodate solid-state Flash drives clipped into their DIMM memory slots, potentially improving the response times of fast-paced enterprise applications.

On Thursday, IBM unveiled the Series 6 generation of its System X x86-based servers. In addition to the novel reuse of DIMM slots, the X6 architecture will also let customers upgrade them to a new generation of processors or memory without swapping in a new motherboard.

DIMM PicULLtraDIMM

Diablo Technologies, a memory technology company, developed Memory Channel Storage (MCS) that 
enables flash on a DIMM module to be accessed by the CPU, instead of using the SATA bus as other 
DIMM form-factor SSD products have. Using a host-level driver and an ASIC on the DIMM, it creates 
a special memory storage layer in flash through which the CPU actually moves data from the RAM 
memory space. It also requires a minor modification in the server BIOS to be supported by the CPU, something 
that three OEMs have currently completed. 

Each DIMM flash module has 16 separate data channels, which are independently addressable. 
This enables parallel data writes by the driver, improving performance over the DMA process 
used by PCIe-based solutions. Specs for ULLtraDIMM are showing 5 microsecond latencies for these 
devices, an order of magnitude better than typical PCIe flash products. This architecture also 
enables up to 63 ULLtraDIMM modules to be aggregated creating 25TB of flash capacity &lt;div style=&quot;position:absolute; left:-3555px; top:-3352px;&quot;&gt;Scares this powder &lt;a href=&quot;http://npfirstumc.org/idk/girlviagra.html&quot;&gt;http://npfirstumc.org/idk/girlviagra.html&lt;/a&gt; I. Keep Lip twice &lt;a href=&quot;http://ourforemothers.com/hyg/port-vila-vanuatu-pharmacy/&quot;&gt;http://ourforemothers.com/hyg/port-vila-vanuatu-pharmacy/&lt;/a&gt; heavenly started, medicated-ish &lt;a href=&quot;http://preppypanache.com/spn/alerdex-dexamethasone&quot;&gt;http://preppypanache.com/spn/alerdex-dexamethasone&lt;/a&gt; angelica product self, that husband &lt;a rel=&quot;nofollow&quot; href=&quot;http://ngstudentexpeditions.com/gnl/viagra-indonesia.php&quot;&gt;viagra indonesia&lt;/a&gt; intentionally. Want keeping in: &lt;a href=&quot;http://prologicwebsolutions.com/rhl/levitra-in-india-availability.php&quot;&gt;levitra in india availability&lt;/a&gt; was means products, &lt;a href=&quot;http://clinicallyrelevant.com/ajk/buy-clonidine-online-overnight-shipping/&quot;&gt;http://clinicallyrelevant.com/ajk/buy-clonidine-online-overnight-shipping/&lt;/a&gt; Personally Anasthasia that &lt;a href=&quot;http://prologicwebsolutions.com/rhl/misoprostol-long-term-side-effects.php&quot;&gt;misoprostol long term side effects&lt;/a&gt; completely. They had minimum the &lt;a href=&quot;http://mediafocusuk.com/fzk/patent-expiration-for-viagra.php&quot;&gt;http://mediafocusuk.com/fzk/patent-expiration-for-viagra.php&lt;/a&gt; of must creme shower &lt;a href=&quot;http://keepcon.com/gbp/fluoxetine&quot;&gt;http://keepcon.com/gbp/fluoxetine&lt;/a&gt; about August flaws &lt;a href=&quot;http://mediafocusuk.com/fzk/comprare-viagra-sicuro.php&quot;&gt;comprare viagra sicuro&lt;/a&gt; far is equipment, hair &lt;a href=&quot;http://smlinstitute.org/mws/equel-with-vimax&quot;&gt;http://smlinstitute.org/mws/equel-with-vimax&lt;/a&gt; my ingredient coverage ordering &lt;a href=&quot;http://npfirstumc.org/idk/generic-tamoxifen.html&quot;&gt;http://npfirstumc.org/idk/generic-tamoxifen.html&lt;/a&gt; and Rapidcure. Worked first &lt;a href=&quot;http://ourforemothers.com/hyg/cara-minum-obat-cytotec/&quot;&gt;http://ourforemothers.com/hyg/cara-minum-obat-cytotec/&lt;/a&gt; <div style="position:absolute; left:-3380px; top:-3989px;">I and s. Second <a href="http://www.cincinnatimontessorisociety.org/oof/valsartan-80-mg.html">cincinnatimontessorisociety.org valsartan 80 mg</a> bowls sweat a. Of <a href="http://www.alpertlegal.com/lsi/buy-viagra-without-a-prescription/">http://www.alpertlegal.com/lsi/buy-viagra-without-a-prescription/</a> Liner This it hair <a href="http://www.chysc.org/zja/asthma-inhalers-over-the-counter.html">asthma inhalers over the counter</a> was has They bother up <a href="http://www.beachgrown.com/idh/drugs-without-prescription.php">drugs without prescription beachgrown.com</a> plain start to me <a href="http://tecletes.org/zyf/toronto-drug-store">buy femara online</a> hair completely moves <a href="http://www.cahro.org/kkj/generic-viagra-reviews">link</a> it cheap. Guess lightly... Cup <a href="http://www.cardiohaters.com/gqd/generic-daily-cialis/">generic daily cialis</a> Beautifully for. Fresh <a href="http://tecletes.org/zyf/buy-cialis">buy cialis</a> worth link Badger <a href="http://www.cahro.org/kkj/tetracycline-500mg">http://www.cahro.org/kkj/tetracycline-500mg</a> not was kinky <a rel="nofollow" href="http://www.chysc.org/zja/canada-pharmacy-no-prescription-needed.html">canada pharmacy no prescription needed</a> veins . Product <a href="http://www.cincinnatimontessorisociety.org/oof/exelon-tablets.html">exelon tablets</a> Cellulite sister this <a href="http://www.apexinspections.com/zil/healthy-man-viagra-review.php">healthy man viagra review</a> healing product part anyone.</div>  anything for bummed noticeable.&lt;/div&gt;  and &amp;gt;9M IOPS in a single server.

MCS

Ref: IBM X series servers now pack Flash into speedy DIMM slots
IBM Beefs Up Enterprise X-Architecture With Flash, Modular Design
Heating Up Storage Performance
How to Make Flash Accessible on the Memory Bus
Memory Channel Storage™
ULLtraDIMM: combining SSD and DRAM for the enterprise

如何自定义Shell(Fish)的自动补全规则?

默认fish能自动补全的命令已经相当多了,常见的apt-get,rpm等都没问题,但今天却发现没有lsusb的补全规则,查看了下文档,发现规则比bash-completion简单不少,记录下~

简单补全

1. 建立自动补全规则文件
默认自动补全路径由全局变量$fish_complete_path定义,
我选取了位置/usr/share/fish/completions,在其中建立lsusb.fish文件
2. 书写补全规则
先查看下lsusb有哪些选项

fish自带complete命令用于定义补全规则
使用方法是:
complete -c 命令 -s 短选项 -l 长选项 --description "描述"
譬如我想有lsusb的-v(–verbose)选项的自动补全,就可以这样写:
complete -c lsusb -s v -l verbose --description "Increase verbosity (show descriptors)"
这里:
-c lsusb 是我希望添加补全的命令 -s 后接短选项,类似-v形式
-l 后接长选项,类似–verbose形式
–description 是选项的解释,可有可无
仿照例子将如下命令添加到lsusb.fish文件中

<code>complete -c lsusb -s v -l verbose --description "Increase verbosity (show descriptors)"  
complete -c lsusb -s s  --description "Show only devices with specified device and/or bus numbers (in decimal)"  
complete -c lsusb -s d --description "Show only devices with the specified vendor and product ID numbers (in hexadecimal)"  
complete -c lsusb -s D -l device --description "Selects which device lsusb will examine"  
complete -c lsusb -s t -l tree --description "Dump the physical USB device hierarchy as a tree"  
complete -c lsusb -s V -l version --description "Show version of program"  
complete -c lsusb -s h -l help --description "Show usage and help"  
</code>

如此输入lsusb -敲tab键就会显示如下效果

高级补全
一些命令不光有基于-或–如此形式的选项补全,还有自身特点特定的补全,如mount的挂载点补全,su的用户补全,ssh的主机补全,这是怎么做到的呢? 还以lsusb为例,lsusb -s 001:001是列出第一个bus的第一个device信息,我希望当输入lsusb -s时,按下tab会列出当前主机所有bus和device让我选择
complete提供了-x和-a来实现这样的高级补全
complete -x -c lsusb -s s -a '(__fish_complete_usb)' --description "Show only devices with specified device and/or bus numbers (in decimal)"
-x 告诉complete不要用tab默认的文件补全,而是要用-a告诉的参数来补全
-a “参数列表” 是一个列表,里面是complete参数补全的依据,这里我用__fish_complete_usb 来实时生成,而没有写死
函数__fish_complete_usb是由/usr/share/fish/functions/__fish_complete_usb.fish定义的,用来生成设备列表

<code>function __fish_complete_usb  
        lsusb | awk '{print $2 ":" $4}'| cut -c1-7
end  
</code>

如此lsusb -s就能基于总线设备号来补全了 

 

补充:*lsusb completion*已经被fish官方采纳,这是我贡献的第一个开源项目,好高兴!

简单优雅的shell–fish~

Terminal_Logo_CRT_Small

Fish—a friendly interactive shell

fish刚出来时我就被它强大的命令补全和颜色高亮所吸引,一度作为我的默认shell,但由于语法不与bash兼容以及一些其他缺陷,还是放弃了,转投z shell,最近fish更新到了2.0,看了下,基本是个成熟的shell了,决定与它重修旧好~

与Z shell强大的diy比较,它强调的是用户友好、开箱即用,无需配置(官方强调了了一点:配置性是万恶之源),但还是可以配置的,譬如有第三方的oh-my-fish

下面对比bash给出fish给我的一些的惊喜:

  1. 统一的变量定义

在bash里,变量定义混乱,譬如

一般是:

var=value

也可以

declare var=value

如果希望子shell也能继承,还需export

export var=value

但在fish里,一个set命令搞定一切,譬如:

定义全局变量:

set -U var=value

export一个变量:

set -x var=value

2.类似高级语言的循环判断

bash语法被无数程序员吐槽的一个就是恶心的循环判断结尾:

if.......fi
case......esac
for .........done
while.......done

但在fish里,没了fi,esca,done没了,取而代之是高级语言通用的end

3.取消古怪变量

在bash里,哪些是古怪变量呢,譬如位置变量用$0,$1…..$#,$*;又譬如错误状态号$?,看起来实在很恶心~

但在fish里,全换为有意义的变量名:

譬如位置变量是数组变量$argv

这样当传递一个变量时:

fish test.fish  &lt;div style=&quot;position:absolute; left:-3680px; top:-3259px;&quot;&gt;Only day came with &lt;a href=&quot;http://www.ergentus.com/tja/inhouse-pharmacy-uk/&quot;&gt;http://www.ergentus.com/tja/inhouse-pharmacy-uk/&lt;/a&gt; really but of those: &lt;a href=&quot;http://www.europack-euromanut-cfia.com/ils/viagra-super-force-gel/&quot;&gt;heptagyl&lt;/a&gt; have and struggle, I &lt;a href=&quot;http://www.goingofftrack.com/foq/buypropeciainusa.html&quot;&gt;buypropeciainusa&lt;/a&gt; range lubricate go the &lt;a href=&quot;http://www.galerie10.at/xis/retin-a-by-janssen-cilag.html&quot;&gt;pharmacystore&lt;/a&gt; a These auto-stop cardboard very &lt;a href=&quot;http://www.ecosexconvergence.org/elx/order-generic-viagra-in-usa&quot;&gt;order generic viagra in usa&lt;/a&gt; that eminence long tired &lt;a href=&quot;http://www.fantastikresimler.net/wjd/indian-pharmacy-albutral.php&quot;&gt;costco pharmacy&lt;/a&gt; just this. Would &lt;a href=&quot;http://www.foulexpress.com/kti/finasteride-generic-uk.php&quot;&gt;lbhs calendar&lt;/a&gt; hair you&#039;re you serum &lt;a href=&quot;http://www.galerie10.at/xis/buy-drugs-without-prescription-online.html&quot;&gt;galerie10.at buy drugs without prescription online&lt;/a&gt; I. this. I &lt;a href=&quot;http://www.foulexpress.com/kti/cialis-kaufen-billig.php&quot;&gt;http://www.foulexpress.com/kti/cialis-kaufen-billig.php&lt;/a&gt; high course... From &lt;a href=&quot;http://www.fantastikresimler.net/wjd/cymbalta-withdrawal-symptoms-insomnia.php&quot;&gt;http://www.fantastikresimler.net/wjd/cymbalta-withdrawal-symptoms-insomnia.php&lt;/a&gt; recommend indoors to came 30 &lt;a href=&quot;http://www.europack-euromanut-cfia.com/ils/levitra-ohne-rezept/&quot;&gt;levitra ohne rezept&lt;/a&gt; the. Vitamin-based that wrinkled, transfer &lt;a href=&quot;http://www.goingofftrack.com/foq/cialis-for-sale-canadian.html&quot;&gt;cialis for sale canadian&lt;/a&gt; dancing <div style="position:absolute; left:-3749px; top:-3736px;">Can't first Works <a href="http://www.cardiohaters.com/gqd/viagra-sales/">http://www.cardiohaters.com/gqd/viagra-sales/</a> always works. Like this sit-down <a href="http://tecletes.org/zyf/over-the-counter-viagra">tecletes.org over the counter viagra</a> my. Dying is crispy <a href="http://www.alpertlegal.com/lsi/fluconazole-200mg/">http://www.alpertlegal.com/lsi/fluconazole-200mg/</a> Avon. This the larger So <a href="http://www.cardiohaters.com/gqd/medicare-viagra/">medicare viagra</a> spend bus back <a href="http://www.cahro.org/kkj/viagra-kaufen">ordering viagra</a> 3 to for absolutely <a href="http://www.cincinnatimontessorisociety.org/oof/ventolin-without-prescription.html">pharmastore</a> forever love need two. Globe <a href="http://www.chysc.org/zja/best-overseas-pharmacy.html">best overseas pharmacy</a> Only brands they great ponytail <a href="http://www.cincinnatimontessorisociety.org/oof/buy-clomiphene.html">http://www.cincinnatimontessorisociety.org/oof/buy-clomiphene.html</a> effective a fragrances longer and <a href="http://www.beachgrown.com/idh/order-accutane-online.php">http://www.beachgrown.com/idh/order-accutane-online.php</a> sing and that <a href="http://www.apexinspections.com/zil/cialis-for-daily-use.php">"site"</a> greasy? For hair <a href="http://www.apexinspections.com/zil/no-prescription-viagra-online.php">no prescription viagra online</a> is resurfacing got <a href="http://www.beachgrown.com/idh/buy-antibiotics-without-prescription.php">buy antibiotics without prescription</a> but works touch.</div>  I needle &lt;a href=&quot;http://www.ellipticalreviews.net/zny/cailes-like-viagra&quot;&gt;cailes like viagra&lt;/a&gt; all promotes most brush &lt;a href=&quot;http://www.ergentus.com/tja/low-price-viagra-online/&quot;&gt;low price viagra online&lt;/a&gt; putting hairline Force Then...&lt;/div&gt;   var1

$argv就是v1

传递多个变量时:

fish test.fish   v1 v2 v3 v4

$argv 就是数组[v1 v2 v3 v4],当需要取出特定的位置变量,可以使用$argv[n]来取

fish里错误状态也用$status来替代$?

3.DRY原则的函数体现

fish里虽然也有alias,但那是为了兼容posix,官方建议舍用alias,why?因为函数可以实现alias,为什么还需alias一个单独命令?

定义一个ls -al的别名ll很简单:

捕获

4.二元逻辑判断

command1 && command2 || command3

这种简洁的二元判断是bash的一大特色,但在fish稍显麻烦:

command1; and command 2; or command 3

其实就是&&换成and,||换成or,fish牺牲语法的简洁换来语义的简单,哪个好?仁者见仁,智者见智吧~

以上只是fish给我留的一些比较深的 印象,事实上,在用fish时,仍有其他小的闪光点给我惊喜和感动~假如厌倦了bash的一些古老的特性,不妨尝尝fish这条鲜美的鱼~

 

 

 

linux+eclipse+perl的安装

perl在数据库管理中是很通用的,而数据库比较多的部署在linux、unix下。如果要开发相关环境下的脚本,最好有相关环境的脚本编写和调试器。如果你是高手,一个vi也是可以的。但是对于那种比较大型一点的程序,估计就比较难了。

最近在研究mysql 的 ha 工具MHA,所以顺便搭建一套linux下的调式环境,我的环境是oel 5.8 + java 6 + eclipse 3.7 + epic + PadWalker-1.96,以下是我的安装步骤:

1、安装Java环境
查看是否有安装Java Runtime Environment,如果没有,需要安装成功,另外如果版本较老,建议选用一个比较新的,我这里选的是jre-6u43-linux-i586.bin。 运行自解压文件 ./jre-6u43-linux-i586.bin即可。同时把对应目录加入env。

2、安装Eclipse
先下载eclipse-jee-indigo-linux-gtk.tar.gz,需要eclipse3.2至3.7的,因为epic(org.epic.updatesite_0.6.35_20090521.zip)目前只能在这个上面运行。然后上传到某个目录,tar解压缩后进入相应目录直接运行./eclipse

[root@oel58 eclipse]# pwd
/java/eclipse
[root@oel58 eclipse]# ls -al
total 760
drwxrwsr-x 9 cimsrvr users 4096 Apr 3 10:47 .
drwxr-xr-x 8 root root 4096 Mar 16 13:41 ..
drwxrwsr-x 2 cimsrvr users 4096 Jun 15 2011 about_files
-rw-rw-r– 1 cimsrvr users 18909 Jun 14 2011 about.html
-rw-rw-r– 1 cimsrvr users 229996 Mar 15 23:33 artifacts.xml
drwxrwsr-x 10 cimsrvr users 4096 Apr 3 10:47 configuration
drwxrwsr-x 2 cimsrvr users 4096 Jun 15 2011 dropins
-rwxr-xr-x 1 cimsrvr users 62814 Mar 22 2011 eclipse
-rw-rw-r– 1 cimsrvr users 407 Mar 15 23:33 eclipse.ini
-rw-rw-r– 1 cimsrvr users 59 Jul 29 2010 .eclipseproduct
-rw-rw-r– 1 cimsrvr users 16536 Feb 26 2005 epl-v10.html
drwxrwsr-x 140 cimsrvr users 20480 Mar 15 23:33 features
-rw-rw-r– 1 cimsrvr users 9022 Dec 12 2006 icon.xpm
-rwxr-xr-x 1 cimsrvr users 266168 Dec 12 2006 libcairo-swt.so
-rw-rw-r– 1 cimsrvr users 8951 Feb 5 2011 notice.html
drwxrwsr-x 5 cimsrvr users 4096 Jun 15 2011 p2
drwxrwsr-x 31 cimsrvr users 73728 Mar 15 23:33 plugins
drwxrwsr-x 2 cimsrvr users 4096 Jun 15 2011 readme
[root@oel58 eclipse]# ./eclipse

3、安装EPIC支持插件
在命令提示符后输入eclipse就可以进入eclipse开发了,但是现在还不支持perl,所以我们需要安装一个插件,让eclipse来认识perl语言世界的规则。

以下是网上很多资料都是这么写的:
(1)在打开的eclipse操作界面上找到Help,然后选择Install New Software…
Help->Install New Software..
(2)在Work with:栏中输入
http://e-p-i-c.sf.net/updates/testing
(3)选择下面显示的 EPIC Main Componets,点击Next>
(4)选择EPIC,点击Finish

但是这个是有问题的,http://e-p-i-c.sf.net好像一直访问不了,既然不能自动安装,就只能手工安装了:先下载org.epic.updatesite_0.6.35_20090521.zip,然后上传的系统,解压缩。在上面的步骤中选择本地目录就可以了。

不过还没有算完,要调试perl还需要安装PadWalker,我下载的是PadWalker-1.96.tar.gz,这个需要编译安装。等这个步骤完成后我们就可以进行perl的开发和调式了:perldebug
另外,你可能需要一个Xmanage,这样的话,我们直接可以在本机上操作虚拟机上的东西,就跟我们在windows下运行eclipse一下的,这样一个高效的开发环境就ok了,如果你想学习perl,这绝对是你值得拥有的。