ZFS Appliance
From dbawiki
Contents
- 1 List the sizes and available space in all filesystems on ZFS appliance
- 2 Create a pool
- 3 Create a ZFS filesystem / dataset in the pool
- 4 Create a snapshot of the filesystem
- 5 Destroy a snapshot
- 6 Rollback a snapshot
- 7 Rename a snapshot
- 8 Destroy a filesystem
- 9 Create a clone
- 10 Oracle Snap Management Utility (SMU)
List the sizes and available space in all filesystems on ZFS appliance
Make sure to be in the root context before running this.
script
run('shares');
projects = list();
printf('%-40s %-10s %-10s\n', 'SHARE', 'USED', 'AVAILABLE');
for (i = 0; i < projects.length; i++) {
run('select ' + projects[i]);
shares = list();
for (j = 0; j < shares.length; j++) {
run('select ' + shares[j]);
share = projects[i] + '/' + shares[j];
used = run('get space_data').split(/\s+/)[3];
avail = run('get space_available').split(/\s+/)[3];
printf('%-40s %-10s %-10s\n', share, used, avail);
run('cd ..');
}
run('cd ..');
}
.
and the same information but "machine readable" sizes
script
fmt = '%-40s %-15s %-15s\n';
printf(fmt, 'SHARE', 'USED', 'AVAILABLE');
run('cd /');
run('shares');
pools = choices('pool');
for (p = 0; p < pools.length; p++) {
set('pool', pools[p]);
projects = list();
for (i = 0; i < projects.length; i++) {
run('select ' + projects[i]);
shares = list();
for (j = 0; j < shares.length; j++) {
run('select ' + shares[j]);
share = pools[p] + ':' + projects[i] + '/' + shares[j];
printf(fmt, share, get('space_data'),
get('space_available'));
run('cd ..');
}
run('cd ..');
}
}
.
Create a pool
[sudo] zfs create datapool mirror /dev/sdc /dev/sdd [sudo] zfs list
Create a ZFS filesystem / dataset in the pool
[sudo] zfs create datapool/scripts -o mountpoint=/scripts
[sudo] zfs list -r datapool
Create a snapshot of the filesystem
[sudo] zfs snapshot datapool/scripts@snap1 [sudo] zfs list -t snapshot
Destroy a snapshot
[sudo] zfs destroy datapool/scripts@snap1 [sudo] zfs list -t snapshot
Rollback a snapshot
Create a file followed by a snapshot to preserve situation
[sudo] echo "hello" >/scripts/test1.txt [sudo] cat /scripts/test1.txt [sudo] zfs snapshot datapool/scripts@before [sudo] zfs list -t snapshot
Change the contents of the file
[sudo] echo "goodbee" >/scripts/test1.txt [sudo] cat /scripts/test1.txt ====Rollback to previous snapshot and see original file contents==== <pre> [sudo] zfs list -t snapshot [sudo] zfs rollback datapool/scripts@before [sudo] cat /scripts/test1.txt [sudo] zfs list -t snapshot
Rename a snapshot
[sudo] zfs rename datapool/scripts@before datapool/scripts@after [sudo] zfs list -t snapshot
Destroy a filesystem
[sudo] zfs destroy datapool/scripts [sudo] zfs list -r datapool
If there are snapshots of the filesystem, add -r to force the destruction
[sudo] zfs destroy -r datapool/scripts [sudo] zfs list -t snapshot
Create a clone
Clones can only be created from a snapshot.
Snapshots cannot be deleted unless the clone is deleted.
Clone the snapshot datapool/scripts@before
[sudo] zfs clone datapool/scripts@before datapool/clone1 zfs list ls /datapool/clone1
Attempt to destroy underlying snapshot
Attempt to destroy underlying snapshot
[sudo] zfs destroy datapool/scripts@before
Destroy clone first
[sudo] zfs destroy datapool/clone1
Attempt to destroy underlying snapshot again
[sudo] zfs destroy datapool/scripts@before
Oracle Snap Management Utility (SMU)
can be accessed via command line Interface (CLI) as well as the standard Browser User Interface (BUI)
cat /opt/oracle/smu/etc/smu.conf
locate the line "sshd.port=<ssh port>" and use this with the root user and password