Overclockers Australia Forums
OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Specific Hardware Topics > Storage & Backup

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Reply
 
Thread Tools
Old 20th August 2010, 11:03 AM   #166
flain
Member
 
Join Date: Oct 2005
Posts: 1,792
Default

Bummer that you got WD Greens. Don't feel too bad though i did the same.

You wont get as good performance from them as other drives due to a number of factors. However, you should be able to run a stable server, just not as fast.

Also - since you got the WD greens, avoid expanders.
flain is offline   Reply With Quote

Join OCAU to remove this ad!
Old 20th August 2010, 11:05 AM   #167
Copie
(Banned or Deleted)
 
Join Date: Jul 2009
Location: Newcastle
Posts: 7,851
Default

Quote:
Originally Posted by kxy View Post
I plan on getting a pair of these cards.
http://cgi.ebay.com.au/ws/eBayISAPI....m=330450478830
Ill be then running 16 drives from the cards, and the other 4 drives can just use onboard controller, and wont be part of the main zpool.

I picked up this board yesterday
http://www.pccasegear.com/index.php?...ducts_id=14128

it has 2x pci-eX16, 1 X4 and 1 X1, which means i can run 2 raid cards, have a dual gig NIC in the X1 slot and still have a X16 slot for something else down the track. I cant see any reason to put a vga card there since the board is has onboard VGA.

So theres no reason for me to use a chenbro Expander as yet.

I have 4 brand new WD green 1.5tb drives, and 4 older 300gig drives, I will build an 8 disk vdev to start with, and swap the 300s for 1.5s as I buy 1 or 2 each payweek, then I will wait til i have another 4 drives and do the same again with a second 8 drive vdev. This should suit my needs for the next year or 2 storage wise.
Dual and quad NIC's are usually 4x, not 1x.
Copie is offline   Reply With Quote
Old 22nd August 2010, 7:45 PM   #168
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

Not sure if I have posted this before, but here is a way to use ssh to run commands on a remote machine without being prompted for a password.

I use this to send backups to my backup opensolaris server and also to control the VM's from the Nagios VM (running in a CentOS VM).

Code:
Instructions here:
http://blogs.sun.com/jkini/entry/how_to_scp_scp_and
How To scp, ssh and rsync without prompting for password

Whenever you need to use scp to copy files, it asks for passwords. Same with rsync as it (by default) uses ssh as well. Usually scp and rsync commands are used to transfer or backup files between known hosts or by the same user on both the hosts. It can get really annoying the password is asked every time. I even had the idea of writing an expect script to provide the password. Of course, I didn't. Instead I browsed for a solution and found it after quite some time. There are already a couple of links out there which talk about it. I am adding to it...

Lets say you want to copy between two hosts host_src and host_dest. host_src is the host where you would run the scp, ssh or rsyn command, irrespective of the direction of the file copy!

On host_src, run this command as the user that runs scp/ssh/rsync

$ ssh-keygen -t rsa

This will prompt for a passphrase. Just press the enter key. It'll then generate an identification (private key) and a public key. Do not ever share the private key with anyone! ssh-keygen shows where it saved the public key. This is by default ~/.ssh/id_rsa.pub:

Your public key has been saved in <your_home_dir>/.ssh/id_rsa.pub 

Transfer the id_rsa.pub file to host_dest by either ftp, scp, rsync or any other method. 

On host_dest, login as the remote user which you plan to use when you run scp, ssh or rsync on host_src. 

Copy the contents of id_rsa.pub to ~/.ssh/authorized_keys 

$ cat id_rsa.pub >>~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys

If this file does not exists, then the above command will create it. Make sure you remove permission for others to read this file. If its a public key, why prevent others from reading this file? Probably, the owner of the key has distributed it to a few trusted users and has not placed any additional security measures to check if its really a trusted user.

