


The master-slave mode and encryption method of redis in PHP development
1. Redis download and installation: https://redis.io/download
$ wget http://download.redis.io/releases/redis-4.0.10.tar.gz $ tar xzf redis-4.0.10.tar.gz $ cd redis-4.0.10 $ make $ src/redis-server $ src/redis-cli redis> set foo bar OK redis> get foo "bar"
Restart:
ps -el | grep redis
redis- cli -h 10.185.141.146 -p 6379 shutdown
You can re-specify redis.conf in this way:
/usr/local/bin/redis-server /export/servers/redis/ redis.conf
2. Introduction to master-slave mode and cluster mode
Note the cluster mode setting: cluster-enabled yes
The master-slave mode is: cluster-enabled no
Reference: https://www.cnblogs.com/janehoo/p/6119175.html
3. Master-slave setup
bind 192.168.119.131 (bind the current machine IP)
Slave settings: slaveof 10.181.24.207 6379
4. Password reference: https://blog.csdn.net/ningxuezhu/article/details/50341613
requirepass "admin.123" #Set redis login password
masterauth "admin.123" #Master-slave authentication password, otherwise master-slave cannot be synchronized
Access:/usr/local/bin/redis- cli -h 10.181.21.214 -p 6379 -a RA8gp8DyAn
Code encryption method:
1)
URI uri = URI.create(config.getUri()); redis = new Jedis(uri, config.getTimeout());
"uri": "redis://:RA8gp8DyAn@10.181.24.207:6379/0"
2)
Jedis jedis=new Jedis(map.get("host"),Integer.parseInt(map.get("port")),Integer.parseInt(map.get("timeout"))
redis=[{name:"redis-lf",host:"10.181.24.207",port:"6379",timeout:"5000",pwd:"RA8gp8DyAn"},\ {name:"redis-mjq",host:"10.185.181.250",port:"6379",timeout:"5000",pwd:"RA8gp8DyAn"},\ {name:"redis-ht",host:"11.24.69.219",port:"6379",timeout:"5000",pwd:"RA8gp8DyAn"}]
3) If redis It has been started. You can set it through config set masterauth "RA8gp8DyAn" first, and then modify the configuration file to load it at the next restart.
5. Persistence
Redis has two persistence methods: Reference: http://redisdoc.com/topic/persistence.html
Reference: https://blog.csdn.net/RobertoHuang/article/details/70847194
1. appendonly yes //Enable aof persistence method
2. RDB is the default persistence method of Redis .
RDB configuration: Three conditions have been preset in the configuration file
save 900 1 # 15分钟内至少有一个键被更改 save 300 10 # 5分钟内至少有10个键被更改 save 60 10000 # 1分钟内至少有10000个键被更改
The default rdb file path is the current directory, and the file name is: dump.rdb , you can modify the path and file name in the configuration file, which are dir and dbfilename
dir ./ # rdb文件存储路径 dbfilename dump.rdb # rdb文件名
The above is the detailed content of The master-slave mode and encryption method of redis in PHP development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



With the rapid development of the Internet and people's increasing demand for information exchange, forum websites have become a common online social platform. Developing a forum website of your own can not only meet your own personalized needs, but also provide a platform for communication and sharing, benefiting more people. This article will teach you step by step how to use PHP to develop your own forum website. I hope it will be helpful to beginners. First, we need to clarify some basic concepts and preparations. PHP (HypertextPreproces

In web development, we often need to use caching technology to improve website performance and response speed. Memcache is a popular caching technology that can cache any data type and supports high concurrency and high availability. This article will introduce how to use Memcache in PHP development and provide specific code examples. 1. Install Memcache To use Memcache, we first need to install the Memcache extension on the server. In CentOS operating system, you can use the following command

How to use PHP to develop a hotel booking website With the development of the Internet, more and more people are beginning to arrange their travels through online booking. As one of the common online booking services, hotel booking websites provide users with a convenient and fast way to book hotels. This article will introduce how to use PHP to develop a hotel reservation website, allowing you to quickly build and operate your own online hotel reservation platform. 1. System requirements analysis Before starting development, we need to conduct system requirements analysis first to clarify what the website we want to develop needs to have.

How to use PHP to develop an online tutoring service platform. With the rapid development of the Internet, online tutoring service platforms have attracted more and more people's attention and demand. Parents and students can easily find suitable tutors through such a platform, and tutors can also better demonstrate their teaching abilities and advantages. This article will introduce how to use PHP to develop an online tutoring service platform. First, we need to clarify the functional requirements of the platform. An online tutoring service platform needs to have the following basic functions: Registration and login system: users can

How to implement version control and code collaboration in PHP development? With the rapid development of the Internet and the software industry, version control and code collaboration in software development have become increasingly important. Whether you are an independent developer or a team developing, you need an effective version control system to manage code changes and collaborate. In PHP development, there are several commonly used version control systems to choose from, such as Git and SVN. This article will introduce how to use these tools for version control and code collaboration in PHP development. The first step is to choose the one that suits you

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to use PHP to develop the coupon function of the ordering system? With the rapid development of modern society, people's life pace is getting faster and faster, and more and more people choose to eat out. The emergence of the ordering system has greatly improved the efficiency and convenience of customers' ordering. As a marketing tool to attract customers, the coupon function is also widely used in various ordering systems. So how to use PHP to develop the coupon function of the ordering system? 1. Database design First, we need to design a database to store coupon-related data. It is recommended to create two tables: one

How to improve search engine rankings through PHP cache development Introduction: In today's digital era, the search engine ranking of a website is crucial to the website's traffic and exposure. In order to improve the ranking of the website, an important strategy is to reduce the loading time of the website through caching. In this article, we'll explore how to improve search engine rankings by developing caching with PHP and provide concrete code examples. 1. The concept of caching Caching is a technology that stores data in temporary storage so that it can be quickly retrieved and reused. for net
