Redis multi-open port-based implementation of redis multi-instance tutorials

Image

------ body content display, start to learn new knowledge ------

Sometimes build in the construction of more than one of the same site when found Redis share triggered data conflicts, then we can open through the Redis multi-open to solve this problem!

Implementing multiple instances of redis based on multiple ports:
1, open the panel to install redis, and configure the use of the maximum memory, for example, the test server here is 4G memory, here chose 512M memory for redis use, configured to restart redis (if it is a production environment, at your own discretion, whether you can restart as well as limit the maximum memory).

图片[1]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

2. Make a copy of redis in accordance with the good
The commands are as follows:

\cp -rp /www/server/redis/ /www/server/redis6378
图片[2]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

3. Release port 6378 (can be assigned according to your actual port usage)

图片[3]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

4, open the file manager, into the /www/server/redis6378 directory below
Open redis.conf and change the port in the configuration file to 6378.

图片[4]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

5, modify the redis pid, log, data storage directory

图片[5]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发
图片[6]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

Save after modification

图片[7]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

6, delete the previous redis generated log and pid file (see the path)

图片[8]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

7. Start and verify the startup command:

/www/server/redis6378/src/redis-server
/www/server/redis6378/redis.conf
图片[9]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发

The new Redis is now up and running!

Lastly to add to the supplement, if there is cached data within the redis that is copied over, it will still cause the data to be misplaced at the later site.
So you need to newly open redis under the corresponding port to clean the cache.
1. Ensure that the process survives first ps -ef|grep redis

2. Execute . /redis-cli or . /redis-cli -h 127.0.0.1 -p 6388maybe6389(Port number is based on self-set)Go to the newly opened redis instance

3. Execute the dbsize command
127.0.0.1:6388> dbsize

4. cleanup 127.0.0.1:6388> flushall

5. exit 127.0.0.1:6388> exit

6. Repeat 2-5 for multiple instances (note port numbers)

© copyright statement
THE END
Image
kudos14 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

请登录后发表评论

    No comments