Connect to the redis instance on the VM locally

Source: Internet
Author: User
Tags install redis

If you want to create a Capturing System and think that it may be better to store temporary data with redis, you just want to dress up with a virtual machine, install redis on the virtual machine, and access redis on the virtual machine through local.

 

After the Virtual Machine and redis are successfully installed, it is found that the local connection is not connected to the redis on the Virtual Machine. First, comment out the following configuration (this is used to restrict the IP addresses that can be connected ):

# Bind 127.0.0.1

Here I connect to redis on the virtual machine through redis manger. The configuration interface of this software is as follows:

After the configuration, I found that I could not connect to the virtual machine, but my xshell can connect to the virtual machine. At this time, I thought it might be a port problem (xshell uses port 22 ), after finding a bunch of data, we found that the port is not open because it is necessary to open the port. We need to add the port opening rule to iptables:

Iptables-I input-P TCP -- dport 6379-J accept

Here, the-I parameter is the meaning of adding a rule. You can also use-a to add it at the end. However, if I try it, it will fail, probably because of the priority of the previous rule, coming soon

Input is the entry rule, and there is also output

-What protocol does P mean by protocol?

-- Dport indicates the destination port.

-J indicates rules, which can be accept and drop.

 

In this way, the rule is added. You can run the following command to check that 6379 has been added:

Iptables-l-N | grep 6379

Test redis manger and find that it can be connected, but it is not actually saved yet. It will expire after restart, but you need to save it by using the following command:

Service iptables save

This command writes the 6379 port rule

/Etc/sysconfig/iptables

File, rather than temporary, it will not disappear after restart. Now, enabling the redis port on the virtual machine is complete.

 

Connect to the redis instance on the VM locally

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.