Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sample Analysis of installation and use in Redis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the example analysis of installation and use in Redis, which is very detailed and has a certain reference value. Friends who are interested must read it!

1. Download:

Project address: https://github.com/MSOpenTech/redis

Download address: https://github.com/MSOpenTech/redis/releases

Note that you should download the zip version, not the msi version.

2. Install:

Unpack it, copy it to the root directory of the e-disk, and rename the folder to redis (kill the version number and so on) to complete the installation.

3. Start:

Open cmd, enter redis, enter the command redis-server.exe redis.windows.conf, enter enter, and start.

A square box pattern appears, even if the startup is successful.

Otherwise, the startup fails.

In a development environment, you need to open cmd as an administrator to start successfully. If it is a server environment, it is an administrator itself, so you don't need to do this specifically.

4. Test:

Open another cmd, enter redis, enter the command redis-cli.exe, enter, and enter the redis operation state.

Entering set age 21 returns OK, indicating that the write was successful.

If you enter get age, 21 will be returned, indicating that the value is successful.

The test is complete.

If you are not connecting locally, or if the port has changed and you find that you can't connect, you should do this:

Redis-cli.exe-h host IP-p new port number

For example, if the port has been changed to 666, it should be written as follows:

Redis-cli.exe-p 666

So you can connect.

5. Persistence:

① AOF:

Modify in redis.windows.conf:

Appendonly yes

Then, an appendonly.aof file, the log file, will be generated under the program folder, and the data will be stored in this file.

② RDB:

By default, a data snapshot named dump.rdb is created under the program folder. The logic of the snapshot is as follows:

# Snapshot created after 900s and at least 1 key changed save 900 1 '300 seconds after and at least 10 key changes create snapshot save 300 10' 60 seconds and at least 10000 key changes create snapshot save 60 10000

You can disable snapshot creation by commenting out save.

③ what is RedisQFork.dat:

This is the memory mapping of redis, and such a file is created when redis starts and disappears when it is closed. This file is to write the data in memory into it and do a mapping.

The more data there is, the bigger the bat will be, which will take up space on disk c. The solution is to change the path to another disk.

Note: I downloaded version 3.2 can not find heapdir, and I set heapdir e:\ redis\ and then launch will report an error, unknown parameter heapdir, in addition, the whole computer can not find the RedisQFork file, I suspect that the new version of redis has abandoned this mapping.

Version 2. 8 was downloaded for testing, and there is a heapdir option.

6. Boot:

Configure redis as a service:

Open cmd as an administrator, enter the e disk, and enter:

The copy code is as follows:

E:\ redis\ redis-server.exe-- service-install E:\ redis\ redis.windows.conf-- loglevel verbose

Enter and the service is created.

You can open run-services.msc- to see the Redis service.

Restart the computer, Redis has been started. You can open the redis-cli test.

Delete the service:

E:\ redis\ redis-server-- service-uninstall

7. Security

Modify it in redis.windows.conf:

① binds ip

It can be local or public, which is generally bound (redis3.2) by default.

Bind 127.0.0.1

② modifies default port

The default 6379 is changed to a different port

③ disables dangerous commands

Setting it to "" disables the following command:

Rename-command FLUSHALL "" rename-command CONFIG "" rename-command EVAL ""

8. Fuzzy query through the command line

If we determine a key, do the query like this:

Get xxx

If we only know that the prefix of this key is test, we can do this:

Keys test*

Can you use * and? To match the blurred parts.

9. Expiration time

The write expiration time of php using redis must be forced to (int), no matter string or double, only int can.

The above is all the contents of the article "sample Analysis of installation and use in Redis". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report