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 section describes how to deploy Redis in HCE 2.0.
Preparations
- Prepare two ECSs and assign a public IP address or an EIP to each ECS. One ECS is used as the primary Redis node, and the other is used as the secondary Redis node.
- Ensure that inbound security group rules allow traffic to flow to the ECSs over port 6379.
Prerequisites
A yum repository has been configured. For details about how to configure a yum repository accessed over the Internet, see Configuring Repositories and Installing Software for HCE.
Procedure
- Install and configure Redis.
- Run the following command on the two ECSs to install Redis:
dnf install redis
- Run the following command on the two ECSs to start Redis:
systemctl start redis
To enable Redis to start 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 primary node, edit the /etc/redis.conf file and configure the following attributes:
bind <primary node IP> # Enter the IP address of the primary node. requirepass ******* # Set a password.
- On the secondary node, edit the /etc/redis.conf file and configure the following attributes:
bind <IP address of the secondary node> # Enter the IP address of the secondary node. requirepass ******* # Set a password. slaveof <IP address of the primary node> <Port of the primary 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 -h <IP address of the primary node> auth <Password>
- Run the following command to check 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