Note that ssh by default does not allow root to log in. This has to be explicitly enabled on host_dest. This can be done by editing /etc/ssh/sshd_config and changing the option of PermitRootLogin from no to yes. Don't forget to restart sshd so that it reads the modified config file. Do this only if you want to use the root login.

Well, thats it. Now you can run scp, ssh and rsync on host_src connecting to host_dest and it won't prompt for the password. Note that this will still prompt for the password if you are running the commands on host_dest connecting to host_src. You can reverse the steps above (generate the public key on host_dest and copy it to host_src) and you

Summary:

Create the key
---------------
nas@nas:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/nas/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /export/home/nas/.ssh/id_rsa.
Your public key has been saved in /export/home/nas/.ssh/id_rsa.pub.
The key fingerprint is:
80:96:37:89:42:eb:80:65:9f:8a:e7:07:2d:4e:58:a1 nas@nas
nas@nas:~$ cat /export/home/nas/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAdlkfsaflkjkjdsfhlskjdfhfkdkBwD1WVJxoH1VTqVMUpDPKJGljLGHlhgljhGLIUttOIV5GYuZ89LLblvSoxmg17VvZwip3IhnBlaAICAI0mCI785JKHGkjg3o1hlxgnsMXk= nas@nas

Copy it to the remote server and put it in ~/.ssh/authorized_keys
Done :)
----------------------------
Now I can do things like this...
Code:
nas@nas:~# zfs snapshot cloud@now04062010
nas@nas:~# zfs send cloud@now04062010 | ssh backup -l backup 'pfexec /usr/sbin/zfs receive backup/cloud'
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.

Last edited by davros123; 22nd August 2010 at 7:47 PM.
davros123 is offline   Reply With Quote
Old 22nd August 2010, 9:38 PM   #169
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

I found a free online ebook on Samba here http://oreilly.com/catalog/samba/cha...k/ch01_01.html

The index does not seem to work but it seems the chapers are all there...and while it may not be the most recent samba, it's still helped me to understand Samba and the config.

Hope it is of use for someone else. Cheers.

Ps..here is how the name samba was born...
Quote:
Samba is the brainchild of Andrew Tridgell, who currently heads the Samba development team from his home of Canberra, Australia. The project was born in 1991 when Andrew created a fileserver program for his local network that supported an odd DEC protocol from Digital Pathworks. Although he didn't know it at the time, that protocol later turned out to be SMB. A few years later, he expanded upon his custom-made SMB server and began distributing it as a product on the Internet under the name SMB Server. However, Andrew couldn't keep that name -- it already belonged to another company's product -- so he tried the following Unix renaming approach:

grep -i 's.*m.*b' /usr/dict/words
And the response was:

salmonberry samba sawtimber scramble
Thus, the name "Samba" was born.
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.

Last edited by davros123; 22nd August 2010 at 10:09 PM.
davros123 is offline   Reply With Quote
Old 23rd August 2010, 6:24 AM   #170
Simwah
Member
 
Join Date: Aug 2005
Location: Bardon, Brisbane
Posts: 2,005
Default

Kinda new to this stuff, how do you expand, add another disk or replace a disk?
Simwah is offline   Reply With Quote
Old 23rd August 2010, 11:02 AM   #171
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

Hi Simwash,
Re. Growing the array...This has been covered a few times and is a topic of much debate...as it's a point of difference between zfs and say mdadm unler linux.

With zfs, there is no "grow" command.

To grow an array you can...
1) Destroy the array and make a new one of the size and config. you now want and restore from the backup...and everyone with a large array does have a backup don't they? It should be factored into the cost of building a fileserver.

Pro: "clean". You have complete freedom on the array shape.
Con: Takes a long time to copy data back.

2) Add a new vdev. ie set of disks which augment the existing set of disks. So, if you have a raidz2 array of 7 disks, just add another vdev consisting of 7 disks (also raidz2) and the space is immediately made available to the pool. The pool is now double the size and you data remains intact.
Pro: Takes 10 seconds
Con: "lose" 1 or 2 disks of space in the new vdev to parity.

