阿里云Ubuntu16.04 修改bind配置后重启动redis报错

目的:需设置运行远程连接redis

操作:修改配置文件/etc/redis/redis.conf  的bind ,值改为阿里云的公网ip
重启:修改后重启redis
报错:重启失败报错  Job for redis-server.service failed because a configured resource limit was exceeded. See "systemctl status redis-server.service" and "journalctl -xe" for details.

root@iZwz993neupeidg9ww5cnuZ:/etc/redis# vi redis.conf 
root@iZwz993neupeidg9ww5cnuZ:/etc/redis# service redis-server restart
Job for redis-server.service failed because a configured resource limit was exceeded. See "systemctl status redis-server.service" and "journalctl -xe" for details.
root@iZwz993neupeidg9ww5cnuZ:/etc/redis# systemctl status redis-server.service
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: resources) since Wed 2018-07-04 11:20:18 CST; 1min 56s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 1925 ExecStopPost=/bin/run-parts --verbose /etc/redis/redis-server.post-down.d (code=exited, status=0/SUCCESS)
  Process: 1919 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 1914 ExecStop=/bin/run-parts --verbose /etc/redis/redis-server.pre-down.d (code=exited, status=0/SUCCESS)
  Process: 1909 ExecStartPost=/bin/run-parts --verbose /etc/redis/redis-server.post-up.d (code=exited, status=0/SUCCESS)
  Process: 1905 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
  Process: 1900 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited, status=0/SUCCESS)
 Main PID: 1721 (code=exited, status=0/SUCCESS)
Jul 04 11:20:18 iZwz993neupeidg9ww5cnuZ systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Jul 04 11:20:18 iZwz993neupeidg9ww5cnuZ systemd[1]: Stopped Advanced key-value store.
Jul 04 11:20:18 iZwz993neupeidg9ww5cnuZ systemd[1]: redis-server.service: Start request repeated too quickly.
Jul 04 11:20:18 iZwz993neupeidg9ww5cnuZ systemd[1]: Failed to start Advanced key-value store.

原因:bind值配置为阿里云的外网ip地址所致,阿里云的公网地址是通过映射得到

root@iZwz993neupeidg9ww5cnuZ:/etc/redis# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3e:06:cb:c7  
          inet addr:172.18.67.XXX  Bcast:172.18.XXX.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6651 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5217 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:636033 (636.0 KB)  TX bytes:770892 (770.8 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:143 errors:0 dropped:0 overruns:0 frame:0
          TX packets:143 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:12154 (12.1 KB)  TX bytes:12154 (12.1 KB)

root@iZwz993neupeidg9ww5cnuZ:/etc/redis# 
解决:方案1 注释掉bind (存在风险,最好把)

          方案2 把bind值改为 阿里云服务器内网ip

重启:正常

root@iZwz993neupeidg9ww5cnuZ:/etc/redis# service redis-server restart
root@iZwz993neupeidg9ww5cnuZ:~# ps -ef |grep redis
redis     2153     1  0 11:56 ?        00:00:03 /usr/bin/redis-server 172.xx.xx.xx:6379
root      2193  1058  0 13:20 pts/1    00:00:00 grep --color=auto redis

redis-cli连接

root@iZwz993neupeidg9ww5cnuZ:/etc/redis# redis-cli -h 172.xx.XX.XX -a XXXredis
172.18.67.246:6379> get key1
"helloredis"

建议:任意主机都可以远程redis ,出于安全性考虑 打开requirepass
etc/redis/redis.conf 



你可能感兴趣的:(阿里云Ubuntu16.04 修改bind配置后重启动redis报错)