1、安装
首先要在存储设备上做好RAID,设置好iSCSI 目标方(target)。
这里主要说明iSCSI initiator的安装。
不同的操作系统对应各自的iSCSI initiator,以Redhat enterprise5为例。到网上下载iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm
# rpm -ivh iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm
在服务器上安装了iSCSI initiator以及iscsiadm
iscsiadm是基于命令行的iscsi管理工具,提供了对iscsi节点、会话、连接以及发现记录的操作。
iscsiadm的使用说明可以查看/usr/share/doc/iscsi-initiator-utils-6.2.0.742/README,也可以运行man iscsiadm或iscsiadm -help

本日志由 flyinweb 于 2011-05-24 11:27:31 发表到 Linux 中,目前已经被浏览 1419 次,评论 0 次;

作者添加了以下标签: ISCSIiscsi-initiator-utilsiscsiadm

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文

Q. I’ve CentOS 5 server running on Dell hardware. I’m getting following error message in my /var/log/message file (some time message is also shown on console):

Jul 05 12:04:05 dell01 kernel: end_request: I/O error, dev fd0, sector 0
Jul 05 12:04:05 dell01 kernel: Buffer I/O error on device fd0, logical block 0
Jul 05 12:04:18 dell01 kernel: end_request: I/O error, dev fd0, sector 0
Jul 05 12:04:18 dell01 kernel: Buffer I/O error on device fd0, logical block 0
Jul 05 12:04:30 dell01 kernel: end_request: I/O error, dev fd0, sector 0
Jul 05 12:04:42 dell01 kernel: end_request: I/O error, dev fd0, sector 0

What do they mean? How do I fix this problem?

A. This message appears when you don’t have a floppy drive attached to Linux server. Solution is quite simple just disable driver for floppy and reboot the system. You can verify this with the following command (this solution works with RHEL, CentOS, Redhat, Ubuntu/Debian and other Linux distros) :
# lsmod | grep -i floppy
Output:

floppy                 95465  0

Open file called /etc/modprobe.d/blacklist:
# vi /etc/modprobe.d/blacklist
Listing a module (driver name) in this file prevents the hotplug scripts from loading it. Usually that'd be so that some other driver will bind it instead,
no matter which driver happens to get probed first. Sometimes user mode tools can also control driver binding. Append following line:
blacklist floppy
Save and close the file. Now reboot the Linux server:
# reboot

Source from:http://www.cyberciti.biz/faq/linux-end_request-ioerror-dev-fd0-sector0/

本日志由 flyinweb 于 2011-05-03 10:21:28 发表到 Linux 中,目前已经被浏览 874 次,评论 0 次;

作者添加了以下标签: end_request: I/O error

简介: 随着Internet技术的迅猛发展,网络技术、性能的不断提高,高可伸缩性、高可用性、可管理性、价格有效性的网络服务技术将成为网络服务技术的主导。各种平台下的技术方案应运而生。本文试图以一篇完整的理论+实践性的文字来介绍如何在优秀的开源操作系统Linux下创建低成本、高性能、高可用的服务集群系统。文中所使用的系统和软件包均为最新版本。希望通过对本文的阅读能使你对如何创建Linux下的集群系统有所帮助。

1.Linux下的解决方案

Linux下的集群系统通常可以分为三类:

  1. HA容错集群 (Fail-over Cluster)
    高可用性集群(High available)用于不可间断服务的环境下。提供冗余的容错备份,在主节点失效后,能够立即接管相关资源及继续提供相应服务。
  2. 负载均衡集群 (Load Balancing Cluster)
    在应用服务的高负载情况下运用该技术,由多台节点提供高可伸缩的,高负载的服务器组。以保证对外提供良好的服务响应。
  3. HPC高性能计算机集群 (High Performance Computing)
    概念并不完全统一,有一定争论,应该理解为并行系统,主要用于科学计算。

本日志由 flyinweb 于 2011-03-11 09:56:13 发表到 Linux 中,目前已经被浏览 2488 次,评论 0 次;

作者添加了以下标签: LVS

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文

我们都知道网易、搜狐等大型门户都有“通行证”的概念,这个通行证系统就是今天讨论的“单点登录系统”。其主要特征是多个站点一个用户中心,一点登陆后其他也自动登录,注销也是。比如我们在126登录了邮箱,再去163.com就是登陆状态。就好比要建一个摩天大楼,打好地基是重点之重.看到SSO的重要性了吧.

