CentOS 7 配置运行多个 Redis Server-Install Redis from Source and Configure Multiple Redis Server on CentOS 7
Prerequisites
- Tencent Cloud Lighthouse(腾讯云轻量云服务器).
- CentOS 7.
- Execute all directive as lighthouse.
Install Redis from Source
Choose a version from Download page.
Download Redis Source and Extract the Installtion.
1 |
|
After you have extracted and moved into the directory, start compiling with the make
command:
1 |
|
The build may take somet time, depending on your server resources. Once completed, you will receive a message as follows:
Next, install Redis binaries with the make install command: sudo make install
(I want set the installtion path to /usr/local, so sudo
is required):
1 |
|
Create Multiple Redis configuration file
After installing Redis, you need to configure two Redis.
1 |
|
Open the Redis configuration files for editing:
Modifying /usr/local/redis/conf/6379/redis.conf
:
1 |
|
Modifying /usr/local/redis/conf/6380/redis.conf
:
1 |
|
Creat directory to store pidfile and DB, then set correct permissions:
1 |
|
Create the Redis system file
Now that Redis is installed and configured, the find step is to create two systemd unit files so you can manage Redis services like regular systemd service.
1 |
|
Add the following directives to service file:
1 |
|
1 |
|
Add the following directives to service file:
1 |
|
Increase the value of somaxconn, Try to execute following command with sudo
.
1 |
|
Note not required: If have problem about limit of somaxconn, try add net.core.somaxconn=65535
in the /etc/sysctl.conf
file:
Enable Redis
1 |
|
Start Redis
1 |
|
Now, the redis-server status is shown as below.
Finally, to verify that the Redis service is functioning correctly, run the command in the picture and the output should shown as well:
That’s it.