18

I have cloud storage data centers running Ubuntu 16.04 LTS and NextCloud/OwnCloud that have no need to be available 24/7 and need power management solutions. Servers are Dell PowerEdge 1950 Gen II and Dell PowerEdge 2950 Gen II

Overall Objective

Hibernate cloud storage servers past an idle time for example 20 minutes and have such de-hibernated with WOL to reduce 6272.09 kilos of carbon dioxide per year being 6680kw from our data center alone, metrics achieved throughout a detailed energy audit.

Ineffective solution tried

Landscape

The landscape on-premises/cron jobs only offer scheduled startup and shutdowns, thereby ineffective for our achievable.

Powernap

powernap seems the way to go but the service is not starting on Ubuntu 16.04

XXXXXXX~$ sudo service powernap status
● powernap.service - PowerNap
   Loaded: loaded (/lib/systemd/system/powernap.service; disabled; vendor preset
   Active: inactive (dead)

powernap seems to use depreciated services such as network.service which are no longer available in Ubuntu 16.04

Achievable objectives

Wake on LAN (WOL)

Enabling WOL is straightforward by following the manual setup on this link. or with the use of power wake

Server Hibernation

Until now, I have only managed to hibernate the servers using sudo systemctl hibernate and sudo systemctl hibernate-sleep

  1. powernap - I am filing bug reports to remove depleted dependencies
  2. systemctl - could lead to somewhere
  3. pm-utils - could lead to somewhere too

Hardware Upgrades

I have upgraded the CPUs of the Dell 1950 Gen II dual Xeon E5335 with Xeon X5365 CPUs. The X5365 enable power management and set power management from BIOS. In all honesty, I was not in favor of such upgrade as the X5365 consume 70 watts per CPU more than E5335, but did such in favor of hibernation testing.

Update 1

At this moment in time pm-utils is the only way to go apart from setting wol on the nic. Currently, I am exploring the optimal configuration to create a powerful hook for ac settings for idle time.

Any recommendations, please.

Mir Rahed Uddin
  • 609
  • 1
  • 8
  • 19
Fab
  • 405
  • 1
  • 4
  • 14
  • 1
    Welcome to Ask Ubuntu. Please, what is your question? Please [be more specific](http://askubuntu.com/help/how-to-ask). – MadMike Feb 21 '17 at 10:08
  • Hibernate cloud servers past an idle time and have such de-hibernated with WOL. The extra detail is to give a working scenario example. – Fab Feb 21 '17 at 10:10
  • 1
    I couldn't quite grasp what your stumbling block(s) is/are. What have you tried that is not working and/or what specifically do you need help understanding? – Zanna Feb 21 '17 at 10:12
  • @Zanna, I am a novice at Linux, so I stumble... server hibernation is an issue as any reference I found was for laptops – Fab Feb 21 '17 at 10:20
  • _“1. A swap equivalent or greater than the physical ram of the system.”_ OK, from the comments (deleted now) I understand this is a precondition for a successful hibernation rather than a criterium to detect the machine idleness. – Melebius Feb 21 '17 at 10:22
  • @Melebius I stand to be corrected but from what I have read, to effectively hibernate a system, you need to have a swap equivalent or greater than the physical ram so to dump your current machine state in. – Fab Feb 21 '17 at 10:23
  • 3
    Isn't hibernating unpractical? Depending on your RAM size and disk read/write speed, hibernating and resuming can take up to few minutes. How are requests handled during that time? Will your users want to wait that long? Simply suspending might be a better compromise to save power while staying more agile. And maybe virtualizing your servers and hosting them on one powerful machine or a cluster that allows you to suspend/resume parts while balancing the load on others could also help saving power. Note that I have no experience with large scale server systems though, just guessing. – Byte Commander Feb 21 '17 at 10:48
  • @ByteCommander just like dropbox and other cloud services providers (OneDrive or Google Drive, etc.) clients store data in a folder on their systems through the NextCloud Client App. Connection with the cloud in our case is purely to sync the local client data with the cloud. We came off the use of hypervisiors as the hosts remain powered just the same. – Fab Feb 21 '17 at 11:03
  • Please vide Edit 1. I installed powernap but I cannot get it to work. – Fab Feb 23 '17 at 21:44
  • 1
    I concur with Byte Commander. For input from people with actual experience in data centre operation you should probably ask over on [SF]. – David Foerster Feb 25 '17 at 08:33
  • @Rinzwind I did manage to manually hibernate could storage servers successfully without any data loss using Ubuntu 16.04.02 LTS, Nextcloud 11, 32gb swap (16gb physical) pm-utilis and wol. What is needed is a package with a daemon monitoring processes, c/p states to do such automatically. PowerNap was a good utility but it is no longer supported on 16.04. – Fab Jun 19 '17 at 08:36
  • Take a look at the saltstack, professional automation, there should even be a way to despawn the machines if not needed to save additional money. I don't know your setup but saltstack can automate whole datacenters, I use it at my work too. We do everything with it, from DNS to Storage to spawning and destroying machines, yadda yadda – s1mmel Jun 21 '18 at 15:47
  • @ByteCommander You're wrong. Hibernating uses your swap. So it takes ~20secs to hibernate and ~10 secs to read it (plus 5 to boot (and efi)) – france1 Sep 07 '21 at 16:02
  • @france1 while my comment you're replying to is four years old and written with a lot less experience than I have today, I still consider the statement correct. Hibernation and resuming from it is slow, as it dumps your entire (used) RAM and other machine state onto persistent disk storage, and reads it back from there. How slow exactly depends on your underlying hardware performance and the relationship between RAM size/usage and disk speed mostly. A small machine with fast NVMe disk may take just seconds, a big machine with hard disk can still easily reach a minute. – Byte Commander Sep 08 '21 at 22:29

3 Answers3

0

To simply hibernate for Ubuntu <21 you can use the hibernate command (sudo apt install hibernate). Other things wont work. Stolen from somewhere: put resume=path-to-your-swap into GRUB_CMDLINE_DEFAULT

I tested this using an apple laptop. It works fine. Using the UUID wont work - somehow changes sometimes

france1
  • 184
  • 1
  • 14
0

When you hibernate an instance, Amazon EC2 signals the operating system to perform hibernation (suspend-to-disk). Hibernation saves the contents from the instance memory (RAM) to your Amazon Elastic Block Store (Amazon EBS) root volume.

0

I put together a little script which you could run in a cronjob every 15 minutes or using systemd timers:

#/bin/bash

NActiveUsers=$(who -q | awk -F'#' '{printf $2}' | awk -F'=' '{printf $2}')
AvgLoad15Min=$(cat /proc/loadavg | awk -F' ' '{print $3}')

ActiveUsersThresh=2
AvgLoadThresh=0.15

if [ "$NActiveUsers" -lt "$ActiveUsersThresh" ]
then
    LoadBelowThresh=$(echo $AvgLoad15Min'<'$AvgLoadThresh | bc -l)
    if [ "$LoadBelowThresh" -eq 1 ]
    then
        systemctl hibernate
    fi
fi

It first gets the number of users which are logged in to the system and the average load during the last 15 minutes. You should be able to find out your idle average system load using cat /proc/loadavg. The third floating point numbers gives the average over the last 15 minutes. This value is helpful to define a threshold set in the variable AvgLoadThresh. This certainly will need tuning. The other thing that you can define is how much users are allowed to be logged in and the system goes to hibernate anyhow. This is set in ActiveUsersThresh. Just to make sure the system is not always hibernating when you are doing maintenance or something.

I guess one could come up with more intelligent checks, so see it as a first simple-minded approach. For example, i don't know which database or webserver is used in your owncloud installation but you could try to stop them gracefully before the hibernate command, so nobody would suddenly loose connection.

derHugo
  • 3,306
  • 5
  • 30
  • 49
romed
  • 141
  • 4