Redis don't work from inside Jail

Hi,

This is my first Ipost :) I'm running FreeBSD 10.3-RELEASE-p7 as jails host using sysutils/ezjail this week I am starting deploy database/redis 3.2.4 on dedicated jail but when I start redis-server

# redis-server /usr/local/etc/redis.conf && redis-server

Redis throw this warning:
Code:
55295:C 19 Oct 10:57:17.749 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
55295:M 19 Oct 10:57:17.755 # Creating Server TCP listening socket *:6379: bind: Address already in use

# cat /usr/local/etc/ezjail/redis
Code:
export jail_redis_hostname="redis"
export jail_redis_ip="lo4|127.0.0.4,bge0|192.168.1.226"
export jail_redis_rootdir="/usr/jails/redis"
export jail_redis_exec_start="/bin/sh /etc/rc"
export jail_redis_exec_stop=""
export jail_redis_mount_enable="YES"
export jail_redis_devfs_enable="YES"
export jail_redis_devfs_ruleset="devfsrules_jail"
export jail_redis_procfs_enable="YES"
export jail_redis_fdescfs_enable="YES"
export jail_redis_image=""
export jail_redis_imagetype="zfs"
export jail_redis_attachparams=""
export jail_redis_attachblocking=""
export jail_redis_forceblocking=""
export jail_redis_zfs_datasets=""
export jail_redis_cpuset=""
export jail_redis_fib=""
export jail_redis_parentzfs="zroot/jails"
export jail_redis_parameters=""
export jail_redis_post_start_script=""
export jail_redis_retention_policy=""

when I execute redis-cli(1) command to check the connection I found that redis use 127.0.0.1 instead of 127.0.0.4 already define in the /etc/hosts file.
# redis-cli ping
Code:
Could not connect to Redis at 127.0.0.1:6379: Connection refused


available network interfaces :
Code:
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
        ether 00:1e:c9:31:12:57
        inet 192.168.1.226 netmask 0xffffffff broadcast 192.168.1.226
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
lo4: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet 127.0.0.4 netmask 0xffffffff
run0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether e8:4e:06:1b:65:12
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
lo2: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
lo3: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>

I succeed to start redis-server on not jailed machine but I don't know how to resolve this problem from inside the jail.

I need you help, thank you.
 
Jails don't have a lo0 interface and therefor no 127.0.0.1 to bind to. You need to bind redis to the specific IP address of the jail. Previous versions would simply bind to all available addresses but apparently this behavior changed recently.
 
Thank you very much SirDice, i rebuild new jail (no lo0 interface) and define the redis jail IP as bind address and that works

# redis-cli ping
PONG


but redis-server still throw the same warning

Code:
55295:C 19 Oct 10:57:17.749 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
55295:M 19 Oct 10:57:17.755 # Creating Server TCP listening socket *:6379: bind: Address already in use

i'am take a look on redis log file

# cat /var/log/redis/redis.log

Code:
19859:C 19 Oct 14:38:05.670 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
19859:M 19 Oct 14:38:05.671 # Creating Server TCP listening socket *:6379: hostname nor servname provided, or not known
redis# more /var/log/redis/redis.log
                _._                                                
           _.-``__ ''-._                                            
      _.-``    `.  `_.  ''-._           Redis 3.2.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 19774
  `-._    `-._  `-./  _.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                
 |    `-._`-._        _.-'_.-'    |           http://redis.io      
  `-._    `-._`-.__.-'_.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                
 |    `-._`-._        _.-'_.-'    |                                
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              

19774:M 19 Oct 14:32:11.828 # Server started, Redis version 3.2.4
19774:M 19 Oct 14:32:11.828 * The server is now ready to accept connections on port 6379
19779:M 19 Oct 14:32:42.330 # Creating Server TCP listening socket 192.168.100.222:6379: bind: Address already in use
 
Use the proper commands to start/stop the service: service redis start, service redis stop.

The command you used before ( redis-server /usr/local/etc/redis.conf && redis-server) is wrong, it starts redis twice.
 
Yes SirDice now i understand what's going wrong with my command i checked sockstat -l and i found that redis is already listening on port 6379 before redis-server

Thank you very much for you effort, it was very helpfull for me specially i dive into FreeBSD for 6 month it's great experience for me.
 
Back
Top