首页 > 代码库 > Redis安装测试(待完善)
Redis安装测试(待完善)
1 Redis安装
在网址http://redis.io/下载redis-3.2.3.tar.gz,解压。
进入解压目录 编译和安装,具体配置项可参考自带的README.md文件
make testmake install
2 启动
开启服务: redis-server --protected-mode no &
客户端连接: redis-cli
停止redis服务: redis-cli shutdow
[2] 4418[sms@gc64 redis]$ 4418:M 30 Aug 16:58:12.425 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.4418:M 30 Aug 16:58:12.425 # Server can‘t set maximum open files to 10032 because of OS error: Operation not permitted.4418:M 30 Aug 16:58:12.425 # Current maximum open files is 1024. maxclients has been reduced to 992 to compensate for low ulimit. If you need higher maxclients increase ‘ulimit -n‘. _._ _.-``__ ‘‘-._ _.-`` `. `_. ‘‘-._ Redis 3.2.3 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ‘‘-._ ( ‘ , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6379 | `-._ `._ / _.-‘ | PID: 4418 `-._ `-._ `-./ _.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | http://redis.io `-._ `-._`-.__.-‘_.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | `-._ `-._`-.__.-‘_.-‘ _.-‘ `-._ `-.__.-‘ _.-‘ `-._ _.-‘ `-.__.-‘ 4418:M 30 Aug 16:58:12.426 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.4418:M 30 Aug 16:58:12.426 # Server started, Redis version 3.2.34418:M 30 Aug 16:58:12.426 # 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.4418:M 30 Aug 16:58:12.426 * The server is now ready to accept connections on port 6379
3 JAVA测试
import axbDemo.utils.RedisUtilities;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.slf4j.MDC;import redis.clients.jedis.JedisPool;import java.util.Map;import java.util.HashMap;/** * Created by DBClient on 2016/8/16. */public class RedisTest { private final static Logger logger = LoggerFactory.getLogger("RedisTest"); public static void main(String[] args) { MDC.put("logname", "redis"); logger.info("hello world"); JedisPool jedisPool = new JedisPool("192.168.150.200", 6379); //logger.info((RedisUtilities.info(jedisPool))); RedisUtilities.set(jedisPool, "name", "lilei"); Map<String, String> red = new HashMap<String, String>(){ { put("h4", "23"); put("h5", "26"); } }; RedisUtilities.hmset(jedisPool, "redKey", red, 0); logger.info(RedisUtilities.get(jedisPool, "name")); logger.info("" + RedisUtilities.hgetall(jedisPool, "redKey")); logger.info(RedisUtilities.hget(jedisPool, "redKey", "h1")); RedisUtilities.del(jedisPool, "name"); logger.info(RedisUtilities.get(jedisPool, "name")); RedisUtilities.hdel(jedisPool, "redKey", "hl"); logger.info("" + RedisUtilities.hgetall(jedisPool, "redKey")); }}
可视化查看下载 redis-desktop-manager-0.7.6.15.exe, 安装后,配置redis服务器信息,即可参看数据库的情况
参考资料
1 Redis 命令参考 http://doc.redisfans.com/
2 Redis 官网 http://redis.io/
3 redis 配置文件信息 http://www.redis.io/topics/config
4 Redis快速入门 http://www.yiibai.com/redis/redis_quick_guide.html
Redis安装测试(待完善)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。