下面我简单介绍一下国际一些名气比较大的SSO解决方案:

本日志由 flyinweb 于 2011-02-14 14:08:11 发表到 Linux 中,目前已经被浏览 1991 次,评论 0 次;

作者添加了以下标签: SSOLoongSSOSingle sign-on

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文

 Raid and Logical Volume Managers are great, until you lose data.

The combination of Linux software RAID (Redundant Array of Inexpensive Disks) and LVM2 (Logical Volume Manager, version 2) offered in modern Linux operating systems offers both robustness and flexibility, but at the cost of complexity should you ever need to recover data from a drive formatted with software RAID and LVM2 partitions. I found this out the hard way when I recently tried to mount a system disk created with RAID and LVM2 on a different computer. The first attempts to read the filesystems on the disk failed in a frustrating manner.

本日志由 flyinweb 于 2011-02-10 15:36:00 发表到 Linux 中,目前已经被浏览 1130 次,评论 0 次;

作者添加了以下标签: LVMLVM recovery

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文

 Over the weekend I had the worrying experience of losing my LVM settings and potentially all my data… a quick search on the web showed a confusing set of information, much of it for older versions of LVM and therefore rather suspect.

Well, I recovered all my data and it was really quite simple, so I’ve written up what I did in the hope that someone else, in a similar situation, will find it useful. It’s a scary thing, losing the whole hard disk and knowing that, in reality, its all there.

本日志由 flyinweb 于 2011-02-10 15:28:40 发表到 Linux 中,目前已经被浏览 1306 次,评论 0 次;

作者添加了以下标签: LVMLVM recovery

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文

IP Range To CIDR Convertor

// Convert a given Ip range to CIDR notation.

