Redis安装测试(待完善)

时间:2021-06-06 13:53:55

1 Redis安装

在网址http://redis.io/下载redis-3.2.3.tar.gz,解压。

进入解压目录 编译和安装,具体配置项可参考自带的README.md文件

make test
make 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.3
4418: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"));
} }

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUQAAACaCAIAAABey6Z6AAALlUlEQVR4nO2dzcGrNhBF086DNkIbHx1kGXWhCpJV3MTDzWUBCCGkQRIYm/E5i+QzAWn0c9EIm5s/WgBQwR/vDgAAzgExAygBMQMoATEDKAExAygBMQMoYRFz0/R2GJ7P5/P5HAbbN82r676+RgDFBGJ+j6LeWPV7afped6s7Y3Q3UObi8T1ZzE3TmccwPExXUk5m1f5K7hZzd/BhOv+c37//+dc7eWQ8p23bMczxoO1rmhwEU5pcjJe7S4r6rTOPoF2D7Sua8FKCBuZfsu3J1PF3kRNPRfOPcycxp06eOm6u1J0QnNk0nbGmm44/TNe0k6qnv0sJyp9LKpq7xWJet2K6vDdlHX4NdTMqddWnpW+78Vwf8P3S7ISYrbXDuMZuxbxVnVuitx+rwy7twIMdftZ4vW7cETNiLj55OtKZh+3bqJg781itgauleD5Q3PDIylyS7n6ImDvzeFE2iJg/Rcwu6bd2eD6fw8MYO7gdpr/nXA7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sT/PFjjwl+kjwxd8a4fe8UpVzsSrRBP6+SNe9GX5sVHxFzNM5VwJv2nilm97QDE3w5GEzw87rLJQTSfHCdM2R8KxPMh6AJrh+CLCz3id3evA16VbjvCHG6bxm27S3ajY/wogVcxHSve+tA+98sfCzzVrH4q3JegYSvoO6HxvcCMQMoATEDKAExAygBMQMoATEDKAExAygBMQMo4X8hutePEQEmxQAAAABJRU5ErkJggg==" alt="" />

可视化查看下载 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