3) Replace the disks one at a time in the array with larger disks and the data will "resilver" onto the new disks. Once all the disks in the vdev are of the new size, the additional space will appear as available. All your data remains intact. For example, say your array is made up of 7 x 1TB drives in raidz2. You "offline" one drive and replace it with a 2TB drive, then online it. ZFS will see the new drive and rebuild the data onto it. This will take ~2 hours. When this is done, move on to the next drive. All this can be done without rebooting the server.

Pro: Can be done progressively over time. Simple.
Con: Best done with Raidz2 as it exposes the array to some risk. Takes time and labor. Need to replace all the disks to see the new space.

I hope that helps.

I recommend option 1). It forces you to value your storage costs as prime and backup. let's say 1.5TB drives can be had for $90, I just price my backup array as costing $180/1.5TB.

Also, re. an overall intro to an opensolaris server, you might want to check out this guys blog.
A home fileserver using zfs

But basically, to replace a drive (in this case, let's say drive c0t3d0 has died) you would do as follows...
Code:
zpool replace tank c0t3d0
zfs will see the new drive and automatically start to resilver it (ie. repopulate it with data).
Code:
zpool status tank
  pool: tank
 state: DEGRADED
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 0h0m, 0.40% done, 2h45m to go
config:

        NAME              STATE     READ WRITE CKSUM
        tank              DEGRADED     0     0     0
          raidz1          DEGRADED     0     0     0
            c0t2d0        ONLINE       0     0     0
            replacing     DEGRADED     0     0     0
              c0t3d0s0/o  FAULTED      0     0     0  corrupted data
              c0t3d0      ONLINE       0     0     0
            c0t4d0        ONLINE       0     0     0
            c0t5d0        ONLINE       0     0     0

errors: No known data errors
and once it's done, you'll see this...
Code:
zpool status tank
  pool: tank
 state: ONLINE
 scrub: resilver completed after 2h34m with 0 errors on Wed Jan 14 21:48:43 2009
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          raidz1    ONLINE       0     0     0
            c0t2d0  ONLINE       0     0     0
            c0t3d0  ONLINE       0     0     0
            c0t4d0  ONLINE       0     0     0
            c0t5d0  ONLINE       0     0     0

errors: No known data errors
Cheers and all the best with the build.
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.

Last edited by davros123; 23rd August 2010 at 11:26 AM.
davros123 is offline   Reply With Quote
Old 24th August 2010, 1:39 PM   #172
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

Well the much tweaked server got a heart transplant today...I swapped out my ever faithful Q6600 for a Xeon 3370.

There was no real need, but I was capping it out on all cores when running the 4 VM's and doing a scrub...now it's more like 70%. Interestingly, it was also capping out when copying to the nas, now again it's ~70% on all cores.

Reading from the nas is still "capped" and dead flat at ~56MB. I still get "dips" in writing to the nas (which goes @ ~105MB), but they are much smaller dips and it seems to recover faster.

It's purring along nicely in "normal" operation @ ~10% on all cores - that's with 4 VM's running.

I need to run another scrub as the last one completed in under 2 hours which is mighty fast for 6.5TB...so I'll run that again tonight just to verify the numbers. If it is true, then that's great as I want my scrubs to complete overnight in the wee hours and as she fills up, this would fit nicely into a Monday am window.

All in all, she is looking pretty damn good at the moment.

Short summary of her duties...

nas - Samba
iSCSI target
VM Box - VirtualBox
email server
voip (elastix)
FTP
VPN server
Web server
torrent - utorrent
teamspeak server
media streaming
security cameras - Mainline Xprotect Essential
Monitoring/alerting - Nagios and Growl to the iPad
DHCP - Disabled at the moment while I work it out.

Now I just need to sort that "capping" @ 56MB when reading from the nas...<no must resist more tinkering>...

EDIT: Did not see a link to the Automatic scrob smf/script in my thread...so for future reference, it is here http://blogs.sun.com/constantin/entr...zfs_auto_scrub
This neat script will schedule scrubs for your pools to happen at pre-determined times and is managed vi smf's.
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.

Last edited by davros123; 24th August 2010 at 1:54 PM.
davros123 is offline   Reply With Quote
Old 25th August 2010, 11:36 PM   #173
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

As you may have seen from a while back, I have been using Nagios to monitor my systems across the house, including the VM's. With re recent re-install, I decided to put Nagios into VM (CentOS5.5) because Opensolaris was being fussy about rrdtool and I wanted to get some graphing happening.

I will likely re-install Nagios onto the opensolaris host (just to monitor and manage the Nagios VM).

Anyway, here's some screen shots of the system showing the charting. It's handy to be able to look back and see what's happened on the system...for example, when cpu peaks or the network has issues.

for example...Nagios looks like this and pnp4Nagios adds a small icon to the screen that when clicked takes you to the historical data. There are other tools out there that do this, but this one suited me and works well. There were some tricks to getting pnp4nagios to work in CentOS5.5, so ping me if you need assistance on this.


Click to view full size!


Click the icon and you get this...

Click to view full size!

Cpu is high as I am transcoding video on that VM ...or this...

Click to view full size!


Once you have nagios and you stop obsessively looking at your servers..you start obsessively looking at Nagios screen! The solution to that is to install nagstatmon on your PC (Win or Linux ).

This cool and unobtrusive app. will sit there all green and happy and monitor nagios in the background. It will beep and flash up any alerts that occur in Nagios. You can then review them and action them - it will even allow you to click on an alert and ssh or vnc straigth into the machine with the issue...Cool!


Click to view full size!

Shows this when there is an alert...otherwise says OK.


That screenshot is not from my system as I do not have any alerts at the moment...I went to click on the warning, but it was from the transcoding and resolved itself just as I was going to screen capture it.

Anyway, just thought I'd share. It's great to finally get the server humming along as it's freeing up time to spend on other projects. And with all the automation I have been able to layer on it, it's starting to really pay dividends.

Oh, if you are going to implement a new monitoring install, check icinga out...it a fork of nagios, newer architecture and looks really good. I may move to it when the new release comes out in a month or 2.

I might even go to bed before midnight tonight
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.

Last edited by davros123; 25th August 2010 at 11:44 PM.
davros123 is offline   Reply With Quote
Old 26th August 2010, 9:23 AM   #174
J-C90
Member
 
J-C90's Avatar
 
Join Date: Jun 2010
Location: VM01
Posts: 190
Default

I use Cacti on a VM for monitoring stuff on my network. Makes troubleshooting issues so much easier! I just wish ESXi had a useful SNMP implementation. I haven't managed to get disk usage on the zpools graphed properly yet, one of my next tasks.
__________________
www.jaseshouse.com
J-C90 is offline   Reply With Quote
Old 28th August 2010, 12:25 AM   #175
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

Hi J-C90, I was going to use Cacti, but then came across the pnp4nagios plugin and went that way...

I am interested in Cacti though, it looks cool. I just came across this post on installing cacti on Opensolaris (also in a zone) I'll leave the link here as I may come back to it some time.

http://fisheyemicro.com/jamwiki/en/Monitoring
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.
davros123 is offline   Reply With Quote
Old 30th August 2010, 11:03 AM   #176
J-C90
Member
 
J-C90's Avatar
 
Join Date: Jun 2010
Location: VM01
Posts: 190
Default

Quote:
Originally Posted by davros123 View Post
Hi J-C90, I was going to use Cacti, but then came across the pnp4nagios plugin and went that way...

I am interested in Cacti though, it looks cool. I just came across this post on installing cacti on Opensolaris (also in a zone) I'll leave the link here as I may come back to it some time.

http://fisheyemicro.com/jamwiki/en/Monitoring
I have an ESXi server on my home LAN and I installed CactiEZ into a VM dedicated to monitoring all my servers/routers etc on the LAN.

http://cactiez.cactiusers.org/

CactiEZ is prepackaged Cacti on Centos with some of the more commonly used plugins. It works really well. I havent checked out Nagios, but it uses RRDTool so sounds pretty similar. I went with Cacti as a Cisco technician recommended it when I was asking about what to use for monitoring the router interfaces at work.
__________________
www.jaseshouse.com
J-C90 is offline   Reply With Quote
Old 30th August 2010, 1:46 PM   #177
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

Cool...sounds easy. I built mine on CentOS 5.5 from scratch...not simple, but as I have done this a few times now, I am starting to get the hang of it.

Correct me if I am wrong, but cacti is more of a reporting and charting tool and nagios is monitoring/alerting/automated recovery/incident management etc.

Really good to have both.

I just completed the integration of Growl so now I get pop-ups on my ipad if there are any issues that nagios is not able to auto-correct (ie. via rebooting/running recovery scripts/etc.)

As an example, I have a script that sends out an email via an external mail server (my isp via SMTP) and then checks to see that it has arrived on my servers's mail server (via IMAP) in an appropriate time.

Hours of fun!
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.
davros123 is offline   Reply With Quote
Old 30th August 2010, 4:23 PM   #178
J-C90
Member
 
J-C90's Avatar
 
Join Date: Jun 2010
Location: VM01
Posts: 190
Default

I want to eventually set up Cacti from scratch on Centos - the problem with CactiEZ is that the Cacti version(and Centos) it uses is a little dated now. I went with CactiEZ because I was in a hurry to get some monitoring up and running to trouble shoot a network issue and it already had the plugins I wanted.

Yeah Cacti is basically a logging/reporting tool, but there are plenty of plugins that enable you to expand its features. One plugin that comes with CactiEZ is 'THOLD' that allows you to set-up alerts based on 'thresholds' you configure. From this apparently you can have alerts sent via email/sms etc. I haven't actually played with this plugin yet! There is a lot I want to fiddle with in Cacti and SNMP when I find some time!

This looks intersting: http://www.assembla.com/wiki/show/npc

Nagios and Cacti may compliment each other as a complete monitoring + reporting tool? I'll have to look closer at Nagios, the recovery and proactive stuff sounds cool!
__________________
www.jaseshouse.com
J-C90 is offline   Reply With Quote
Old 2nd September 2010, 6:40 PM   #179
davros123 Thread Starter
Member
 
Join Date: Jun 2008
Posts: 1,854
Default

Hi Guys, a few pages back I posted a link to a blog that gave info on how to setup VirtualBox as an SMF...I thought I'd post a summary here (one of the members asked for this info.).

In my case I have 4 VM's named : Nagios, Server5, Server6 and Elastix. You'll need to edit the SMF xml to reflect the names of your VM's.

Summary of the setup Instructions
Code:
Install VB as per instructions...
ie      pkgadd -d VirtualBox-3.2.0-SunOS-r61806.pkg

pfexec bash
Install manifest and vbox script
cp vbox.xml /var/svc/manifest/site/vbox.xml
cp vbox /bin/vbox
chmod 755 /bin/vbox
chown root:bin /bin/vbox
mkdir /export/home/nas/svc
mkdir /export/home/nas/svc/var
cd /var/svc/manifest/site/
svccfg validate vbox.xml
svccfg import vbox.xml
svcadm enable vbox:Nagios
svcadm enable vbox:Server5
svcadm enable vbox:Server6
svcadm enable vbox:Elastix
svcs -xv
vbox.xml (the SMF script).
Code:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
   http://adumont.serveblog.net/2009/09/01/virtualbox-smf-2/

   This manifest is distributed under the following MIT License terms:

   Copyright (c) 2009 Alexandre Dumont

   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation
   files (the "Software"), to deal in the Software without
   restriction, including without limitation the rights to use,
   copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the
   Software is furnished to do so, subject to the following
   conditions:

   The above copyright notice and this permission notice shall be
   included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   OTHER DEALINGS IN THE SOFTWARE.
-->


<service_bundle type='manifest' name='vbox'>

<service
   name='site/vbox'
   type='service'
   version='0.03'>

   <dependency
      name='multi-user-server'
      type='service'
      grouping='require_all'
      restart_on='none'>
      <service_fmri value='svc:/milestone/multi-user-server' />
   </dependency>

   <!--   Wait for network interfaces to be initialized. -->
   <dependency
      name='network'
      grouping='require_all'
      restart_on='none'
      type='service'>
      
      <service_fmri value='svc:/milestone/network:default' />
      
   </dependency>

   <!--    Wait for all local filesystems to be mounted.    -->
   <dependency
      name='filesystem-local'
      grouping='require_all'
      restart_on='none'
      type='service'>
      
      <service_fmri value='svc:/system/filesystem/local:default' />
      
   </dependency>

   <exec_method
      type='method'
      name='start'
      exec='/bin/vbox start'
      timeout_seconds='60'
   />

   <exec_method
      type='method'
      name='stop'
      exec='/bin/vbox stop'
      timeout_seconds='60'
   />

   <property_group name='startd' type='framework'>
      <propval name='duration' type='astring' value='transient' />
   </property_group>

   <instance name='Server5' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>

   <instance name='Server6' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>
   <instance name='Nagios' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>
   <instance name='Elastix' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>

   <stability value='Unstable' />

   <template>
      <common_name>
         <loctext xml:lang='C'>Sun xVM Virtualbox</loctext>
      </common_name>
      <documentation>
         <manpage title='Sun xVM Virtualbox' section='1' />
      </documentation>
   </template>

</service>

</service_bundle>
vbox (the script that the vbox.xml executes)
Code:
#!/sbin/sh
#
# http://adumont.serveblog.net/2009/09/01/virtualbox-smf-2/
#
# This SMF method is distributed under the following MIT License terms:
#
# Copyright (c) 2009 Alexandre Dumont
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

. /lib/svc/share/smf_include.sh

# SMF_FMRI is the name of the target service. This allows multiple instances
# to use the same script.

getproparg() {
        val=`svcprop -p $1 $SMF_FMRI`
        [ -n "$val" ] && echo $val
}

if [ -z $SMF_FMRI ]; then
   echo "SMF framework variables are not initialized."
   exit $SMF_EXIT_ERR
fi

start_vm() {
   /usr/bin/VBoxManage startvm $1 --type vrdp
}

stop_vm() {
   # STOP_METHOD=acpipowerbutton|savestate
   STOP_METHOD="$( getproparg vm/stop_method )"

   case "$STOP_METHOD" in
      acpipowerbutton|savestate|acpisleepbutton|poweroff)
         ;;
      *)
         STOP_METHOD="savestate"
         ;;
   esac

   /usr/bin/VBoxManage controlvm $1 $STOP_METHOD
}

