当前位置:网站首页>Redis02: install redis in Linux Environment
Redis02: install redis in Linux Environment
2022-07-18 05:05:00 【@Misty rain fell on the city】
Table of contents title
| Redis Official website | Redis Official website in Chinese |
|---|---|
| http://redis.io | http://redis.cn/ |
1、 Installation steps
First step : download Redis Installation package

The second step : Use Xftp Tool upload redis-5.0.7.tar.gz To linux System .

The third step : decompression redis-5.0.2.tar.gz To /opt Catalog


Step four : compile redis, Go to unzip directory

Step five : Basic environment installation ( install gcc)
yum install gcc-c++
What is? gcc ?
gcc yes GNU compiler collection Abbreviation , It is Linux The next compiler collection ( amount to javac ), yes c or c++ The compiler of the program .

Step six : perform make Command to compile

Step seven : perform make install install redis

Be careful : stay make Execute after execution make install, This action will src Many of the executable files under are copied to /usr/local/bin Under the table of contents , This can be done in any directory redis The command of the software ( For example, start , stop it , And so on ), make install You don't have to execute , Personal habits .
see make Compilation result ,cd src Catalog


Step eight : take redis Copy the configuration file to our current directory

Step nine :redis It is not started in the background by default , You need to modify the configuration file to ensure background startup
[[email protected] hconfig]# vim redis.conf

Step 10 : start-up Redis service
[[email protected] bin]# redis-server hconfig/redis.conf

Step 11 : Use redis The client connects
[[email protected] bin]# redis-cli -p 6379

The twelfth step : see redis Whether the process of
[[email protected] ~]$ ps -ef|grep redis

Thirteenth Step : close redis service
① Use redis Client shutdown , Issue a shutdown command to the server
Single instance close :redis-cli shutdown
You can also enter the terminal and then close it ( The following is the closing after entering the terminal )
Multi instance shutdown , The specified port is closed :redis-cli -p 6379 shutdown
sign out Redis client :exit perhaps quit Instructions .
This is the recommended way , redis Finish the data operation first , Then turn it off .
for example :

Check again that the process has closed

②kill pid perhaps kill -9 pid
This method does not consider whether the current application has data in operation , Just close the app .
First use ps -ef | grep redis Find out the process number , Reuse kill pid

2、Redis Basic knowledge
2.1 test Redis performance
| Serial number | Options | describe | The default value is |
|---|---|---|---|
| 1 | -h | Specify the server host name | 127.0.0.1 |
| 2 | -p | Specify the server port number | 6379 |
| 3 | -s | Specify the server socker | |
| 4 | -c | Specify the number of concurrent | 50 |
| 5 | -n | Specify the number of requests | 10000 |
| 6 | -d | Specify... In bytes SET/GET Data size of value | 3 |
| 7 | -k | 1=keep alive 0=reconnect | 1 |
Example :100 Two concurrent connections ,100000 Requests
First of all to enter bin Catalog
[[email protected] ~]$ cd /usr/local/bin
[[email protected] bin]$ redis-benchmark -h localhost -p 6379 -c 100 -n 100000

2.2 Redis Communication command , Check the status
redis >ping
return PONG
# explain : Input ping,redis Come back to us PONG, Express redis The service is running normally

2.3 see redis Server statistics :info
grammar :info [section]
effect : In a format that is easy to explain and easy to read , Return to about Redis All kinds of information and statistics of the server .section Used to return the statistics of the specified part . section Value :server , clients ,memory wait . No addition section Return all statistics
Return value : Appoint section Statistics or all information about
example 1: Statistics server Information about

example 2: Count all the information

2.4 redis By default 16 Databases
Redis By default 16 Databases , from 0 To 15. Modify the number of databases , stay redis.conf In file databases 16, Theoretically, you can configure an unlimited number of .

