A detailed account of the process of climbing a pit of Docker deployment service

A detailed account of the process of climbing a pit of Docker deployment service

First time writing. Allow me to introduce myself...

Hello everyone, I am Jasmine. Why is it called Jasmine? Emmm ID Jasmine is spinning in circles? Just kidding, hehe. The author is a two-year rookie (three days away from completing two years). Because there are only two people in the company, me and the front-end developer. So the task of online service deployment naturally fell on my shoulders. This is the first time that Docker is used to deploy services in a production environment. Climb out of one pit and fall into another. Just record the bugs encountered during this launch. Please correct me if there is anything wrong with what I wrote. Forgive me! Okay. Without further ado. action!

This project uses spring cloud+spring boot+spring gateway+mysql and also uses rabbitmq. The server is centos7. There is one big cauldron missing here. I actually have a backend colleague who I have been working with for three months. This guy was fired because his boss didn't approve his request for leave to go for an interview but he went anyway. He was the one who set up the framework. emmmm so the blame was put on my head!

The zuul he used was replaced by gateway by me. Zuul is based on servlet 2.5 (uses 3.x), uses a blocking API. It does not support any persistent connections such as websockets. Gateway is built on Spring Framework 5, Project Reactor, and Spring Boot 2 and uses a non-blocking API. Websockets are supported and since it is tightly integrated with Spring it will be a much better development experience.

The Docker image service uses Alibaba Cloud's container image service. I asked a colleague and he said that he used Google's container tool jib. So I pressed Cmd+Shift+F and searched for jib globally. (Forgive me, it is the company code, so it is the cavalry code ⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄)

Click in to see

Enter Alibaba Cloud and find the container image service (I omitted the steps here because I didn't know that the image warehouse was partitioned and couldn't find the warehouse because I didn't have permission. Then I shamelessly asked for an administrator account and changed the employee account of a colleague who had resigned, but still couldn't find the warehouse)

Then I created a namespace xxx-prod, and then built a warehouse and private warehouse for each service under this space. For the code source, I chose to push the local repository to the mirror repository. I don’t know much about the others.

(Later I found out that I didn't need to build it. Jib submission will automatically create the repository. I chose it when I created it manually.) After submitting it using jib, I can see the update in the version information of the repository.

Then connect to the server. Create a docker folder under the home folder

//In the root directory//~]# How to say emmm in centos7, it is $ on GitBash and OS system, cmd under windows is>
//Create a docker folder under home~]# mkdir /home/docker
//Enter the created docker
~]# cd /home/docker

Then start pulling the image we uploaded to Alibaba Cloud. In fact, any directory can be pulled (I omitted the first time I pulled Alibaba Image Service. I didn’t read the operation guide. I suspected that my account didn’t have permission, but I didn’t log in. Then I kept docker login, but I didn’t know that I should add Alibaba Cloud’s image address at the end: registry.cn-hangzhou.aliyuncs.com) In Alibaba Cloud’s Image Service Management Console, click on any image repository -> Management, and you can see the operation guide for the image repository

After the image is pulled, enter

~]# docker images

You can see the image you just pulled.

I asked my colleague why there were so many mirrors here, and he explained to me

Emmm, okay! I always feel that there are a lot of images taking up memory (I hope someone who knows can give me some advice, thank you)

Start eureka

~]# docker run -d --name eureka -p 8761:8761 -p 15672:15672 -p 9001:9001 -v /etc/localtime:/etc/localtime registry.cn-hangzhou.aliyuncs.com/xx_xxx_prod/eureka
// -d background run -p bind port here bind three ports, one is the port of the registration center itself, one is the port of the gateway, and the other is the port of rabbitmq //-v print version information

Since rabbitmq is used, you need to create another rabbitmq container. Or pull the image first

//Note that when getting the image, you should get the management version instead of the last version. The management version has the management interface.
~]# docker pull rabbitmq:management
~]# docker run -d --name rabbit -e RABBITMQ_DEFAULT_USER=xxx -e RABBITMQ_DEFAULT_PASS=xxx --network=container:eureka rabbitmq:management
//Because the docker containers are separated by network--network is added to the same network environment as eureka so that it can be accessed by services under eureka governance.
//-e is to set the default account password, which is xxx in the command. Friends who use it are welcome to adjust it by themselves.

Then start your own service

