Install ZFS on CentOS use yum

使用打包好的安装, 好处是加了dkms支持. 一些配置也都弄好了.

以centos 6.x为例

需要访问外网.

$ sudo yum localinstall --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release$(rpm -E %dist).noarch.rpm

$ sudo yum install zfs 

如果你的机子仅仅只能临时出外网的话, 用完建议重命名.

下次要用的时候, 先申请出外网的权限再把它改回去.

[root@db- ~]# cd /etc/yum.repos.d/

[root@db- yum.repos.d]# ll

total 16

-rw-r--r--. 1 root root 2081 Mar 14 14:27 CentOS6-Base-skymobi_San_Dun.repo

-rw-r--r--. 1 root root 1109 Mar 14 14:27 epel6-skymobi_San_Dun.repo

drwxr-xr-x  2 root root 4096 Mar 14 14:30 repos_back

-rw-r--r--  1 root root  771 May 31 05:14 zfs.repo

[root@db- yum.repos.d]# mv zfs.repo zfs.repo.bak

使用yum安装的话, 自动添加init.d服务.

[root@db-172-16-3-150 src]# chkconfig --list|grep zfs

zfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@db-172-16-3-150 src]# cat /etc/init.d/zfs

#!/bin/bash

#

# zfs           This script will mount/umount the zfs filesystems.

#

# chkconfig:    2345 01 99

# description:  This script will mount/umount the zfs filesystems during

#               system boot/shutdown.  Configuration of which filesystems

#               should be mounted is handled by the zfs 'mountpoint' and

#               'canmount' properties.  See the zfs(8) man page for details.

#               It is also responsible for all userspace zfs services.

#

### BEGIN INIT INFO

# Provides: zfs

# Required-Start:

# Required-Stop:

# Should-Start:

# Should-Stop:

# Default-Start: 2 3 4 5

# Default-Stop: 1

# Short-Description: Mount/umount the zfs filesystems

# Description: ZFS is an advanced filesystem designed to simplify managing

#              and protecting your data.  This service mounts the ZFS

#              filesystems and starts all related zfs services.

### END INIT INFO

export PATH=/usr/local/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

if [ -z "$init" ]; then

    # Not interactive

    grep -Eqi 'zfs=off|zfs=no' /proc/cmdline && exit 3

fi

# Source function library & LSB routines

. /etc/rc.d/init.d/functions

# script variables

RETVAL=0

ZFS="/sbin/zfs"

ZPOOL="/sbin/zpool"

ZPOOL_CACHE="/etc/zfs/zpool.cache"

servicename=zfs

LOCKFILE=/var/lock/subsys/$servicename

# functions

zfs_installed() {

        modinfo zfs > /dev/null 2>&1 || return 5

        $ZPOOL  > /dev/null 2>&1

        [ $? == 127 ] && return 5

        $ZFS    > /dev/null 2>&1

        [ $? == 127 ] && return 5

        return 0

}

# i need a bash guru to simplify this, since this is copy and paste, but donno how

# to correctly dereference variable names in bash, or how to do this right

# first parameter is a regular expression that filters fstab

read_fstab() {

        unset FSTAB

        n=0

        while read -r fs mntpnt fstype opts blah ; do

                fs=`printf '%b\n' "$fs"`

                FSTAB[$n]=$fs

                let n++

        done < <(egrep "$1" /etc/fstab)

}

start()

{

        # Disable lockfile check

        # if [ -f "$LOCKFILE" ] ; then return 0 ; fi

        # check if ZFS is installed.  If not, comply to FC standards and bail

        zfs_installed || {

                action $"Checking if ZFS is installed: not installed" /bin/false

                return 5

        }

        # Requires selinux policy which has not been written.

        if [ -r "/selinux/enforce" ] &&

           [ "$(cat /selinux/enforce)" = "1" ]; then

                action $"SELinux ZFS policy required: " /bin/false || return 6

        fi

        # Delay until all required block devices are present.

        if [ -x /sbin/udevadm ]; then

                /sbin/udevadm settle

        elif [ -x /sbin/udevsettle ]; then

                /sbin/udevsettle

        fi

        # load kernel module infrastructure

        if ! grep -q zfs /proc/modules ; then

                action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5

        fi

        sleep 1

        action $"Mounting automounted ZFS filesystems: " $ZFS mount -a || return 152

        action $"Exporting ZFS filesystems: " $ZFS share -a || return 153

        # Read fstab, try to mount zvols ignoring error

        read_fstab "^/dev/(zd|zvol)"

        template=$"Mounting volume %s registered in fstab: "

        for volume in "${FSTAB[@]}" ; do

                string=`printf "$template" "$volume"`

                action "$string" mount "$volume" 2>/dev/null || /bin/true

        done

        # touch "$LOCKFILE"

}

stop()

{

        # Disable lockfile check

        # if [ ! -f "$LOCKFILE" ] ; then return 0 ; fi

        # check if ZFS is installed.  If not, comply to FC standards and bail

        zfs_installed || {

                action $"Checking if ZFS is installed: not installed" /bin/false

                return 5

        }

        # the poweroff of the system takes care of this

        # but it never unmounts the root filesystem itself

        # shit

        action $"Syncing ZFS filesystems: " sync

             # about the only thing we can do, and then we

             # hope that the umount process will succeed

             # unfortunately the umount process does not dismount

             # the root file system, there ought to be some way

             # we can tell zfs to just flush anything in memory

             # when a request to remount,ro comes in

        #echo -n $"Unmounting ZFS filesystems: "

        #$ZFS umount -a

        #RETVAL=$?

        #if [ $RETVAL -ne 0 ]; then

        #       failure

        #       return 8

        #fi

        #success

        rm -f "$LOCKFILE"

}

