1、官网下载
下载地址: redis 5.0.7
2、上传到centos 7
[root@hadoop03 opt]# mkdir redis
#从本机上传
bogon:Downloads fandong$ scp redis-5.0.7.tar.gz root@hadoop03.fandong.com:/opt/redis
root@hadoop03.fandong.com's password:
redis-5.0.7.tar.gz 100% 1938KB 25.5MB/s 00:00
bogon:Downloads fandong$
3、源码安装
[root@hadoop03 redis-5.0.7]# cat README.md
Building Redis
--------------
Redis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD.
We support big endian and little endian architectures, and both 32 bit
and 64 bit systems.
It may compile on Solaris derived systems (for instance SmartOS) but our
support for this platform is *best effort* and Redis is not guaranteed to
work as well as in Linux, OSX, and \*BSD there.
It is as simple as:
% make
You can run a 32 bit Redis binary using:
% make 32bit
After building Redis, it is a good idea to test it using:
% make test
使用make 进行安装,
4、使用test 命令监测,是否安装OK
[root@hadoop03 redis-5.0.7]# make test
cd src && make test
make[1]: 进入目录“/opt/redis/redis-5.0.7/src”
CC Makefile.dep
make[1]: 离开目录“/opt/redis/redis-5.0.7/src”
make[1]: 进入目录“/opt/redis/redis-5.0.7/src”
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] 错误 1
make[1]: 离开目录“/opt/redis/redis-5.0.7/src”
make: *** [test] 错误 2
发现test,运行有问题,这个不影响,可以暂时不用测试。
把命令安装到/usr/local/bin 下,使用
[root@hadoop03 redis-5.0.7]# make install
cd src && make install
make[1]: 进入目录“/opt/redis/redis-5.0.7/src”
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: 离开目录“/opt/redis/redis-5.0.7/src”
[root@hadoop03 redis-5.0.7]# ls
[root@hadoop03 bin]# ll
总用量 32772
-rwxr-xr-x. 1 root root 4366864 11月 30 09:53 redis-benchmark
-rwxr-xr-x. 1 root root 8125256 11月 30 09:53 redis-check-aof
-rwxr-xr-x. 1 root root 8125256 11月 30 09:53 redis-check-rdb
-rwxr-xr-x. 1 root root 4807944 11月 30 09:53 redis-cli
lrwxrwxrwx. 1 root root 12 11月 30 09:53 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8125256 11月 30 09:53 redis-server
5、启动redis
Running Redis
-------------
To run Redis with the default configuration just type:
% cd src
% ./redis-server
If you want to provide your redis.conf, you have to run it using an additional
parameter (the path of the configuration file):
% cd src
% ./redis-server /path/to/redis.conf
It is possible to alter the Redis configuration by passing parameters directly
as options using the command line. Examples:
% ./redis-server --port 9999 --replicaof 127.0.0.1 6379
% ./redis-server /etc/redis/6379.conf --loglevel debug
All the options in redis.conf are also supported as options using the command
line, with exactly the same name.
[root@hadoop03 src]# ./redis-server
5975:C 30 Nov 2019 09:43:58.017 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5975:C 30 Nov 2019 09:43:58.017 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=5975, just started
5975:C 30 Nov 2019 09:43:58.017 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
5975:M 30 Nov 2019 09:43:58.018 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 5975
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
5975:M 30 Nov 2019 09:43:58.035 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
5975:M 30 Nov 2019 09:43:58.035 # Server initialized
5975:M 30 Nov 2019 09:43:58.035 # 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.
5975:M 30 Nov 2019 09:43:58.036 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
5975:M 30 Nov 2019 09:43:58.037 * Ready to accept connections
可以看到,已经启动成功了。
获取的信息为启动port 6379 ,
2、 使用配置文件启动;
把我们的配置文件copy到 /etc 目录下(专门配置)。
[root@hadoop03 etc]# cp /opt/redis/redis-5.0.7/redis.conf /etc/
修改配置文件,使其能使用守护进程运行。
我们需要其他的机器访问,注释掉这个。bind 127.0.0.1
把守护进行 设置为 yes。
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1
# 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 no
daemonize yes
启动:ps -ef| grep redis 查看是否启动
[root@hadoop03 bin]# ./redis-server /etc/redis.conf
6068:C 30 Nov 2019 10:13:18.993 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6068:C 30 Nov 2019 10:13:18.993 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=6068, just started
6068:C 30 Nov 2019 10:13:18.993 # Configuration loaded
[root@hadoop03 bin]# ps -ef|grep redis
root 6069 1 0 10:13 ? 00:00:00 ./redis-server 127.0.0.1:6379
root 6075 1662 0 10:14 pts/0 00:00:00 grep --color=auto redis
登录redis-cli 进行测试.
[root@hadoop03 bin]# ./redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>