CentOS6.8中安装redis3.2.8

一.单机版安装

1.下载 http://download.redis.io/releases/redis-3.2.8.tar.gz

2.解压:

[root@localhost files]# tar -zxvf redis-3.2.8.tar.gz

3.安装:

[root@localhost files]# cd redis-3.2.8

 make编译:

[root@localhost redis-3.2.8]# make PREFIX=/usr/local/programrun/redis install

4.1.前台启动:

[root@localhost bin]# ./redis-server 

4.2.后台启动:

    1. 拷贝redis.conf到安装目录

    2.修改redis.conf 修改daemonize yes

    3.启动:[root@localhost bin]# ./redis-server redis.conf 

5.开启远程连接:

     1.设置密码 :使用命令 :/ requirepass 快速查找到 # requirepass foobared 去掉注释foobared改为自己的密码

    1.修改redis.conf 默认绑定本机bind 127.0.0.1,将其注释

    2.修改redis.conf 修改protected-mode no(redis3.2之后需修改) 

    3.开放防火墙6379端口:         

 开发6379端口
[root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
 保存
[root@localhost ~]# /etc/rc.d/init.d/iptables save
 查看端口状态
[root@localhost ~]# /etc/init.d/iptables status

安装完成

1.Redis可视化工具,RedisDesktopManager   

  下载连接:https://redisdesktop.com/download

2. Java中调用客户端:

	    JedisPool jedisPool = new JedisPool("192.168.1.105", 6379);
		
		Jedis jedis = jedisPool.getResource();
		//密码认证
		jedis.auth("123456");
		String string = jedis.get("name");
		System.out.println(string);
		
		jedisPool.close();

pom依赖

        <!-- jedis -->
		<dependency>
		    <groupId>redis.clients</groupId>
		    <artifactId>jedis</artifactId>
		    <version>2.8.0</version>
		</dependency>

 

转载于:https://my.oschina.net/ludd79806329/blog/849314

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值