vm_state() {
   /usr/bin/VBoxManage showvminfo $1 --details --machinereadable |
      grep VMState\= | tr -s '"' ' ' | cut -d " " -f2

   if [ $? -ne 0 ]; then
      echo >&2 "ERROR: Failed to get VMState for VM $1"
      exit $SMF_EXIT_ERR_FATAL
   fi
}

INSTANCE=$( echo $SMF_FMRI | cut -d: -f3 )

case $1 in
start)
   VM_STATE=$( vm_state $INSTANCE )

   if [ "x$VM_STATE" = "xpoweroff" ]
   then
      start_vm $INSTANCE
   else
      echo "INFO: VM $INSTANCE is in state $VM_STATE, I can't start it."
   fi
   ;;
stop)
   VM_STATE=$( vm_state $INSTANCE )

   if [ "x$VM_STATE" = "xrunning" ]
   then
      stop_vm $INSTANCE
   else
      echo "INFO: VM $INSTANCE is in state $VM_STATE, I won't stop it."
   fi
   ;;
esac

if [ $? -ne 0 ]; then
    echo "ERROR: VM $INSTANCE failed to start/stop."
    exit $SMF_EXIT_ERR_FATAL
fi

exit $SMF_EXIT_OK
__________________
Want a nas, you may find my Esxi/Solaris ZFS NAS build thread of interest.
Quote:
Originally Posted by Stanza View Post
yeah well I just reported my own post...ferk....
Quote:
Originally Posted by Blinky View Post
If you have become content with the size of your e-penis, sticking clear of rack mounted stuff will save you heaps of $$$.

