当前位置:网站首页>My deployment notes
My deployment notes
2022-07-28 06:58:00 【wr_01】
Deployment related
1. Purchase cloud server
Purchase Alibaba cloud server , If it's a student , Very cheap
Installation environment :yum To install
For example, to install java , Baidu search yum -y install java
For example, to install the database , Baidu search yum How to install mysql 5.7
2. Domain name filing
3. Deploy
3.1 pack
Possible problems , The packing didn't work , But the code works properly
Solution :
Wrong file code , stay setting -> File Encoding in Change it to UTF-8
Compile the original plug-in Replace with
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <dependencies> <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-filtering</artifactId> <version>1.3</version> </dependency> </dependencies> </plugin> </plugins>
4. install docker
# 1、yum The package is updated to the latest
yum update
# 2、 Install the required packages , yum-util Provide yum-config-manager function , The other two are devicemapper driving-dependent
yum install -y yum-utils device-mapper-persistent-data lvm2
# 3、 Set up yum Source
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 4、 install docker, When the input interface appears, press y
yum install -y docker-ce
# 5、 see docker edition , Verify that the verification is successful
docker -v
# start-up docker
/bin/systemctl start docker.service
5. Pull the mirror image 、 Create a container
docker pull nginx
docker pull redis:5.0.3
docker pull java:8
docker pull mysql:5.7
5.1 start-up mysql
Create a container , Set port mapping 、 Directory mapping
mkdir /mnt/docker/mysql
cd /mnt/docker/mysql
docker run -id \
-p 3307:3306 \
--name=c_mysql \
-v /mnt/docker/mysql/conf:/etc/mysql/conf.d \
-v /mnt/docker/mysql/logs:/logs \
-v /mnt/docker/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=root \
mysql:5.7
stay /mnt/docker/mysql/conf establish my.cnf
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
lower_case_table_names=1
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Subsequent changes mysql Configuration file for You can change here
# To view the mysql Corresponding docker Containers ip Address , Configure to project
docker inspect c_mysql
5.2 start-up reids
docker run -id --name=redis -p 6379:6379 redis:5.0.3
6. Dockerfile
- Dockerfile It's a text file
- Contains bars of instructions
- Each instruction builds a layer , Based on the basic image , Finally, a new image is built
- For developers : It can provide a completely consistent development environment for the development team
- For testers : You can take the image built during development directly or through Dockerfile file
Building a new image starts to work - For operations : At deployment time , It can realize seamless migration of applications
6.1 keyword
| keyword | effect | remarks |
|---|---|---|
| FROM | Specify the parent image | Appoint dockerfile Based on which image structure |
| MAINTAINER | The author information | Used to mark this dockerfile Who wrote it |
| LABEL | label | Used to indicate dockerfile The label of have access to Label Instead of Maintainer It's all in the end docker image Basic information can be viewed in |
| RUN | Carry out orders | Execute a command The default is /bin/sh Format : RUN command perhaps RUN [“command” , “param1”,“param2”] |
| CMD | Container start command | Provides the default command to start the container and ENTRYPOINT In combination with . Format CMD command param1 param2 perhaps CMD [“command” , “param1”,“param2”] |
| ENTRYPOINT | entrance | It is usually used in containers that are closed immediately after execution |
| COPY | Copy file | build Copy files to image in |
| ADD | Add files | build Add files to image in It's not just about the present build Context It can come from remote services |
| ENV | environment variable | Appoint build The environment variables at that time You can start the container adopt -e Cover Format ENV name=value |
| ARG | Build parameters | Build parameters Parameters used only at build time If there is ENV that ENV Values with the same name are always overridden arg Parameters of |
| VOLUME | Define data volumes that can be mounted externally | Appoint build Of image Those directories can be mounted to the file system when they are started Use when starting a container -v binding Format VOLUME [“ Catalog ”] |
| EXPOSE | Exposed port | Define the port that the container listens to when it is running Start the use of the container -p To bind exposed ports Format : EXPOSE 8080 perhaps EXPOSE 8080/udp |
| WORKDIR | working directory | Specify the working directory inside the container If not, automatically create If specified / It's an absolute address If not / At the beginning, that's the last one workdir The relative path of the path |
| USER | Specify the executing user | Appoint build Or when it starts user stay RUN CMD ENTRYPONT The user at the time of execution |
| HEALTHCHECK | health examination | Specifies the command to monitor the health monitoring of the current container It's basically useless Because a lot of times The application itself has a health monitoring mechanism |
| ONBUILD | trigger | When it exists ONBUILD When the keyword image is used as the basic image When executed FROM When it's done Will execute ONBUILD The order of But it doesn't affect the current image It's not very useful |
| STOPSIGNAL | Send semaphore to host | The STOPSIGNAL Instruction sets the system call signal that will be sent to the container to exit . |
| SHELL | Specifies the shell | Appoint RUN CMD ENTRYPOINT When executing an order The use of shell |
6.2 Release springboot project
Definition dockerfile, Release springboot project
Implementation steps
① Define the parent image :FROM java:8
② Define author information :MAINTAINER mszlu [email protected]
③ take jar Add package to container : ADD springboot.jar app.jar
④ Define the command that the container starts executing :CMD java –jar app.jar
⑤ adopt dockerfile Build a mirror image :docker bulid –f dockerfile File path –t Image name : edition
FROM java:8
MAINTAINER mszlu <[email protected]>
ADD ./blog_api.jar /app.jar
CMD java -jar /app.jar --spring.profiles.active=prod
FROM java:8
ADD ./blog-api-1.0.jar /app.jar
CMD java -jar /app.jar --spring.profiles.active=prod
Execute the build command :
docker build -f ./springboot_dockerfile -t app .
docker build -f ./blog_dockerfile -t app .
7. Service Orchestration (Docker Compose)
7.1 install Docker Compose
# Compose At present, we have fully supported Linux、Mac OS and Windows, Before we install Compose Before , You need to install Docker. Next I They are installed in a compiled binary package Linux In the system .
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# Set file executable permissions
chmod +x /usr/local/bin/docker-compose
# View version information
docker-compose -version
7.2 uninstall Docker Compose
# Binary package installation , Delete the binary file
rm /usr/local/bin/docker-compose
7.3 Use docker compose layout nginx+springboot project
establish docker-compose Catalog
mkdir /mnt/docker/docker-compose cd /mnt/docker/docker-composeTo write docker-compose.yml file
version: '3' services: nginx: image: nginx container_name: nginx ports: - 80:80 - 443:443 links: - app depends_on: - app volumes: - /mnt/docker/docker-compose/nginx/:/etc/nginx/ - /mnt/mszlu/web:/mszlu/web - /mnt/mszlu/blog:/mszlu/blog network_mode: "bridge" app: image: app container_name: app expose: - "8888" network_mode: "bridge"establish ./nginx Catalog
mkdir -p ./nginxstay ./nginx Under the table of contents To write nginx.conf file
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }stay nginx Create conf.d Catalog ,conf.d Create blog.conf
gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 2; gzip_vary off; upstream appstream{ server app:8888; } server{ listen 80; server_name mszlu.com www.mszlu.com; rewrite ^(.*) https://www.mszlu.com/$1 permanent; } server{ listen 80; server_name blog.mszlu.com; rewrite ^(.*) https://blog.mszlu.com/$1 permanent; } server { listen 443 ssl; server_name mszlu.com www.mszlu.com; index index.html; ssl_certificate /etc/nginx/ssl/mszlu.com.crt; ssl_certificate_key /etc/nginx/ssl/mszlu.com.key; ssl_session_timeout 5m; location / { root /mszlu/web; index index.html; } } server { listen 443 ssl; server_name blog.mszlu.com; index index.html; ssl_certificate /etc/nginx/ssl/blog.mszlu.com.crt; ssl_certificate_key /etc/nginx/ssl/blog.mszlu.com.key; ssl_session_timeout 5m; location /api { proxy_pass http://appstream; } location / { root /mszlu/blog/; index index.html; } location ~* \.(jpg|jpeg|gif|png|swf|rar|zip|css|js|map|svg|woff|ttf|txt)$ { root /mszlu/blog/; index index.html; add_header Access-Control-Allow-Origin *; } }stay /mnt/docker/docker-compose Under the table of contents Use docker-compose Start the container
docker-compose up docker-compose up -d # On behalf of background startTest access
边栏推荐
- Which is the best air conduction Bluetooth headset? Air conduction Bluetooth headset ranking
- FTP service
- Cocos2d-x learning notes Tile Map tiledmap
- Insertion and deletion of nodes in linked list
- 2022 Tanabata gift recommendation! Nice, cheap and practical gift recommendation
- DNS domain name resolution service
- [learning notes] thread creation
- Difference between process and thread
- VMware Workstation 配置net模式
- Archery database audit platform deployment
猜你喜欢

RAID disk array

Applet custom components - data, methods, and properties

技术分享 | 接口测试常用代理工具

SSH服务配置

Shell script - regular expression

Technology sharing | detailed explanation of actual combat interface test request methods get, post

DNS domain name resolution service

Mongo SSL configuration practice

shell脚本——正则表达式

What kind of air conduction Bluetooth headset with good configuration is recommended
随机推荐
Difference between process and thread
Detailed explanation of LNMP construction process
HDU-1097-A hard puzzle(快速幂)
Ubuntu18.04+Centos7配置redis主从【学习笔记】
FTP service
Wechat applet custom compilation mode
Principle and configuration of NAT and pat
链表中结点的插入和删除
Qgraphicsview promoted to qchartview
Custom components -- slots
[learning notes] linked list operation
OSI七层模型
Suger Bi create task
Create, traverse and search nodes as required for single linked list
Ubuntu18.04 set up redis cluster [learning notes]
What is the most practical gift for Tanabata? A gift that will never go wrong is worth buying
小tips
Wechat applet custom compilation mode
RAID disk array
Technology sharing | interface testing value and system