How to deploy ASP. Net core in combination with consumer under CentOS 7.4


In the last part, we talked about the concept of consumer and how to use it under win:

The steps are as follows:

1. Install VM

2. Download and install CentOS 7.4

Download address:

This is the installation example: VM virtual machine installation CentOS example

3. Configure the network environment (ensure the network communication)

4. Download and install dotnet operating environment

4.1. Register the Microsoft key, register the product repository, and install the required dependencies: once per machine

Execute the command as follows:

# sudorpm-Uvh

As shown in the figure below

4.2. Install. Net SDK

Execute the command as follows:

#Sudo Yum install dotnet-sdk-2.1 change to which version you want to use

As shown in the figure below

4.3. Check whether the installation is successful:

Execute the command as follows:

#dotnet –version

As shown in the figure below

5. Upload the project generation and release we created under windows to Linux

The operation steps are as follows:

5.1 generate and publish the project:

5.2. Find the published folder and package it into a zip compressed file

5.3 download and install a tool (I use xftp 5 to upload files to Linux)

5.4 upload the compressed package for project release:

Before uploading: I used the command to create a folder: the command is as follows:

# mkdir~/AspNetCore

Start to upload: as shown below

5.5. Execute the command to decompress:

Unzip command: unzip / root / aspnetcore /

As shown in the figure below:

5.6 run the project under the currently unzipped folder

As shown in the figure below:

5.7. Let’s run it to see the results as follows:

6. Install consul under Linux

6.1. Download the Linux version of consumer

We provided the address at the beginning of the last article:

6.2 send to Linux for installation

1): This is the first method:

2): the second method: Command Download:

Execute command: WGet

6.3 unzip file: Command unzip

Execute command: unzip consumer 1.1.0 Linux

As shown in the figure

6.4 run start consumer: Command run

Execute command:. / consumer to view version

As shown in the picture:

Execute command:. / consumer agent – Dev developer run

6.5 page access: Address:

The results are as follows:

6.6. We run the project registration service through the command line

Because our port is read through the command line, we need to input relevant commands in the command line

The command line is as follows:

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

7. Install and configure the daemons:

The meaning of installing daemons: in order to keep our website running when we exit the command interface, just as we run projects in VS, when vs stops running, the projects will not run

7.1 installation of Supervisor

Official documents learn more:

Why do you choose to do it with this: because Microsoft officially recommends,

Execute command to download: Supervisor

yum install python-setuptools

7.2 installation

Executing commands: installing

Command: easy? Install Supervisor

7.3. View the supervisor configuration file

Enter command:echo_supervisord_conf

The results are as follows:

We can see in the last line of the output information of the terminal as shown in the following figure:

In this sentence, we need to replace the new line: the purpose is to facilitate reading our configuration file: first, we create a folder: Mobile echo ﹣ supervisor ﹣ 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 in the figure below

7.5. New configuration: in / etc / Supervisor / supervisor.conf

Be careful not to add; space

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

Execute command: VIM / etc / Supervisor / supervisor.conf

The content is as follows:

7.6 add configuration information to new configuration file

New folder command: MKDIR conf.d

Switch to folder: CD conf.d

New profile command: touch aspnetcore.conf

Open compile configuration file command: VIM aspnetcore.conf

As shown in the figure: add configuration information:

Note as follows: NOTE must be removed

7.7. Reload configuration information / etc / Supervisor / supervisor.conf

Method 1: sudo supervisor CTL shutdown & & sudo Supervisor – C / etc / Supervisor / supervisor.conf

Our private configuration is already running when starting here: because we added [include] files = conf.d / *. Conf in the configuration file

Method two:

#Stop: sudo Service Supervisor stop

#Start: sudo Service Supervisor start

7.8 operation results:

When the supervisor is restarted, our configuration will take effect

1) first, let’s visit the site we started through the configuration file:

2) in view of our consumer, we have registered the service

Some simple commands for supervisor CTL:

Supervisor CTL stop project: stop a process (programxxx)

Supervisor CTL start project: start a process

Supervisor CTL restart project: restart a process

Supervisor CTL stop groupworker: restart all processes belonging to the group worker

Supervisor CTL stop all: stop all processes

Supervisor CTL reload: reload configuration file

Supervisor CTL update: modify a process:

The above is the whole content of this article. I hope it will help you in your study, and I hope you can support developepaer more.