当前位置:网站首页>[redis] redis installation
[redis] redis installation
2022-07-25 16:42:00 【StudyWinter】
1 redis Introduction
redis It's a key-value The storage system . and Memcached similar , It supports storage value There are more types , Include string( character string )、list( Linked list )、set( aggregate )、zset(sorted set -- Ordered set ) and hash( Hash type ). these data type All support push/pop、add/remove And take intersection, union and difference sets and more abundant operations , And these operations are atomic . On this basis ,redis Support various sorts of sorting . And memcached equally , To ensure efficiency , The data is cached in memory . The difference is redis Periodically, updated data is written to disk or changes are written to an appended log file , And on this basis to achieve master-slave( Master-slave ) Sync .
Redis Is a high-performance key-value database . redis Appearance , A lot of compensation memcached This kind of key/value Insufficient storage , In some cases, it can play a very good complementary role to the relational database . It provides Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erlang Such as the client , Easy to use .
Redis Support master-slave synchronization . Data can be synchronized from the master server to any number of slaves , A slave server can be the master server associated with other slaves . This makes Redis Single-layer tree replication can be performed . The disk can write to the data intentionally or unintentionally . Because it's fully realized Release / subscribe Mechanism , Enables trees to be synchronized anywhere from the database , Subscribe to a channel and receive a complete record of message publication from the master server . Synchronization helps with scalability and data redundancy for read operations .
Reprint :Redis_ Baidu Encyclopedia
1.1 redis What is it?
Redis:REmote DIctionary Server( Remote dictionary server ) It's completely open source and free , use C language-written , comply with BSD agreement , Is a high-performance (key/value) Distributed memory database , Run based on memory , And support persistent NoSQL database , It's the hottest NoSql One of the databases , Also known as data structure server .
Redis And others key - value Cache products have the following three characteristics :
Redis Support data persistence , Data in memory can be kept on disk , When you restart, you can load it again for use ;
Redis It's not just about supporting simple key-value Data of type , It also provides list,set,zset,hash Such as data structure storage ;
Redis Support data backup , namely master-slave Mode data backup .
1.2 What can I do?
Memory storage and persistence :redis Support asynchronous write data in memory to hard disk , At the same time, it does not affect the continued service
Take the latest N Data operations , Such as : You can put the latest 10 Of comments ID Put it in Redis Of List In the assembly
The simulation is similar to HttpSession This function needs to set expiration time
Release 、 Subscribe to the messaging system
Timer 、 Counter
1.3 Where to download
Redis Official website :Redis
Redis Chinese net :CRUG Website
1.4 How do you play?
data type 、 Basic operation and configuration
Persistence and replication ,RDB/AOF
Control of transactions
Copy ( Master-slave relationship )
2 redis Installation
linus:centos7
redis edition :redis-4.0.11
After downloading the compressed package on the official website , Drag into virtual machine , decompression
tar -zxvf redis-4.0.11.tar.gz
notes : The version I first installed is 6.0.9, But the later installation was unsuccessful , So I changed the version , It uses 4.0.11. The installation process is the same , The screenshot uses 6.0.9
Enter the unzipped installation package

makegcc The order was not found !!!【 This machine is missing gcc Environment 】

gcc yes linux Compiler under , yes C Compiler for , install gcc
yum install gcc-c++
Again make

Need to put the first make Clean up your files . make distclean Again after make

make install
/usr: Many of the user's applications and files are in this directory , similar windows Under the program files file

Get into opt/redis4.0.11 Next , Copy redis.conf Go to the new directory usr/etc/ Next

To configure redis-conf. Be careful , stay root Use by user vim
vim redis-conf
Modify the daemon to yes
Check with the command redis Has the process of :
ps -ef|grep redis
start-up redis
redis-server /usr/etc/redis.conf ## Start the configured , Didn't touch the original 
redis-cli -p 6379, It means that

redis yes k-v Key value pair

The process has started in the background

Turn off the redis

Look at the process again , No, redis process

3 redis Miscellaneous basics after startup
3.1 test set and get
cd /usr/local/bin
3.3 
3.2 Single process
Single process model to handle client requests . Response to events such as reading and writing Is based on epoll Function to do this .Redis The actual processing speed of depends on the execution efficiency of the main process
epoll yes Linux The kernel has made improvements to handle large quantities of file descriptors epoll, yes Linux Lower multiplexing IO Interface select/poll Enhanced version of , It can significantly improve the system when the program is only active in a large number of concurrent connections CPU utilization .
3.3 library
Default 16 A database , Similar array the following table starts from zero , The initial default is to use library zero , It can be configured in the configuration file .
3.4 A simple command
select Command switch database

dbsize Check the... Of the current database key The number of

see key Number

flushdb: Empty the current libraryflushall; Kill all the warehousesUnified password management ,16 Every library is the same password , Or both OK Or none of them can connect
Redis Indexes start from scratch
Why is the default port 6379 Nine key middle :6-m 3-e 7-r 0-z merz
边栏推荐
- Test Driven Development (TDD) online practice room | classes open on September 17
- 今天去 OPPO 面试,被问麻了
- Roson的Qt之旅#99 QML表格控件-TableView
- [xiao5 chat] check the official account < the service provided by the official account has failed, please wait a moment>
- [book club issue 13] +ffmpeg open source project
- 【图像隐藏】基于混合 DWT-HD-SVD 的数字图像水印方法技术附matlab代码
- MyBaits
- MySQL global lock
- 【ZeloEngine】反射系统填坑小结
- The presentation logic of mail sending and receiving inbox outbox and reply to the problem of broken chain
猜你喜欢

easyui修改以及datagrid dialog form控件使用
![[zeloengine] summary of pit filling of reflection system](/img/7a/c85ba66c5dd05908b2d784fab306a2.png)
[zeloengine] summary of pit filling of reflection system

谁动了我的内存,揭秘 OOM 崩溃下降 90% 的秘密

基于SqlSugar的开发框架循序渐进介绍(13)-- 基于ElementPlus的上传组件进行封装,便于项目使用

【故障诊断】基于贝叶斯优化支持向量机的轴承故障诊断附matlab代码

0x80131500 solution for not opening Microsoft Store

Emqx cloud update: more parameters are added to log analysis, which makes monitoring, operation and maintenance easier

自定义mvc项目登录注册和树形菜单

3D语义分割——PVD

Verifiable random function VRF
随机推荐
MySQL view
【目标检测】TPH-YOLOv5:基于transformer的改进yolov5的无人机目标检测
Test framework unittest test test suite, results output to file
China's chip self-sufficiency rate has increased significantly, resulting in high foreign chip inventories and heavy losses. American chips can be said to have thrown themselves in the foot
测试框架-unittest-跳过测试
[xiao5 chat] check the official account < the service provided by the official account has failed, please wait a moment>
How does win11's own drawing software display the ruler?
百度富文本编辑器UEditor单张图片上传跨域
unity 最好用热更方案卧龙 wolong
7. Dependency injection
【云驻共创】探秘GaussDB如何助力工商银行打造金融核心数据
今天去 OPPO 面试,被问麻了
Who moved my memory and revealed the secret of 90% reduction in oom crash
【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part4):结合问题分类的问题解析与检索语句生成
【obs】转载:OBS直播严重延迟和卡顿怎么办?
城市燃气安全再拉警钟,如何防患于未“燃”?
[book club issue 13] +ffmpeg video capture function
华泰vip账户证券开户安全吗
【故障诊断】基于贝叶斯优化支持向量机的轴承故障诊断附matlab代码
doGet与doPost