Deploying Redis
Introduction
Remote Dictionary Server (Redis) is an open-source, in-memory, distributed, and durable key-value pair storage database written in C. Redis is a storage system with rich functions and applies to various scenarios, including caching, session storage, rankings, and real-time analysis. It is widely used and has active community support. This tutorial describes how you can deploy Redis in HCE 2.0.
Preparations
- Prepare two ECSs and assign a public IP address or EIP to each ECS. One ECS functions as the master Redis node, and the other serves as the slave Redis node.
- Ensure that inbound security group rules allow traffic to flow to the ECSs over port 6379.
Procedure
- Install and configure Redis.
- Run the following command on the two ECSs to install Redis:
dnf install redis -y
- Run the following command on the two ECSs to start Redis:
systemctl start redis
To set Redis to automatically enable upon system boot, run the following command:
systemctl enable redis
- Run the following command to check the Redis status:
systemctl status redis
If active (running) is displayed, Redis is started.
- On the master node, edit the /etc/redis.conf file and configure the following attributes:
bind 0.0.0.0 # Replace the value with the IP address of the master node. In this example, enter any IP address. requirepass ******* # Set a password.
- On the slave node, edit the /etc/redis.conf file and configure the following attributes:
bind 0.0.0.0 # Replace the value with the IP address of the slave node. In this example, enter any IP address. requirepass ******* # Set a password. slaveof <IP address of the master node> <Port of the master node> masterauth <Password of the master node>
- Run the following command on the two ECSs to restart Redis:
systemctl restart redis
- Run the following command on the two ECSs to install Redis:
- Verify Redis.
- Run the following command on the master node to connect to Redis:
redis-cli auth <Password>
- Run the following command to view the node information:
127.0.0.1:6379> info replication # Replication role:master connected_slaves:1 slave0:ip=x.x.x.x,port=6379,state=online,offset=4382,lag=0 master_replid:5d68ccf7722f461cc5f004c7e96fd7c506990508 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:4382 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:4382 127.0.0.1:6379>
- Run the following command on the master node to connect to Redis:
The preceding configuration and Redis deployment architecture are used only for tests. Exercise caution when using them in the service environment.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot