Article Directory
1. Overview of redis
redis: It is a remote dictionary server and a memory-based key-value Nosql database.
Official explanation: Remote Dictionary Server (remote dictionary service) is completely open source, written in ANSIC language and complies with the BSD protocol. It is a high-performance Key-Value database that provides rich data structures, such as String, Hash, List, Set, SortedSet etc. Data exists in memory, and Redis supports transactions, persistence, LUA scripts, publish/subscribe, cache elimination, streaming technology and other functional features Provides master-slave mode, Redis Sentinel and Redis Cluster cluster architecture solutions
Features :
- Supports multiple data structures (lists, maps, sets and sorted sets, etc.)
- single thread single process
- The data is stored in memory, and the reading and writing speed is fast
- Support data persistence
2. Redis installation
1. Go to the official website to download the zip archive
Redis official website: Redis
Redis Chinese address: CRUG website (redis.cn) , this Chinese, the disadvantage is that the version of Redis may not be the latest.
2. Download gcc
gcc is a programming program under Linux and a compiling tool for C programs. I need to install gcc if I want to compile redis.
yum -y install gcc c++
Figure 1:
Figure II :
Redis has been installed, let's start Redis
3. Start redis
Figure 1: Modify the configuration file before starting
Figure II :
Figure 3:
Let's complete the writing of a hello world
quit just exits the redis client, but does not close the redis server, so let's close it
- Single instance shutdown:
redis-cli -a 1234 shutdown
- Multiple instances are closed, and the specified port is closed:
redis-cli -p 6379 shutdown
ps and grep combined command use _ps |grep_She_lock
Summarize :
启动 redis 服务器
redis-server + 配置文件所在的地方
例如 : redis-server /myredis/redis7.conf
连接服务器 :
redis-cli + -a + 密码 + -p + 端口号
例如 : redis-cli -a 1234 -p 6379
退出客户端 :
quit
关闭服务器 :
处于连接状态 : 直接输入 shutdown , 然后输入 quit 退出客户端.
在任何地方关闭服务器 : redis-cli -a 1234 (这里可以指定 需要关闭 redis 的端口号) shutdown
例如 : redis-cli -a 1234 -p 6379 shutdown
4. Redis uninstall
The deletion here is very simple. Didn’t we use the default installation to install redis before? The installation location is in the /usr/local/bin directory. To delete here, just delete the relevant redis in the bin directory.
1. 查找 /usr/local/bin 目录下所有与 redis 有关的文件
ls -l /usr/local/bin/redis- *
2. 执行删除操作 : rm rf /usr/local/bin/redis- *
3. 最后可以在执行 : ls -l /usr/local/bin/ redis- * 查看一下是否删除干净了.