In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the method of installing redis in Linux", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "the method of installing redis in Linux"!
connect('192.168.1.4', 6379);
PHP code is as follows:
$redis->set('tag', 'hello');echo 'name:', $redis->get('tag');?>
When executing the above code, the error is as follows:
Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away' in xxxxRedisException: Redis server went away in xxxxxx
Error analysis and solutions
The reason for the error is simple, that is, there is no connection to the redis service. Due to the security policy adopted by redis, only local access is allowed by default. Simple configuration is required to allow external network access.
Modify redis configuration file to block all bind information.
# bind 192.168.1.100 10.0.0.1 # bind 192.168.1.8 # bind 127.0.0.1
After the modification is complete, the redis service needs to be restarted.
Modify the Linux firewall (iptables) to open your redis service port, the default is 6379.
-A INPUT -m state -state NEW -m tcp -p tcp -dport 6379 -j ACCEPT …… -A INPUT -j REJECT -reject-with icmp-host-prohibited
Note that you must place the firewall configuration for redis before REJECT. Then perform service iptables restart.
At this point, accessing the code just above will link to the redis service and display it correctly.
About bind
Specify redis to accept only requests from this IP address, if not set, then all requests will be processed, it is best to set this in a production environment. This explanation will totally confuse beginners and even be wrong. the original english version of this section reads:
# If you want you can bind a single interface, if the bind option is not # specified all the interfaces will listen for incoming connections. # bind 127.0.0.1
This means that it is an interface, that is, a network interface. A server can have one network interface (colloquially called a network card), or multiple. For example, there are two network cards on the machine, 192.168.205.5 and 192.168.205.6 respectively. If bind 192.168.205.5, only the network card address accepts external requests. If not bound, both network cards accept requests.
OK, I don't know if I can explain it clearly. Let me give you another example. In my experiment above, I commented out the bind item, but I actually have a solution. Since the address of my redis server is www.example.com. 192.168.1.4 If I don't annotate the bind item, what else can I do? I can do the following configuration:
# bind 192.168.1.4
Here many people mistakenly think that the bound ip should be the ip of the source of the request. In fact, this should be bound to your redis server itself to accept the request ip.
At this point, I believe that everyone has a deeper understanding of "the method of installing redis in Linux", so you may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.