Python Full Stack road Day6

Source: Internet
Author: User

first edited September 22, 2017 21:44:24

Summary
One. Nginx Service
Two. Nginx Reverse proxy
Three. Shared storage NFS
Homework
Summary today

Summary

Citation: Mr. Haifeng

    1. Nginx Service
    2. nginx.conf file
    3. Nginx Reverse Proxy
    4. Shared storage NFS
One. Nginx Service
  1. Nginx Service
    1. Installed Nginx front-mounted Epel-release:yum install Epel-release-y (based on this source installation nginx)
    2. Installing Nginx:yum Install Nginx-y
    3. Modify configuration file: vim/etc/nginx/nginx.conf
      • Where Access_log is the running log
      • The root directory under Server is under the Web site for example:/usr/share/nginx/html
      • CD to root vim opens the index.html file, which is downloaded when the user accesses it
      • URL Uniform Resource Locator: for example, http://192.168.1.1:80 targeting software
      • URI Uniform Resource Identifier: for example, Http://192.168.1.1:80/a/b/c.txt navigates to a file file path of:/usr/share/nginx/html/a/b/c.txt
    4. Edit index.html file, and restart Systemctl [Re]start nginx
      • Systemctl Status Nginx for check service state
      • Systemctl disable nginx for boot-up not booting
      • Systemctl Enable nginx for boot
      • Systemctl Reload Nginx for reload, read config file
    5. Shut down firewall: Systemctl stop firewalld (or iptables-f clean up firewall rules)
      • Because of their own experiment many times will still appear permissions problems, multi-access, the following treatment methods
        • Why SELinux is set to turned on (enabled)
          Check the on state of the native SELinux first, if the SELinux status parameter is enabled
          /usr/sbin/sestatus-v
          or use the Getenforce command to check
        • Find out why, how to close SELinux?
          1. Temporary shutdown (no restart)
          Setenforce 0
          2, modify the configuration file/etc/selinux/config, change selinux=enforcing to Selinux=disabled
          Vi/etc/selinux/config
          Note: Modifying the configuration file requires rebooting the system reboot and then shutting down the firewall.
    6. can access
  2. nginx.conf file
    1. Location where the "/" stands for the custom root directory, where {} can be defined by itself, for example root/var/www/html; ( note the end of the semicolon)
    2. Log_format for log format
Two. Nginx Reverse proxy
    1. Forward proxy and Reverse proxy:
      • Agent: A access b,a put his own request to C agent, C go to access B
      • Forward Proxy: A explicitly know the existence of their agent C, a explicitly specify their proxy address is C, let C go to access B, get results to a, usually used to FQ
      • Reverse proxy: The user request to Nginx, by the nginx load to the agent of the machine, to get the results, and then returned by Nginx to the client (so, Nginx will be a bunch of their agents to hide the machine to the back end, the external access is Nginx)
    2. Load Balancing
      • Round-robin: Polling, turn to proxy server;
      • Least-connected: Minimum number of links;
      • Ip-hash: Based on IP address (session keeping);
    3. Reverse proxy configuration
      Reference:nginx Reverse Proxy
      1. Load Balancing Settings
        • Upstream in http: Defines a set of machines that Nginx needs to manage, with the group named Myapp1,server as the proxy server
        • Location/medium modified to: Proxy_pass Http://myapp1;
      2. Minimum number of connections settings
        • Simply add least_conn to the server on a single line; Can
      3. Ip-hash settings
        • Simply add Ip_hash to the server on a single line; Can
      4. Weight settings
        • You need to add Weight=number to the server line (number is a few weights)
Three. Shared storage NFS
  1. Installation
    1. The RPC protocol Package and NFS package are required first: Yum install Rpcbind nfs-utils-y
  2. Configuration
    1. The configuration file is/etc/exports (this file is the primary NFS configuration file, but the system does not have a default value, so this file does not necessarily exist, you may want to use Vim to manually build, and then write the configuration content in the file)
    2. /etc/exports File Content format:
      • < output directory > [Client 1 options (access rights, user mappings, others)] [Client 2 options (access rights, user mappings, others)]
      • Output directory: The output directory refers to the NFS system needs to be shared to the client to use the directory;
      • Client: The client refers to a computer on the network that can access this NFS output directory
      • Access Permissions Options
        • Set output Directory read-only: RO
        • Set output directory Read/write: RW
      • See Unit 19th NFS Services for details
        Reference:NFS Services
    3. Modify Configuration
      • [Email protected] nginx]# Cat/etc/exports
      • /share 192.168.31.0/24 (rw,sync,fsid=0)
        • 192.168.31.0/24: Specifies all hosts in the subnet
        • Sync: Write data synchronously to the memory buffer and disk, but it is inefficient, but can guarantee the consistency of data
    4. File storage and block storage and object storage
      • Block Storage: Hard disk
      • File storage: Directly can create additions and deletions to search
      • Object storage: Create changes that need to be loaded locally and then uploaded
    5. Open Permissions (NFS does not open the W permission, others also need to have W permissions to the/share directory)
      • Chmod-r O+w/share
    6. Boot up
      1. Systemctl Enable Nfs-server.service
      2. Systemctl Enable Rpcbind.service
    7. Start the service
      1. Systemctl start Rpcbind.service (must be started first)
      2. Systemctl Start Nfs-server.service
    8. Confirm that the NFS server started successfully
      1. Rpcinfo
      2. Exportfs
      3. Showmount-e #默认查看自己共享的服务, the premise is to DNS can resolve their own, otherwise prone to error
      4. Showmount-a #显示已经与客户端连接上的目录信息
  3. Client Configuration
    1. Yum Install Rpcbind nfs-utils-y: Installing the Software
    2. Systemctl Enable Rpcbind.service && systemctl start rpcbind.service: Boot up
    3. SHOWMOUNT-E NFS Server IP #检查 NFS server-side directory sharing
    4. Mount-t NFS 192.168.31.106:/share/var/www/html/: Mount
  4. Test
    • Based on the Nginx load Balancer configuration, open the backend is Proxy service Access.log log, tail-f Access.log to observe access, Access lb refresh page to find content consistency, but each agent machine's Access.log log has new content come in
Homework
    • No
Summary today
    1. Nginx Access
      • The browser locates the Nginx software via IP and port
      • Nginx will read its own configuration file nginx.conf get the root directory
      • Getting files from the root directory
      • Send it back with the HTTP protocol
    2. Nginx Reverse Proxy
      • Reverse proxy settings
    3. NFS Shared storage
      • Service side
      • Client

Python Full Stack road Day6

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.