MacBook安装Redis
1.下载redis最新的稳定版
https://github.com/redis/redis/archive/7.2.1.tar.gz
2.解压
TIGERHUTANG-MB0:redis root# tar -zxf 7.2.1.tar.gz
TIGERHUTANG-MB0:redis root# ls -la
total 8232
drwxr-xr-x 4 root staff 128 9 7 10:42 .
drwxr-xr-x 4 tigerhutang staff 128 9 7 10:34 ..
-rw-r--r-- 1 root staff 3421236 9 7 10:42 7.2.1.tar.gz
drwxrwxr-x 27 root wheel 864 9 7 01:56 redis-7.2.1
3.编译
make编译报错:./server.h:58:10: fatal error: 'systemd/sd-daemon.h' file not found
#需要禁用systemd-daemon
make USE_SYSTEMD=no
make USE_SYSTEMD=no
编译报错:fatal error: 'openssl/ssl.h' file not found
brew install openssl
编译报错:clang: error: no such file or directory: '../deps/hiredis/libhiredis_ssl.a'
解决上述报错:
解决完上述报错后,继续编译可以成功完成编译:
make USE_SYSTEMD=no
4.编译测试
make test
5.运行redis
cd ./utils
#执行安装脚本
./install_server.sh
#启动server
cd ../src
./redis-server /etc/redis/6379.conf --loglevel debug
#客户端测试
% cd src
% ./redis-cli
redis> ping
PONG
redis> set foo bar
OK
redis> get foo
"bar"
redis> incr mycounter
(integer) 1
redis> incr mycounter
(integer) 2
redis>
> 更多命令请参考官网文档:https://redis.io/commands/