In configuration file redis.conf, the default bind interface is 127.0.0.1, which is the local loopback address. In this case, access to the Redis service can only be connected through a native client, not through a remote connection,
This avoids exposing the Redis service to a dangerous network environment, preventing some unsafe people from casually passing remote
Connect to the Redis service.
If the BIND option is empty, it will accept all connections from the available network interfaces.
The connection is unsuccessful when using Redis;
Import the jar package Jedis-2.7.2.jar in the project, write the test class
@Test public
void Testjedissingle () throws Exception {
//Create a Jedis object
Jedis Jedis = new Jedis (" 192.168.64.129 ", 6379);
Jedis.set ("Test", "Hello Jedis");
String string = Jedis.get ("test");
System.out.println (string);
Jedis.close ();
}
Depending on the value of bind in the redis.conf configuration file, different prompt information is present, but the normal use of Redis in Linux system is not affected;
When bind is not present
Redis.clients.jedis.exceptions.JedisDataException:DENIED Redis is running in protected mode because protected mod E is enabled, no bind address was specified, no authentication password are requested to clients. The This mode connections is only accepted from the loopback interface. If you want-to-connect from external computers to Redis-adopt one of the following solutions:1) Just disable prot ected mode sending the command ' CONFIG SET protected-mode No ' from the loopback interface by connecting to Redis from the Same host the server is running, however make sure Redis are not publicly accessible from Internet if your do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the PROTECTE d mode option to ' No ', and then restarting the server. 3) If You started the server manually just for testing, restart it with the '--protected-mode no ' option. 4) Setup a bind AddreSS or an authentication password. Note:you only need to does one of the above things in order for the server to start accepting connections from the outside.
When bind the native IP address
The code can be tested, but there are problems with the Linux system
[Root@root redis]#./bin/redis-cli-c
Could not connect to Redis at 127.0.0.1:6379:connection refused
Could not connect to Redis at 127.0.0.1:6379:connection refused
When BIND is the default 127.0.0.1
Code test does not pass
Redis.clients.jedis.exceptions.JedisConnectionException:java.net.ConnectException:Connection Refused:connect
Normal operation in Linux
the current approach, code, and Redis clients in Linux can be used
1. Configure multiple IP addresses in bind, bind 192.168.64.129 127.0.0.1
2. Configure the value of bind to bind 0.0.0.0