ASP. NET core load Balancing cluster setup (Centos7+nginx+supervisor+kestrel)

Source: Internet
Author: User
Tags dotnet

    • Overview
The purpose of this paper is to build three ASP. NET core clusters with Nginx load balancer
    • First prepare the source code to run
Http://pan.baidu.com/s/1qYNBvEs prepare three servers (or virtual machines) 192.168.182.129, 192.168.182.130, 192.168.182.131 and publish the source to three servers/root /ASPNETCORE/ANUOAPC Directory
    • Build the following environment on three machines
First step: NET Core installation (CentOS 7)
1.sudo Yum Install libunwind Libicucurl-ssl-o dotnet.tar.gz https://go.microsoft.com/fwlink/? Linkid=809131sudo mkdir-p/opt/dotnet && sudo tar zxf dotnet.tar.gz-c/opt/dotnetsudo ln-s/opt/dotnet/dotnet/ Usr/local/bin2.mkdir hwappcd hwappdotnet new3.dotnet restoredotnet run See Hello World installed successfully! Step Two: Nginx installation1.curl-o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/ NGINX-RELEASE-CENTOS-7-0.EL7.NGX.NOARCH.RPM2.RPM-IVH Nginx.rpmyum Install nginx3.systemctl start Nginx to start Nginx. Systemctl enable Nginx to set the Nginx boot start 4. Turn off firewall CentOS 7systemctl stop firewalld.service #停止firewallsystemctl disable Firewalld.service #禁止firewall开机启动5. Modify/etc/ nginx/conf.d/default.conf file. Replace the contents of the file with:


Upstream MyServer {
Server 192.168.182.129:9090;
Server 192.168.182.130:9090;
Server 192.168.182.131:9090;
}

server {
Listen 80;

Location/{
Proxy_pass http://MyServer;
Proxy_http_version 1.1;
Proxy_set_header Upgrade $http _upgrade;
Proxy_set_header Connection keep-alive;
Proxy_set_header Host $host;
Proxy_cache_bypass $http _upgrade;
}
}

Last: Nginx–s reload make it effective immediately 6. Close selinuxcd/etc/selinux/Open config file, set the SELinux value inside to disabled restart CentOS for it to take effect step three. Configuring the Daemon Supervisor1. Installing Supervisoryum install Python-setuptoolseasy_install Supervisor2. Configuring mkdir/etc/supervisorecho_supervisord_conf >/etc/supervisor/supervisord.conf 3. Modify the supervisord.conf file to change the configuration of the end of the file to: [Include]files = conf.d/*. Conf4. Start Supervisord-c/etc/supervisor/supervisord.conf 5. Create a anuoapc.conf file that reads as follows [program:anuoapc]command=dotnet AnuoApc.Web.dll; Command directory=/root/aspnetcore/anuoapc/to run the program; The directory autorestart=true the command execution; If the program quits unexpectedly automatically restarts the Stderr_logfile=/var/log/anuoapc.err.log; Error log file Stdout_logfile=/var/log/anuoapc.out.log; Output log file environment=aspnetcore_environment=production; Process environment variable User=root; The user identity of the process execution stopsignal=int6. Copy the file to: "/etc/supervisor/conf.d/" under Supervisord reload make it effective. Ps-ef | grep ANUOAPC If you see the dotnet AnuoApc.Web.dll process represents a successful runThe fourth step is to revise the source code and publish it to threeChange the source of I am Node3 to Node2 to one of the three and let the release take effect with the following command:

Supervisorctl Restart ANUOAPC

And so on, three separate Hello World releases! I am Node1; Hello World! I am Node2; Hello World! I am Node3; So you can see the load on that machine when you call the interface back. The fifth step calls the interface with postmanClick three consecutive timesThe miracle happened., each loaded to three. Here you are!!!Recommended reference article: http://www.cnblogs.com/ants/p/5732337.html

ASP. NET core load Balancing cluster setup (Centos7+nginx+supervisor+kestrel)

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.