免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 26308 | 回复: 28
打印 上一主题 下一主题

ZFS基本命令 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-27 16:19 |只看该作者 |倒序浏览
看论坛里好像没有ZFS的资料,其实ZFS还是很强大的。

自己从文档总结了一下,没那么啰嗦。有不对的请指教。

以下均在虚拟机中测试。共6块硬盘:
       0. c0d0 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@7,1/ide@0/cmdk@0,0wr
       1. c0d1 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@7,1/ide@0/cmdk@1,0
       2. c1d1 <VMware V-0000000000000000-0001-2.00GB>
          /pci@0,0/pci-ide@7,1/ide@1/cmdk@1,0
       3. c2t0d0 <VMware,-VMware Virtual S-1.0-2.00GB>
          /pci@0,0/pci15ad,1976@10/sd@0,0
       4. c2t1d0 <VMware,-VMware Virtual S-1.0-2.00GB>
          /pci@0,0/pci15ad,1976@10/sd@1,0
       5. c2t2d0 <VMware,-VMware Virtual S-1.0-2.00GB>
          /pci@0,0/pci15ad,1976@10/sd@2,0
c0d0和c0d1大小为16G,其他盘大小为2G。

ZFS GUI

First, S10u6 has a different security setting when the server communicates to the outside world.
Run this:
# svccfg -s svc:/system/webconsole setprop options/tcp_listen=true; smcwebserver restart

root@newly # svcs -a|grep web
disabled       10:27:07 svc:/application/management/webmin:default
online         10:28:26 svc:/system/webconsole:console
root@newly # svccfg -s svc:/system/webconsole setprop options/tcp_listen=true; smcwebserver restart
Restarting Sun Java(TM) Web Console Version 3.1 ...
The console is running
root@newly #
Now log on to the console: https://<server_name>:6789
If you do not see the ZFS Administration GUI showing there, do this:
# wcadmin deploy -a zfs -x zfs /usr/share/webconsole/webapps/zfs ; smcwebserver restart
Now you should be able to see the GUI. Install this patch if you see a JVM crash. This will happen if you have at least one zpool configured in the system. Thus, it also happens to servers that use ZFS as their root file system.
For S10 - SPARC,
#141104-01: SunOS 5.10: ZFS Administration Java Web Console Patch
For S10 - x86,
#141105-01: SunOS 5.10_x86: ZFS Administration Java Web Console Patch
Run "patchadd" to install the patch. Make sure you restart the web console by running "smcwebserver restart".





ZFS CLI
查看ZFS存储池状态
root@newly # zpool list
NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
rpool  15.9G  6.04G  9.84G    38%  ONLINE  -
root@newly # zpool status
  pool: rpool
state: ONLINE
scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          c0d0s0    ONLINE       0     0     0

errors: No known data errors
查看ZFS文件系统状态
root@newly # zfs list
NAME                        USED  AVAIL  REFER  MOUNTPOINT
rpool                      6.95G  8.67G    34K  /rpool
rpool/ROOT                 4.95G  8.67G    21K  legacy
rpool/ROOT/s10x_u8wos_08a  4.95G  8.67G  4.95G  /
rpool/dump                 1.00G  8.67G  1.00G  -
rpool/export                 44K  8.67G    23K  /export
rpool/export/home            21K  8.67G    21K  /export/home
rpool/swap                    1G  9.59G  85.0M  -
根池做镜像
root@newly # zpool attach rpool c0d0s0 c0d1s0
cannot attach c0d1s0 to c0d0s0: EFI labeled devices are not supported on root pools.
由于根池不支持EFI标签磁盘需要格式化磁盘并改为SMI标签磁盘
root@newly # format –e
format> l
[0] SMI Label
[1] EFI Label
Specify Label type[1]: 0
Warning: This disk has an EFI label. Changing to SMI label will erase all
current partitions.
Continue? y
You must use fdisk to delete the current EFI partition and create a new
Solaris partition before you can convert the label.
format> fdisk  使用fdisk删除EFI分区并重新label为SMI label
root@newly # prtvtoc /dev/rdsk/c0d0s2 | fmthard -s - /dev/rdsk/c0d1s2
fmthard:  New volume table of contents now in place.
root@newly # zpool attach rpool c0d0s0 c0d1s0
Please be sure to invoke installgrub(1M) to make 'c0d1s0' bootable.
安装引导信息
SPARC:
# installboot -F zfs /usr/platform/‘uname -i‘/lib/fs/zfs/bootblk /dev/rdsk/c0t1d0s0
X86:
root@newly # installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d1s0
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 272 sectors starting at 50 (abs 16115)

root@newly # zpool status

  pool: rpool
state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress for 0h3m, 17.10% done, 0h18m to go
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          mirror    ONLINE       0     0     0
            c0d0s0  ONLINE       0     0     0
            c0d1s0  ONLINE       0     0     0  1.03G resilvered

errors: No known data errors
查看状态可发现数据正在同步,1.03G为已同步的数据量
拆除镜像
root@newly # zpool detach rpool c0d1s0
root@newly # zpool status
  pool: rpool
state: ONLINE
scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          c0d0s0    ONLINE       0     0     0

errors: No known data errors
为存储池创建高速缓存设备
对于根池同样需要设置为SMI标签磁盘
root@newly # zpool add rpool cache c1d1s0
root@newly # zpool status
  pool: rpool
