Compile and install Redis 7 on CentOS Stream 9

Compile and install Redis 7 on CentOS Stream 9

1. Download

1. Visit Redis official website: https://redis.io , click "Download" on the right side of the menu bar to enter the download page
insert image description here

2. On the left side of the download page, you can see Redis related information, right-click "Download 7.0.10", and then select "Copy Link" to get the download address of the Redis source code
insert image description here

3. Execute the following command in CentOS to download the Redis source code compression package

curl -OL https://github.com/redis/redis/archive/7.0.10.tar.gz
  • -O download file
  • -L supports redirection

2. Installation

1. You need to use make and gcc when compiling Redis, execute the following command to install

yum install make gcc

2. After the installation is complete, execute the following command to decompress the Redis source code

tar -xvf 7.0.10.tar.gz
  • -x decompress
  • -v show process
  • -f target is a file

3. After the decompression is complete, execute the following command to switch to the Redis source code directory

cd redis-7.0.10

4. After the directory is switched, execute the following command to compile Redis

make

You can use the -j parameter for multi-threaded compilation to improve compilation speed

5. After the compilation is complete, execute the following command to install Redis

make install

Redis is installed to /usr/local/bin by default

Three, run

1. Execute the following command to run the Redis server, the Redis server will block the current session by default

redis-server

insert image description here

2. After the server is running, execute the following command in another session to run the Redis client. The Redis client will connect to the local Redis server by default.

redis-cli

insert image description here

3. Enter the following command in the Redis client to close the connected Redis server

shutdown

insert image description here

4. Enter the following command in the Redis client to exit the Redis client

exit

insert image description here

attach, supplement

1. The following error occurs when compiling

zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or
directory

Reason: Execute the make command when gcc is not installed, install gcc after an error occurs, and execute the make command again to generate the error.
Solution: compile again after cleaning the source code directory

make distclean
make

2. The following warning appears when running

WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition.

Reason: The current system does not allow excessive application of memory space
Solution: Allow the current system to allow excessive application of memory space

1.打开文件:/etc/sysctl.conf
2.添加或修改配置:vm.overcommit_memory=1,然后保存文件
3.执行命令"sysctl -p" 或 重启系统,使配置生效

Guess you like

Origin blog.csdn.net/u010044182/article/details/130275695
Recommended