Article directory
1 Official website address
Download address: https://redis.io/download/
2 Check if the gcc compiler is installed
redis
is C++
written, therefore, requiresgcc
gcc --version
Install the gcc compiler if not
yum install -y gcc
3 install redis
3.1 Unzip the uploaded Redis installation package
tar -zvxf redis-7.0.4.tar.gz
3.2 Enter the decompression directory and compile
cd redis-7.0.8/
make
- Wait for a while, the compilation is complete! ! !
3.3 Installation command
- default installation
make install
Default installation directory The contents of /usr/local/bin
the installation are
redis-benchmark
: performance testing tools, which can be run on your own computer, to see how your book performs
redis-check-rdb
: repairing problematic dump.rdb
files
redis-sentinel
: Redis
cluster use
redis-check-aof
: repairing problematic AOF
files
redis-cli
: client, operation entry
redis-server
: Redis
server startup command
auto Define the installation directory
make install PREFIX=[安装位置目录]
bin
The production directory will be created under the custom installation directory
- Here is a custom installation
make install PREFIX=/opt/redis/redis-7.0.8
4 modify the configuration
4.1 Configure environment variables
- Open
/etc/profile
vim /etc/profile
- Add at the end:
export REDIS_HOME=/opt/redis/redis-7.0.8
export PATH=$PATH:$REDIS_HOME/bin
- Refresh the configuration file to make the configuration take effect
source /etc/profile
4.2 Modify the redis configuration file
4.2.1 Setting background startup
- Modify the file redis.conf,
daemonize no
change the setting toyes
vim redis.conf
Due to the large content of the file, you can enter it through a quick search: /daem
+ 回车
Quickly locate the content that needs to be modified, and press n
Find Next.
4.2.2 Set to allow external access
Modify redis.conf
the file, commenting out bind 127.0.0.1 -::1
orbind 0.0.0.0
4.2.3 Set redis password
Modify redis.conf
the file and find requirepass
the setting password
5 start
Switch to the bin directory and use the modified configuration file
redis-server ../redis.conf
6 Whether the test was successful
6.1 Use redis-cli link
redis-cli -p 6379
flushall //清空数据库
- display
OK
, then success!
6.2 Check whether the redis process is enabled
ps -ef|grep redis
- The port number of the process is
6379
7 Close the redis service
shutdown
exit //退出redis服务