Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.
Resource icon

Configuring UPS support for single or multiple FreeNAS servers

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,110
Spearfoot submitted a new resource:

Configuring UPS support for single or multiple FreeNAS servers - Details on configuring the NUT UPS tools for use with FreeNAS servers connected to a UPS

If you are running a FreeNAS server you definitely need to connect it to a UPS.

Standalone Configuration

The official FreeNAS 9.10 UPS service documentation is available at doc.freenas.org and you should read it before proceeding.

Configuring a standalone FreeNAS server is fairly simple, provided your UPS is supported by the Network UPS Tools driver used by FreeNAS. You may consult networkupstools.org's...
Read more about this resource...
 

marksibert

Neophyte
Joined
Jun 5, 2018
Messages
7
I agree - great resource! Is there any documentation on how to set up multiple UPSs, in the case where there is a server with redundant power supplies, each plugged into its own UPS?
 

jp83

Junior Member
Joined
Mar 31, 2017
Messages
23
Trying to set this up myself. Spearfoot's guide "ssh root@esxihost poweroff" and neb50's "ssh root@ipaddress /sbin/poweroff" both seem to Power Off VMs as opposed to Shutdown Guest (using VM Tools for a safe shutdown). I was watching the tasks at the bottom. I also looked in the config in the esxi NUT client and it appears to use the poweroff command as well. Sounds like permissions issues prevent a wrapper script from working, so how are you safely shutting down ESXi VMs?

Cross-post link: https://forums.freenas.org/index.php?threads/ups-shutdown-esxi-6-5.63211/#post-486371
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,110
Trying to set this up myself. Spearfoot's guide "ssh root@esxihost poweroff" and neb50's "ssh root@ipaddress /sbin/poweroff" both seem to Power Off VMs as opposed to Shutdown Guest (using VM Tools for a safe shutdown). I was watching the tasks at the bottom. I also looked in the config in the esxi NUT client and it appears to use the poweroff command as well. Sounds like permissions issues prevent a wrapper script from working, so how are you safely shutting down ESXi VMs?

Cross-post link: https://forums.freenas.org/index.php?threads/ups-shutdown-esxi-6-5.63211/#post-486371
No, the 'poweroff' command shuts down the ESXi host, not the VMs. The latter are shutdown as part of the normal ESXi server shutdown sequence -- but only if you have configured it correctly! Otherwise (if memory servers) ESXi will simply power them down. So you must configure your ESXi server to send a graceful shutdown command to at least the FreeNAS VM, and any other VMs not homed on storage provided by the FreeNAS VM.

With this setup, as part of the ESXi host shutdown sequence, the FreeNAS VM itself receives a shutdown command from its ESXi host. This invokes your FreeNAS shutdown script, which should send shutdown commands to each VM it stores (either on NFS or iSCSI storage). These VMs should have the VMware tools installed.

See my resource Utility scripts for FreeNAS and VMware ESXi for scripts you can modify to use on your AIO (All-In-One) server to do all of this stuff.

It can be a little tough to wrap your mind around all of this, but it really does work very well. I've been using this setup for several years on multiple AIO servers.

Good luck!
 

NasKar

Neophyte Sage
Joined
Jan 8, 2016
Messages
633
Thanks for the great guide. I'm not running ESXi so is the Shutdown Command
Code:
/sbin/shutdown -p now
ok for the Master and Slave?
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,110
Thanks for the great guide. I'm not running ESXi so is the Shutdown Command
Code:
/sbin/shutdown -p now
ok for the Master and Slave?
Yes
 

Sundog

Newbie
Joined
Jun 10, 2020
Messages
2
Thanks for posting the guide it was very useful! I'm a little stuck on one part though. If I run the poweroff command as a test in Freenas shell, I'm still getting prompted for a password when I connect to my ESXI server. I don't think this should be happening because I setup SSH keypairs and an SSH connection under System in FreeNAS and I copied the public key to ESXI and pasted it into the authorized keys list. If I run the upsmon -fsd command it doesn't do anything other than stop the UPS service.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,110
Thanks for posting the guide it was very useful! I'm a little stuck on one part though. If I run the poweroff command as a test in Freenas shell, I'm still getting prompted for a password when I connect to my ESXI server. I don't think this should be happening because I setup SSH keypairs and an SSH connection under System in FreeNAS and I copied the public key to ESXI and pasted it into the authorized keys list. If I run the upsmon -fsd command it doesn't do anything other than stop the UPS service.
Thank you, @Sundog

I admit skipping over the details of configuring SSH keypairs, saying only "first enable the SSH service on the ESXi server and set up private key authentication", but in my defense there are probably hundreds of tutorials about this subject on the internet and I didn't want to get bogged down.

If you're being prompted for a password, something still isn't right with your VMware setup. VMware is a little different from everyone else, their SSH implementation looks in /etc/ssh/keys-root for the authorized_keys file. Also, you need to enable the ESXI shell service in addition to SSH; this service gives you access to CLI commands such as poweroff, etc.
 

Sundog

Newbie
Joined
Jun 10, 2020
Messages
2
Thanks for replying @Spearfoot

The strange part is that it's only an issue if I try and SSH from Freenas shell into the ESXi host. If I do it from Putty SSH client with it's own keypair then it works fine and I don't get prompted for a password. Both public keys are in the authorized_keys file each on a separate line. Maybe there's a syntax for separating them? I also recall before getting the Keypairs setup in Freenas I got prompted for whether I wanted to accept an unknown server key I think (something like that). I entered yes but I'm not sure if that could be the issue.

I currently have it sort of working by installing the NUT tools on the ESXi host, but that's not as clean as just doing it through SSH the way you did. The issue I've noticed with the poweroff command is that it doesn't seem to be gracefully powering off the VMs and isn't respecting the ESXi shutdown delay settings. I'll take another look at it today though and see if I can figure something out.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,110
Thanks for replying @Spearfoot

The strange part is that it's only an issue if I try and SSH from Freenas shell into the ESXi host. If I do it from Putty SSH client with it's own keypair then it works fine and I don't get prompted for a password. Both public keys are in the authorized_keys file each on a separate line. Maybe there's a syntax for separating them? I also recall before getting the Keypairs setup in Freenas I got prompted for whether I wanted to accept an unknown server key I think (something like that). I entered yes but I'm not sure if that could be the issue.

I currently have it sort of working by installing the NUT tools on the ESXi host, but that's not as clean as just doing it through SSH the way you did. The issue I've noticed with the poweroff command is that it doesn't seem to be gracefully powering off the VMs and isn't respecting the ESXi shutdown delay settings. I'll take another look at it today though and see if I can figure something out.
Yikes! I wouldn't recommend installing the NUT tools on your ESXi server.

I believe you will have success if configure your system according to these instructions. I'm using this setup on four FreeNAS-on-ESXi All-In-One systems here at my home, and I've been using this setup for ~5 years.

1> Until you can log on to your ESXi host via SSH using keys instead of a password, there's no hope of getting the FreeNAS UPS support to shut down your ESXi server. Did you double-check the key location I mentioned above? ESXi is a little different from other operating systems. In brief, your authorized_keys file for user root must be located here:

/etc/ssh/keys-root/

2> In addition to the SSH service (and it's key setup), you need to make sure the ESXi Shell service is running, too. See the screen shot below:
esxi-services.jpg


3> Lastly, the burden is on you to configure ESXi for graceful shutdown, it doesn't work that way out of the box. You'll have to install the VMware tools on all VMs and configure ESXi to shut them down instead of simply powering them off, see 'Stop Action' below:
esxi-startup-config.jpg
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,110
Top