Jump to content
We're Hiring! Full Stack Developer ×

How to shutdown 2 serverS on 1 UPS


Recommended Posts

Depends on the brand of your UPS, typically though one UPS can shut down only one server, whichever server the the smart cable is plugged into and the software is installed on. Some UPS's such as APC SmartUPS can have 'network' cards and they are able to shutdown multiple servers, but the software can be expensive to do this. Its probably cheaper just to buy a second UPS.

Link to comment

Depends on the brand of your UPS, typically though one UPS can shut down only one server, whichever server the the smart cable is plugged into and the software is installed on. Some UPS's such as APC SmartUPS can have 'network' cards and they are able to shutdown multiple servers, but the software can be expensive to do this. Its probably cheaper just to buy a second UPS.

 

Um I was hoping i could use a script that would send a shutdown command to the second server.

I guess i will have to open a suggestion to lime tech in hope thay can add a custom scripts to execute before shutdown with the ups settings on unRAID

Link to comment

Hi is there an easy way I can get my first server to send a signal to my second server when UPS is low so it shutsdown cleanly. main server is plugged into UPS by USB

Yes, if you are using the unraid stock ups software (apcupsd). On the slave server set the cable type to Ether, the ups type to Net, and the device to <master_server_name_or_ip>:3551

 

Make SURE that the conditions to shutdown are set to keep the master on long enough to allow the slave server to shutdown first.

 

Personally, I have the master machine set to shut down after 300 seconds on battery, and the slave after 270 seconds. If the power around here is off more than a minute, it's going to be out a while.

 

BTW, this also works for VM's. I have apcupsd set up in all my VM's to initiate shutdown after 60 seconds of no power, so they have plenty of time to finish up what they are doing and shutdown cleanly before unraid pulls the rug out from under them.

  • Like 2
  • Thanks 4
Link to comment

Oh, forgot to mention, I personally use a really cheap APC ups to trigger the apcupsd signalling, my servers are actually running on 2KVA online UPS's that don't talk to apcupsd. It works out well, when the building's power goes down, the apcupsd master sends the signal to all the machines, desktops and servers alike, and they each have their own settings on how long to stay running. Downside is I don't get any realtime feedback on battery levels, but I typically match loads so that in a pinch I have about 30 minutes runtime, and shutdown routines trigger in a small fraction of that. Infrastructure like routers, switches and access points typically stay up for an hour before I kill them.

 

Be VERY sure that any slaves on apcupsd will still have a valid path to the master when the power is out. It would suck to forget that your little 5 port pocket hub under the desk isn't connected to a UPS.

  • Thanks 1
Link to comment

Oh, forgot to mention, I personally use a really cheap APC ups to trigger the apcupsd signalling, my servers are actually running on 2KVA online UPS's that don't talk to apcupsd. It works out well, when the building's power goes down, the apcupsd master sends the signal to all the machines, desktops and servers alike, and they each have their own settings on how long to stay running. Downside is I don't get any realtime feedback on battery levels, but I typically match loads so that in a pinch I have about 30 minutes runtime, and shutdown routines trigger in a small fraction of that. Infrastructure like routers, switches and access points typically stay up for an hour before I kill them.

 

Be VERY sure that any slaves on apcupsd will still have a valid path to the master when the power is out. It would suck to forget that your little 5 port pocket hub under the desk isn't connected to a UPS.

 

Jonathanm thanks so much for your help. I have it all working now. Set my slave to shut down after 90 seconds and have the master to shut down on 10% battery. Power outs seem to be about 30 mins here. The ups will power my main server for about 40 mins but not both for 30.

 

And thanks to both you and Frank1940 for the heads up re all switches. I have repurposed on old small apc 350 to run my router phone etc in the other room :)

Link to comment
. I have it all working now. Set my slave to shut down after 90 seconds and have the master to shut down on 10% battery. Power outs seem to be about 30 mins here. The ups will power my main server for about 40 mins but not both for 30.

You may want to increase that 10% power figure, depending on how often it happens and how frequently you wish to replace batteries. Pulling SLA batteries that low will have a very negative effect on their lifetime, I suspect you may only get 2 or 3 cycles down that low before you start noticing a drop in capacity. Personally I don't like to get below 50%.

 

Also consider recharge times from that depth of discharge, it may take many hours to recover from a discharge event, so if you happen to have multiple outages, you may already be too low to properly shut down from the second event.

Link to comment

You should really think about your power outages.  Where I live, if the the power is out for more than thirty seconds, it is going to be out for a extended period of time well beyond the capacity of any  reasonably priced UPS.  I initiate shutdown thirty seconds after the power goes out.  Using this short period on battery operation also allows for the deterioration of the battery as it ages. 

 

You say that most of outages are less than thirty minutes.  If you intend to run to 10% of battery charge, you may be in for a surprise.  Most unRAID servers have most (or all) drives spun down.  When the server shuts down, it spins up all of the drives and your 10% remaining charge suddenly drops precipitously! 

 

