In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to deploy and implement the Linux cluster website for small companies, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
In fact, in many small companies and small enterprises, especially the websites involving e-commerce and electronic advertising, their websites also require high-availability Linux clusters for load balancing, but due to cost constraints, the boss will require system architects to design programs that can achieve this requirement with the least money. As system architects, how should we achieve this requirement?
First of all, it is the choice of the computer room. If the company has its own data center, it will be fine. If you do not have your own data center, I recommend you to put it in the BGP server room for hosting. If you have a choice, * will choose the server room with hardware firewall, which is guaranteed in terms of security. In addition, how do we choose the server? After we have a highly available cluster environment for load balancer, we can assemble our own servers, which is also cost-effective. Although the quality of brand servers such as IBM and DELL is guaranteed, the price is often unacceptable to the boss. Of course, everything takes stability as the premise and principle.
The first is the choice of load balancing equipment. We can have two choices, one is through hardware, the common hardware is relatively expensive commercial load balancers such as NetScaler, F5, Radware and Array. Its advantage is that there is a professional maintenance team to maintain these services, but the disadvantage is that it is too expensive, so it is not necessary for smaller network services for the time being. The other is the open source and free load balancing software strategy based on Linux, which is similar to LVS/HAProxy and Nginx. These are all implemented at the software level, so the cost is very low. Due to the cost problem for small companies and small enterprises, software-level load balancing is a * choice.
As for the highly available architecture of load balancer, I first recommend the architecture of Nginx/HAProxy+Keepalived. At this time, many friends have questions about why you don't choose a cluster solution based on LVS+Keepalived. This is because our deployed websites generally have the need for static and dynamic separation and regular distribution. If we choose the LVS+Keepliaved architecture first, then we should at least add a second-tier load balancing machine in the middle, which consumes more machines and virtually increases the cost of the entire website. In addition, a problem that many friends are worried about is that Nginx/HAProxy+Keepalived is not as stable as LVS+Keepalived, which is actually a misunderstanding. Through the successful implementation of more than a dozen projects and several years of observation, we find that the stability of these software-level load balancers is indeed very good, and there is little possibility of downtime in the case of high concurrency, while a commercial website implemented recently uses HAProxy+Keepalived, and HAProxy is rock solid under the impact of 100 million / day concurrent traffic. LVS is * in terms of performance, especially when the number of subsequent nodes (such as Web or MySQL database servers) exceeds 10. The concurrency and traffic of small companies are generally not very large, about a day lasting between 1 million / day, so I also recommend Nginx/HAProxy+Keepalived here.
If the website is hosted in the IDC computer room, and there is no hardware firewall protection in front of the computer room, we try our best to do a good job of traffic monitoring. I usually install MRTG+Nload software on the main Nginx/HAProxy to monitor the traffic. Nload can monitor the traffic in real time, and its installation is also very simple. Let's install RPMForege first. RPMforge is a software repository under the Centos system, with more than 4000 software packages. It is considered by the Centos community to be the safest and most stable software repository with the address of http://pkgs.repoforge.org/rmpforge-release. After this installation is successful, we can easily install nload with the command yum-y install nload. After entering this command, the nload software will intuitively display the real-time status of the traffic. The upper part of ncoming is the traffic entering the network card, and the lower part of Outgoing is the traffic outbound from this network card. Each part has current traffic (Curr), aPCge traffic (Avg), minimum traffic (Min), * * traffic (Max) and total traffic (Ttl). Because this software is intuitive, I use it to replace the previous real-time traffic monitoring software iptraf,Nload. The working interface is as follows:
Many friends who are interested in clustering often ask me, if a website is to deploy a highly available Linux cluster solution for load balancing, and the company wants to implement it in the most cost-effective way, how many servers are generally needed? My answer is four, that is, the 2x2 architecture. There are two Nginx/HAProxy+Keeplaived machines in the front and two Web machines in the back. The MySQL database is placed on two Web machines in an one-master and one-slave manner. The monitoring Nagios is deployed on the slave Nginx/HAProxy machine. I generally put the master Nginx/HAProxy for traffic monitoring, the software uses the MRTG+Nload method, and the data synchronization between the servers uses the rsync+inotify method, of course. I use the pure rsync method to avoid the trouble of reading disk frequently when there are changes to large files on the website. Of course, if your company has higher requirements for file servers (such as image type), we can consider adding two more servers to make DRBD+Heartbeat+NFS; if there are a large number of files that need to be stored, we can consider using MFS, which is also more machine-consuming.
How do we solve the problem of session synchronization in a small company cluster architecture like the one above? We can use Nginx's ip_hash and HAProxy's balance source mechanism. Their principles are similar. They both allow a client to access only a real Web server at a fixed back end for quite a long time, so that the session can be maintained. When we do login on the website page, we will not jump back and forth between the two Web servers, and naturally the website will not remind you that you have not logged in after a login. A situation that requires re-login.
In addition, we have at least two choices for small companies' Web servers: one is Apache, the other is Nginx. In the environment of low traffic and concurrency, we can choose Apache as our Web server. Although its anti-concurrency ability is not high, but its stability is *, many of my e-commerce sites are based on Apache; and large traffic concurrency environment, I am more inclined to Nginx.
MySQL here I am using an one-master-one-slave design, although many friends think this design is relatively simple, but the facts have proved that it is also the most stable. My e-commerce website also adopts this architecture. In the past few years, there has never been a loss of orders because of the failure of the database. In the early stage of the website launch, we can select the Slave machine for the entry of the background query function through the PHP program, which can greatly reduce the pressure on the main database. In addition, the MySQL machine not only plays the role of backup and backup, we completely transfer the complex queries in the background to the MySQL machine through the PHP program. Of course, the master-slave replication status monitoring of MySQL is also very important. I usually monitor it through both Nagios and SHELL scripts.
The above is all the contents of the article "how to deploy and implement Linux Cluster websites for small companies". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.