Centos安装单机版Redis
2018-01-17 09:18
309 查看
1、安装gcc-c++(redis源码编译需要):yum install gcc-c++
2、解压缩redis目录
3、进入解压缩目录,使用make命令进行编译
4、进行安装:make install PREFIX=/usr/local/redis (PREFIX指定安装目录)
5、复制解压目录中的redis.conf到安装目录
6、修改配置文件
修改daemonize=yes,使得redis默认为后台运行
7、启动redis
8、检测redis后台:ps aux|grep redis
9、jedis连接Redis
/**
* 单机版单链接测试
* @throws Exception
*/
@Test
public void testRedis() throws Exception{
//创建jedis连接对象
Jedis jedis = new Jedis("192.168.25.139", 6379);
jedis.set("test", "HelloWorld");
String name = jedis.get("test");
System.out.println(name);
//关闭连接
jedis.close();
}
/**
* 单机版
* 测试jedis连接池
* @throws Exception
*/
@Test
public void testJedisPool() throws Exception {
//创建连接池
JedisPool pool = new JedisPool("192.168.25.139", 6379);
//获取一个连接对象
Jedis jedis = pool.getResource();
jedis.set("test", "HelloWorld");
System.out.println(jedis.get("test"));
//关闭连接,每次使用完毕后关闭连接。连接池回收资源。
jedis.close();
//关闭连接池
pool.close();
}
工具:下载
2、解压缩redis目录
3、进入解压缩目录,使用make命令进行编译
4、进行安装:make install PREFIX=/usr/local/redis (PREFIX指定安装目录)
5、复制解压目录中的redis.conf到安装目录
6、修改配置文件
修改daemonize=yes,使得redis默认为后台运行
7、启动redis
8、检测redis后台:ps aux|grep redis
9、jedis连接Redis
/**
* 单机版单链接测试
* @throws Exception
*/
@Test
public void testRedis() throws Exception{
//创建jedis连接对象
Jedis jedis = new Jedis("192.168.25.139", 6379);
jedis.set("test", "HelloWorld");
String name = jedis.get("test");
System.out.println(name);
//关闭连接
jedis.close();
}
/**
* 单机版
* 测试jedis连接池
* @throws Exception
*/
@Test
public void testJedisPool() throws Exception {
//创建连接池
JedisPool pool = new JedisPool("192.168.25.139", 6379);
//获取一个连接对象
Jedis jedis = pool.getResource();
jedis.set("test", "HelloWorld");
System.out.println(jedis.get("test"));
//关闭连接,每次使用完毕后关闭连接。连接池回收资源。
jedis.close();
//关闭连接池
pool.close();
}
工具:下载
相关文章推荐
- CentOS6.5 中安装单机版redis
- Redis安装 centOS单机版
- CentOS 安装单机版Redis3.0
- centos 安装单机版 redis 补充
- Centos7下redis-3.2.8安装(单机版)
- redis安装(centos单机版)
- CentOS6.5 中安装单机版redis
- CentOS安装Redis单机版
- 分布式--CentOS安装zookeeper(单机版)
- CentOS6.5安装Redis2.8.19
- CentOS上安装redis
- CentOS6.5下redis-3.2.6的安装与配置
- CentOS 6.9 redis安装与基本配置(下)
- centos 关于redis 集群配置安装
- CentOS 6.5 安装Redis
- 单机版 redis 安装
- Redis 3 在CentOS 6.5上安装笔记,含启动脚本
- CentOS中,安装Apache+PHP+Mongo DB+Redis DB
- CentOS中,安装Apache+PHP+Mongo DB+Redis DB
- CentOS 7 Redis 3.2.8的安装和使用