I have heard of folks who have rigged up a UPS to a car battery for extended runtime but there are some serious safety issues that have to be addressed. 

Link to comment

Thanks Guys for all of your help. Yes, all of that makes perfect sense. I never really thought about the wear to the UPS by draining it. I also didn't think about the fact of all the drives spinning up before shutdown using more power.

My main reason for wanting 30 minutes running time was in case I was out of the house and power went out. If it was to shut down i would not be able to VPN into it should I want to. Sure if the girlfriend was home I could call her to restart it but would rather not!!

 

I have taken your advice and I have set it now to shut down the first slave server after 90 seconds then the main server 270 seconds. I definitely think what you say is right and more important than keeping the server running just so I can login.

 

However I was thinking maybe I will use a raspberry pi with a relay switch. That way it can it can switch on the server when i am away.

My thoughts are. The pi should just restart itself when the power comes back on. Then whenever the pi starts it could ping the server to see if it is up, and if there is no response it turns on the server via the relay or maybe power it on from wake on LAN but I guess wake on lan only works from sleep . Maybe fun to give that a try  :)

Link to comment
Then whenever the pi starts it could ping the server to see if it is up, and if there is no response it turns on the server via the relay or maybe power it on from wake on LAN but I guess wake on lan only works from sleep .

WOL works best from power off. Waking a server from sleep is dicey at best, servers are not designed for sleep. Many high end consumer routers include WOL, so if you have VPN into your router, you can just WOL your server from the router. If you have a server board with IPMI, then just log in and wake it from there.

 

There are several routes to get to your end destination, it all depends on what hardware and software you already have, and possibly need to set up to connect the dots.

Link to comment

You should really think about your power outages.  Where I live, if the the power is out for more than thirty seconds, it is going to be out for a extended period of time well beyond the capacity of any  reasonably priced UPS.  I initiate shutdown thirty seconds after the power goes out.  Using this short period on battery operation also allows for the deterioration of the battery as it ages. 

 

You say that most of outages are less than thirty minutes.  If you intend to run to 10% of battery charge, you may be in for a surprise.  Most unRAID servers have most (or all) drives spun down.  When the server shuts down, it spins up all of the drives and your 10% remaining charge suddenly drops precipitously! 

 

I have heard of folks who have rigged up a UPS to a car battery for extended runtime but there are some serious safety issues that have to be addressed.

Another thing that can happen is you let it use most of the UPS battery and then power comes back so it doesn't need to shutdown. Then a little later power goes out again and your UPS hasn't had time to recharge so it doesn't have enough power left to let it shutdown.
Link to comment

Then whenever the pi starts it could ping the server to see if it is up, and if there is no response it turns on the server via the relay or maybe power it on from wake on LAN but I guess wake on LAN only works from sleep .

WOL works best from power off. Waking a server from sleep is dicey at best, servers are not designed for sleep. Many high end consumer routers include WOL, so if you have VPN into your router, you can just WOL your server from the router. If you have a server board with IPMI, then just log in and wake it from there.

 

There are several routes to get to your end destination, it all depends on what hardware and software you already have, and possibly need to set up to connect the dots.

Oh, I didn't know that WOL works best from shutdown. I found that my WOL from sleep didn't work well after changing the hardware I used for my server. When I found it didn't work from sleep I didn't bother using it again but never tried from shutdown. So if I can get it to work from shutdown i wouldn't need to use a relay on the PI. I can just have my PI  when it starts up sends a magic packet to both servers and switch them on :)

Link to comment

Or, you can set it in bios to boot when power is reapplied. Apc ups can shut itself down when the server goes off, when power is back, apc will wake up and so will your server.

 

But in that scenario, make sure you set a conservative shutdown threshold because you don't want the server to come online with the ups battery almost depleted

 

Link to comment

Or, you can set it in bios to boot when power is reapplied. Apc ups can shut itself down when the server goes off, when power is back, apc will wake up and so will your server.

 

But in that scenario, make sure you set a conservative shutdown threshold because you don't want the server to come online with the ups battery almost deleted

 

Awesome. I seem to have been overcomplicating matters that seems the best way. I will try that thanks

Link to comment
  • 3 years later...
On 1/16/2017 at 2:57 PM, jonathanm said:

Yes, if you are using the unraid stock ups software (apcupsd). On the slave server set the cable type to Ether, the ups type to Net, and the device to <master_server_name_or_ip>:3551

 

Make SURE that the conditions to shutdown are set to keep the master on long enough to allow the slave server to shutdown first.

 

Personally, I have the master machine set to shut down after 300 seconds on battery, and the slave after 270 seconds. If the power around here is off more than a minute, it's going to be out a while.

 

BTW, this also works for VM's. I have apcupsd set up in all my VM's to initiate shutdown after 60 seconds of no power, so they have plenty of time to finish up what they are doing and shutdown cleanly before unraid pulls the rug out from under them.

BOOM -- thanks for this... Works like a charm

Link to comment
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...