当前位置:网站首页>NoSQL database redis installation
NoSQL database redis installation
2022-06-27 08:35:00 【Students Mr sun】
Installed version
- 6.2.1 for Linux(redis-6.2.1.tar.gz)
- Don't think about it windows Environment Redis Support for
Installation steps
preparation : Download and install the latest version of gcc compiler
install C The compiling environment of language
yum install centos-release-scl scl-utils-build
yum install -y devtoolset-8-toolchain
scl enable devtoolset-8 bash
test gcc edition
gcc --version

download redis-6.2.1.tar.gz discharge /opt Catalog
Unpack the command :tar -zxvf redis-6.2.1.tar.gz
After decompression, enter the directory :cd redis-6.2.1
stay redis-6.2.1 Execute... Again in the directory make command ( Just compile )
If not ready C Language compiling environment ,make Meeting Report errors —Jemalloc/jemalloc.h: There is no such document
Solution : function make distclean
stay redis-6.2.1 Execute... Again in the directory make command ( Just compile )
skip make test Carry on : make install
The installation directory :/usr/local/bin
View the default installation directory :
redis-benchmark: Performance testing tools , You can run it in your own book , Look at the performance of your book
redis-check-aof: Fix the problem AOF file ,rdb and aof Later on
redis-check-dump: Fix the problem dump.rdb file
redis-sentinel:Redis Cluster use
redis-server:Redis Server start command
redis-cli: client , Operation entrance
The front desk starts ( Not recommended )
The front desk starts , The command line window cannot be closed , Otherwise, the server stops

Background start ( recommend )
Backup redis.conf
Copy a redis.conf Go to other directories
cp /opt/redis-3.2.5/redis.conf /etc
Background startup settings daemonize no Change to yes
modify redis.conf(282 That's ok ) The document will contain daemonize no Change to yes, Let the service start in the background
Redis start-up
redis-server /etc/redis.conf
Use the client to access :redis-cli
Multiple ports can :redis-cli -p6379
Test verification : ping

Redis close
Single instance close :redis-cli shutdown

You can also enter the terminal and then close it
Multi instance shutdown , The specified port is closed :redis-cli -p 6379 shutdown
Redis key (key)
Add data
set k1 "123"
keys * View all of the current library key ( matching :keys *1)
exists key Judge a certain key Whether there is
type key View your key What type is it
del key Delete specified key data
unlink key according to value Select non blocking delete
Only will keys from keyspace Delete from metadata , The real deletion will be done asynchronously later .
expire key 10 10 Second : For a given key Set expiration time
ttl key See how many seconds are left to expire ,-1 Never expire ,-2 Indicates that it has expired
select Command switch database
dbsize Check the... Of the current database key The number of
flushdb Empty the current library
flushall Kill all the warehouses
Common commands
set <key><value> Add key value pair
*NX: When the database key When there is no , Can be key-value Add database
*XX: When the database key In existence , Can be key-value Add database , And NX Parameters are mutually exclusive
*EX:key Time out seconds for
*PX:key Timeout milliseconds for , And EX Mutually exclusive
get <key> Query the corresponding key value
append <key><value> Will be given <value> Append to the end of the original value
strlen <key> Get the length of the value
setnx <key><value> Only in key When there is no Set up key Value
incr <key>
take key Increase the value of the number stored in 1
Can only operate on numeric values , If it is empty , The new value added is 1
decr <key>
take key The number stored in minus 1
Can only operate on numeric values , If it is empty , The new value added is -1
incrby / decrby <key>< step > take key Increase or decrease the number value stored in . Custom step size .
Atomicity So-called atom Operation means Operations that are not interrupted by thread scheduling ; Once this operation begins , It runs until the end , There won't be any context switch ( Switch to another thread ). (1) In a single thread , Operations that can be performed in a single instruction can be considered as " Atomic manipulation ", Because interrupts can only occur between instructions . (2) In multithreading , Can't be used by other processes ( Threads ) The interrupted operation is called atomic operation . Redis The atomicity of a single command is mainly due to Redis The single thread . Case study : java Medium i++ Is it atomic operation ? No i=0; Two threads are connected to i Conduct ++100 Time , What is the value ? 2~200
|
mset <key1><value1><key2><value2> .....
Set one or more... At the same time key-value Yes
mget <key1><key2><key3> .....
Get one or more at the same time value
msetnx <key1><value1><key2><value2> .....
Set one or more... At the same time key-value Yes , If and only if all given key It doesn't exist .
Atomicity , If one fails, all fail
getrange <key>< The starting position >< End position >
Get the range of values , similar java Medium substring, Front bag , Back bag
setrange <key>< The starting position ><value>
use <value> overwrite <key> String value stored , from < The starting position > Start ( Index from 0 Start ).
setex <key>< Expiration time ><value>
While setting the key value , Set expiration time , Unit second .
getset <key><value>
Trade in new for old , Set the new value and get the old value .
边栏推荐
- [batch dos-cmd command - summary and summary] - environment variables, path variables, search file location related instructions - set, path, where, what if there are spaces in the path parameters of
- 一种太阳能电荷泵供电电路的方案设计
- Game asset reuse: a new way to find required game assets faster
- 2022.06.26 (LC Luo 6101 Luo determines whether the matrix is an X matrix)
- MySQL environment variable configuration tutorial
- sql注入之order by注入
- DV scroll board width of datav rotation table component
- RockerMQ消息发送模式
- 数据类型占内存大小?LongVsObject
- MySQL索引详解
猜你喜欢

100%弄明白5种IO模型

我大抵是卷上瘾了,横竖睡不着!竟让一个Bug,搞我两次!

SPARQL basic introductory exercise

DV scroll board width of datav rotation table component

Ready to migrate to the cloud? Please accept this list of migration steps

JVM层次上的对象的创建过程和内存布局

LVGL GUI GUIDER移植代码到STM32
![[batch dos-cmd command - summary and summary] - output / display command - echo](/img/44/cddad70eeb756db15c19100c25c61a.png)
[batch dos-cmd command - summary and summary] - output / display command - echo

DataV轮播表组件dv-scroll-board宽度问题

(原创)自定义Drawable
随机推荐
DataV轮播表组件dv-scroll-board宽度问题
MySQL environment variable configuration tutorial
[13. number and bit operation of 1 in binary]
[11. two dimensional difference]
I'm almost addicted to it. I can't sleep! Let a bug fuck me twice!
今日3大面试Demo[Integer ASCII 类关系]
[12. maximum continuous non repeating subsequence]
vim 从嫌弃到依赖(20)——global 命令
枚举?构造器?面试Demo
支付宝微信支付业务流程图
[batch dos-cmd command - summary and summary] - environment variables, path variables, search file location related instructions - set, path, where, what if there are spaces in the path parameters of
Obsidian 一周使用心得(配置、主题和插件)
100% understanding of 5 IO models
Redis主从复制以及哨兵模式
直接修改/etc/crontab 文件内容,定时任务不生效
Ue5 magic power - POI solution
UE5神通--POI解决方案
March into machine learning -- Preface
Eight misunderstandings, broken one by one (final): the cloud is difficult to expand, the customization is poor, and the administrator will lose control?
2022.06.26(LC_6100_统计放置房子的方式数)