Article Directory
1. Prepare the Linux server
1.1. Install Linux virtual machine
-
Download the Linux distribution Centos iso image
We use Windows systems more often, but it is not an excellent server operating system. Therefore, when developing locally, it is recommended to deploy the application on Linux. -
Install VirtualBox
VirtualBox download: https://www.virtualbox.org/ -
Install Xshell
to access servers under different remote systems, so as to better achieve the purpose of remote control of the terminal. Although it can be operated in a virtual machine, the experience is not good. For example, when we are using a cloud server, we can directly use Xshell to connect to the server to perform remote operations without opening the management interface of the cloud server. At the same time, it saves the trouble of entering the account and password every time.
1.2. Purchase Tencent Cloud
First enter the official website of Tencent Cloud: https://cloud.tencent.com/?fromSource=gwzcw.150044.150044.150044 After registration, you will be authenticated.
After the certification is completed, select the product-cloud server. As shown below:
2. Install Docker
2.1. Use yum command to install online
yum install docker
2.2. Check the Docker version after installation
docker -v
2.3. Start and stop Docker
启动docker:service docker start
停止docker:service docker stop
重启docker:service docker restart
查看docker状态:service docker status
开机启动:chkconfig docker on
3. Install mysql
3.1. Search mirror
Find the mysql mirror on docker hub
docker search mysql
[root@localhost ~]# docker search mysql
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/mysql MySQL is a widely used, open-source relati... 8458 [OK]
docker.io docker.io/mariadb MariaDB is a community-developed fork of M... 2914 [OK]
docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... 626 [OK]
docker.io docker.io/centurylink/mysql Image containing mysql. Optimized to be li... 60 [OK]
docker.io docker.io/centos/mysql-57-centos7 MySQL 5.7 SQL database server 59
docker.io docker.io/mysql/mysql-cluster Experimental MySQL Cluster Docker images. ... 49
docker.io docker.io/deitch/mysql-backup Automated and scheduled mysql database dum... 40 [OK]
docker.io docker.io/tutum/mysql Base docker image to run a MySQL database ... 32
docker.io docker.io/bitnami/mysql Bitnami MySQL Docker Image 29 [OK]
docker.io docker.io/schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic back... 28 [OK]
docker.io docker.io/linuxserver/mysql A Mysql container, brought to you by Linux... 21
docker.io docker.io/prom/mysqld-exporter 20 [OK]
docker.io docker.io/centos/mysql-56-centos7 MySQL 5.6 SQL database server 15
docker.io docker.io/circleci/mysql MySQL is a widely used, open-source relati... 13
docker.io docker.io/mysql/mysql-router MySQL Router provides transparent routing ... 12
docker.io docker.io/arey/mysql-client Run a MySQL client from a docker container 10 [OK]
docker.io docker.io/imega/mysql-client Size: 36 MB, alpine:3.5, Mysql client: 10.... 6 [OK]
docker.io docker.io/openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 ima... 6
docker.io docker.io/yloeffler/mysql-backup This image runs mysqldump to backup data u... 6 [OK]
docker.io docker.io/fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron t... 4 [OK]
docker.io docker.io/genschsa/mysql-employees MySQL Employee Sample Database 2 [OK]
docker.io docker.io/jelastic/mysql An image of the MySQL database server main... 1
docker.io docker.io/ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 0 [OK]
docker.io docker.io/monasca/mysql-init A minimal decoupled init container for mysql 0
docker.io docker.io/widdpim/mysql-client Dockerized MySQL Client (5.7) including Cu... 0 [OK]
3.2. Pull the image
[root@localhost ~]# docker pull docker.io/mysql
Using default tag: latest
Trying to pull repository docker.io/library/mysql ...
latest: Pulling from docker.io/library/mysql
0a4690c5d889: Pull complete
98aa2fc6cbeb: Pull complete
0777e6eb0e6f: Pull complete
2464189c041c: Pull complete
b45df9dc827d: Pull complete
b42b00086160: Pull complete
bb93567627c7: Pull complete
bda91ab2ec35: Pull complete
50b4c0c50b33: Pull complete
70c2999bc788: Pull complete
3cf3e568e51b: Pull complete
c80d654aa77e: Pull complete
Digest: sha256:b1b2c176a45f4ff6875d0d7461fe1fdd8606deb015b38b69545f72de97714efd
Status: Downloaded newer image for docker.io/mysql:latest
3.3. View the mirror
[root@localhost ~]# docker images mysql
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql latest 2151acc12881 Less than a second ago 445 MB
docker.io/mysql <none> 7bb2586065cd 2 months ago 477 MB
3.4. Start the mirror
Use mysql mirror
docker exec -it The container ID after MySQL runs successfully /bin/bash
docker run -di --name mysql_0803 -p 33306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
-p stands for port mapping, the format is host mapping port: container running port
-e stands for adding environment variable MYSQL_ROOT_PASSWORD is the login password of the root user
3.5. Enter the MySQL container, log in to MySQL
Enter the mysql container
docker exec -it mysql_0803 /bin/bash
Log in to mysql
mysql -u root -p
External Win10 also comes to connect to the mysql service running on dokcer.
We connect to the Docker container in the virtual machine Centos on our local computer. Here 192.168.247.130 is the IP of the virtual machine operating system.
Turn off the firewall.
firewall-cmd --state
service firewalld stop
firewall-cmd --state
3.6.Mysql connection permissions
Reason: mysql 8.0 uses caching_sha2_password authentication mechanism by default; the client does not support the new encryption method.
Solution:
modify the user (root) encryption method
Step 1: Enter the inside of the mysql container
[root@localhost ~]# docker exec -it mysql01 bash ## mysql01是容器的别名,这里也可以用容器的id代替
Step 2: Log in to mysql
root@e285125c99d6:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Step 3: Set user configuration items
- View user information
mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host | user | plugin | authentication_string |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| % | root | caching_sha2_password | $A$005$HF7;krfwhkKHp5fPenQm4J2dm/RJtbbyjtCUVdDCcboXQw3ALxsif/sS1 |
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
Remarks: host is %, which means ip is not restricted. localhost means that this machine uses plugin instead of mysql_native_password, you need to change the password
- Modify encryption method
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; ### 123456 mysql的登录密码
flush privileges;
Then check the user information
mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host | user | plugin | authentication_string |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| % | root | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
5 rows in set (0.00 sec)
- Test: successful connection
4. Install redis
4.1. Pull Redis image
[root@localhost ~]# docker pull redis
Using default tag: latest
Trying to pull repository docker.io/library/redis ...
latest: Pulling from docker.io/library/redis
f5d23c7fed46: Pull complete
831c20fd50cb: Pull complete
bc2a0f25caa5: Pull complete
745ac314a007: Pull complete
6deeca231441: Pull complete
6291e84f5373: Pull complete
Digest: sha256:854715f5cd1b64d2f62ec219a7b7baceae149453e4d29a8f72cecbb5ac51c4ad
Status: Downloaded newer image for docker.io/redis:latest
4.2. Create Redis container
[root@localhost ~]# docker run -di --name=my_redis -p 6388:6379 redis
f0980b9a56e90a5c3564591f9dfb1c7ecf1f9223d85c011d3aea41aeb14c9d27
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0980b9a56e9 redis "docker-entrypoint..." 8 seconds ago Up 7 seconds 0.0.0.0:6388->6379/tcp my_redis
4.3. Client test
At the command prompt of your local computer, use the window version of redis to test
5 Unified development environment
5.1 Maven
Configure Alibaba Cloud image
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
Configure jdk 1.8 to compile the project
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
5.2 Idea&VsCode
idea install lombok, mybatisx plugin Translation plugin, etc...
Vscode installs and develops essential plug-ins
Vetur-syntax highlighting, IntelliSense includes formatting function, Alt+Shift+F (format the full text), Ctrl+K Ctrl+F (format the selected code, two
Ctrls need to be pressed at the same time) EsLint one by one syntax correction Wrong
Auto Close Tag one by one automatically close HTML/XML tags
Auto Rename Tag one by one automatically complete the synchronization modification of the other-side tag
JavaScript (ES6) code snippets one by ES6 grammar smart prompt and quick input, in addition to j, it also supports .ts, .jsx, .tsx, .html, .vue; saves the time to configure it to support various is code files