Last edited by davros123; 2nd September 2010 at 6:48 PM.
davros123 is offline   Reply With Quote
Old 3rd September 2010, 1:18 AM   #180
Statts
Member
 
Statts's Avatar
 
Join Date: Aug 2004
Location: Radelaide, SA
Posts: 2,109
Default

Quote:
Originally Posted by davros123 View Post
Hi Guys, a few pages back I posted a link to a blog that gave info on how to setup VirtualBox as an SMF...I thought I'd post a summary here (one of the members asked for this info.).

In my case I have 4 VM's named : Nagios, Server5, Server6 and Elastix. You'll need to edit the SMF xml to reflect the names of your VM's.

Summary of the setup Instructions
Code:
Install VB as per instructions...
ie      pkgadd -d VirtualBox-3.2.0-SunOS-r61806.pkg

pfexec bash
Install manifest and vbox script
cp vbox.xml /var/svc/manifest/site/vbox.xml
cp vbox /bin/vbox
chmod 755 /bin/vbox
chown root:bin /bin/vbox
mkdir /export/home/nas/svc
mkdir /export/home/nas/svc/var
cd /var/svc/manifest/site/
svccfg validate vbox.xml
svccfg import vbox.xml
svcadm enable vbox:Nagios
svcadm enable vbox:Server5
svcadm enable vbox:Server6
svcadm enable vbox:Elastix
svcs -xv
vbox.xml (the SMF script).
Code:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
   http://adumont.serveblog.net/2009/09/01/virtualbox-smf-2/

   This manifest is distributed under the following MIT License terms:

   Copyright (c) 2009 Alexandre Dumont

   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation
   files (the "Software"), to deal in the Software without
   restriction, including without limitation the rights to use,
   copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the
   Software is furnished to do so, subject to the following
   conditions:

   The above copyright notice and this permission notice shall be
   included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   OTHER DEALINGS IN THE SOFTWARE.