# See how we are called

case "$1" in

        start)

                start

                RETVAL=$?

                ;;

        stop)

                stop

                RETVAL=$?

                ;;

        status)

                lsmod | grep -q zfs || RETVAL=3

                $ZPOOL status && echo && $ZFS list || {

                        [ -f "$LOCKFILE" ] && RETVAL=2 || RETVAL=4

                }

                ;;

        restart)

                stop

                start

                ;;

        condrestart)

                if [ -f "$LOCKFILE" ] ; then

                        stop

                        start

                fi

                ;;

        *)

                echo $"Usage: $0 {start|stop|status|restart|condrestart}"

                RETVAL=3

                ;;

esac

exit $RETVAL

[参考]
1. http://zfsonlinux.org/epel.html

时间: 2024-09-30 03:41:09

Install ZFS on CentOS use yum的相关文章

GlusterFS on ZFS on CentOS 6.x x64

原文如下, 但是这里有几点不推荐按照原文来做. 1. zfs set sync=disabled sp1  (不推荐) 如果没有UPS的话, 不推荐关闭sync, 因为任何异常都可能会导致数据丢失.              sync=standard | always | disabled            Controls  the  behavior  of  synchronous  requests  (e.g. fsync, O_DSYNC).              1. s

CentOS epel yum 源配置

EPEL,即Extra Packages for Enterprise Linux,这个软件仓库里有很多非常常用的软件,而且是专门针对RHEL设计的,对RHEL标准yum源是一个很好的补充,完全免费使用,由Fedora项目维护,所以如果你使用的是RHEL,或者CentOS,Scientific等RHEL系的linux,可以非常放心的使用EPEL的yum源. centos 6.5 wget http://mirrors.kernel.org/fedora-epel/6/x86_64/epel-re

centos下yum搭建安装linux+apache+mysql+php环境教程_Linux

我们利用linux系统中yum安装Apache+MySQL+PHP是非常的简单哦,只需要几步就可以完成,具体如下: 一.脚本YUM源安装: 1.yum install wget                                                     #安装下载工具wget 2.wget http://www.atomicorp.com/installers/atomic       #下载atomic yum源,配置CentOS 6.5第三方yum源 3. sh 

CentOS 7 YUM 搭建Kubernetes 1.0

Kubernetes 日前终于发布了稳定版 1.0, 本文将要出一个系列的文章来讲述如何搭建环境,部署服务,网络分析,升级服务,备份数据,最后到达如何对Kubernetes进行二次发. CentOS7 YUM 搭建Kubernetes 1.0 相信点击进来的人都应该知道Kubernetes是什么吧,关于介绍,请看: http://www.infoq.com/cn/articles/Kubernetes-system-architecture-introduction?utm_campaign=i

CentOS 下yum安装mysql、jdk和tomcat的方法_Linux

0. 创建个人文件夹 # 使用 yum 安装tomcat 和 mysql # 创建文件夹 cd /usr/local mkdir hehe 1. 安装rzsz # 1. 安装rzsz yum list lrzsz* yum install lrzsz -y 2. 安装JDK,path之类的已经自动设置好了 # 2. 安装JDK yum list java* yum install java-1.7.0-openjdk* -y 3. 安装mysql # 3. 安装mysql yum list my

CentOS中yum 源的配置与使用详解_Linux

一.yum 简介 yum,是Yellow dog Updater, Modified 的简称,是杜克大学为了提高RPM 软件包安装性而开发的一种软件包管理器.起初是由yellow dog 这一发行版的开发者Terra Soft 研发,用python 写成,那时还叫做yup(yellow dog updater),后经杜克大学的Linux@Duke 开发团队进行改进,遂有此名.yum 的宗旨是自动化地升级,安装/移除rpm 包,收集rpm 包的相关信息,检查依赖性并自动提示用户解决.yum 的关键

centos下yum搭建安装linux+apache+mysql+php环境的方法_Linux

一.脚本YUM源安装: 1.yum install wget #安装下载工具wget 2.wget http://www.atomicorp.com/installers/atomic #下载atomic yum源,配置CentOS 6.5第三方yum源 3. sh ./atomic #脚本执行 4. yum check-update #更新yum软件包 二.163yum源的安装 1.进入yum源配置目录 cd /etc/yum.repos.d 2.备份系统自带的yum源 mv CentOS-B

搭建CentOS在线yum源镜像服务器的步骤

说明: 操作系统:CentOS 6.x IP地址:192.168.21.188 实现目的:同步CentOS镜像站点的内容到此服务器,并且通过配置http服务器,能够向外提供yum服务 准备篇: 一.安装http服务器 这里使用Nginx服务器提供http服务  二.系统约定 Nginx站点根目录:/usr/local/nginx/html 服务器执行脚本文件存放目录:/home/crontab 三.开始Nginx目录浏览功能 vi /usr/local/nginx/conf/nginx.conf

Redhat 6.0如何使用CentOS的yum源在线安装软件

由于Redhat的yum在线更新是收费的,如果没有注册的话是不能使用的,即不能在线安装软件.在这种情况下,想使用Redhat系统,还想用yum源来在线安装软件,有没有办法?答案是有办法,请往下看! 1.删除redhat原有的yum &http://www.aliyun.com/zixun/aggregation/37954.html">nbsp;  rpm -aq|grep yum|xargs rpm -e --nodeps  #删除 2.下载新的yum安装包  #这里我们使用Ce