Home > Database > Redis > How to match 2 redis

How to match 2 redis

(*-*)浩
Release: 2019-11-20 11:42:04
Original
2438 people have browsed it

How to match 2 redis

To start two Redis on the same server. The default port of Redis is 6379. You need to start another Redis with port 6389. The two Redis work independently and do not conflict with each other.

The redis-server.exe in the root directory will load the default configuration, and the port is 6379. The second Redis only needs to create a new configuration file and load the new configuration file when the exe is opened. (Recommended learning: Redis video tutorial)

Principles and steps of redis multi-opening:

Principle:

①The principle is the same as adding containers, single instance and multiple applications such as nginx and tomcat. Copy the new configuration file, change the configuration name, modify the port number, PID file path, log file path, and dump file path in the configuration file. , ensure that two or more redis services will not conflict;

②: The default Redis program is installed in the /usr/local/redis directory;

Configuration file: /usr/local/redis /redis.conf, the port configured in this configuration file is the default port: 6379;

Redis startup command path: /usr/local/bin/redis-server.

You can specify the port to start multiple Redis processes.

Specific steps:

cd /usr/local/redie   #切换到redis安装路径下
cp  redis.conf redis6380.conf  #复制到新的配置文件供第二个redis使用
vim  redis6380.conf  #配置新redis文件,避免两个redis冲突,在配置文件找到以下几项,进行修改;

pidfile /var/run/redis/redis_6380.pid   #指定新的PID文件路径
port 6380    #指定新的端口号
logfile /var/log/redis/redis_6380.log   #指定新的日志文件路径
dbfilename dump_6380.rdb   #指定新的转储文件路径
#配置文件修改完成  保存退出
Copy after login

Start the multi-instance command and view the startup results:

redis-server /usr/local/redis/redis6380.conf  #启动新实例命令
netstat -lnpt        #通过端口查看服务器是否启动,结果如下:

tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      1288/redis-server 1
tcp        0      0 127.0.0.1:6380          0.0.0.0:*               LISTEN      4084/redis-server 1
Copy after login

You can see two redis All are running. Remember to open new ports when using cloud servers.

The above is the detailed content of How to match 2 redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template