linux上安装redis数据库,并实现 java连接redis一路遇到的错误

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Moneywa/article/details/48212935
1. 问题:解压完redis后进行make时,提示错误“gcc命令未找到”。
    原因:没有安装 gcc编译器。
    解决方法: 使用命令 yum install -y gcc g++ gcc-c++ make 安装

2. 问题:make 时出错,提示 zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
    解决方法:使用命令 :make MALLOC=libc

3. 问题:ssh 连接虚拟机中的linux系统
    解决方法:使用命令 ifconfig 查看linux系统的IP地址,其中 inet addr: 后面的为IP地址

4. 问题:java连接redis出错,可能原因:Centos防火墙未关闭
    解决方法:
   1) 永久性生效,重启后不会复原 
         开启: chkconfig iptables on 
         关闭: chkconfig iptables off 
  2) 即时生效,重启后复原 
        开启: service iptables start 
        关闭: service iptables stop

5. 问题:java连接redis出错,可能原因:Redis的配置文件redis.conf里使用了 bind localhost 或者 bind 127.0.0.1 
    band localhost 只能本机访问,局域网内计算机不能访问
    bind 局域网IP 只能局域网内IP的机器访问, 本地localhost都无法访问.
    解决方法:注释掉bind 的代码  如:#bind localhost

6. 问题:java连接redis错误,可能原因:redis默认使用的 6379 端口 未开放
    解决方法:配置linux,允许访问6379端口,命令: iptables -A INPUT -p tcp –dport 6379 -j ACCEPT

7. 问题:java连接redis出错,错误信息如下:
    Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect...
   解决方法:检查以上6个地方。

猜你喜欢

转载自blog.csdn.net/Moneywa/article/details/48212935