当前位置:网站首页>Teach you how to build virtual machines locally and deploy microservices
Teach you how to build virtual machines locally and deploy microservices
2022-07-02 15:50:00 【Java geek Technology】
Every day in the morning It's seven thirty , Push dry goods on time

Photo by Patrick Hendry on Unsplash
A fan used to play a lot about virtual machines , But rarely summarized , Easy to forget , Today, it's just a one-stop summary !
One 、 Introduce
Usually we develop good projects , It is usually tested locally , And then put the project war The package is handed over to the operation and maintenance department or passed jenkins And other construction tools are published to the corresponding server resources .
For production environment , We may use the server resources of the cloud manufacturer , Of course, it would be better if the company had its own computer room .
however For the test environment , Especially small businesses , It is expensive to purchase a ECS resource for testing alone , We usually use virtual software to partition a local computer into several separate resource environments , To save resources 、 Purpose of saving money .
Recently, I was just tossing about the installation and configuration of virtual machines , To be honest, I encountered many pits , The main idea is to deploy several local microservices to virtual machines , Then test , See if the service can run normally ?
This time we use VMware Software , I chose the trial version !
I won't introduce the installation step , Relatively simple , You can baidu yourself !

After the virtual machine software is installed , In order to be consistent with the real production environment , The system image selected this time is Centos 7.8, You can directly access Alibaba cloud's image site http://mirrors.aliyun.com/centos/7.8.2003/isos/x86_64/, Download will be very fast , choice CentOS-7-x86_64-Minimal-2003.iso that will do .

Two 、 Install the image
- After downloading , open
VMware Software , Click create new virtual machine .

- Select the recommended configuration

- Select the downloaded system image

And then click next , Until completion , Wait for the virtual machine to be created and installed successfully !
The installation process is a fool's operation , I installed three on this machine , Relatively simple !
The key point is the network environment configuration , Let's take a look .
3、 ... and 、 Introduction to the Internet
After virtual machine installation , You need to configure the corresponding network to get online ,VMware It provides us with two network configuration schemes , One is : Bridging mode , The other is :NAT Pattern .
3.1、 Bridging mode ( recommend )
Bridging mode , To put it simply , Is to create a separate host in a LAN , He can access all the hosts in this lan , But you need to manually configure the subnet mask 、 gateway 、DNS etc. , And it is in the same network segment as the real host , In this model , Virtual machines and host computers can interact with each other ping through .

3.3、NAT Pattern
NAT Pattern , To put it simply , The virtual machine accesses the external network through the network of the host , Virtual network wants to access the Internet , You have to go through the host IP Address , Both host and virtual machine are external IP Address , Therefore, other machines in the LAN cannot connect to the virtual machine .

Four 、 Environment configuration
After understanding the introduction of network configuration , It is obvious that , What we need is that machines in the whole LAN can access virtual machines , Therefore, the virtual machine needs to configure the bridge mode to access the Internet .
- Click edit , Choose virtual network editor

- Click change settings

- Choose VMnet0, choice Bridging mode , And choose the corresponding Host network card

- It is very important to obtain the host network card information , If you don't know which one to choose , You can view it through the task manager

- After the virtual network editor is configured , Click a single virtual machine to set the network

- Choose bridge mode , Connect to the network

- Enter
ipconfig /all Get the subnet mask of the host 、 gateway 、DNS Etc , It is convenient for subsequent virtual machine configuration

- Finally, log in to the terminal virtual machine for network configuration
# Edit the information of the corresponding network card in the virtual machine (centos7)
vi /etc/sysconfig/network-scripts/ifcfg-ens33
# If it is centos6, Edit the file as follows
vi /etc/sysconfig/network-scripts/ifcfg-eth0
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- Add the following information at the end of the file , The default is dynamic acquisition IP
ONBOOT=yes # Turn on auto enable network connection
NETMASK=255.255.252.0 # Set subnet mask ( Subnet mask in the host )
GATEWAY=197.168.24.1 # Set up the gateway ( Gateway in the host )
DNS1=197.168.12.2 # Set master DNS( In the host DNS The server )
- 1.
- 2.
- 3.
- 4.
- Of course, you can also configure static IP Address , modify
BOOTPROTO Parameters
BOOTPROTO=static # Enable static IP Address , The default is dhcp, Show dynamic
- 1.
- Set static IP Address , With the host IP In the same network segment
IPADDR=197.168.24.201 # Set static IP Address
ONBOOT=yes # Turn on auto enable network connection
NETMASK=255.255.252.0 # Set subnet mask ( Subnet mask in the host )
GATEWAY=197.168.24.1 # Set up the gateway ( Gateway in the host )
DNS1=197.168.12.2 # Set master DNS( In the host DNS The server )
- 1.
- 2.
- 3.
- 4.
- 5.
- After saving successfully , Restart NIC
systemctl restart network
- 1.
- Finally, test whether you can surf the Internet , If there is a return message , You can surf the Internet
ping www.baidu.com
- 1.

