You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[root@localhost ~]# redis-server
12408:C 16 Jul 21:30:29.657 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12408:C 16 Jul 21:30:29.657 # Redis version=4.0.0, bits=64, commit=00000000, mod ified=0, pid=12408, just started
12408:C 16 Jul 21:30:29.657 # Warning: no config file specified, using the defau lt config. In order to specify a config file use redis-server /path/to/redis.con f
12408:M 16 Jul 21:30:29.658 * Increased maximum number of open files to 10032 (i t was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.0 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 12408
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
12408:M 16 Jul 21:30:29.663 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
12408:M 16 Jul 21:30:29.663 # Server initialized
12408:M 16 Jul 21:30:29.663 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_m emory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.ove rcommit_memory=1' for this to take effect.
12408:M 16 Jul 21:30:29.664 # WARNING you have Transparent Huge Pages (THP) supp ort enabled in your kernel. This will create latency and memory usage issues wit h Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transpar ent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to reta in the setting after a reboot. Redis must be restarted after THP is disabled.
12408:M 16 Jul 21:30:29.664 * Ready to accept connections
$ redis-cli
redis 127.0.0.1:6379> ping
PONG
redis 127.0.0.1:6379> set mykey somevalue
OK
redis 127.0.0.1:6379> get mykey
"somevalue"
Uh oh!
There was an error while loading. Please reload this page.
本文中的两个配置文件可在这里找到
操作系统:Linux
Linux发行版:Centos7
安装
下载地址,点这里Redis4.0.0.tar.gz
或者使用命令:
wget http://download.redis.io/releases/redis-4.0.0.tar.gz
然后执行make编译源码:
编译完成后启动
$ src/redis-server
测试效果:
make命令执行完成后,会在src目录下生成6个可执行文件,分别是redis-server、redis-cli、redis-benchmark、redis-check-aof、redis-check-dump、redis-sentinel
可以使用如下命令,把redis-server和redis-cli拷贝到合适的位置(/usr/local/bin/):
或者,使用 sudo make install可以把6个文件都拷贝过去;
这样的话,只要/usr/local/bin/在PATH环境变量里,

我们就可以直接使用redis-server和redis-cli而不需要指定全路径了。比如:
关闭redis服务
使用如下命令可以关闭redis服务
$ redis-cli shutdown
配置初始化脚本,以服务方式启动redis
拷贝redis-4.0.0下的utils目录下的初始化脚本到/etc/init.d目录,并重命名文件为:redis_+端口号
sudo cp utils/redis_init_script /etc/init.d/redis_6379
确保redis_6379文件内的REDISPORT变量是你使用的端口号
新建文件夹/etc/redis/ ,并拷贝redis-4.0.0下的 redis.conf 文件到到改目录下,使用端口号作为文件名
创建用来存储redis持久化文件的目录(6379为端口号)
sudo mkdir -p /var/redis/6379
编辑6379.conf文件,修改如下几个参数:
设置开机自动启动
将redis_6379放入linux启动管理体系中

chkconfig --add redis_6379
查看redis_6379服务在各运行级状态
chkconfig --list redis_6379
重启服务器测试效果:
reboot
重启完成后,直接使用redis-cli连接redis,效果如下:
配置成功,完!
参考:
Redis入门指南(第2版)(顺便推荐下这本书,作为redis入门书籍非常不错)
Redis Quick Start
The text was updated successfully, but these errors were encountered: