------ 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多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133737368-1024x429.png)
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多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133801416-1024x516.png)
3. Release port 6378 (can be assigned according to your actual port usage)
![图片[3]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133814293-1024x161.png)
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多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133828133-1024x467.png)
5, modify the redis pid, log, data storage directory
![图片[5]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133850653-1024x532.png)
![图片[6]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133900422-1024x471.png)
Save after modification
![图片[7]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133915623-1024x663.png)
6, delete the previous redis generated log and pid file (see the path)
![图片[8]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133925817-1024x446.png)
7. Start and verify the startup command:
/www/server/redis6378/src/redis-server
/www/server/redis6378/redis.conf
![图片[9]-Redis多开基于端口实现redis多实例教程-互悦科技源码-软件定制开发](https://osshyym.oss-accelerate.aliyuncs.com/wp-content/uploads/2024/07/20240816133935580-1024x248.png)
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)
















No comments