当前位置:网站首页>Redis-01. First meet redis
Redis-01. First meet redis
2022-07-05 06:28:00 【Cold leaves elegant_】
NoSQL
SQL and NoSQL The difference between
| SQL | NoSQL | |
|---|---|---|
| data structure | structured | Unstructured ( Key value 、 file 、 Column 、 Map, etc. ) The structure is loose |
| Data Association | The associated | Unrelated |
| A query | SQL Inquire about | Not SQL |
| Transaction features | ACID | BASE |
| storage | disk | Memory |
| Extensibility | vertical | level |
| Use scenarios | 1) The data structure is fixed 2) For data security 、 High consistency is required | 1) The data structure is not fixed 2) For consistency 、 Safety requirements are not high 3) Performance requirements |
Redis
features :
- Key value type ,value Support a variety of different data structures
- Single thread , Every command is atomic
- Low latency , Fast ( Memory based 、IO Multiplexing 、 Good coding )
- Support data persistence
- Support the master-slave cluster 、 Fragmentation cluster
- Support for multilingual clients
1. install Redis
1. install Redis rely on
Redis be based on C Language implementation , So first install gcc rely on
yum install -y gcc tcl
2. Upload the installation package and unzip it
Upload Redis Installation package to /usr/local/src
Decompress after entering this path
tar -xzf redis-6.2.6.tar.gz
After decompression, enter the decompression path
cd redis-6.2.6
Run the compile command :
make && make install
After successful operation , Just install it
The default installation path is /usr/local/bin/
This directory and the default configuration to the environment variable , Therefore, you can run these commands in any directory . among :
- redis-cli: yes redis The command line client provided
- redis-server: yes redis Server startup script
- redis-sentinel: yes redis Sentinel startup script
3. start-up
redis There are many ways to start , for example :
- The default startup
- Specify the configuration to start
- Boot from boot
1. The default startup
After installation , Enter... In any directory redis-server Command to start Redis:
redis-server
This startup belongs to The front desk starts , Will block the entire session window , Close the window or press CTRL + C be Redis stop it . It is not recommended to use .
2. Specify the configuration to start
If you want to make Redis With backstage Mode start , You have to modify Redis The configuration file , Just before we unzipped redis Under the installation package (/usr/local/src/redis-6.2.6), Name is redis.conf
First, back up this configuration file :
cp redis.conf redis.conf.bck
Modify the configuration file
vi redis.conf
And then modify redis.conf Some configurations in the file :
# Address allowed to access , The default is 127.0.0.1, Will result in local access only . It is amended as follows 0.0.0.0 It can be in any IP visit , The production environment should not be set to 0.0.0.0
bind 0.0.0.0
# Daemon , It is amended as follows yes After, it can run in the background
daemonize yes
# password , Access after setting Redis You must enter a password
requirepass redispasswd
Redis Other common configurations :
# Listening port
port 6379
# working directory , The default is the current directory , Which is running redis-server When the command , journal 、 Files such as persistence will be saved in this directory
dir .
# Number of databases , Set to 1, Stands for using only 1 Databases , The default is 16 Databases , Number 0~15
databases 1
# Set up redis Maximum memory available
maxmemory 512mb
# Log files , The default is empty. , Do not log , You can specify the log file name
logfile "redis.log"
start-up Redis:
# Get into redis The installation directory
cd /usr/local/src/redis-6.2.6
# start-up
redis-server redis.conf
Out of Service :
# utilize redis-cli To execute shutdown command , Just stop Redis service ,
# Because the password was configured before , So it needs to pass -a To specify the password
redis-cli -a 123321 shutdown
3. Boot from boot
We can also realize self startup through configuration .
First , Create a new system service file :
vi /etc/systemd/system/redis.service
The contents are as follows :
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /usr/local/src/redis-6.2.6/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Then reload the system services :
systemctl daemon-reload
Now? , We can use the following set of commands to operate redis 了 :
# start-up
systemctl start redis
# stop it
systemctl stop redis
# restart
systemctl restart redis
# Check the status
systemctl status redis
Execute the following command , It can make redis Boot from boot :
systemctl enable redis
2.Redis client
installation is complete Redis, We can operate Redis, To achieve data CRUD 了 . It needs to use Redis client , Include :
- Command line client
- Graphical desktop client
- Programming client
1.Redis Command line client
Redis After the installation is completed, the command-line client comes with it :redis-cli, Use as follows :
redis-cli [options] [commonds]
One of the common ones is options Yes :
-h 127.0.0.1: Specify the... To connect to redis Node IP Address , The default is 127.0.0.1-p 6379: Specify the... To connect to redis Port of node , The default is 6379-a 123321: Appoint redis Access code for
Among them commonds Namely Redis Operation command of , for example :
ping: And redis The server does a heartbeat test , The server will normally returnpong
Don't specify commond when , Will enter redis-cli Interactive console
First start redis client
redis-cli
Then enter the password
auth "123321"
ping once
ping
ping If successful, it will return a pong
have access to set Store the data in the database in the form of a dictionary 
2. Graphical desktop client
Installation package warehouse :https://github.com/lework/RedisDesktopManager-Windows/releases
Source code :https://github.com/uglide/RedisDesktopManager
According to myself redis You can connect by setting the configuration of

You can find , Deposited before redis The data of was successfully saved in redis In the database of 
Reference material :
- https://www.bilibili.com/video/BV1cr4y1671t?p=7&spm_id_from=pageDriver
- https://blog.csdn.net/Mr_wangB0/article/details/102741624
- https://blog.csdn.net/qq_26710805/article/details/80171101
边栏推荐
- Game theory acwing 894 Split Nim game
- [2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
- 博弈论 AcWing 894. 拆分-Nim游戏
- 5.Oracle-表空间
- Idea debug failed
- 求组合数 AcWing 888. 求组合数 IV
- Sum of three terms (construction)
- Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
- 3. Oracle control file management
- Paper reading report
猜你喜欢

VLAN experiment

ADG5412FBRUZ-RL7应用 双电源模拟开关和多路复用器IC

confidential! Netease employee data analysis internal training course, white whoring! (attach a data package worth 399 yuan)

高斯消元 AcWing 884. 高斯消元解异或線性方程組

Vant weave swipecell sets multiple buttons

MySQL advanced part 2: SQL optimization

Knapsack problem acwing 9 Group knapsack problem

5. Oracle tablespace

Game theory acwing 894 Split Nim game

Find the combination number acwing 887 Find combination number III
随机推荐
【高德地图POI踩坑】AMap.PlaceSearch无法使用
Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
H5内嵌App适配暗黑模式
5.Oracle-錶空間
4. Object mapping Mapster
Redis-02.Redis命令
中国剩余定理 AcWing 204. 表达整数的奇怪方式
Game theory acwing 893 Set Nim game
International Open Source firmware Foundation (osff) organization
[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis
阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
11-gorm-v2-02-create data
MySQL advanced part 2: SQL optimization
Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
Quickly use Amazon memorydb and build your own redis memory database
H5 embedded app adapts to dark mode
NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
What is socket? Basic introduction to socket
Bit of MySQL_ OR、BIT_ Count function