20 2010

Centos5 连接IP-SAN

Posted by admin in 日记

首先需要确认机器上是否有:

iscsi-initiator-utils-6.2.0.871-0.12.el5_4.1

 

2:
iscsiadm –mode discovery –type sendtargets –portal 10.10.1.10 (端口默认为3260)

iscsi会自动去与 存储端沟通。在存储端,需要将相应的 LUN映射到该机器上面。

3.

iscsiadm –mode node –targetname targetname –portal 10.10.1.10 –login

也可以  /etc/init.d/iscsi restart  重启服务。

[root@localhost ~]# /etc/init.d/iscsi restart
Logging out of session [sid: 1, target: iqn.2006-08.com.huawei:oceanstor:21000022a101beea::10.10.1.10, portal: 10.10.1.10,3260]
Logout of [sid: 1, target: iqn.2006-08.com.huawei:oceanstor:21000022a101beea::10.10.1.10, portal: 10.10.1.10,3260]: successful
Stopping iSCSI daemon:
iscsid dead but pid file exists
[  OK  ]off network shutdown. Starting iSCSI daemon: [  OK  ]
[  OK  ]
Setting up iSCSI targets: Logging in to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:21000022a101beea::10.10.1.10, portal: 10.10.1.10,3260]
Login to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:21000022a101beea::10.10.1.10, portal: 10.10.1.10,3260]: successful
[  OK  ]
[root@localhost ~]# 

 

 

4.然后就是分区了。

 

 

 

 

 

 

 

 

 

 

 

 

 

以下为备用资料

——————————–

 

 

 

1.1 连接ISCSI

操作系统:麒麟linux(2.6.18-1.std)

Iscsi包: iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm(Open-iSCS提供http://www.open-iscsi.org/)

注意:以下操作仅针对以上版本内核和iscsi包

并且仅保证可用,不保证最优。

www.ixdba.net

1.1.1 安装rpm包

将iscsi包cp到本地盘,并在该包所在的目录下运行命令

[root@linux ~]# rpm –ivh iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm

运行此命令后,会生成一个目录/etc/iscsi,该目录下有两个文件:

Initiatorname.iscsi和iscsid.conf

1.1.2 启动ISCSI服务

安装完iscsi服务默认是关闭的,需要手工启动

[root@linux ~]# cd /etc/init.d

[root@linux ~]# ./iscsi start

1.1.3 搜寻盘阵

运行以下命令搜寻target,即目标端:7612i存储

[root@linux ~]#iscsiadm –mode discovery –type sendtargets –portal 192.168.1.221

以上IP即是7612i的iscsi口的IP,其它固定。

1.1.4 显示盘阵

显示存储端target name

[root@linux ~]# iscsiadm –mode node

显示结果与在7612i串口 iscsi management→iscsi node名字相同

1.1.5 登陆盘阵

target登陆

[root@linux ~]#iscsiadm –mode node –targetname targetname –portal 192.168.1.221:3260 –login

其中targetname即是步骤4中结果。(注:横杆是中杠)

(注:3,4,5实施中是在/etc/iscsi下运行,是否可以在别的路径执行,可自行测试。以上3个命令格式是从man iscsiadm查出)

1.1.6 设置自动启动盘阵服务

经过以上几步,fdisk –l就可以看到所挂接分区了,为确保重启后也能看到,再修改一下/etc/iscsi/iscsid.conf,将第5步的命令iscsiadm –mode node –targetname targetname –portal 192.168.1.221:3260 –login

[root@linux ~]# vi /etc/iscsi/iscsid.conf

iscsiadm –mode node –targetname targetname –portal 192.168.1.221:3260 –login

添加到该文件中的开始部分

*****************

# Startup settings

#***************** 这个栏下面即可。

其实这个文件大多数内容处于被注释状态,该命令添加位置应该影响不大.然后重启电脑后直接fdisk –l 依然可以看到所挂接的分区。至此iscsi所有操作完成,但挂载的分区不是linux所识别,必须使用FDISK进行磁盘分区。

1.2 设置分区

1.2.1 使用fdisk命令进行磁盘分区

fdisk是各种Linux发行版本中最常用的分区工具,是被定义为Expert级别的分区工具。我们可以通过fdisk来分区使用iscsi设备。它还包括一个二级选单,首先输入命令,然后出现问答式界面,用户通过在这个界面中输入命令参数来操作fdisk。

# fdisk /dev/hdb

运行后出现fdiak的命令提示符:

Command (m for help):

使用n命令创建一个分区,会出现选择主分区(p primary partition)还是扩展分区(l logical)的提示,通常选用主分区。然后按照提示输入分区号(Partion number(1-4):)、新分区起始的磁盘块数(First Cylinder)和分区的大小,可以是以MB为单位的数字(Last cylindet or +siza or +sizeM or +sizeK:)。例如:

[root@linux ~]#fdisk /dev/sdb

查看分区,如果是第一次操作时,显示为无。

Command (m for help):p

Disk /dev/sdb:255 heads, 63 sectors, 4427 cylinders

Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System

建立分区

Command (m for help):n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-4427, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-4427, default 4427):

