How to deploy Aspnetcore combined consul under CentOS 7.4

Source: Internet
Author: User
Tags dotnet

In the previous article we talked about the concept of consul and how to use it under win: http://www.cnblogs.com/szlblog/p/9162557.html

The steps are as follows:

1. Installing Virtual machine VMS
2 . Install CentOS 7.4 under Download (address is not provided)

This is the installation example: VM virtual machine installation CentOS sample https://www.jb51.net/article/108088.htm

3. Configure network environment (ensure network Pass) 4. Download and install dotnet operating environment

4.1 , registering a Microsoft key, registering a product repository, and the dependencies required for installation : Every machine executes once

The following commands are executed:

# sUdo rpm -uvh https://packages.microsoft.com/config/rhel/7/ packages-microsoft-prod.rpm

As shown

    

4.2. Installing the. NET SDK            

The following commands are executed:

# sudo yum install dotnet-sdk-2.1 you want to use which version to change which version

As shown

    

  4.3. Check if the installation is successful:       

The following commands are executed:

# dotnet–version

As shown

    

5. Upload the projects we created under Windows to Linux

The procedure is as follows:

5.1, build the project to publish:

     

5.2 , locate the published folder and package The compressed file in ZIP format

    

  5.3.Download and install a tool (whichever is ok I use xftp 5) to upload files to Linux

  5.4 , make a project release compress package upload:

    Before uploading: I created a folder with a command: The command is as follows:

# mkdir ~/aspnetcore

    Start uploading: if

    

  5.5 , execute command decompression:

    Unzip command: # Unzip/root/aspnetcore/myframeworkcore.zip

    As shown in the following:

     

5.6 , run the project under the currently unpacked folder

As shown in the following:

    

5.7, let's run it. See the results below:

    

6. Install Consul under Linux  

  6.1, Download Linux version of consul

we provided the address at the beginning of the previous article:

   

6.2 , send to Linux for installation

1): This is the first method:

     

2): The second method: Command download:

Execute command: Wget https://releases.hashicorp.com/consul/1.1.0/consul_1.1.0_linux_amd64.zip

     

  6.3 , unzip the file: command decompression

Execute command: # unzip Consul_1.1.0_linux_amd64.zip

    

    

6.4 , run start Consul: command Run

Execute command: ./consul can view versions

    

     

Execute command: ./consul Agent-dev developer Run

     

6.5 , page access: address is 127.0.0.1:8500

    Results:

     

   6.6 , we run the Project registration service through the command line

Because our ports are read by the command line, we need to enter the relevant command at the command line

The command line is as follows:

    

    Note that if we are running the project, we must start consul

     

7. Install the configuration daemon:  

What it means to install daemons: to keep our site running when we exit the command screen, like when we run a project in VS, when vs stops running, the project won't run.

7.1 , installation Supervisor

Official documentation Learn MORE: http://supervisord.org/

Why choose to do this: Because Microsoft is the official recommendation ,

Execute command to download: Supervisor

Yum Install Python-setuptools

    

7.2 , to install

Execute command: Install

Command: Easy_install Supervisor

    

7.3 , viewing the Supervisor configuration file

Input command: echo_supervisord_conf

The results are as follows:

    

we can see the last line in the output information of the terminal as shown in:

    

In this sentence we need to replace the new line: The purpose is to facilitate the reading of our configuration file: First we create a folder: Move echo_supervisord_conf file

The command is as follows: Mkdir/etc/supervisor

    

7.4 , move the command file to the new folder

Execute command: echo_supervisord_conf >/etc/supervisor/supervisord.conf

As shown

    

7.5 , new configuration: in/etc/supervisor/supervisord.conf

Take care not to add; Spaces

Add content: [include]files=conf.d/*.conf

Execute command: vim/etc/supervisor/supervisord.conf

The contents are as follows:

    

7.6 , new configuration file add configuration information

New Folder command: mkdir conf.d

Switch to folder under: CD CONF.D

New configuration File command: Touch aspnetcore.conf

Open the Compile configuration File command: Vim aspnetcore.conf

: New Add configuration information:

    

Note the following: note must be removed

View Code

7.7 , reload configuration information:/etc/supervisor/supervisord.conf

Method One: sudo supervisorctl shutdown && sudo supervisord-c/etc/supervisor/supervisord.conf

We have already run our private configuration when it is started: because we have added [include]files=conf.d/*.conf] in the configuration file

    

Method Two:

#停止: sudo service supervisor stop

#启动: sudo service supervisor start

7.8 , running results:

Our configuration is in effect when supervisor is restarted.

1), first we visit the site that we started with the configuration file:

    

2), in view of our Consul is registered service

    

Some simple commands for Supervisorctl:

Supervisorctl Stop Project: Stop a process (programxxx)

Supervisorctl Start Project: Start a process

Supervisorctl Restart Project: restarting a process

Supervisorctl Stop Groupworker: Restarts all processes that belong to the named Groupworker

Supervisorctl StopAll: stops all Processes

Supervisorctl Reload: Reload configuration file

SUPERVISORCTL Update: Modify a process:

There is a lack of hope that we will learn from each other,

This article original: reprint please indicate the source thank you!

How to deploy Aspnetcore combined consul under CentOS 7.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.