Java microservices project deployment

Project deployment

Step 1: Install Linux system (if it is a purchased server, you do not need to install the system)

Step 2: Modify the file source (modify the accelerator)

Step 3: install docker-compose and docker

1. The general process of getting started

1. docker-compose installation, you can use the following command to install or upload from the official download to the specified directory, pay attention to modify the version number
<!--安装方式一-->
sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
<!--然后执行下面的语句修改权限-->
sudo chmod +x /usr/local/bin/docker-compose

Installation method two

http://www.funtl.com/2018/05/13/docker/Docker-Compose-install and uninstall /

2. Uninstall docker-compose
sudo rm /usr/local/bin/docker-compose
3. Enter / usr / local / docker / tomcat to create (if you don't create your own folder)
<!--进入/usr/local/docker/tomcat里面创docker-compose.yml 文件-->
cd /usr/local/docker/tomcat

vi docker-compose.yml
4. Configure relevant information in the docker-compose.yml file (the host container of the data volume volumes can be replaced with ./ROOT means the current relative path and

: The front indicates the path of the host machine: the back indicates the storage location to which the data volume is mapped)

version: '3'
services:
   web:
    restart: always
    image: tomcat
    container_name: web
    ports:
      - 8080:8080
    volumes:
       - /usr/local/docker/myshop/ROOT:/usr/local/tomcat/webapps/ROOT
   mysql:
    restart: always
    image: mysql:5.7.22
    container_name: mysql
    ports:
      - 3306:3306
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: 123456
    command:
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --explicit_defaults_for_timestamp=true
      --lower_case_table_names=1
      --max_allowed_packet=128M
      --sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO"
    volumes:
      - mysql-data:/var/lib/mysql
volumes:
  mysql-data:
5. If docker is not installed, follow the following command to install docker. Use docker version to check whether it is actually installed. If it is installed, you can omit this step
sudo apt-get update

sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get -y update

sudo apt-get -y install docker-ce

sudo systemctl enable docker

sudo systemctl start docker
6. Start and delete containers through commands
<!--启动容器-->
docker-compose up
<!--删除容器-->
docker-compose down

note:

1.docker-compose command can be executed from the command have docker-compose.yml of
2. If you want to guard state operation then use the Docker Compose-up -d
3. View the log by docker-compose logs tomcat but want to have docker-compose The folder location of the
docker-compose.yml file is executed 4. A docker-compose.yml can have multiple services, and the combination of multiple services is a project

2. Common commands

<!--查看相关命令的使用格式-->
docker-compose help
<!--查看版本的相关信息-->
docker-compose version
<!--构建属于自己的相关-->
docker-compose build [options] [SERVICE...]
<!--开启服务-->
docker-compose start
<!--重启服务-->
docker-compose restart
<!--停止所有的服务-->
docker-compose stop
<!--删除所有的容器-->
docker-compose rm
7. Enter the data volume directory, the data volume managed by docker-compose is under the docker installation directory
/var/lib/docker/volumes/myshop_mysql-data/_data
<!--在目录中使用命令即可看到数据-->
docker volume ls
8. Upload the project to be deployed to the / usr / local / docker / myshop / ROOT folder and unzip it (you can apt-get install unzip automatically install without unzip)
/usr/local/docker/myshop/ROOT
apt-get install unzip
9. Enter WEB-INF to modify the configuration file
<!--进入到修改配置文件的目录下面-->
cd /usr/local/docker/myshop/ROOT/WEB-INF/classes
<!--修改配置文件-->
vi 数据库配置文件
10. Delete the compressed package or put the compressed package out of ROOT or delete it.
Published 19 original articles · praised 7 · visits 6638

Guess you like

Origin blog.csdn.net/William_TWG/article/details/84064279