Found a very good container management tool, so that can not use Docker can also quickly install the environment, this is today’s hero Rancher. Rancher truly implements one-click application deployment

Preparations for Rancher installation environment

  1. Docker pulls the image
docker pull rancher/server
Copy the code
  1. Create the Rancher container
docker run -id --name=rancher -p 9090:8080 rancher/server
Copy the code
  1. Open your browser and type in IP :9090 to see Rancher’s top screen

  1. There is a language switch at the bottom of the browser

Rancher initialization

1. Add an environment

Rancher supports grouping resources into multiple environments, each with its own independent infrastructure resources and services, managed by one or more users, teams, and organizations For example, you can create separate development, test, and production environments to ensure secure isolation between environments, giving developers access to the development environment but limiting access to the production environment

1.1 Choose Default -> Environment Management and click Add Environment

1.2 Enter a name and click Create button

1.3 You can click the menu on the left to switch in various environments

2. Add hosts

2.1 Choose Infrastructure > Host and click Add Host

2.2 Copying scripts to the Server

If there is a problem with the download, execute it several times. If it still does not work, please see the solution at the end of the page

2.3 After clicking the close button, the host will be displayed in the interface

3. Add an application

3.1 Click Application -> All (or users) click “Add Application” button

Fill in name and description

Click the Create button to add the new application to the list

4. Deploy applications

MySQL 4.1 deployment

Mirror: MySQL: 5.7

Notice You need to add environment variables

Click the Create button to complete the creation of the appeal command equivalent to the following Docker command

Docker run-id --name=mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1qaz@WSX mysql:5.7Copy the code

Redis 4.2 deployment

Same steps as mysql

4.3 Project Deployment

  1. Set up a private warehouse

Start a private repository

docker run -id --name=registry -p 5000:5000 registry
Copy the code

Changes the daemon. Json

vi /etc/docker/daemon.json
Copy the code

Add the following, then save and exit

{"insecure-registries": ["10.0.40.61:5000"]}
Copy the code
  1. Modify docker configuration to allow remote access
vi /lib/systemd/system/docker.service
Copy the code

Including ExecStart = add configuration – H after TCP: / / 0.0.0.0:2375 – H Unix: / / / var/run/docker. Refresh the sock modified configuration

systemctl daemon-reload
systemctl restart docker
docker start registry
Copy the code
  1. Modified the microservices project and added the DockerMaven plugin

  2. Connect to the mysql database and execute the library building script

  3. Add service mirror in Rancher IP :5000/unicloud-admin: 1.0-snapshot Port mapping 9092:9092

— Appendix 1: Problem solving

Conf 2. Add nameserver 8.8.8.8 3. Restart the Docker and pull againCopy the code

— Appendix 2:DockerMaven configuration

<build>
   <finalName>app</finalName>
   <plugins>
       <plugin>
           <groupId>org.springframework.boot</groupId>
           <artifactId>Spring ‐ boot ‐ maven ‐ plugin</artifactId>
       </plugin><! ‐ ‐ docker maven plugin, website: https://github.com/spotify/docker ‐ maven ‐ plugin ‐ ‐ ><plugin>
           <groupId>com.spotify</groupId>
           <artifactId>Docker ‐ maven ‐ plugin</artifactId>
           <version>0.4.13</version>
           <configuration>   
                   <imageName>ip:5000/${project.artifactId}:${project.version}</imageName>
                   <baseImage>jdk1.8</baseImage>
                   <entryPoint>[" Java, "" ‐ jar", "/ ${project. Build. FinalName}. The jar"]</entryPoint>
                   <resources>
                       <resource>
                           <targetPath>/</targetPath>
                           <directory>${project.build.directory}</directory>
                           <include>${project.build.finalName}.jar</include>
                       </resource>
                   </resources>
                   <dockerHost>http://10.0.40.61:2375</dockerHost>
           </configuration>
       </plugin>
   </plugins>
</build>
Copy the code

The above files automatically generate a Dockerfile file