Using default value 4427

保存分区信息

Command (m for help)w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING:If you have created or modified any DOS 6.x

partitions, please see the fdisk manual page for additional

information.

Syncing disks.

1.2.2 现在验证新分区:

[root@linux ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 4427.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):p

Disk /dev/sdb:255 heads, 63 sectors, 4427 cylinders

Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 4427 35559846 83 Linux

Command (m for help):q

1.2.3 格式化分区

[root@localhost ~]# mkfs -t ext3 /dev/sdb1

mke2fs 1.39 (29-May-2006)

Filesystem label=OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

214761472 inodes, 429495759 blocks

21474787 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=0

13108 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

102400000, 214990848

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

1.2.4 设定加载点:

文件系统必须有一个挂载点,它只是一个空的目录,新文件系统在这里与系统目录树“相连”。经过以上的操作,我的 Linux服务器已经连接到 iSCSI 储存设备, 并且如同Linux 本机上面的一个 SCSI 硬盘一样。 使用的方式几乎一模一样。

假设iSCSI 主机挂载到 /cluster/raid 目录下:

[root@linux ~]# mkdir /cluster/raid

[root@linux ~]# mount /dev/sda1 /cluster/raid

[root@linux ~]# df

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/hda1 10080488 2950408 6618012 31% /

tmpfs 5036316 81172 4699312 0% /dev/shm

/dev/sda1 1914788196 27040372 1790482212 2% /cluster/raid

1.2.5 设定自动挂载:

在机器重新启动后自动加载分区,你必须在/etc/fstab中加入相应分区,但分区类型必须市”_netdev”.例如加载的分区sdb1:

[root@linux ~]# vi /etc/fstab

/dev/sdb1 /cluster/raid ext3 ­_netdev 0 0

/dev/sdc1 /data/sdc1 ext3 _netdev 0 0

/dev/sdd1 /data/sdd1 ext3 _netdev 0 0

1.2.6 查看挂载分区:

[root@localhost ~]# df -h

文件系统 容量 已用 可用 已用% 挂载点

/dev/sda1 64G 5.6G 55G 10% /

tmpfs 1.7G 0 1.7G 0% /dev/shm

/dev/sdb1 1.6T 197M 1.5T 1% /data/sdb1

/dev/sdc1 1.6T 197M 1.5T 1% /data/sdc1

收藏与分享
19 2010

Centos yum Source (163.com)

Posted by admin in 日记

[main]
cachedir=/var/cache/yum
keepcache=1
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[base]
name=centos-5 – Base
baseurl=http://mirrors.163.com/centos/5/os/i386/
# the other site: http://centos.candishosting.com.cn/centos/5/os/i386/
# you can find more site in: http://www.centos.org/modules/tinycontent/index.php?id=13
enabled=1
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#released updates
[update]
name=CentOS-5 – Updates
baseurl=http://mirror.centos.org/centos/5/updates/i386/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-5 – Addons
baseurl=http://mirror.centos.org/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5 – Extras
baseurl=http://mirror.centos.org/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 – Plus
baseurl=http://mirror.centos.org/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#contrib – packages by Centos Users
[contrib]
name=CentOS-5 – Contrib
baseurl=http://mirror.centos.org/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#packages in testing
[testing]
name=CentOS-5 – Testing
baseurl=http://mirror.centos.org/centos/5/testing/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5

收藏与分享
09 2010

OpenVPN and CentOS 5 Installation and Configuration Guide

Posted by admin in Linux, 电脑网络

Many ppl found that installing VPN on linux is not that easy, the abvailable installation guides on VPN is often limited. I have tried a lot of installation guides and finally get it connected successfully.

Here are the steps to guide you installed a secure connection between your? CentOS5 and Windows with OpenVPN open source application.

 

 

Read entire article.

收藏与分享
29 2009

在CentOS上安装BIND9

Posted by admin in Linux

需要以下几个软件包。
bind-libs-9.3.4-10.P1.el5
bind-chroot-9.3.4-10.P1.el5
bind-9.3.4-10.P1.el5
bind-utils-9.3.4-10.P1.el5
bind-libbind-devel-9.3.4-10.P1.el5
bind-sdb-9.3.4-10.P1.el5
bind-devel-9.3.4-10.P1.el5
caching-nameserver-9.3.4-10.P1.el5
Read entire article.

收藏与分享
26 2009

在redhat linux上加双网卡

Posted by admin in Linux

今天在CentOS中添加了一块8139的网卡。启动完成后。没看到eth1这块网卡起来

通过lspci 可以看到已经存在两块网卡,/etc/sysconfig/network-script/里面已经存在ifcfg-eth1文件。

可能运行ifconfig eth1 却提示没有这个设备。

然后通过cat /etcs/sysconfig/hwconf 找到新增网卡的MAC名。然后在 eth1文件里面添加此文件。

重启network 后,成功找到设备!!!

在redhat linux上加双网卡,网关,路由 Read entire article.

收藏与分享