state: ONLINE
scrub: resilver completed after 0h20m with 0 errors on Wed Jan 27 11:15:00 2010
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          mirror    ONLINE       0     0     0
            c0d0s0  ONLINE       0     0     0
            c0d1s0  ONLINE       0     0     0  6.04G resilvered
        cache
          c1d1s0    ONLINE       0     0     0

errors: No known data errors
可通过zpool iostat 查看池io情况
root@newly # zpool iostat -v rpool
               capacity     operations    bandwidth
pool         used  avail   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
rpool       6.06G  9.81G     17      3   447K  10.9K
  mirror    6.06G  9.81G     20      3   506K  12.3K
    c0d0s0      -      -     13      0   511K  9.88K
    c0d1s0      -      -      0     19  1.91K   514K
cache           -      -      -      -      -      -
  c1d1s0    66.9M  1.91G      0     11  2.41K  1.19M
----------  -----  -----  -----  -----  -----  -----
为存储池创建单独的日志设备
root@newly # zpool add tpool log c2t2d0
创建RAIDZ存储池
单奇偶校验RAID-Z 与RAID-5 类似。双奇偶校验RAID-Z 与RAID-6 类似。
如果要创建包含许多磁盘的RAID-Z 配置,则最好将包含14 个磁盘的RAID-Z 配置拆分为两个包含7 个磁盘的分组。若RAID-Z 配置包含的分组中的磁盘数目为一位数(1-9),则该配置的性能应该更好。
root@newly # zpool create testpool raidz c2t0d0 c2t1d0 c2t2d0
创建双奇偶校验
root@newly # zpool create testpool raidz2 c2t0d0 c2t1d0 c2t2d0
root@newly # zpool status testpool
  pool: testpool
state: ONLINE
scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          raidz1    ONLINE       0     0     0
            c2t0d0  ONLINE       0     0     0
            c2t1d0  ONLINE       0     0     0
            c2t2d0  ONLINE       0     0     0

errors: No known data errors
更换RAIDZ或镜像中的设备
root@newly # zpool replace testpool c2t2d0 c1d1
root@newly # zpool status testpool
  pool: testpool
state: ONLINE
scrub: resilver completed after 0h0m with 0 errors on Wed Jan 27 11:15:10 2010
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          raidz1    ONLINE       0     0     0
            c2t0d0  ONLINE       0     0     0
            c2t1d0  ONLINE       0     0     0
            c1d1    ONLINE       0     0     0  39K resilvered

errors: No known data errors
查看及修改ZPOOL & ZFS属性
查看存储池属性
#zpool get all rpool
#zpool set failmode=coninue rpool
查看ZFS属性
#zfs get all rpool
#zpool set compression=on rpool
ZFS快照
root@newly # zfs snapshot rpool@today
root@newly # zfs list
NAME                        USED  AVAIL  REFER  MOUNTPOINT
rpool                      6.98G  8.65G    36K  /rpool
rpool@today                    0      -    36K  -
rpool/ROOT                 4.98G  8.65G    21K  legacy
rpool/ROOT/s10x_u8wos_08a  4.98G  8.65G  4.98G  /
rpool/dump                 1.00G  8.65G  1.00G  -
rpool/export                 56K  8.65G    23K  /export
rpool/export/home            33K  8.65G    33K  /export/home
rpool/swap                    1G  9.56G  85.0M  -
tpool                        81K  1.95G    21K  /tpool
ZFS快照储存在目录下的.zfs文件夹中

ZFS快照回滚
root@newly # zfs rollback rpool@today
ZFS快照备份
备份到本地文件系统
#zfs send pool1@snap1 | zfs recv pool2/rs01
#zfs send pool1@snap1 | gzip > backupfile.gz
备份到远程文件系统
#zfs send pool1@snap1 | ssh host2 zfs recv pool2/rs01
发送增量备份
#zfs send –I pool1@snap1 pool1@snap2 | ssh host2 zfs recv pool2/rs02
其中snap1为较早的快照,snap2为较晚的快照
ZFS快照恢复
#zfs recv [-F] pool1 < /backupfile.gz

论坛徽章:
0
2 [报告]
发表于 2010-04-27 16:21 |只看该作者
沙发

论坛徽章:
0
3 [报告]
发表于 2010-04-27 16:22 |只看该作者
谢谢共享

论坛徽章:
0
4 [报告]
发表于 2010-04-27 16:25 |只看该作者
学习并收藏了

论坛徽章:
0
5 [报告]
发表于 2010-04-27 16:26 |只看该作者
收藏之

论坛徽章:
0
6 [报告]
发表于 2010-04-27 16:27 |只看该作者
果然混到精华了 我很欣慰

论坛徽章:
0
7 [报告]
发表于 2010-04-27 16:32 |只看该作者
果然混到精华了 我很欣慰
喊佛 发表于 2010-04-27 16:27



    哈 欢迎哥们继续分享更多好东西

论坛徽章:
0
8 [报告]
发表于 2010-04-28 12:56 |只看该作者
定期得做做scrub。

论坛徽章:
0
9 [报告]
发表于 2010-04-28 22:16 |只看该作者
大家都对这比较感兴趣吧

论坛徽章:
0
10 [报告]
发表于 2010-04-28 22:33 |只看该作者
回复 8# oasvr


    能同步同步数据,清清碎片?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP