89

I'm trying to run Elastic search in an Ubuntu EC2 machine (t2.medium).

But I'm getting the message:

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

How can I increase the vm.max_map_count value?

Syscall
  • 19,327
  • 10
  • 37
  • 52
Filipe Ferminiano
  • 8,373
  • 25
  • 104
  • 174

8 Answers8

141

To make it persistent, you can add this line:

vm.max_map_count=262144

in your /etc/sysctl.conf and run

$ sudo sysctl -p

to reload configuration with new value

jdbs
  • 1,578
  • 1
  • 11
  • 8
25

I use

# sysctl -w vm.max_map_count=262144 

And for the persistence configuration

# echo "vm.max_map_count=262144" >> /etc/sysctl.conf

Att.

Dmytro Dadyka
  • 2,208
  • 5
  • 18
  • 31
  • 3
    In case did not work like above instead do it like sudo /bin/su -c "echo 'vm.max_map_count=262144' >> /etc/sysctl.conf" – Daniel Nov 13 '21 at 18:48
20

Note that

From version 207 and 21x, systemd only applies settings from /etc/sysctl.d/*.conf and /usr/lib/sysctl.d/*.conf. If you had customized /etc/sysctl.conf, you need to rename it as /etc/sysctl.d/99-sysctl.conf. If you had e.g. /etc/sysctl.d/foo, you need to rename it to /etc/sysctl.d/foo.conf.

See https://wiki.archlinux.org/index.php/sysctl#Configuration

So add vm.max_map_count=262144 in /etc/sysctl.d/99-sysctl.conf and then run

sudo sysctl --system

Wenpin CHOU
  • 371
  • 2
  • 6
13
sysctl -w vm.max_map_count=262144
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Filipe Ferminiano
  • 8,373
  • 25
  • 104
  • 174
8

When:

permission denied on key 'vm.max_map_count'

sudo sysctl -w vm.max_map_count=262144
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Dani Mathew
  • 808
  • 10
  • 18
3

If you are using ubuntu VM, then navigate to etc folder.

  1. Run vim sysctl.conf

  2. Add vm.max_map_count=262144 to the end of the file and save

  3. Finally run sudo sysctl -w vm.max_map_count=262144 this command you will see vm.max_map_count=262144

ejuhjav
  • 2,660
  • 2
  • 21
  • 32
  • 3
    Just wondering from a Linux intermediate user perspective; the `-w` flag means it writes the info, but in line 2 above you already manually wrote the info to the file. So why write it again on line 3? – J. Scott Elblein Oct 06 '20 at 06:59
2

Following command as worked fine on Fedora 28 (Linux 4.19 Kernel)

sudo echo "vm.max_map_count=262144" >> /etc/sysctl.d/elasticsearchSpecifications.conf && sudo sysctl --system

Stanislas5
  • 21
  • 1
0

I found that when adding the settings to /etc/sysctl.conf, the system actually saved the changes to /etc/sysctl.d/99-sysctl.conf.

And when saving the changes to /etc/sysctl.d/99-sysctl.conf, it's also saved to /etc/sysctl.conf, so I think they both point to the same file.

David Liu
  • 181
  • 1
  • 2