Redis The library is similar to a database instance in a relational database , But there are some differences , such as redis Each library in cannot be named by user , It can only be expressed by serial number ,redis Each library in is not completely independent , It is best to use one for each application redis example , Not recommended redis Save the data of multiple applications in the instance .Redis The storage space occupied by the instance itself is actually very small , So there is no waste of storage space .
2.5 Switch library commands :select db
By default, use section 0 individual , If you want to use another database , The order is select index

2.6 View the current database key Number of :dbsize
# grammar :dbsize# effect : Returns the... Of the current database key The number of .# Return value : Numbers ,key The number of

**2.7 View what is in the current database key:keys ***

2.8 Empty the current library :flushdb

2.9 Empty all database contents :flushall

It also shows redis The libraries in are not completely irrelevant .
**2.10 get redis All configuration values for :config get ***
example 1: Get the number of databases config get databases

example 2: Get the port number config get port

2.11 Redis A single thread + multiple IO Multiplexing technology
Redis yes C language-written , The official data is 100000+ Of QPS, It's no better than using the same key-value Of Memcache Bad
Redis Why is single thread so fast ?
- myth 1: High performance server must be multithreaded ?
- myth 2: Multithreading (CPU Context switch ) It must be more efficient than a single thread ?
- The core :redis Is to put all the data in memory , Using a single thread to operate the seat is the most efficient , Because multithreading CPU Will be carried out in Context switch , Time consuming operations !!! For memory systems , If there is no context switching, the efficiency is the highest , Because many times I read and write in a CPU On , Less time-consuming .
Multiplexing : It refers to using one thread to check multiple file descriptors (Socket) The ready state of , For example, call select and poll function , Pass in multiple file descriptors , If there is a file descriptor ready , Then return to , Otherwise it blocks until it times out . After getting the ready state, the real operation can be executed in the same thread , You can also start thread execution ( Like using thread pools )
Serial vs Multithreading + lock (memcached) vs Single thread + multiple IO Reuse (Redis)
边栏推荐
- Sending cluster meet messages to join the cluster waiting for the cluster to join
- Uni app form data does not reappear
- 动态规划 | 0-1背包问题
- In the fiery VR market of yuancosmos, bytes have just touched a little bit
- Dream CMS foreground SQL injection
- uni-app 标签跳转
- An example of how to render objects and arrays on the page by rendering the data obtained in the background
- 红外超分调研
- Realize the side-by-side display of two elements (including the explanation of some flex attributes)
- graphsage模型使用photo数据集loss计算为nan
猜你喜欢

40+倍提升,详解 JuiceFS 元数据备份恢复性能优化之路

一图看懂:国企数字化转型4个方向3个战略

Experience first! What kind of experience is it to write fluent in the browser?

(PC+WAP)织梦模板防水建材类网站

A 59 year old doctor studying in the United States, today received his fifth listed company

创建线程的方式

聊一聊Spark实现TopN的几种方式

信息系统项目管理师必背核心考点(四)UML类与类之间的关系

Dynamic memory functions and common dynamic memory errors

Matlab first learning
随机推荐
三、索引优化
MATLAB初次学习
Dynamic memory functions and common dynamic memory errors
Docker---Docker安装,Docker上MySQl安装,并将项目部署在Docker上
SN6 multispectral and SAR data fusion
动态规划 | 最长公共子序列
LeetCode_滑动窗口_简单_643.子数组最大平均数 I
争议中的换电:头部玩家的有限游戏
EN 1158 building hardware door coordination device - CE certification
Niuke 2021 summer training 4-e-tree XOR
hbuilder提交代码
信息系统项目管理师必背核心考点(十)信息系统规划
Huawei cloud stack opens its framework to the south to help ecological partners enter the cloud efficiently
40 + times improvement, explain in detail how to optimize the performance of juicefs metadata backup and recovery
Generate XML file of VOC dataset
Sqli labs less-1 (updatexml of error injection)
uni-app 标签跳转
电商平台后台管理系统--->项目前期准备(需求分析、系统设计、环境搭建与配置文件)
Niuke 2021 summer training 8-f-robots
Experience first! What kind of experience is it to write fluent in the browser?