-->


<service_bundle type='manifest' name='vbox'>

<service
   name='site/vbox'
   type='service'
   version='0.03'>

   <dependency
      name='multi-user-server'
      type='service'
      grouping='require_all'
      restart_on='none'>
      <service_fmri value='svc:/milestone/multi-user-server' />
   </dependency>

   <!--   Wait for network interfaces to be initialized. -->
   <dependency
      name='network'
      grouping='require_all'
      restart_on='none'
      type='service'>
      
      <service_fmri value='svc:/milestone/network:default' />
      
   </dependency>

   <!--    Wait for all local filesystems to be mounted.    -->
   <dependency
      name='filesystem-local'
      grouping='require_all'
      restart_on='none'
      type='service'>
      
      <service_fmri value='svc:/system/filesystem/local:default' />
      
   </dependency>

   <exec_method
      type='method'
      name='start'
      exec='/bin/vbox start'
      timeout_seconds='60'
   />

   <exec_method
      type='method'
      name='stop'
      exec='/bin/vbox stop'
      timeout_seconds='60'
   />

   <property_group name='startd' type='framework'>
      <propval name='duration' type='astring' value='transient' />
   </property_group>

   <instance name='Server5' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>

   <instance name='Server6' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>
   <instance name='Nagios' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>
   <instance name='Elastix' enabled='false'>
   
      <method_context working_directory='/export/home/nas/svc/var'>
         <method_credential user='nas' group='staff' />
      </method_context>
   
      <property_group  name='vm' type='application'>
         <!-- stop_method is used to set how SMF will stop the VM:
         Possible values are: acpipowerbutton, savestate, acpisleepbutton, poweroff -->
         <propval name='stop_method' type='astring' value='acpipowerbutton' />
      </property_group>
   
   </instance>

   <stability value='Unstable' />

   <template>
      <common_name>
         <loctext xml:lang='C'>Sun xVM Virtualbox</loctext>
      </common_name>
      <documentation>
         <manpage title='Sun xVM Virtualbox' section='1' />
      </documentation>
   </template>

