jueves, 8 de marzo de 2018

openSuSE Leap 42.3 + Redis


Y una nueva aventura, instalando Redis en openSuSE Leap no podría ser más sencillo ya que Redis está disponible en los repositorios de la distribución.

Sin embargo para arrancarlo no basta con:

systemctl start redis.target

que parece no tuvo uso. Recien cuando ejecuté:

sudo redis-server

arrancó el servicio y pude tener acceso al cliente

redis-cli

Sin embargo el servidor presentó los siguientes mensajes:

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 
... 
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 
WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 
* The server is now ready to accept connections on port 6379

Las instrucciones están incluidas, pero si da flojera leer, StackOverflow tiene algo de información, aquí: Tech and me - Performance tips for Redis Cache Server

 Para el primer mensaje:

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

Se debe escribir en consola:

sysctl -w net.core.somaxconn=65535

pero para ahorrarse el trabajo de tener que hacerlo cada vez que se inicia el sistema, se debe editar el archivo:

/etc/rc.d/boot.local

Para el segundo mensaje:

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

se require editar el archivo:

/etc/sysctl.conf

para añadir la línea solicitada:

vm.overcommit_memory=1

Para la tercera línea:

WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot.

Se necesita editar nuevamente el archivo:

/etc/rc.d/boot.local
 
y añadir la línea:

echo never > /sys/kernel/mm/transparent_hugepage/enabled

El texto continúa con una descripción para dejar de usar TCP, puerto 6379, y usar el socket UNIX, "transmisión interna", para acelerar la respuesta en caso de que el servidor Redis se encuentre en el mismo equipo del cliente. Lo cual preferí no llevar a cabo.

Es recomendable revisar el tutorial interactivo disponible en la web de Redis. Es una manera sencilla para conocer la mayoría de comandos de Redis y la imortancia de los hashes.

Tomar en consideración que para la edición de los archivos necesarios para la ejecución correcta de Redis, es necesario disponer de permisos de usuario root, (su -) y saber usar un editor como nano o vim facilita el trabajo.