使用jedis连接云端远程linux服务器详细配置步骤

1、创建maven项目导包

	 <!--导入jedis的包-->
	    <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
	    <dependencies>
	        <dependency>
	            <groupId>redis.clients</groupId>
	            <artifactId>jedis</artifactId>
	            <version>3.6.0</version>
	        </dependency>
	        <dependency>
	            <groupId>com.alibaba</groupId>
	            <artifactId>fastjson</artifactId>
	            <version>1.2.75</version>
	        </dependency>
	    </dependencies>

2、远程服务器配置

1、首先修改redis.config 建议先备份

		protected-mode  no	改为no,原来为yes
		bind 127.0.0.1 	注释掉
		requirepass 123456	如果需要就设置密码  123456
							连接时需要
							auth 123456 
							jedis.auth("123456")
		然后wq保存

2、开启防火墙

			firewall-cmd --list-ports	查看所有端口
			firewall-cmd --zone=public --add-port=6379/tcp --permanent	开启端口
			systemctl restart firewalld.service	重启防火墙

3、在服务器上添加安全组

4、如果需要 停止掉之前的服务

		lsof -i:6379	查看某个端口所占进程
		kill -9 PID 	杀死进程

5、redis-server /myserver/redis.conf 开启服务

3、建立连接

		 Jedis jedis = new Jedis("123.123.123.123",6379);	连接服务器
		 jedis.auth("123456");	输入密码
		 System.out.println(jedis.ping());	测试连接
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

琰玥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值