Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy surging distributed micro-service engine based on docker

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to deploy surging distributed microservice engine based on docker". In daily operation, I believe many people have doubts about how to deploy surging distributed microservice engine based on docker. I have consulted all kinds of materials and sorted out simple and easy operation methods. I hope to help you answer the doubts about "how to deploy surging distributed microservice engine based on docker"! Next, please follow the small series to learn together!

overview

A container is a vessel for storing an image, and an image is a lightweight, stand-alone, executable package built to include everything needed to execute it: code, runtime environment, system tools, system libraries, settings.

A program is built as a mirror image in a container, and the underlying environment it depends on doesn't matter anymore. It can run anywhere, even in hybrid cloud environments. So why did containers catch on, and the rise of container technology made docke gradually come into view?

So what is docker?

docker is an open-source container engine based on go.

Docker packages everything you need to run your application into isolated containers

Docker automates and configures development/online environments to quickly build, test and run complex multi-container applications

Docker can also scale and provision applications with thousands of nodes or containers quickly.

It can run on mainstream linux, mac and windows systems, and ensures that no matter where the software is deployed, it will run normally and get the same results.

Introduction to related concepts

Image and container: You can think of both as class and instance objects, or iso system images and virtual machines. Different images contain different software or environments, but you can manage them using dockerfiles (files created by docker-specific syntax rules). Container is a miniature system that can run independently with image as template. One image can create multiple container instances.

registry: docker hub mirror repository, providing huge mirror resources for everyone to pull and use

dockerfile: is a file that groups together mirroring commands for automatic construction of images

environment construction

system environment

Host: Windows 10 Pro

Linux Server: Centos 3.10

1. install Docker

Docker requires centos kernel version higher than 3.10. Check out the prerequisites on this page to verify that your version of centos supports docker.

Check your current kernel version with uname -r

[root@runoob ~]# uname -r 3.10.0-862.e17.x86_64

# yum install docker-engine Install docker package

After successful installation, use docker version command to check whether the installation is successful. After successful installation-----as shown below

start the Docker

systemctl start docker

View docker information, as shown below

systemctl status docker

Test run hello-world

#docker run hello-world

2. Install rancher

download mirror

docker pull rancher/server

Start rancher

docker run -d --restart=always -p 8080:8080 rancher/server

After successful installation, access through http://ip:8080, as shown in the following figure

3. Install rabbitmq

download mirror

docker run -d --restart=always -p 8080:8080 rancher/server

The copy code is as follows:

#docker run -d --name rabbitmq --publish 5672:5672 --publish 4369:4369 --publish 25672:25672 --publish 15671:15671 --publish 15672:15672 \rabbitmq:management

After successful installation, access through http://ip:15672, as shown in the following figure

4. Install consume

download mirror

#docker pull docker.io/consul:latest

Create consume configuration

#vim /opt/platform/consul/server.json{ "datacenter": "quark-consul", "data_dir": "/consul/data", "server": true, "ui": true, "bind_addr": "192.168.249.162", "client_addr": "192.168.249.162", "bootstrap_expect": 1, "retry_interval": "10s", "rejoin_after_leave": false, "skip_leave_on_interrupt": true}

configuration instructions

When the official starts the container, some of the configuration parameters are used as docker run parameters, and I wrote the parameters to the configuration file.

datacenter: Data center name (library name)

data_dir: data storage directory

Server: Running in server mode

UI: Use UI interface

bind_addr: Address of the internal cluster communication binding. The default is 0.0.0.0 If there are multiple network cards, you need to specify them. Otherwise, you will start with an error.

client_addr: address bound to client interface, default is 127.0.0.1;

retry_join: rejoin the cluster

retry_interval: retry time

rejoin_after_leave: Rejoin after leaving the cluster

skip_leave_on_interrupt: After startup, whether ctrl+c gracefully exits, we are container mode, so don't worry, just true.

Start consul-server

The copy code is as follows:

docker run -d --net=host --name consul -v /opt/platform/consul/config:/consul/config -v /opt/platform/consul/data:/consul/data consul agent

After successful installation, access through http://ip:8500, as shown in the following figure

5. Install dotnetcore 2.1 runtime

download mirror

#sudo docker pull microsoft/dotnet:2.1-runtime

start

#sudo docker run -it microsoft/dotnet:2.1-runtime

deployer

1. Deploy surging engine without referring to any business module, create dockerfile file

from microsoft/dotnet:2.1-runtimeworkdir /appcopy . .entrypoint ["dotnet", "surging.services.server.dll"]

distribute the program

dotnet publish -r centos.7-x64 -c release

Creating Mirrors Using Dockerfile

#docker build -t surgingserver .

start

#docker run --name surgingserver --env mapping_ip=192.168.249.162 --env mapping_port=198 --env rootpath=/home/fanly --env register_conn=192.168.249.162:8500 --env eventbusconnection=172.17.0.4 --env surging_server_ip=0.0.0.0 -v /home/fanly:/home/fanly -it -p 198:198 surgingserver

configuration instructions

mapping_ip: external ip of mapping (environment variable)

mapping_port: external port of mapping (environment variable)

rootpath: root path of business module storage (environment variable)

register_conn: registry address (environment variable)

eventbusconnection: eventbus address (environment variable)

surging_server_ip: IP inside container (environment variable)

After startup, the rancher is shown below

For convenience, the directory of the host is mounted. Microsurfing is a distributed microservice engine, modules is a business module directory, and surgingapi is a gateway.

2. Deploy surging gateway and create dockerfile

from microsoft/dotnet:2.1-runtimeworkdir /appcopy . .entrypoint ["dotnet", "surging.apigateway.dll"]

distribute the program

dotnet publish -r centos.7-x64 -c release

Creating Mirrors Using Dockerfile

docker build -t surgingapi .

start

The copy code is as follows:

#docker run --name surgingapi -it -p 729:729 --env register_conn=192.168.249.162:8500 surgingapi

After startup, the rancher is shown below

Available at http://ip:729

Then you can test the gateway through postman, as shown below

At this point, the study of "how to deploy surging distributed microservice engine based on docker" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report