linux编译安装zfs,ZFS安装配置

参考链接:

安装ZFS

选择的AWS EC2镜像如下:

安装yum源

#yum install -y http://download.zfsonlinux.org/epel/zfs-release.el6.noarch.rpm

#gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux

备注说明:

After installing the zfs-release package and verifying the public key users can opt to install ether the kABI-tracking kmod or DKMS style packages. For most users the kABI-tracking kmod packages are recommended in order to avoid needing to rebuild ZFS for every kernel update. DKMS packages are recommended for users running a non-distribution kernel or for users who wish to apply local customizations to ZFS on Linux.

注意:2和3选择一种方法安装即可,此处选择2

使用kmod安装

1修改zfs.repo

#vi /etc/yum.repos.d/zfs.repo

[zfs]

name=ZFS on Linux for EL 7 - dkms

baseurl=http://download.zfsonlinux.org/epel/7/$basearch/

-enabled=1

+enabled=0

metadata_expire=7d

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux

@@ -9,7 +9,7 @@

[zfs-kmod]

name=ZFS on Linux for EL 7 - kmod

baseurl=http://download.zfsonlinux.org/epel/7/kmod/$basearch/

-enabled=0

+enabled=1

metadata_expire=7d

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux

2安装zfs

#yum install –y zfs

3加载内核

#modprobe zfs

DKMS安装

#yum install –y epel-release

#yum install –y "kernel-devel-uname-r == $(uname -r)" zfs

#modprobe zfs

创建zfspool

创建存储池

#zpool create 

示例:zpool create  mypool xvdf

示例raidz1:zpool create mypool raidz1 xvdb xvdc xvdd xvde xvdg xvdh

示例:挂载   zfs mount -a

配置NFS

安装nfs

#yum install –y nfs-utils rpcbind

#service rpcbind start

#service nfs start

#service nfslock start

#chkconfig rpcbind on

#chkconfig nfs on

#chkconfig nfslock on

开启NFS共享

#zfs sharenfs=on mypool

配置nfs

#zfs set sharenfs=’rw=@0.0.0.0/0’ mypool

启动共享

#zfs share –a

查看共享

#showmount –e localhost

查看需要监听的端口(安全组需要放行下面的端口)

#rpcinfo –p

zfs扩容

示例:zpool add mypool raidz1 xvdb xvdc xvdd xvde xvdf xvdg xvdh

zfs快照

#zfs snapshot poolname@snapshotname

示例:zfs snapshot -r mypool@snapshot-`date '+%F-%H-%M-%S'`-`date +%s`

注:如果有子zfs文件系统,需要加-r递归创建快照

zfs设置容量限制

#zfs set quota=20T  mypool/myfs1

zfswatcher安装

参考链接:

下载

安装

#yum install -y zfswatcher-0.03-1.x86_64.rpm

修改配置文件

#vim /etc/zfs/zfswatcher.conf

修改  [www] 模块

enable改为true

bind 改为 可用端口,如80,8080等

修改  [wwwuser “root”]  模块

password 设置密码,需要使用zfswatcher -P生成hash值

启动服务

#service zfswatcher restart

iptables、安全组放行

访问

http://ip:port

用户名:root

密码:输入设置的密码

ZFS快照脚本

#!/bin/bash

#create and delete zfs snapshot for /mypool

cd /root/shell

#timestamp for delete snapshot

time0=$((`date +%s`-21600))

#create snapshot for mypool

/sbin/zfs snapshot -r mypool@snapshot-`date '+%F-%H-%M-%S'`-`date +%s`

#delete snapshot >6h

/sbin/zfs list -t snapshot mypool -r |grep "@"|awk '{print $1}' >delete_list1

cat delete_list1 | while read line

do

time1=`echo $line|awk -F- '{print $(NF)}'`

[[ ${time1} -lt ${time0} ]]&&/sbin/zfs destroy $line

done

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值