Skip to content
ᴀɴᴛᴏɴ ɴᴏᴠᴏᴊɪʟᴏᴠ edited this page Sep 3, 2024 · 16 revisions

I've never used RDS before and don't understand what to do there. What should I do?

The best way to get started with RDS is to create your first instance:

  1. Create an instance using the sudo rds create command;
  2. Start your instance with the command sudo rds start <id>, where <id> is your instance ID;
  3. Check the list of all instances using the sudo rds list command;
  4. Stop your instance with the command sudo rds stop <id>;
  5. Destroy your instance with sudo rds destroy <id>.

You can see a list of all available commands and arguments by running sudo rds --help. You can also see detailed help for an individual command by running sudo rds help <command>.

How do I know that the server is correctly configured to use RDS?

RDS automatically checks kernel, limits and THP settings when instances are created, started or restarted. You can also use the sudo rds -vv command to check the settings.

RDS is asking me about replication, what is that?

RDS supports replication. By default, RDS clusters have 1 master and 1 minion (there can be as many minions as you like). The utility asks you about type of instance to put on the minion.

  • S (standby) - an instance with the same settings as the master instance, but it doesn't synchronise with the master instance;
  • R (replica) - a full replica of the instance on the master node, with data synchronised with the master instance.

I selected the wrong replication type, how do I change it?

Use the command sudo rds edit <id>. One of the questions will be which replication type to use.

Remember that changing the replication type from replica to standby will remove all data from instances on minions.

Why am I being asked for a password?

The password is used for destructive commands (like deleting an instance), and for viewing private information about the instance.

For most commands, authorization is done by username and ownership of the instance. If you know the password to someone else's instance, you can perform destructive commands on it.

I tried to run a command (like FLUSHALL, CONFIG, SAVE…), but redis-cli says I don't have permission to do it. How can I run this command?

By default, RDS creates instances without permissions for @admin and @dangerous commands. To run forbidden commands, use the rds cli command with the --private/-p option:

sudo rds cli -p 42:3 FLUSHDB ASYNC

I've lost my instance password, what should I do?

If you have a superuser password (generated during configuration), use it with the command sudo rds edit <id>. If you don't have this password, ask your DevOps engineer or system administrator (or the person who installed and configured RDS) to change your password (you can use this new password to change it to your own).

We have lost the superuser password, how can we regain access?

Superuser authentication information is stored in the su.dat file in the RDS installation directory. Remove this file with sudo rm and run sudo rds go to generate a new superuser password.

Are there any nuances of creating instances?

Yes, there are some.

  • If you need to create an instance to store session keys or queues that doesn't need to save data to disk, use the --disable-saves option when creating it.
  • If you need an instance with authorisation support, use the --secure switch, you will be asked for the authorisation password.
  • If you want to add some tags to your instance, use the --tags option when creating the instance.

I have an instance with hundreds of gigabytes of data that I don't need, should I stop it before deleting it?

No. Delete it immediately. Stopping the instance will start a saving process that you don't need. Deletion of a running instance will immediately send a KILL signal to it. As a result, this instance will be deleted in a few seconds.

I want to deploy a new version of the service that may corrupt my data. Is there a way to back up my data?

Yep. You can use the sudo rds backup-create <id>' command to create a snapshot (_up to 10_) of the current instance data. If something goes wrong, you can restore your data with sudo rds backup-restore '.

How can I view a list of just my instances?

The list command supports the ability to filter output. Here are some examples.

  • sudo rds list my - shows your instances;
  • sudo rds list my active - shows your active instances;
  • sudo rds list j.doe saving - shows instances of user j.doe that are currently saving data to disk.

Further examples and a list of all available filters can be viewed by running the command sudo rds help list.

User bob has dozens of instances, how do I transfer them to user john?

Firstly, you need a superuser password. Next, you can combine two features - the batch-edit command and the raw output of the list command.

sudo rds batch-edit $(sudo rds list bob)

In this example, the list command returns the IDs of bob's instances to the batch-edit input. Using batch-edit you can change owner to john.

We need to make unique settings for one or more instances, how do we do that?

RDS generates an instance configuration file from a template for a particular Redis version, located in the templates directory inside the main RDS directory (/opt/rds by default).

To generate unique settings, the instances to which we want to apply the settings must be tagged with unique tags (you can find more information about tags using the sudo rds help tags-add command). Then we make some changes to the configuration template. You can read more about the template language here.

{{if .HasTag "limited"}}
maxmemory 5gb
{{end}}

As a result, if an instance has the tag limited, the configuration file will be created with this condition. We can also, for example, set a limit of 10 gigabytes for instances without the tag:

{{if .HasTag "limited"}}
maxmemory 5gb
{{else}}
maxmemory 10gb
{{end}}

The important thing is not to forget to regenerate the configuration files of the instances that need these changes.

There are some important actions that need to be performed on the server or RDS, is there any way to restrict user actions at this point?

With the superuser password, you can enable or disable maintenance mode with the sudo rds maintenance command. To enable maintenance mode run the next command:

sudo rds maintenance enable

After that, all RDS commands require the superuser password.

To enable maintenance mode run the next command:

sudo rds maintenance disable

I need to perform a lot of monotonous actions with a lot of instances, is there any way to automate this?

Yep. You can use bash and RDS I/O capabilities to do this. As a simple example, we have 20 instances tagged testing. We want to regenerate configuration files for them and reload new configurations. This task could be solved with the following script:

for id in $(sudo rds list testing) ; do
  sudo rds regen "$id" < ~/rds-su-password || exit 1
  sudo rds reload "$id" < ~/rds-su-password || exit 1
done

In our loop, we use output from our list command, but instead of showing a table with instances information, when we run it as part of a script (or pipe it with |), it just returns a list of instance IDs that we can use. Next, we run the regen and reload commands on instance with given ID; both commands require a password, so we save the password to a file and pass it as input via stdin to our command; at the same time, we added a condition at the end of each command call that if execution of any of the commands fails with an error code (the exit code is not 0), we abort the script.

I know all about RDS, how can I disable ProTips?

There are two ways to turn off ProTips in RDS. DevOps/System Administrators can completely disable ProTips in the RDS configuration file (/etc/rds.knf):

  # Disable ProTips
  disable-tips: true

Users can turn off ProTips using a preferences file.

Clone this wiki locally