解压:tar -vxf redis-5.0.14.tar.gz
进入解压目录编译安装包: make MALLOC=libc
gcc -v
"make test"
可能报错:(具体报错具体百度哦)
You need tcl 8.5 or newer in order to run the Redis test
Makefile:271: recipe for target 'test' failed
make[1]: *** [test] Error 1
make[1]: Leaving directory '/usr/local/redis-5.0.14/src'
Makefile:6: recipe for target 'test' failed
make: *** [test] Error 2
原因是缺少"tcl"资源
解决:
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
./configure
make
make install
再次"make test"成功
......
[ok]: PSYNC2: cluster is consistent after failover
[ok]: MIGRATE with multiple keys migrate just existing ones
[ok]: MIGRATE with multiple keys: stress command rewriting
[ok]: Test replication with blocking lists and sorted sets operations
[ok]: Memory efficiency with values in range 16384
[ok]: MIGRATE with multiple keys: delete just ack keys
[34/50 done]: integration/block-repl (27 seconds)
Testing unit/pendingquerybuf
[ok]: WAIT should not acknowledge 2 additional copies of the data
[ok]: PSYNC2 #3899 regression: kill chained replica
[ok]: Slave should be able to synchronize with the master
[ok]: Detect write load to master
[ok]: MIGRATE AUTH: correct and wrong password cases
[ok]: PSYNC2 #3899 regression: kill first replica
[ok]: HyperLogLog sparse encoding stress test
[ok]: Corrupted sparse HyperLogLogs are detected: Additionl at tail
[ok]: Corrupted sparse HyperLogLogs are detected: Broken magic
[ok]: Corrupted sparse HyperLogLogs are detected: Invalid encoding
[ok]: Corrupted dense HyperLogLogs are detected: Wrong length
[35/50 done]: unit/dump (29 seconds)
......
\o/ All tests passed without errors!
Cleanup: may take some time... OK
进入redis解压目录
root@VM-16-167-debian:/usr/local/redis-5.0.14# cd src && make install
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
启动redis服务
root@VM-16-167-debian:/usr/local/redis-5.0.14/src# ./redis-server
2475:C 25 Aug 2023 14:45:28.691 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2475:C 25 Aug 2023 14:45:28.691 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=2475, just started
2475:C 25 Aug 2023 14:45:28.691 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
2475:M 25 Aug 2023 14:45:28.691 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.14 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 2475
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
补充:
配置后台服务,修改redis.conf文件:将daemonize no 改 yes
################################# GENERAL #####################################
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
将redis.conf复制到/etc/redis 目录下,并改名为 6379.conf
cd /etc
mkdir redis
cd redis
cp /usr/local/redis-5.0.14/redis.conf 6379.conf# 该文件为稍后安装的后台服务使用的配置文件
创建服务脚本(工具自己的情况)
cp /usr/local/redis-5.0.14/utils/redis_init_script /etc/init.d/redis
REDISPORT=6379
#修改为自己的安装目录
EXEC=/usr/local/redis-5.0.14/src/redis-server
CLIEXEC=/usr/local/redis-5.0.14/src/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
# 添加一个&
$EXEC $CONF &
fi
;;
stop)
直接启动服务报错
root@VM-16-167-debian:/etc/init.d# service redis start
Failed to start redis_6379.service: Unit redis.service not found.
刷新一下
root@VM-16-167-debian:/etc/init.d# systemctl daemon-reload
重新启动
root@VM-16-167-debian:/etc/init.d# service redis start
启动成功
root@VM-16-167-debian:/etc/init.d# ps -ef | grep redis
root 10902 1 0 15:16 ? 00:00:00 /usr/local/redis-5.0.14/src/redis-server 127.0.0.1:6379
root 11538 8035 0 15:18 pts/3 00:00:00 grep redis