~]# docker run -d --name xxx -v /home/docker/web-prod/logs:/logs -v /etc/localtime:/etc/localtime --network=container:eureka registry.cn-hangzhou.aliyuncs.com/xx_xxx_prod/xxx 
//-v is to mount the log to a directory you specify. Similarly, --network joins the eureka network, and there is no need to bind a port here.
//After startup, you can view the service status in the console of the registration center. ip + port of eureka.

This way the service is running. The other service steps are similar. Finally, I would like to add some small episodes that I encountered when going online. At first, I didn’t know that the docker containers were separated by a network, and I couldn’t connect to rabbitmq because I had never used --network to set the eureka network. Therefore, rabbitmq cannot be accessed from localhost within the service. Also, if the rabbitmq delay queue is used in the service, the delay queue plug-in needs to be installed. Plugin installation steps

Open the official website to download: http://www.rabbitmq.com/community-plugins.html
Select the corresponding version "3.7.x" and click Download.
~]# docker cp /home/docker/rabbitmq_delayed_message_exchange-20171201-3.7.x.ez rabbit:/plugins
//Enter docker~]# docker exec -it rabbit /bin/bash
//Open the plugin rabbitmq-plugins enable rabbitmq_delayed_message_exchange
//View all installed plugins rabbitmq-plugins list

The installation was successful, as shown in the figure:

When docker rm deletes a container, it suddenly cannot be deleted. docker ps -a found that the status of the container was Dead. I looked up a lot of information online, such as forced deletion, checking mount status, manually deleting folders, and checking port occupancy. Tried almost everything, no effect.

Finally, probably due to experience, I somehow turned off both nginx and httpd and then deleted them. Don't ask me why I installed nginx and httpd on the same server. This project was originally a php project deployed by them. After I took over, I used nginx myself.

There is another very strange problem. Although it was solved, I still don’t quite understand why it happened. There is a last_password_reset_date in the user table. When the user logs in, this time field will be checked and the token will always be reported as invalid. After entering the logs of each field, it was found that this field was 10 hours different from the time in the database. At that time, I thought it was a time zone problem. However, the time of another register_date field in the same table is normal, so the time zone is not processed. After a long investigation, I thought that the time type accepted by Java was incorrect, or a colleague processed this field. It has not been fixed yet. Later I added the test library to the online environment and found that it was normal again. Finally, I checked the time zone of the test environment database, which was GMT+8. The online library is the default GTM. Finally, just change the official database time to the East 8th District.

Another one is Redis, because there was a public account service before that used redis, and the redis service was on the host machine at that time. So, I thought about connecting to the server host, but I couldn't connect at first. Later, I changed the redis configuration file and bound the bind parameter to the intranet IP. Then use the intranet ip to connect to redis in the program.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to build php+nginx+swoole+mysql+redis environment with docker
  • Explanation of Dockerfile instructions and basic structure
  • Docker container log analysis
  • How to quickly deploy an Elasticsearch cluster using docker
  • How to deploy MySQL 5.7 & 8.0 master-slave cluster using Docker
  • Use dockercompose to build springboot-mysql-nginx application
  • Example of how to deploy Spring Boot using Docker
  • Deploy Nginx+Flask+Mongo application using Docker
  • Use of environment variables in Docker and solutions to common problems
  • Explanation of the process of docker packaging node project

<<:  In-depth understanding of slot-scope in Vue (suitable for beginners)

>>:  MySQL 5.0.96 for Windows x86 32-bit green simplified version installation tutorial

Recommend

How to use CSS to pull down a small image to view a large image and information

Today I will talk about a CSS special effect of h...

Summary of common sql statements in Mysql

1. mysql export file: SELECT `pe2e_user_to_compan...

A brief discussion on JS regular RegExp object

Table of contents 1. RegExp object 2. Grammar 2.1...

Summary of Creating and Using Array Methods in Bash Scripts

Defining an array in Bash There are two ways to c...

Vue page monitoring user preview time function implementation code

A recent business involves such a requirement tha...

Convert psd cut image to div+css format

PSD to div css web page cutting example Step 1: F...

Summary of several replication methods for MySQL master-slave replication

Asynchronous replication MySQL replication is asy...

js realizes the dynamic loading of data by waterfall flow bottoming out

This article shares with you the specific code of...

How to add vim implementation code examples in power shell

1. Go to Vim's official website to download t...

JavaScript event delegation principle

Table of contents 1. What is event delegation? 2....