Linux Basics (4)

Source: Internet
Author: User

Linux Basics (iv)

Through the previous knowledge of learning, to learn now sell it!

1. Title: Cluster construction

1.1, the deployment of Nginx reverse proxy three Web services, scheduling algorithm using weighted polling;

1.2, all Web services use shared storage NFS, to ensure that all the web has read and write permissions to ensure data consistency;

How does this come true?

Let's start by introducing Nginx,nginx is a Web server. It is similar to LIGHTTPD, as a lightweight Web server that can replace heavyweight apache/iis. Built for performance optimization, Nginx is a fast and highly load-tested Web server.

Let's introduce the concept and principle of two concepts forward proxy and reverse proxy

A forward proxy is a server that is located between the client and the original server (Origin server), in order to obtain content from the original server, the client sends a request to the agent and specifies the target (the original server). The agent then forwards the request to the original server and returns the obtained content to the client. The client must make some special settings to use the forward proxy.

Reverse proxy is just the opposite, it is like the original server for the client, and the client does not need to make any special settings. The client sends a normal request to the content in the reverse proxy's namespace (name-space), and then the reverse proxy determines where (the originating server) forwards the request and returns the obtained content to the client, as if the content had been its own.

1.1, the deployment of Nginx reverse proxy three Web services, scheduling algorithm using weighted polling; The implementation steps are as follows:

Nginx Server Installation

1. Install Epel-release First

# Epel is a derivative release, such as CentOS, that is used to compensate for centos content updates that sometimes lag behind or that some extension sources do not.
View Code

2. Start installing Nginx

Yum install Nginx  # installation Nginx
View Code

3. View Nginx configuration information

cat/etc/nginx/nginx.conf   # View information  /etc/nginx/nginx.conf   # modifiable configuration file 
View Code

4. Installing Rpcbind and NFS

Yum install rpcbind nfs-utils-y  #Vim/etc/init.d/rpcbind can see the details; it's just a RPC service, which is responsible for notifying clients when sharing NFS , the NFS port number for the server. A simple understanding of RPC is an intermediary service. 
View Code

5. The point is coming!!! After installation do not think it is done, there are some operations to do, otherwise the results can not be out of the back

Systemctl Stop Firewalld.service  # after installing Nginx the first thing to do is to first shut down the operation of the firewall nginx  systemctl Restart Nginx  # start nginx-S Stop      # stop nginx-ANPT | grep  # View Nginx's running status
View Code

This is the state in which the boot is running normally.

6. Realize the cluster construction work (because I can only enable one Web side for my Computer problem)

Modify the Nginx configuration file on the Web side

The main change is location.

Location/{      /var/www/index.html;      Index index.html;}
View Code

7. Create content to be displayed on the site

displayed on the website: wb1

vim/var/www/index.html  # create this file in which to write Web1
View Code

8. Enter this WEB1 IP on the website to display what you want to display!

9. Implementing a reverse proxy three Web services

Modifying configuration files on the server side

1. Add paragraph    html{       upstream pythonweb{       192.168.205.129  # weights        in HTML Server 192.168.205.129;        192.168.205.129;      # I don't ask for a machine, so start a Web}} 2/ {           proxy_pass HTPP://
View Code

On the website to enter this server side of the IP address point refresh on it (I machine problem, only show web1)

For the rest of the scheduling algorithm is interesting to see: http://nginx.org/en/docs/http/load_balancing.html

1.2, all Web services use shared storage NFS, to ensure that all the web has read and write permissions to ensure data consistency;

1.2.1 Build a share directory

Mkdir/share  # Create a directory touch/share/share.txt  # Create a share.txt file in the share directory echo  gongxing >/share/share.txt  # Write content gongxing vim/etc/exports # in a file    View the configuration file exports.  Users can edit the file system that needs to be shared directly into the/etc/exports file, so that when the NFS server restarts, the system automatically reads the/etc/exports file, telling the kernel which file system to output and the associated access rights. In the following example, the contents of several entries in the/etc/exports file are shown, and the file system mounted in the/pub directory has read-only access, and all computers do not have to undergo security checks when accessing the file system. 
View Code

1.2.2 Configuration file contents (/etc/exports)

/share 192.168.205.0/24 (rw,sync,fsid=0)
View Code

1.2.3. Starting a service

systemctl start Rpcbind.servicesystemctl start NFS-server.service
View Code

1.2.4 View various information

1.2.4.1 Mounting Information


2.4.2 mount and machine start-up



1.2.4.3 viewing the status of a startup


1.2.4.4 viewing information in the WEB1 segment


Yes, the goal is reached, and today is a day off!

Linux Basics (4)

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.