redis安装与配置
2016-01-22 13:55
555 查看
redis安装
1、下载redis下载地址http://redis.io/download
2、安装redis
下载后解压 tar zxvf redis-3.0.6.tar.gz 到任意目录,例如/usr/local/redis
解压后,进入redis目录
cd /usr/local/redis make cp redis.conf /etc/ 这个文件时redis启动的配置文件 cp redis-benchmark redis-cli redis-server /usr/bin/
3、启动redis服务
[root@localhost ~]# redis-server /etc/redis.conf 6229:M 22 Jan 14:03:11.096 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.6 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 6229 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 6229:M 22 Jan 14:03:11.096 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.6229:M 22 Jan 14:03:11.097 # Server started, Redis version 3.0.6 6229:M 22 Jan 14:03:11.097 # 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.6229:M 22 Jan 14:03:11.099 * DB loaded from disk: 0.003 seconds 6229:M 22 Jan 14:03:11.099 * The server is now ready to accept connections on port 6379
查看进程,确认redis已经启动
[root@localhost ~]# ps -ef|grep redis root 6229 2270 0 14:03 pts/0 00:00:00 redis-server *:6379 root 6257 6236 0 14:04 pts/1 00:00:00 grep redis
上面的启动方法并没有在后台启动,修改redis.conf,设置redis进程为后台守护进程
# 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 yes #redis后台运行 dir /usr/local/redis #指定持久化文件保存路径
4、测试redis
[root@localhost ~]# redis-cli 127.0.0.1:6379> set name songbin OK 127.0.0.1:6379> get name "songbin"
5、关闭redis服务
[root@localhost ~]#redis-cli shutdown
6、自启动脚本
[root@localhost redis]# cp utils/redis_init_script /etc/init.d/redis [root@localhost redis]#vi /etc/init.d/redis #chkconfig: 2345 80 90 REDISPORT=6379 EXEC=/usr/bin/redis-server CLIEXEC=/usr/bin/redis-cli PIDFILE=/var/run/redis.pid CONF="/etc/redis.conf"
添加 #chkconfig: 2345 80 90
并修改配置文件路径 ,以及redis-server路径
[root@localhost redis]# chkconfig --add redis [root@localhost redis]# chkconfig redis on [root@localhost redis]# service redis start Starting Redis server...
相关文章推荐
- redis和ehcache比较
- Redis 基本操作
- python redis模块
- CentOS 下安装 Redis
- 负载均衡之Nginx+tomcat+redis实现session共享的负载均衡
- redis客户端jedis连接和spring结合
- Redis企业集群工具RLEC
- redis 安装简介
- Redis安装及简单測试
- redis(源码1):封装hiredis库,提供直观的C++函数操作
- Spring-data-redis操作redis cluster
- SpringSessionRedis配置及发现的问题
- 用redis实现支持优先级的消息队列
- redis快照文件dump.rdb解析工具--redis-rdb-tools
- Redis数据备份与恢复
- Redis 发布订阅
- Redis 横向扩展案例
- redis提示Could not get a resource from the pool(jedis连接池配置)
- Redis 缓存 + Spring 的集成示例
- Redis HyperLogLog