Archive

Archive for the ‘Command Line’ Category

CIFS data migrations

March 3rd, 2011

Almost seamless! Sort of…

As with most of my thoughts, it started with an innocent customer query. EMC have some very cool inbuilt tools for doing seamless CIFS data migration, but NetApp don’t. It’s something that often causes a fair amount of problems and some careful planning with NetApp as we don’t have this. But I was thinking today, we kinda do, I just don’t think we leverage the tools available properly.

Enter widelinks. Here is an excerpt from a NetApp KB article on the topic (KB 3011420)…

A symbolic link is a special file created by NFS clients that points to another file or directory. Widelink entries are a way to redirect absolute symbolic links on the filer. They allow the symbolic link destination to be a share on the same filer or on another filer. The following examples illustrate how to create a symlink from volume to qtree on the same filer, and from volume to volume on different filers.

What does this mean and why will my life be easier after reading the rest of this article?

So if I have a nice shiny new NetApp filer (or an old one I haven’t got round to migrating my CIFS data onto yet), and I have my old CIFS file server that is rapidly approaching failure or out of support. I can create my new file and share structure on my NetApp, and then use widelinks to redirect the user to the CIFS file server while I worry about all the data copy out of hours without having the ball-ache of copying all my data all at once.

Command Line, General , , , ,

SnapMirror Setup Script

March 14th, 2010

I had the task of replicating an existing customers filer to their new DR system. This was quite a large system, and as much as creating SnapMirrors isn’t particularly complex, it is time consuming. So as with many things I do, I wrote a script to help my achieve this task quicker, and go have yet another coffee.

You’ll need pre-shared keys setup (as ever), but the rest is prompted for. There’s no data validation (no surprise). The script will output 4 text files, one for creating/restricting all the volumes, one for the “snapmirror.conf”, on to be used in place of “snapmirror.conf” while you are doing the baseline initialization, and finally one to actually initialize the snapmirrors. There’s no intelligence around concurrent streams, so initialization is still a bit of a juggling act and waiting game.

Please let me know if you find this useful.

#!/bin/bash

echo “Please enter the name of the PRIMARY filer: ”
read PRI_FILER

echo “Please enter the name of the DR filer: ”
read DR_FILER

ConnectString=”ssh -c 3des”
#ConnectString=”rsh”

SnapMirrorHour=22
SnapMirrorMinute=0
SnapMirrorStagger=5

echo “” > ${DR_FILER}_filer_volumes.txt
echo “” > ${DR_FILER}_snapmirror.conf
echo “” > ${DR_FILER}_sm_initialize.txt
echo “” > ${DR_FILER}_snapmirror_init.conf

for AGGR in `${ConnectString} $PRI_FILER “aggr status” | awk ‘$2!~/State/{print $1}’`
do
 SIZE=`${ConnectString} $PRI_FILER “df -Ah $AGGR” | sed ‘s/\([0-9][KMGT]\)B/\1/g’ | awk ‘$1!~/.snapshot|Aggregate/{print $2}’`
 for VOL in `${ConnectString} $PRI_FILER “aggr show_space $AGGR” | awk ‘$1!~/Space/{print $0}’ | awk ‘$4~/volume|file|none/{print $1}’`
 do
  echo “vol create ${VOL} -s none ${AGGR} ${SIZE} ” >> ${DR_FILER}_filer_volumes.txt
  echo “vol restrict ${VOL}” >> ${DR_FILER}_filer_volumes.txt
  echo “snapmirror initialize -S ${PRI_FILER}:${VOL} ${DR_FILER}:${VOL}” >> ${DR_FILER}_sm_initialize.txt
  echo “${PRI_FILER}:${VOL} ${DR_FILER}:${VOL} – ${SnapMirrorMinute} ${SnapMirrorHour} * *” >> ${DR_FILER}_snapmirror.conf
  echo “${PRI_FILER}:${VOL} ${DR_FILER}:${VOL} – – – – -” >> ${DR_FILER}_snapmirror_init.conf

  SnapMirrorMinute=`expr $SnapMirrorMinute + $SnapMirrorStagger`

Command Line , , , ,

NetApp Save Config Command

April 27th, 2009

I think it’s very important to save a config of a good setup. Firstly it’s a great reference if you ever need to go back and refer to things, secondly it’s a great way to show what you did was actually correct and that you did configure things correctly from the start!

There is a handy tool provided within ONTAP to do entire config dumps, compares and restores. This is limited to the filers base configuration and doesn’t necessarily include areas like volume setup.

filer01> config
Usage:
config clone <filer> <remote_user>
config diff [-o <output_file>] <config_file1> [ <config_file2> ]
config dump [-f] [-v] <config_file>
config restore [-v] <config_file>

The command is very simple and straight forward. You start by dumping out the configuration from the filer. This automatically goes into /etc/configs. From here you can then clone the config if needed, or compare (diff) the config. Running diff is a very good way of comparing a config between 2 points in time, if you aren’t sure what has changed, or even if you are comparing a filer upgrade and you copy the config files between the 2 systems (checkout [cref netapp-file-copy]). And finally you can also use the restore feature, although this would probably require a reboot, and may have a knockon affect to what may or may not be required in various other config files within /etc.

Overall a very useful command. I use this most for taking backups of filer configs and comparing them between similar systems (for instance primary and DR), or even comparing configs over time.

Command Line , , , ,

NetApp File Copy

April 11th, 2009

It always comes up, how can I copy single files, or large areas directly from the NetApp console? Generally the answer comes back, you can’t, use RoboCopy or rsync or another file migration tool. However there are definitely ways of copying files around directly from the filer itself, and often this is the most efficient way of doing it! However, these aren’t the most intuitive or well documented commands.

There may be other methods, and if you have something you have used in the past or you know of, please feel free to share! Not all methods are suitable for all tasks, but each has it’s own individual uses.

ndmpcopy

This is often overlooked as a file / folder copy command, and is often just used to migrate entire volumes around. In fact it can be used to copy individual folders or filers around, and even better can be used to copy data to other filers! Make sure ndmp is enabled first (ndmpd on). The syntax is quite simple…

ndmpcopy /vol/vol_source_name/folder/file /vol/vol_dest_name/file

Just to break this down, we are choosing to copy a filer from “/vol/vol_source_name/folder” and we want to copy it into “/vol/vol_dest_name”. This isn’t too restrictive, we don’t have to keep the same path, and we can even copy things about in the same volume (such as copying things into QTrees if you need). You can copy things from an entire volume, to a single QTree, down to single folders way down in the directory tree. The only real restriction is you cannot use wildcards, and you cannot select multiple files to copy.

If you want to copy files from one filer to another, we simply extend this syntax…

ndmpcopy -sa <user>:<pass> -da <user>:<pass> source_filer:/vol/vol_source_name/folder/file destination_filer:/vol/vol_dest_name/file

Command Line , , , , ,

Moving / Renaming vol0

February 13th, 2009

There’s been many occasions where I’ve wanted / needed to move the vol0 to somewhere else. Just last week I had a customer that wanted to destroy the root aggregate and move some disks around, but they’d already setup the filer and didn’t want to lose this

The process is actually very simple!

Command Line , , , , ,

Creating iGroups on the DR filer

January 22nd, 2009

This is another script I wrote to aid in site failover. Basically the snapmirror script works great to bring volumes online, but if everything is in VMware (and as such iSCSI from within the VM), you want these to be automatically re-mapped, and save you some leg work!

Well, this script would run from a server sat in the DR location that has access to the primary filers. I’ve tried to make this script pretty dynamic, so you can put in as many primary filers as you want (create a ‘primary_filers.txt’ file with 1 filer name per line). However it only fails over to one filer on the DR side. This would be easily remedied, but again, just showing a concept of how easy this sort of thing is to achieve.

The difficulty here is that ‘igroup show’ outputs ‘FCP’ and ‘iSCSI’, where as ‘igroup create’ requests you use ‘f’ and ‘i’, so a bit more scripting in the middle to solve this.

This script creates a script (and if run as a cron, simply overwrites it each time) that can be run to recreate all the iGroups on the DR filer. Really handy if you have a few LUNs that need mapping. Even doing this manually for 10 is a pain. Most of my customers have at least 50+

Command Line , , ,

SnapMirror failover

January 22nd, 2009

So I helped a customer a few months ago (before SRM) to script a complete site failover. It will bring the DR site online within about 30 minutes, the scripts are a bit clunky and need a massive re-design, so I thought I’d post the originals here.

This, I think, is a great example of how flexible the NetApp systems are in that you can quickly and easily setup SSH access from a management host and script your heart away! Soon as I get the hang of the API, I’m sure there’ll be plenty more info coming along too.

This script will bring all volumes online on the DR filer, what’s more, an volume that is labelled as “_vm” at the end (which is a nice naming convention to use for all VMware volumes anyway), will get re-mapped to a new igroup you choose and already have setup for the DR ESX servers.

I’ve modified this script slightly since writing it to remove filer names, so I don’t expect it to work out of the box, as with my other scripts, it’s just meant to as an example of how this can be achieved.

Command Line , , , ,

Virtual Machine Creation

January 20th, 2009

This script can help track when a VM was created. I’m not sure if it’s technical correct however as it works on the create time of a .vmsd file. Anyway, the principles are there, and should do the job.

Command Line ,

Virtual Machine Sizes

January 20th, 2009

This can be useful to keep track of what people are creating. Get an index of the Virtual Machine sizes and the free space in the datastores (very important).

Command Line , ,

Virtual Machine Logs

January 20th, 2009

I hate the VM logs, and in a lot of cases you can end up with thousands of them which are very hard to delete or even browse to the directory. I have this script running on a cron to do a regular clear up. As a matter of course I disable VM logging now, but it can still be a challenge to clear up all the log files.

Command Line , ,



This site is not affiliated or sponsored in anyway by NetApp or any other company mentioned within.