# cat  rangeToCidr

  1. /* rangeToCidr.c - Convert Ip ranges to CIDR */ 
  2.  
  3. /* 
  4. modification history http://snippets.dzone.com/tag/cidr
  5. -------------------- 
  6. 01a,17sep08,karn written 
  7. */ 
  8.  
  9. /* includes */ 
  10.  
  11. #include<stdio.h> 
  12. #include<unistd.h> 
  13. #include<string.h> 
  14. #include<math.h> 
  15. #include<errno.h> 
  16. #include <sys/socket.h> 
  17. #include <netinet/in.h> 
  18. #include <arpa/inet.h> 
  19.  
  20. /* defines */ 
  21. //#define DBG 
  22. #ifdef DBG 
  23. #define DEBUG(x) fprintf(stderr,x) 
  24. #else 
  25. #define DEBUG 
  26. #endif /* DBG */ 
  27.  
  28. #define IP_BINARY_LENGTH 32+1  /* 32 bits ipv4 address +1 for null */ 
  29. #define IP_HEX_LENGTH    10    
  30. #define MAX_CIDR_MASK    32 
  31. #define MAX_CIDR_LEN     18+1   /*255.255.255.255/32*/ 
  32.  
  33. /* Forward declaratopms */ 
  34. void rangeToCidr(uint32_t from ,uint32_t to, 
  35.                  void (callback)(char *cidrNotation)); 
  36. int ipToBin(uint32_t ip , char * pOut); 
  37.  
  38. void printNotation(char *cidrNotation); 
  39.  
  40. /* Globals */ 
  41.  
  42.  
  43. /******************************************************************************* 
  44. * 
  45. * ipToBin - convert an ipv4 address to binary representation  
  46. *           and pads zeros to the beginning of the string if  
  47. *           the length is not 32  
  48. *           (Important for ranges like 10.10.0.1 - 20.20.20.20 ) 
  49. * 
  50. * ip   - ipv4 address on host order 
  51. * pOut - Buffer to store binary. 
  52. * 
  53. * RETURNS: OK or ERROR  
  54. */ 
  55.  
  56. int ipToBin(uint32_t ip , char * pOut) 
  57.     { 
  58.     char hex[IP_HEX_LENGTH]; 
  59.     int i; 
  60.     int result=0; 
  61.     int len; 
  62.     char pTmp[2]; 
  63.     int tmp; 
  64.     /* 
  65.      * XXX: Could use bit operations instead but was easier to debug 
  66.      */ 
  67.     char binMap[16][5] = {  
  68.                         "0000","0001","0010","0011""0100"
  69.                         "0101","0110","0111","1000""1001"
  70.                         "1010","1011","1100""1101","1110","1111"
  71.                         }; 
  72.     pTmp[1]=0x0; 
  73.     memset(hex,0x0,sizeof(hex)); 
  74.     len=sprintf(hex,"%x",ip); 
  75.  
  76.     for(i=0;i<len;i++) 
  77.         { 
  78.  
  79.         /* Ugly but to use strtol , we need the last byte as null */ 
  80.         pTmp[0]=hex[i]; 
  81.  
  82.         errno = 0; 
  83.         tmp = strtol(pTmp, 0x0, 16); 
  84.  
  85.         /* Should not happen */ 
  86.         if (errno != 0) 
  87.             { 
  88.             memset(pOut,'0',IP_BINARY_LENGTH -1); 
  89.             DEBUG ("strtol failed for hex 0x%s\n",pTmp); 
  90.             return -1; 
  91.             } 
  92.  
  93.         result+=sprintf(pOut+result,"%s",binMap[tmp]); 
  94.         } 
  95.  
  96.         DEBUG("bits %u printed for ip address for hex len %u\n",result,len); 
  97.         /* if length is not 32 , pad the start with zeros*/ 
  98.  
  99.     if(result < IP_BINARY_LENGTH-1) 
  100.         { 
  101.         char pSwap[IP_BINARY_LENGTH]; 
  102.         strncpy(pSwap,pOut,IP_BINARY_LENGTH); 
  103.         memset(pOut,'0',IP_BINARY_LENGTH); 
  104.         strncpy(pOut+IP_BINARY_LENGTH-1-result,pSwap,result); 
  105.         DEBUG("corrected length to 32\n"); 
  106.         } 
  107.  
  108.     else if (result > IP_BINARY_LENGTH-1) 
  109.         return -1; 
  110.  
  111.     /* Success */ 
  112.     return 0; 
  113.     } 
  114.  
  115. /******************************************************************************* 
  116. *  main :  
  117.  
  118. *  arg1 : Start Ip Address 
  119. *  arg2 : End Ip address 
  120. */ 
  121.  
  122. int main (int argc,char **argv) 
  123.     { 
  124.     long fromIp, toIp; 
  125.     struct in_addr addr; 
  126.     if(argc !=3 ) 
  127.         { 
  128.         printf("Usage: %s <from> <to>\n",argv[0]); 
  129.         return(0); 
  130.         } 
  131.  
  132.     /* All operation on host order */    
  133.     if (inet_aton(argv[1],&addr) == 0) 
  134.         goto error; 
  135.     fromIp = ntohl(addr.s_addr); 
  136.  
  137.     if (inet_aton(argv[2],&addr) ==0) 
  138.         goto error; 
  139.     toIp = ntohl(addr.s_addr); 
  140.  
  141.     rangeToCidr(fromIp,toIp,printNotation); 
  142.  
  143.     return 0; 
  144. error: 
  145.     printf("Invalid Argument\n"); 
  146.     return -EINVAL; 
  147.     } 
  148.  
  149.  
  150. /******************************************************************************* 
  151. * 
  152. * rangeToCidr - convert an ip Range to CIDR, and call 'callback' to handle 
  153. *               the value.  
  154. * 
  155. * from     - IP Range start address 
  156. * to       - IP Range end address 
  157. * callback - Callback function to handle cidr. 
  158. * RETURNS: OK or ERROR  
  159. */ 
  160.  
  161. void rangeToCidr(uint32_t from ,uint32_t to, 
  162.                  void (callback)(char *cidrNotation)) 
  163.     { 
  164.     int     cidrStart = 0; 
  165.     int     cidrEnd = MAX_CIDR_MASK - 1; 
  166.     long    newfrom; 
  167.     long    mask; 
  168.     char    fromIp[IP_BINARY_LENGTH]; 
  169.     char    toIp[IP_BINARY_LENGTH]; 
  170.     struct  in_addr addr; 
  171.     char    cidrNotation[MAX_CIDR_LEN]; 
  172.  
  173.     memset (fromIp,0x0,sizeof(fromIp)); 
  174.     memset (toIp,0x0,sizeof(toIp)); 
  175.  
  176.     if ( ipToBin(from,fromIp) != 0 )  
  177.         return
  178.     if ( ipToBin(to,toIp) != 0 ) 
  179.         return
  180.  
  181.     DEBUG ("from %lu to %lu\n", from,to); 
  182.     DEBUG("from %s\n",fromIp); 
  183.     DEBUG("to   %s\n",toIp); 
  184.  
  185.     if(from < to ) 
  186.         { 
  187.  
  188.         /* Compare the from and to address ranges to get the first 
  189.          * point of difference 
  190.          */ 
  191.  
  192.         while(fromIp[cidrStart]==toIp[cidrStart]) 
  193.             cidrStart ++; 
  194.         cidrStart = 32 - cidrStart -1 ; 
  195.         DEBUG("cidrStart is %u\n",cidrStart); 
  196.  
  197.         /* Starting from the found point of difference make all bits on the  
  198.          * right side zero  
  199.          */ 
  200.  
  201.         newfrom = from >> cidrStart +1  << cidrStart +1 ;         
  202.  
  203.         /* Starting from the end iterate reverse direction to find  
  204.          * cidrEnd 
  205.          */  
  206.         while( fromIp[cidrEnd] == '0' && toIp[cidrEnd] == '1'
  207.             cidrEnd --; 
  208.  
  209.         cidrEnd = MAX_CIDR_MASK - 1 - cidrEnd; 
  210.         DEBUG("cidrEnd is %u\n",cidrEnd); 
  211.  
  212.         if(cidrEnd <= cidrStart) 
  213.             { 
  214.             /*  
  215.              * Make all the bit-shifted bits equal to 1, for 
  216.              * iteration # 1. 
  217.              */ 
  218.              
  219.             mask = pow (2, cidrStart ) - 1; 
  220.             DEBUG("it1 is %lu \n",newfrom | mask ); 
  221.             rangeToCidr (from , newfrom | mask, callback); 
  222.             DEBUG("it2 is %lu \n",newfrom | 1 << cidrStart); 
  223.             rangeToCidr (newfrom | 1 <<  cidrStart ,to ,callback); 
  224.             } 
  225.         else 
  226.             { 
  227.             addr.s_addr = htonl(newfrom); 
  228.             sprintf(cidrNotation,"%s/%d",  
  229.                     inet_ntoa(addr), MAX_CIDR_MASK-cidrEnd); 
  230.             if (callback != NULL) 
  231.                 callback(cidrNotation); 
  232.             } 
  233.         } 
  234.  
  235.     else 
  236.         { 
  237.         addr.s_addr = htonl(from); 
  238.         sprintf(cidrNotation,"%s/%d",inet_ntoa(addr),MAX_CIDR_MASK); 
  239.         if(callback != NULL) 
  240.             callback(cidrNotation); 
  241.         } 
  242.     } 
  243.  
  244. /******************************************************************************* 
  245. * 
  246. * printNotation - This is an example callback function to handle cidr notation.  
  247. * 
  248. * RETURNS: 
  249. */ 
  250.  
  251. void printNotation(char *cidrNotation) 
  252.     printf("%s\n",cidrNotation); 

编译:

# gcc rangeToCidr.c -lm -o rang2cidr

Perl版本:

  1. #!/usr/bin/perl -w 
  2. # range2cidr.pl 
  3.  
  4. use Net::CIDR; 
  5. use Net::CIDR ':all'
  6.  
  7. if (@ARGV == 0) { 
  8.   die "Usage Example: $0 192.168.0.0-192.168.255.255 \n"
  9.  
  10. print join("\n", Net::CIDR::range2cidr("$ARGV[0]")) . "\n"

本日志由 flyinweb 于 2011-01-28 11:06:29 发表到 Linux 中,目前已经被浏览 1521 次,评论 0 次;

作者添加了以下标签: rangeToCidrrange2cidr

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文

I'm new to networking and need help with network settings. I'm looking for a tool for calculating available host address ranges with CIDR using Linux command prompt. How do I use subnet calculator under Linux or UNIX?

本日志由 flyinweb 于 2011-01-26 08:46:24 发表到 Linux 中,目前已经被浏览 1369 次,评论 0 次;

作者添加了以下标签: CIDRSubnet

首页只显示了部分日志内容,要查看日志的全部内容请阅读全文

2485/31