centos7安装redis
程序员文章站
2022-05-31 11:14:56
...
安装gcc wget
yum install gcc
yum -y install wget
下载安装redis
wget http://download.redis.io/releases/redis-3.0.0.tar.gz
tar zxvf redis-3.0.0.tar.gz
cd redis-3.0.0
make
启动
cd src
./redis-server
本机测试
cd /home/udbwcso/redis-3.0.0/src
./redis-cli
127.0.0.1:6379> set test 1
OK
127.0.0.1:6379> get test
"1"
此时只能在本机访问,局域网内不可访问
开放端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
重启防火墙
firewall-cmd --reload
测试
局域网内访问
import redis.clients.jedis.Jedis;
public class JedisExample {
public static void main(String[] args) throws Exception {
Jedis jedis = new Jedis("172.18.100.133", 6379);
System.out.println(jedis.get("test"));
System.out.println("Connected to Redis");
}
}
转载于:https://my.oschina.net/u/657390/blog/635587