2012 年五月
« 四    
 12345
6789101112
13141516171819
20212223242526
2728293031  
  • Posts Tagged ‘centos’

    RedHat / Centos Disable IPv6 Networking

    Our policy and network configuration does not requires IPv6 support in RHEL / CentOS / Fedora Linux. How do I prevent the kernel module from loading at boot time and disable IPv6 networking?

    You can easily prevent the kernel module from loading by updating the following two files:

    /etc/modprobe.conf - Kernel driver configuration file.
    /etc/sysconfig/network - RHEL / CentOS networking configuration file. 

    Read the rest of this entry »

    如何生成IOU l2的License

        今天冲网上得到了IOU的L2版本。

     

     

    因为我的环境比较特殊。

    我以前的IOU使用的环境是Vmware+Centos5.4。

    当然现在有更好的环境就是AndLinux。可是我玩不懂这个。所以还是只有在Centos 的环境下去运行IOUL2了。

     

    可是一运行就提示我的License有错。

    IOU License Error: invalid license
    License for key 7f03b7 required on host "CDlinux".
    Obtain a license for this key and host from the following location: 
    
    http://wwwin-enged.cisco.com/ios/iou/license/index.html
    
    Place in your iourc file as follows (see also the web page
    for further details on iourc file format and location) 
    
    [license]
    CDlinux = <16 char license>;
    IOU 3328 exit

    Read the rest of this entry »

    CentOS 使用YUM从CDROM中更新软件

    #cd /media

    #mkdir cdrom

    #mount /dev/cdrom /media/cdrom

    #yum –disablerepo=\* –enablerepo=c5-media install gcc

    最后一句是使用yum安装gcc

    当然,操作前记得把光盘放进光驱里

    Read the rest of this entry »

    Install Mod-page-speed In my VPS

     

    System OS: Linux vps4.ghitr.com 2.6.18-194.26.1.el5.028stab070.14 #1 SMP Thu Nov 18 16:34:01 MSK 2010 i686 i686 i386 GNU/Linux
    Mod-page-speed Get URL:https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm

     

    First: yum install at
    Rpm –U mod-pagespeed*.rpm

    最后重启 apache 就好了。

     

    image

    LinuxVPS自动每日备份文件和数据库上传FTP空间

     

     

    最近买了几个VPS,虽说用着舒服,可是也怕数据掉呀。

    此文介绍一种,每天自动备份网站以及数据库文件,发送EMAIL到邮箱,并上传网站和数据加文件到FTP空间,自动删除旧备份的方法。

    首先安装EMAIL发送组件:

    yum install sendmail mutt

    脚本下载地址:http://www.vpsmm.com/soft/AutoBackupToFtp.sh

    脚本代码如下(注意修改FTP服务器地址用户名密码):

    #!/bin/bash
    #你要修改的地方从这里开始
    MYSQL_USER=root                             #mysql用户名
    MYSQL_PASS=123456                      #mysql密码
    MAIL_TO=cat@hostloc.com                 #数据库发送到的邮箱
    FTP_USER=cat                              #ftp用户名
    FTP_PASS=123456                         #ftp密码
    FTP_IP=imcat.in                          #ftp地址
    FTP_backup=backup                          #ftp上存放备份文件的目录,这个要自己得ftp上面建的
    WEB_DATA=/home/www                          #要备份的网站数据
    #你要修改的地方从这里结束
    #定义数据库的名字和旧数据库的名字
    DataBakName=Data_$(date +"%Y%m%d").tar.gz
    WebBakName=Web_$(date +%Y%m%d).tar.gz
    OldData=Data_$(date -d -5day +"%Y%m%d").tar.gz
    OldWeb=Web_$(date -d -5day +"%Y%m%d").tar.gz
    #删除本地3天前的数据
    rm -rf /home/backup/Data_$(date -d -3day +"%Y%m%d").tar.gz /home/backup/Web_$(date -d -3day +"%Y%m%d").tar.gz
    cd /home/backup
    #导出数据库,一个数据库一个压缩文件
    for db in `/usr/local/mysql/bin/mysql -u$MYSQL_USER -p$MYSQL_PASS -B -N -e ‘SHOW DATABASES’ | xargs`; do
        (/usr/local/mysql/bin/mysqldump -u$MYSQL_USER -p$MYSQL_PASS ${db} | gzip -9 – > ${db}.sql.gz)
    done
    #压缩数据库文件为一个文件
    tar zcf /home/backup/$DataBakName /home/backup/*.sql.gz
    rm -rf /home/backup/*.sql.gz
    #发送数据库到Email,如果数据库压缩后太大,请注释这行
    echo "主题:数据库备份" | mutt -a /home/backup/$DataBakName -s "内容:数据库备份" $MAIL_TO
    #压缩网站数据
    tar zcf /home/backup/$WebBakName $WEB_DATA
    #上传到FTP空间,删除FTP空间5天前的数据
    ftp -v -n $FTP_IP << END
    user $FTP_USER $FTP_PASS
    type binary
    cd $FTP_backup
    delete $OldData
    delete $OldWeb
    put $DataBakName
    put $WebBakName
    bye
    END

    给脚本添加执行权限:

    chmod +x /root/AutoBackupToFtp.sh

    利用系统crontab实现每天自动运行:

    crontab -e

    输入以下内容:

    00 00 * * * /root/AutoBackupToFtp.sh

    其中00 00为时间分/小时,可自行修改,例如:30 12 ***,就是每天12.30运行这个脚本。

    附一个使用lftp备份文件

    #!/bin/bash
    #定义数据库的名字和旧数据库的名字
    DataBakName=Data_$(date +"%Y%m%d").tar.gz
    WebBakName=Web_$(date +%Y%m%d).tar.gz
    #删除本地3天前的数据
    rm -rf /home/backup/Data_$(date -d -3day +"%Y%m%d").tar.gz /home/backup/Web_$(date -d -3day +"%Y%m%d").tar.gz
    #导出mysql数据库
    /usr/local/mysql/bin/mysqldump -uroot -ppassword –databases db1 > /home/backup/databackup.sql
    #压缩数据库
    tar zcf /home/backup/$DataBakName /home/backup/databackup.sql
    rm -rf /home/backup/databackup.sql
    #压缩网站数据
    tar zcvf /home/backup/$WebBakName /home/wwwroot
    #使用lftp同步备份目录
    lftp -u user,password -e "mirror -R –only-newer /home/backup /backup" ftp.yoursite.cn
    exit
    END

    转载自:http://imcat.in/auto-backup-site-files-database-upload-ftp/

    Centos5 连接IP-SAN

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

    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

    Centos yum Source (163.com)

    [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

    OpenVPN and CentOS 5 Installation and Configuration Guide

    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 the rest of this entry »

    在CentOS上安装BIND9

    需要以下几个软件包。
    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 the rest of this entry »

    在redhat linux上加双网卡

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

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

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

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

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

    在redhat linux上加双网卡,网关,路由 Read the rest of this entry »