一,下載源碼
1,可以直接去官網(wǎng)(redis.io)下載源碼。
2,linux直接下載(本文使用redis-6.2.1版本為例)。
wget https://download.redis.io/releases/redis-6.2.1.tar.gz
二,解壓及編譯
tar xzf redis-6.2.1.tar.gz
cd redis-6.2.1
make
三,運行測試程序
然后在src目錄下生成redis服務(wù)端程序redis-server和redis客戶端程序redis-cli。
省去其他的多余內(nèi)容
rw-r--r-- 1 root root 12944 Mar 18 13:57 mt19937-64.o
-rwxr-xr-x 1 root root 12698168 Mar 18 13:57 redis-server*
-rwxr-xr-x 1 root root 12698168 Mar 18 13:57 redis-sentinel*
-rw-r--r-- 1 root root 363 Mar 18 13:57 redis-cli.d
-rw-r--r-- 1 root root 1386024 Mar 18 13:57 redis-cli.o
-rw-r--r-- 1 root root 191 Mar 18 13:57 cli_common.d
-rw-r--r-- 1 root root 17376 Mar 18 13:57 cli_common.o
-rwxr-xr-x 1 root root 7187040 Mar 18 13:57 redis-cli*
-rw-r--r-- 1 root root 408 Mar 18 13:57 redis-benchmark.d
-rw-r--r-- 1 root root 908016 Mar 18 13:57 redis-benchmark.o
-rwxr-xr-x 1 root root 7269584 Mar 18 13:57 redis-benchmark*
-rwxr-xr-x 1 root root 12698168 Mar 18 13:57 redis-check-rdb*
drwxrwxr-x 3 root root 12288 Mar 18 13:57 ./
-rwxr-xr-x 1 root root 12698168 Mar 18 13:57 redis-check-aof*
運行redis服務(wù)端程序:
root@iZbp19tzbfkht2jgiwxh2eZ:/home/redis/redis-6.2.1/src# ./redis-server
275187:C 18 Mar 2021 13:58:03.591 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
275187:C 18 Mar 2021 13:58:03.591 # Redis version=6.2.1, bits=64, commit=00000000, modified=0, pid=275187, just started
275187:C 18 Mar 2021 13:58:03.591 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
275187:M 18 Mar 2021 13:58:03.591 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.2.1 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 275187
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
275187:M 18 Mar 2021 13:58:03.592 # Server initialized
275187:M 18 Mar 2021 13:58:03.592 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
275187:M 18 Mar 2021 13:58:03.592 * Ready to accept connections
運行客戶端程序:
root@iZbp19tzbfkht2jgiwxh2eZ:/home/redis/redis-6.2.1/src# ./redis-cli
127.0.0.1:6379> keys *
1) "foo1"
2) "foo"
127.0.0.1:6379>