search
HomeWeb Front-endJS TutorialRedis basic knowledge, installation, deployment, configuration notes_Basic knowledge

Basic knowledge

1. Redis data type:
Strings, lists, sets, sort sets, hash tables
2. Unique features of Redis compared with memcache:
(1) Redis can be used for storage, while memcache is used for cache. This feature is mainly due to its "persistence" function
(2) The stored data has a "structure". For memcache, there is only one type of stored data - "string", while redis can store strings, linked lists, sets, ordered sets, and hash-order structures.
3. Two methods of persistence:
Redis stores data in memory or is configured to use virtual memory.
Two ways to achieve data persistence:
(1) Use screenshots to continuously write data in the memory to the disk (high performance, but may cause a certain degree of data loss)
(2) Use a method similar to mysql to record the log of each update
4. Redis master-slave synchronization: very beneficial to improving reading performance
5. The default port of the Redis server is 6379

Next let’s install Redis

1. First go to the Redis official website (redis.io) to download the redis installation package

2. Download it to my /lamp directory
3. Unzip and enter its directory

4. Compile source program

Copy code The code is as follows:

make
cd src
​make install PREFIX=/usr/local/redis

5. Move the configuration file to the redis directory

6. Start the redis service

7. By default, Redis does not run in the background. We need to run redis in the background

Copy code The code is as follows:

vim /usr/local/redis/etc/redis.conf

Change the value of daemonize to yes

8. Client connection

Copy code The code is as follows:

/usr/local/redis/bin/redis-cli

9. Stop the redis instance

Copy code The code is as follows:

​/usr/local/redis/bin/redis-cli shutdown

Or
Copy code The code is as follows:

pkill redis-server

10. Let redis start automatically at boot
Copy code The code is as follows:

vim /etc/rc.local

Join
Copy code The code is as follows:

​/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis-conf

11. Next, let’s take a look at the files in the /usr/local/redis/bin directory
Copy code The code is as follows:

redis-benchmark: redis performance testing tool

redis-check-aof: Tool for checking aof logs

redis-check-dump: Tool for checking rdb logs

redis-cli: client for connection

redis-server: redis service process

Redis 구성

데몬화: 백그라운드에서 실행해야 한다면 이 항목의 값을 yes로 변경하세요

pdifile: pid 파일을 /var/run/redis.pid에 넣고 다른 주소로 구성할 수 있습니다

바인딩: 이 IP에서만 요청을 받도록 redis를 지정합니다. 설정하지 않으면 모든 요청이 처리됩니다.

포트: 수신 포트, 기본값은 6379

시간 초과: 클라이언트가 연결될 때 시간 초과 시간을 초 단위로 설정합니다.

로그 레벨: 레벨은 디버그, 개정, 알림, 경고의 4가지 레벨로 구분됩니다. 프로덕션 환경에서는 일반적으로 알림이 켜져 있습니다

로그 파일: 로그 파일 주소를 구성합니다. 기본적으로 명령줄 터미널의 포트에 인쇄되는 표준 출력이 사용됩니다.

데이터베이스: 데이터베이스 수를 설정합니다. 기본 데이터베이스는 0입니다.

저장: redis에 의한 데이터베이스 미러링 빈도 설정

rdbcompression : 이미지 백업 수행 시 압축 여부

dbfilename : 이미지 백업 파일의 파일명

dir : 데이터베이스 미러 백업 파일이 있는 경로

slaveof: 이 데이터베이스를 다른 데이터베이스의 슬레이브 데이터베이스로 설정합니다.

Masterauth: 마스터 데이터베이스 연결에 비밀번호 인증이 필요한 경우 여기에서 설정하세요.

requirepass: 클라이언트가 연결된 후 다른 사양을 지정하기 전에 필요한 비밀번호를 설정하세요.

maxclients: 동시에 연결되는 클라이언트 수를 제한합니다

maxmemory: redis가 사용할 수 있는 최대 메모리를 설정합니다

Appendonly: 추가 전용 모드를 활성화한 후 redis는 수신된 모든 쓰기 작업을appendonly.aof 파일에 추가합니다. redis가 다시 시작되면 이 파일에서 이전 상태가 복원됩니다.

appendfsync:appendonly.aof파일 동기화 빈도 설정

 vm_enabled: 가상 메모리 지원 활성화 여부

vm_swap_file : 가상 메모리 스왑 파일의 경로를 설정합니다

vm_max_momery: 가상 메모리가 켜진 후 redis가 사용할 최대 물리적 메모리 크기를 설정합니다. 기본값은 0입니다

vm_page_size: 가상 메모리 페이지의 크기를 설정

vm_pages: 스왑 파일의 총 페이지 수 설정

 vm_max_thrrads: vm IO가 동시에 사용하는 스레드 수 설정

Statement
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
es和redis区别es和redis区别Jul 06, 2019 pm 01:45 PM

Redis是现在最热门的key-value数据库,Redis的最大特点是key-value存储所带来的简单和高性能;相较于MongoDB和Redis,晚一年发布的ES可能知名度要低一些,ES的特点是搜索,ES是围绕搜索设计的。

一起来聊聊Redis有什么优势和特点一起来聊聊Redis有什么优势和特点May 16, 2022 pm 06:04 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于redis的一些优势和特点,Redis 是一个开源的使用ANSI C语言编写、遵守 BSD 协议、支持网络、可基于内存、分布式存储数据库,下面一起来看一下,希望对大家有帮助。

实例详解Redis Cluster集群收缩主从节点实例详解Redis Cluster集群收缩主从节点Apr 21, 2022 pm 06:23 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis Cluster集群收缩主从节点的相关问题,包括了Cluster集群收缩概念、将6390主节点从集群中收缩、验证数据迁移过程是否导致数据异常等,希望对大家有帮助。

Redis实现排行榜及相同积分按时间排序功能的实现Redis实现排行榜及相同积分按时间排序功能的实现Aug 22, 2022 pm 05:51 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,希望对大家有帮助。

详细解析Redis中命令的原子性详细解析Redis中命令的原子性Jun 01, 2022 am 11:58 AM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于原子操作中命令原子性的相关问题,包括了处理并发的方案、编程模型、多IO线程以及单命令的相关内容,下面一起看一下,希望对大家有帮助。

实例详解Redis实现排行榜及相同积分按时间排序功能的实现实例详解Redis实现排行榜及相同积分按时间排序功能的实现Aug 26, 2022 pm 02:09 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,下面一起来看一下,希望对大家有帮助。

一文搞懂redis的bitmap一文搞懂redis的bitmapApr 27, 2022 pm 07:48 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了bitmap问题,Redis 为我们提供了位图这一数据结构,位图数据结构其实并不是一个全新的玩意,我们可以简单的认为就是个数组,只是里面的内容只能为0或1而已,希望对大家有帮助。

redis error什么意思redis error什么意思Jun 17, 2019 am 11:07 AM

redis error就是redis数据库和其组合使用的部件出现错误,这个出现的错误有很多种,例如Redis被配置为保存数据库快照,但它不能持久化到硬盘,用来修改集合数据的命令不能用。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),