- Input
ip addr Check out the Internet

- You can also use
ifconfig command , If there is no command found , You can install it with the following commands
# install net-tools
yum install net-tools
- 1.
- 2.

5、 ... and 、 Project deployment
After the network configuration is completed , You can install the service 、 The project has been deployed .
- Enter the following command , install JDK
yum -y install java-1.8.0-openjdk
- 1.
- Input
java -version Check whether the installation is successful

- Use
winScp Tools will jar perhaps war Upload the package to the server directory

- Use
xshell Command tools such as remote login server , Enter the command to start the service
# Start a jar service , Print log to service.log In file
nohup java -jar service.jar > service.log 2>&1 &
- 1.
- 2.
- In case of remote inaccessibility , Check if the firewall is on , If on, turn it off
# Check if the firewall is on
systemctl status firewalld.service
# Turn off firewall
systemctl stop firewalld.service
# It is forbidden to start the firewall automatically
systemctl disable firewalld.service
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
6、 ... and 、 summary
The whole content is more , They were all tested by themselves , In particular, there are many holes in the network configuration , When configuring the network , Be sure to check which network card of the host is surfing the Internet , Then select the network card type when configuring the bridge mode !
If there is something wrong , Hope netizens criticize and point out !
7、 ... and 、 Reference resources
1、 Autumn night rain lane - VMWare Virtual machine network configuration
边栏推荐
- /bin/ld: 找不到 -lgssapi_krb5
- Strings and arrays
- Ant group's large-scale map computing system tugraph passed the national evaluation
- Fiddler实现手机抓包——入门
- Cultural scores of summer college entrance examination
- Add an empty column to spark dataframe - add an empty column to spark dataframe
- 爱可可AI前沿推介(7.2)
- 【LeetCode】1905-统计子岛屿
- 2279. 装满石头的背包的最大数量
- /bin/ld: 找不到 -lxslt
猜你喜欢

Finally, I understand the event loop, synchronous / asynchronous, micro task / macro task, and operation mechanism in JS (with test questions attached)

Aike AI frontier promotion (7.2)
![[leetcode] 1254 - count the number of closed Islands](/img/84/f888ae0e164951cd9623fb3bf4a984.png)
[leetcode] 1254 - count the number of closed Islands
![[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)](/img/26/3f19d36c048e669c736e27384e0fa7.jpg)
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)

Traversal before, during and after binary tree

可视化技术在 Nebula Graph 中的应用

Comment réaliser un graphique Nebula d'importation CSV hors ligne de niveau milliard

Basic knowledge of cryptography

Introduction to dynamic planning I, BFS of queue (70.121.279.200)

全是精华的模电专题复习资料:基本放大电路知识点
随机推荐
/Bin/ld: cannot find -lcrypto
动态规划入门一,队列的bfs(70.121.279.200)
Analysis of the difference between array and linked list
解决BASE64Encoder报错的问题
beforeEach
[experience cloud] how to get the metadata of experience cloud in vscode
中科大脑知识图谱平台建设及业务实践
(万字精华知识总结)Shell脚本编程基础知识
fastjson List转JSONArray以及JSONArray转List「建议收藏」
已知两种遍历序列构造二叉树
Why does the system convert the temp environment variable to a short file name?
【Salesforce】如何确认你的Salesforce版本?
GraphX 图计算实践之模式匹配抽取特定子图
PTA ladder game exercise set l2-001 inter city emergency rescue
数据库系统概论第一章简答题-期末考得怎么样?
beforeEach
【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
使用FFmpeg命令行进行UDP、RTP推流(H264、TS),ffplay接收
6092. Replace elements in the array
[2. Basics of Delphi grammar] 3 Object Pascal constants and variables