Under Windows remote Access redis,windows Redis bound IP is invalid, the Redis setup password is invalid, Windows Redis Configuration does not take effect, Windows Redis Requirepass does not take effect, Configuration of remote access Redis under Windows

Source: Internet
Author: User
Tags windows remote access install redis


Reprint: http://fanshuyao.iteye.com/blog/2384074


First, Redis:



Https://github.com/MicrosoftArchive/redis/releases



1, Redis-x64-3.2.100.msi for the installation version



2, Redis-x64-3.2.100.zip for compression package



Second, because I use the installation version, this issue is also the installation version of the problem



1, after the installation of the directory






2. The installation version of Redis post-installation service will start automatically.






Third, the problem lies in:



Since the installation version of the Redis service is started directly through Redis-server.exe, the Redis configuration file (redis.windows.conf) is not loaded at startup, resulting in the BIND configuration and password settings in Redis not taking effect . It took me a long time to realize the problem.



Iv. common problems with redis self-booting are:



1. Starting with the CMD command load configuration file (redis.windows.conf) is unsuccessful. Tips are as follows:


Code
 
 
1  D:\soft\Redis>redis-server.exe redis.windows.conf  
2     [13760] 11 Jul 16:39:51.067 # Creating Server TCP listening socket 127.0.0.1:6379: bind: No error  



Because the Redis service is self-booting, it will not start again, so loading the configuration file is a failure. There is also no Redis boot small box (below the picture, slowly looking down), note that the Windows version of the Redis installation, the default boot loaded configuration file is redis.windows-service.conf, as shown in:









2. Invalid password



Although the password is set in the configuration file (redis.windows.conf), the password is 123456:


Code
1 ################################################################################################## #####################
2 ... omit...
3 # requirepass foobared
4 requirepass 123456 


However, it is a serious security issue that the client does not require a password when it initiates a redis command operation, and does not prompt for an operation without permission.


Code
 
 
1     D:\soft\Redis>redis-cli.exe  
2     127.0.0.1:6379> get name  
3     "haha"  
4     127.0.0.1:6379>  


3. The Redis access IP bind (BIND) is invalid



The Redis default binding IP is 127.0.0.1, but if you want the intranet to be able to access the machine, you need to set the intranet IP address, such as 192.168.100.66, and then Redis.host can be set to 192.168.100.66 access to Redis.






Redis IP Address binding default description:


Code
 
 1     ################################## NETWORK #####################################  
 2       
 3     # By default, if no "bind" configuration directive is specified, Redis listens  
 4     # for connections from all the network interfaces available on the server.  
 5     # It is possible to listen to just one or multiple selected interfaces using  
 6     # the "bind" configuration directive, followed by one or more IP addresses.  
 7     #  
 8     # Examples:  
 9     #  
10     # bind 192.168.1.100 10.0.0.1  
11     # bind 127.0.0.1 ::1  
12     #  
13     # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the  
14     # internet, binding to all the interfaces is dangerous and will expose the  
15     # instance to everybody on the internet. So by default we uncomment the  
16     # following bind directive, that will force Redis to listen only into  
17     # the IPv4 lookback interface address (this means Redis will be able to  
18     # accept connections only from clients running into the same computer it  
19     # is running).  
20     #  
21     # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES  
22     # JUST COMMENT THE FOLLOWING LINE.  
23     # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
24     bind 127.0.0.1  





The main point is that if bind is set, Redis can only be accessed through the bound address.



If BIND is not set, all addresses can be accessed, and if the network is deployed outside the project, everyone can access it, so this is also a noted address, or it is more secure to set bind.



To bind multiple IP addresses:


Code
    1. Bind 127.0.0.1 192.168.100.66  


127.0.0.1 and 192.168.100.66 are separated by spaces, not commas.



However, if Redis is self-booting and no load configuration file (redis.windows.conf) is started, the settings here are not valid.



If you do not bind the IP address (192.168.100.66), setting the redis.host=192.168.100.66 directly is not accessible, and the following error occurs:


Java code
    1. 1


So, Redis is self-booting by Windows, configuration files ( redis.windows.conf ) is not valid for the settings



V. Solutions:



1. Disable Redis self-boot, set to manual



2. do not use the Redis installation version, use the compact version



3. Start by command line cmd load configuration file (redis.windows.conf)


Code
    1. D:\soft\redis>redis-server.exe redis.windows.conf


The interface that starts with CMD is different, as follows:



Saw the normal start of the box.



4. Open a new cmd (do not close the cmd window before) and start the Redis client:


Code
    1. D:\soft\redis>redis-cli.exe


5. Get the value of a key in Redis and prompt for no permissions.


Code
 
1     127.0.0.1:6379> get name  
2     (error) NOAUTH Authentication required.  
3     127.0.0.1:6379>  





This is the right thing to do.



6. Access via password, using auth + password, as follows:


Code
 
1     127.0.0.1:6379> get name  
2     (error) NOAUTH Authentication required.  
3     127.0.0.1:6379> auth 123456  
4     OK  
5     127.0.0.1:6379> get name  
6     "haha"  
7     127.0.0.1:6379>  
 








If Redis has a password set, Spring integrated Redis is also required to set the password, some of the specific configuration:






7, spring integration of some of the Redis configuration (Jedispool stand-alone version):



Jedispool pool for spring.xml file configuration:


Java code

 
 
1     127.0.0.1:6379> get name  
2     (error) NOAUTH Authentication required.  
3     127.0.0.1:6379> auth 123456  
4     OK  
5     127.0.0.1:6379> get name  
6     "haha"  
7     127.0.0.1:6379>  

Redis.properties configuration file

#*****************jedis connection parameter setting *********************#
#redisserverip#
Redis.host=192.168.100.66
#redisserverport#
Redis.port=6379
Timeout: Unit ms#
Redis.timeout=3000
#Authorization password, no password, no setting, but the attribute should be retained#
Redis.password=123456



Six, if it is not the installation version of Redis, but also want to let Redis self-boot, you can add self-starting services to Windows:



1. Access to the Redis installation directory


Code
    1. D:\soft\redis>


2. Execute the command:


Code
    1. Redis-server--service-install redis.windows.conf--loglevel notice--service-name redis


3. Complete Example:


Code
    1. D:\soft\redis>redis-server--service-install redis.windows.conf--loglevel notice--service-name Redis


--service-install redis.windows.conf specifying the Redis configuration file






--loglevel notice specifying the log level



--service-name Redis Specifying service name






The results of the operation are as follows (Redis successfully installed as a service.):


Code
    1. D:\soft\redis>redis-server--service-install redis.windows.conf--loglevel notice--service-name Redis
    2. [7176] Jul: 50.730 # granting Read/write access to ' NT AUTHORITY\NetworkService ' on: " D:\soft\Redis " " D:\soft\Redis\ "
    3. [7176] Jul :50.730 # Redis successfully installed as a service.


4, after the installation of services, the default is not immediately start, but the startup type is self-booting, if you want to start immediately, please execute the command:


Code
    1. Redis-server--service-start
Code
    1. The successful start of the service is shown below:
    2. [9876] Jul :41.251 # Redis service successfully started.


or restart your computer.



Stop service:


Code
    1. Redis-server--service-stop


5. Remove Redis Service:


Code
    1. Redis-server--service-uninstall


Under Windows remote Access redis,windows Redis bound IP is invalid, the Redis setup password is invalid, Windows Redis Configuration does not take effect, Windows Redis Requirepass does not take effect, Configuration of remote access Redis under Windows


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.