</service>

</service_bundle>
vbox (the script that the vbox.xml executes)
Code:
#!/sbin/sh
#
# http://adumont.serveblog.net/2009/09/01/virtualbox-smf-2/
#
# This SMF method is distributed under the following MIT License terms:
#
# Copyright (c) 2009 Alexandre Dumont
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

. /lib/svc/share/smf_include.sh

# SMF_FMRI is the name of the target service. This allows multiple instances
# to use the same script.

getproparg() {
        val=`svcprop -p $1 $SMF_FMRI`
        [ -n "$val" ] && echo $val
}

if [ -z $SMF_FMRI ]; then
   echo "SMF framework variables are not initialized."
   exit $SMF_EXIT_ERR
fi

start_vm() {
   /usr/bin/VBoxManage startvm $1 --type vrdp
}

stop_vm() {
   # STOP_METHOD=acpipowerbutton|savestate
   STOP_METHOD="$( getproparg vm/stop_method )"

   case "$STOP_METHOD" in
      acpipowerbutton|savestate|acpisleepbutton|poweroff)
         ;;
      *)
         STOP_METHOD="savestate"
         ;;
   esac

   /usr/bin/VBoxManage controlvm $1 $STOP_METHOD
}

vm_state() {
   /usr/bin/VBoxManage showvminfo $1 --details --machinereadable |
      grep VMState\= | tr -s '"' ' ' | cut -d " " -f2

   if [ $? -ne 0 ]; then
      echo >&2 "ERROR: Failed to get VMState for VM $1"
      exit $SMF_EXIT_ERR_FATAL
   fi
}

