(二)安装redies,配置,启动

一,redies安装

1.首先下载redies包:

wget http://download.redis.io/releases/redis-4.0.6.tar.gz
100%

[==========================================================================================================>] 1,723,533   13.6KB/s   in 3m 40s2020-04-16 16:41:12 7.65 KB/s) - ‘redis-4.0.6.tar.gz’ saved [1723533/1723533]

2.解压包

anaconda-ks.cfg  clear.sh  json  raisecom.r3.tar  redis-4.0.6.tar.gz  start.sh
[root@performancevm-8 ~]# tar -zxvf redis-4.0.6.tar.gz
redis-4.0.6/

3.安装依赖包:gcc

yum install gcc

4.进入到redis解压目录下

cd redis-4.0.6

5.安装编译redies

make MALLOC=libc 
[root@performancevm-8 redis-4.0.6]# cd src && make installCC Makefile.depHint: It's a good idea to run 'make test' ;)INSTALL installINSTALL installINSTALL installINSTALL installINSTALL install
[root@performancevm-8 src]#

二,启动redies
在src目录下

[root@performancevm-8 src]# ./redis-server
20170:C 16 Apr 16:49:56.032 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
20170:C 16 Apr 16:49:56.032 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=20170, just started
20170:C 16 Apr 16:49:56.032 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf_.__.-``__ ''-.__.-``    `.  `_.  ''-._           Redis 4.0.6 00000000/0) 64 bit.-`` .-```.  ```\/    _.,_ ''-._    '      ,       .-`  | `,    )     Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379|    `-._   `._    /     _.-'    |     PID: 20170`-._    `-._  `-./  _.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'||    `-._`-._        _.-'_.-'    |           http://redis.io`-._    `-._`-.__.-'_.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'||    `-._`-._        _.-'_.-'    |`-._    `-._`-.__.-'_.-'    _.-'`-._    `-.__.-'    _.-'`-._        _.-'`-.__.-'20170:M 16 Apr 16:49:56.037 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
20170:M 16 Apr 16:49:56.037 # Server initialized
20170:M 16 Apr 16:49:56.039 # 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.
20170:M 16 Apr 16:49:56.039 # 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.
20170:M 16 Apr 16:49:56.039 * Ready to accept connections

如上图:redis启动成功,但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。按 ctrl + c可以关闭窗口。

第一步:修改redis.conf文件

daemonize no

修改为

daemonize yes#:以守护进程运行

bind 170.0.0.1改为本地IP
databases后面添加创建数据库的个数,默认16个
dump.rbd#存储数据文件
slaverof主从复制
第二步:指定redis.conf文件启动

1

./redis-server /usr/local/redis-4.0.6/redis.conf
[root@iZwz991stxdwj560bfmadtZ src]# ./redis-server /usr/local/redis-4.0.6/redis.conf 
18713:C 13 Dec 13:07:41.109 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18713:C 13 Dec 13:07:41.109 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18713, just started
18713:C 13 Dec 13:07:41.109 # Configuration loaded

第三步:关闭redis进程

首先使用ps -aux | grep redis查看redis进程

[root@iZwz991stxdwj560bfmadtZ src]# ps -aux | grep redis
root     18714  0.0  0.1 141752  2008 ?        Ssl  13:07   0:00 ./redis-server 127.0.0.1:6379
root     18719  0.0  0.0 112644   968 pts/0    R+   13:09   0:00 grep --color=auto redis

使用kill命令杀死进程

[root@iZwz991stxdwj560bfmadtZ src]# kill 18714

Could not connect to Redis at 172.16.110.128:6379: Connection refused
解决办法:

 redis-server  /root/redis-4.0.6/redis.conf

3、启动redis
首先启动:redis server

[root@performancevm-8 redis-4.0.6]# redis-cli -h 172.16.110.128
172.16.110.128:6379>

启动验证:

[root@performancevm-8 redis-4.0.6]# redis-cli -h 172.16.110.128
172.16.110.128:6379> ping
PONG

参考文献:https://www.cnblogs.com/zuidongfeng/p/8032505.html

Published by

风君子

独自遨游何稽首 揭天掀地慰生平