下载文件名为:redis-4.0.9.tar.gz scp -i /Users/lby/key.pem -r /Users/lby/Desktop/AWS文件/redis-4.0.9.tar.gz ec2-user@123.123.123.1523:/data
以上命令表示:将redis-4.0.9.tar.gz文件上传至服务器/data文件夹下.
- 注意:
scp的具体用法可以参考
解压文件命令如下: tar -zxvf redis-4.0.9.tar.gz
此时当前路径下的文件名为redis-4.0.9.如果需修改文件名,使用以下命令: mv redis-4.0.9 redis
命令含义为:mv 原文件名 修改后文件名 cd /data/redis make
如果出现以下错误: make[3]: Entering directory `/data/installfiles/redis-4.0.9/deps/hiredis' gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c make[3]: gcc: Command not found make[3]: *** [net.o] Error 127 make[3]: Leaving directory `/data/installfiles/redis-4.0.9/deps/hiredis' make[2]: *** [hiredis] Error 2 make[2]: Leaving directory `/data/installfiles/redis-4.0.9/deps' make[1]: [persist-settings] Error 2 (ignored) CC adlist.o /bin/sh: cc: command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory `/data/installfiles/redis-4.0.9/src' make: *** [test] Error 2
根据gcc: Command not found提示可知,缺少gcc,那就安装gcc.
通过yum安装gcc的命令: sudo yum install gcc
执行成功后显示: Installed: gcc.noarch 0:4.8.5-1.22.amzn1 Dependency Installed: cpp48.x86_64 0:4.8.5-28.142.amzn1 gcc48.x86_64 0:4.8.5-28.142.amzn1 glibc-devel.x86_64 0:2.17-222.173.amzn1 glibc-headers.x86_64 0:2.17-222.173.amzn1 kernel-headers.x86_64 0:4.14.33-51.37.amzn1 libgcc48.x86_64 0:4.8.5-28.142.amzn1 libgomp.x86_64 0:6.4.1-1.45.amzn1 libmpc.x86_64 0:1.0.1-3.3.amzn1 mpfr.x86_64 0:3.1.1-4.14.amzn1 Complete! make test
如果出现以下错误: make[1]: Entering directory `/data/installfiles/redis-4.0.9/src' CC Makefile.dep make[1]: Leaving directory `/data/installfiles/redis-4.0.9/src' make[1]: Entering directory `/data/installfiles/redis-4.0.9/src' CC adlist.o In file included from adlist.c:34:0: zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory #include ^ compilation terminated. make[1]: *** [adlist.o] Error 1 make[1]: Leaving directory `/data/installfiles/redis-4.0.9/src’
根据zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory提示可使用以下命令解决: make MALLOC=libc
显示 Hint: It's a good idea to run 'make test' ;) make test make install cd src ./redis-server
如果以下信息表示redis服务开启成功. _._ _.-``__ ''-._ _.-`` `.`_. ''-._ Redis 4.0.8 (00000000/0) 64 bit .-`` .-```.```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'`_.-'| Port: 6379 |`-._ `._ / _.-' | PID: 39798`-._ `-._`-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| |`-._`-._ _.-'_.-' | [http://redis.io](http://redis.io)`-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._`-._`-.__.-'_.-' _.-'`-._ `-.__.-' _.-'`-._ _.-' `-.__.-' 39798:M 10 Apr 17:21:48.446 # Server initialized 39798:M 10 Apr 17:21:48.447 * Ready to accept connections ./redis-cli
显示: 127.0.0.1:6379>
输入 ping
显示:pong,表示,redis服务可以使用.
也可以输入keys *查看redis缓存中的所有key. keys * cd /data/redis cp redis.conf /etc cd /etc
此时,etc文件下已经有redis.conf文件. vim redis.conf
输入i进入编辑状态. i
找到daemonize no参数,改为daemonize yes.
强制写入保存并退出 :wq! redis-server /etc/redis.conf
最终显示: 6691:C 23 May 06:59:02.250 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 6691:C 23 May 06:59:02.250 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=6691, just started 6691:C 23 May 06:59:02.250 # Configuration loaded