INSTANCE=$( echo $SMF_FMRI | cut -d: -f3 )

case $1 in
start)
   VM_STATE=$( vm_state $INSTANCE )

   if [ "x$VM_STATE" = "xpoweroff" ]
   then
      start_vm $INSTANCE
   else
      echo "INFO: VM $INSTANCE is in state $VM_STATE, I can't start it."
   fi
   ;;
stop)
   VM_STATE=$( vm_state $INSTANCE )

   if [ "x$VM_STATE" = "xrunning" ]
   then
      stop_vm $INSTANCE
   else
      echo "INFO: VM $INSTANCE is in state $VM_STATE, I won't stop it."
   fi
   ;;
esac

if [ $? -ne 0 ]; then
    echo "ERROR: VM $INSTANCE failed to start/stop."
    exit $SMF_EXIT_ERR_FATAL
fi

exit $SMF_EXIT_OK
Note that it's also important to add in your username (that the VM was created under), group etc into the xml file.

Thanks for the PM's today, davros. Actually worked it out myself from the same link in the end, and very happy when I got it all working. Now have the machine booting to CLI and running VBoxHeadless Very happy.
__________________
Desktop: Windows 7 Ultimate
HTPC: Windows 7 Home Premium, MediPortal 1.3
Microserver: Solaris 11, ZFS, Windows Server 2k8 R2 VM
Portable: Nexus 4 (Android 4.2.2), Nexus 7 (Timur's USB-ROM)
Statts is offline   Reply With Quote
Reply

Bookmarks

Tags
home, nas, server, solaris, zfs

Sign up for a free OCAU account and this ad will go away!

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time now is 8:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. -
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!