本文介绍了在AWS中redis的下载以及相关的配置
一.从官网下载redis.
下载文件名为:redis-4.0.9.tar.gz
二.将下载的redis文件上传AWS.
1.通过SCP上传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的具体用法可以参考<Java开发>之AWS jdk下载和配置标题二
中的讲解.
三.解压redis-4.0.9.tar.gz文件并修改文件名.
解压文件命令如下:
tar -zxvf redis-4.0.9.tar.gz
此时当前路径下的文件名为redis-4.0.9.如果需修改文件名,使用以下命令:
mv redis-4.0.9 redis
命令含义为:mv 原文件名 修改后文件名
四.redis配置.
1.进入redis文件中.
cd /data/redis
2.执行make命令.
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!
3.执行make test命令.
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 <jemalloc/jemalloc.h>
^
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' ;)
4.重新执行make test命令
make test
5.执行make install命令
make install
6.进入redis下的src文件.
cd src
7.开启redis服务
./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
8.查看redis是否开启
./redis-cli
显示:
127.0.0.1:6379>
输入
ping
显示:pong,表示,redis服务可以使用.
也可以输入keys *
查看redis缓存中的所有key.
keys *
五.redis自启动配置.
1.进入redis文件
cd /data/redis
2.将redis.conf文件复制到etc文件目录下
cp redis.conf /etc
3.进入etc文件
cd /etc
此时,etc文件下已经有redis.conf
文件.
4.修改redis.conf文件中的daemonize no参数为daemonize yes.
vim redis.conf
输入i
进入编辑状态.
i
找到daemonize no
参数,改为daemonize yes
.
强制写入保存并退出
:wq!
5.使配置生效.
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
网友评论