Redis-Sentinel with Redis whose CONFIG command is renamed - redis

The CONFIG command is renamed to CONFIG_2267bccb973c432d96a26e96ca50860a
As I know, Redis-sentinel relies on this command, yes? How can configure redis-sentinel to use the renamed command?

You can't. Redis sentinel doesn't support renamed config commands. By the way this is an admin question so it belongs on serverfault.

Related

Redis Sentinel Rename-Command Ignored

I am trying to limit the allowed privileges for external redis sentinel users by renaming critical commands as follow:
sentinel rename-command mymaster FAILOVER failover-secret
However, the configurations are being ignored, and I still can trigger the renamed command using the original name:
127.0.0.1:26379> sentinel failover mymaster
OK
Redis Version:
Redis server v=6.0.9 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=e874f7259751a389
The best option would be to put this in your Redis server's config file as opposed to setting it via CLI. It sounds like setting it this way either only applies to that connection (so other connections won't have that config change) or it only persists until the server restarts. Putting it in the config file would persist for all connections, and across restarts.
Another option if you're using Redis v6 (or can upgrade to v6) is to create separate users and specify the available commands per user. This option is discussed in this answer.

Running multiple instance of Redis on Centos

I want to run multiple instance of Redis on Centos 7.
Can anyone point me to proper link or post steps here.
I googled for the information but I didn't find any relevant information.
You can run multiple instances of Redis using different ports on a single machine. If this what concerns you then you can follow the below steps.
By installing the first Redis instance, it listens on localhost:6379 by default.
For Second Instance create a new working directory
The default Redis instance uses /var/lib/redis as its working directory, dumped memory content is saved under this directory with name dump.rdb if you did not change it. To avoid runtime conflicts, we need to create a new working directory.
mkdir -p /var/lib/redis2/
chown redis /var/lib/redis2/
chgrp redis /var/lib/redis2/
Generate configurations
Create a new configuration file by copying /etc/redis/redis.conf
cp /etc/redis/redis.conf /etc/redis/redis2.conf
chown redis /etc/redis/redis2.conf
Edit following settings to avoid conflicts
logfile "/var/log/redis/redis2.log"
dir "/var/lib/redis2"
pidfile "/var/run/redis/redis2.pid"
port 6380
Create service file
cp /usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis2.service
Modify the settings under Service section
[Service]
ExecStart=/usr/bin/redis-server /etc/redis/redis2.conf --daemonize no
ExecStop=/usr/bin/redis-shutdown redis2
Set to start with boot
systemctl enable redis2
Start 2nd Redis
service redis2 start
Check Status
lsof -i:6379
lsof -i:6380
By Following this you can start two Redis servers. If you want more repeat the steps again.
If I set to --daemonize no, Redis will crash when data insert.
ExecStart=/usr/bin/redis-server /etc/redis2.conf --daemonize no
Should change to
ExecStart=/usr/bin/redis-server /etc/redis2.conf --supervised systemd
My Redis is 5.0.7.
FYI.

Is it possible to rename commands in the AWS ElastiCache Redis?

Normally we can rename/remove redis commands using config file
rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
rename-command CONFIG ""
Is this possible in AWS redis?
You can with 5.0.3 version of ElastiCache Redis
https://aws.amazon.com/about-aws/whats-new/2019/02/amazon-elasticache-for-redis-adds-support-for-redis-503-and-the-ability-to-change-redis-command-names/
Simple answer: No this is not possible.
You can find all the parameters that can be configured in: http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/ParameterGroups.Redis.html

Sentinel work fail after rename config command of redis

I've installed stablest redis(ver 3.2). Everything work fine until I renamed CONFIG command of redis, sentinel could not promote slave to be master.
Think the problem is sentinel still use CONFIG command (has been renamed) to change configuration of redis.
Is there any way to change configuration of sentinel (via redis-cli or configuration files sentinel.conf) to adapt redis configuration (renamed config command). If there isn't, how about changing source code?
Thanks
After google, I found solution for this problem.
I replace redis/src/sentinel.c via this redis github, rebuild and install redis from source.
Then I could add a directive to sentinel.conf to configure sentinel use renamed config command.
sentinel config-command mymaster <renamed-command>

How to keep redis server running

I am using redis for session support in nodejs app. I have installed redis server and it works when I run redis-server, but when I close terminal redis stops and does not work. How do I keep redis server running after closing the terminal?
And, if you'd like a quick option, run: redis-server --daemonize yes.
The easiest way to launch Redis as a daemon is to edit the configuration file and change the following line:
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
Be sure to provide the configuration file on the redis-server command line when you launch it.
An example of configuration file is provided in the Redis distribution.
As mentioned by #DidierSpezia in his answer,
Set daemonize yes in Redis conf file.
Set daemonize yes in Redis conf file at /path/to/redis.conf Generally
it should be there at /etc/.
And :
Then trigger redis-server with the conf file as an argument:
./redis-server /etc/redis.conf
UPDATE
You may directly run the redis with demonize flag as well
redis-server --daemonize yes
The accepted answer is mostly outdated.
While the question is old, Google still ranks this highly, so allow me to correct this.
The OP did not provide any detail about his setup, but you can assume it is a linux, and he doesn't mention containers, so you can also assume he is running redis without them.
There is three detail that make the accepted answer a thing to forget
Most (popular) distros come with systemd by default
Most (popular) distros have redis in their official repos
that official redis package installs systemd service for redis
So
It will have supervised systemd in its default config
To start: the redis daemon with sudo systemctl start redis#instanceName where you substitue "instanceName". Also sudo systemctl enable redis#instanceName for auto-starting on boot. (BTW, forget about service start, and init scripts already! These are less portable nowdays than calling directly systemctl).
do NOT set to daemonize: yes, that will interfere with the systemd supervisioning redis!
Systemd will supervise, restart your redis, and you can set service depenedencies and service preconditions to/for it, even for a custom executable it is not that hard, search for systemd unit files (you'll need a ~10 lines config file). Chances are, you'd want it.
If the three detail (making systemd the correct answer) are not met/relevant, you are most likely running redis containerized. For docker/podman/etc., it is another question altogether... (no systemd in the inner linux, but you'd have to (or already do) supervise(d) the container-daemon itself)