docker单节点搭建在线商城

本文档使用到的软件包以上传到资源中

目录

1.  创建容器并配置基础内容

1.1  将gpmall-repo上传到容器中

1.2  添加yum源

2.  安装基础服务

2.1  安装JAVA环境

2.2  安装Redis缓存服务

2.3  安装Elasticsearch服务

2.4  安装Nginx服务

2.5  安装MariaDB数据库

2.6  安装zookeeper服务

2.7  安装kafka服务

3.  开启服务

3.1  启动MariaDB数据库

3.2  启动redis服务

3.3  启动Elasticsearch

3.4  启动nginx

4.  部署

4.1  部署前端

4.2  部署后端

登录验证


1.  创建容器并配置基础内容

可以直接docker pull centos:7

我这里用的是自己做的镜像,放资源中了,可前往查看

[root@wq images_docker]# docker load -i CentOS7_1804.tar
4826cdadf1ef: Loading layer [==================================================>]  207.8MB/207.8MB
14373f3a403e: Loading layer [==================================================>]  173.8MB/173.8MB
5ac0fc2030b4: Loading layer [==================================================>]  6.656kB/6.656kB
d4ce7d7d577a: Loading layer [==================================================>]  6.144kB/6.144kB
ee747055941b: Loading layer [==================================================>]  6.656kB/6.656kB
d0d06aa60ad3: Loading layer [==================================================>]   5.12kB/5.12kB
b3f3bc1666f9: Loading layer [==================================================>]  5.632kB/5.632kB
9692fa18f16b: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: centos7:1804[root@wq ~]# docker images
REPOSITORY        TAG       IMAGE ID       CREATED        SIZE
centos7           1804      8c1f6d23d72e   4 years ago    370MB[root@wq ~]# docker run -d --name mall -p 8045:80 centos7:1804
b2581295b40b15eb117f07fc221e91ed02ed91d7f1d145a69841c52e469ea82c[root@wq ~]# docker ps
CONTAINER ID   IMAGE          COMMAND               CREATED         STATUS        PORTS                                           NAMES
b2581295b40b   centos7:1804   "/usr/sbin/sshd -D"   3 seconds ago   Up 1 second   22/tcp, 0.0.0.0:8045->80/tcp, :::8045->80/tcp   mall

1.1  将gpmall-repo上传到容器中

 先将gpmall上传到服务器或者虚拟中

[root@wq ~]# docker ps
CONTAINER ID   IMAGE          COMMAND               CREATED         STATUS        PORTS                                           NAMES
b2581295b40b   centos7:1804   "/usr/sbin/sshd -D"   3 seconds ago   Up 1 second   22/tcp, 0.0.0.0:8045->80/tcp, :::8045->80/tcp   mall
[root@wq ~]# docker cp /root/gpmall-repo b2581295b40b:/root
Successfully copied 323MB to b2581295b40b:/root

/etc/hosts配置文件如下

1.2  添加yum源

[root@b2581295b40b ~]# cd /etc/yum.repos.d/
[root@b2581295b40b yum.repos.d]# ll
total 32
-rw-r--r-- 1 root root 1664 May 17  2018 CentOS-Base.repo
-rw-r--r-- 1 root root 1309 May 17  2018 CentOS-CR.repo
-rw-r--r-- 1 root root  649 May 17  2018 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root  630 May 17  2018 CentOS-Media.repo
-rw-r--r-- 1 root root 1331 May 17  2018 CentOS-Sources.repo
-rw-r--r-- 1 root root 4768 May 17  2018 CentOS-Vault.repo
-rw-r--r-- 1 root root  314 May 17  2018 CentOS-fasttrack.repo
[root@b2581295b40b yum.repos.d]# vi local.repo
[root@b2581295b40b yum.repos.d]# yum clean all && yum repolist
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras mall updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
base                                                                            | 3.6 kB  00:00:00
extras                                                                          | 2.9 kB  00:00:00
mall                                                                            | 2.9 kB  00:00:00
updates                                                                         | 2.9 kB  00:00:00
(1/5): mall/primary_db                                                          | 144 kB  00:00:00
(2/5): extras/7/x86_64/primary_db                                               | 250 kB  00:00:00
(3/5): base/7/x86_64/group_gz                                                   | 153 kB  00:00:00
(4/5): base/7/x86_64/primary_db                                                 | 6.1 MB  00:00:01
(5/5): updates/7/x86_64/primary_db                                              |  25 MB  00:00:05
repo id                                        repo name                                         status
base/7/x86_64                                  CentOS-7 - Base                                   10072
extras/7/x86_64                                CentOS-7 - Extras                                   519
mall                                           mall                                                165
updates/7/x86_64                               CentOS-7 - Updates                                 5766
repolist: 16522

2.  安装基础服务

2.1  安装JAVA环境

[root@b2581295b40b yum.repos.d]# yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
[root@b2581295b40b yum.repos.d]# java -version
openjdk version "1.8.0_402"
OpenJDK Runtime Environment (build 1.8.0_402-b06)
OpenJDK 64-Bit Server VM (build 25.402-b06, mixed mode)

2.2  安装Redis缓存服务

[root@b2581295b40b yum.repos.d]#yum install -y redis

2.3  安装Elasticsearch服务

[root@b2581295b40b yum.repos.d]# yum install -y elasticsearch

2.4  安装Nginx服务

[root@b2581295b40b yum.repos.d]# yum install -y nginx

2.5  安装MariaDB数据库

[root@b2581295b40b yum.repos.d]# yum install -y mariadb mariadb-server

2.6  安装zookeeper服务

上传zookeeper包到服务器或者虚拟机中

[root@wq ~]# ll
total 1113272
drwxr-xr-x 5 root root       4096 Mar  5 19:46 gpmall-repo
-rw-r--r-- 1 root root   37676320 Mar  5 20:12 zookeeper-3.4.14.tar.gz[root@wq ~]# docker cp zookeeper-3.4.14.tar.gz b2581295b40b:/root/
Successfully copied 37.7MB to b2581295b40b:/root/# 容器内查看
[root@b2581295b40b yum.repos.d]# ll /root
total 36804
-rw------- 1 root root     3302 May 31  2018 anaconda-ks.cfg
drwxr-xr-x 5 root root     4096 Mar  5 11:46 gpmall-repo
-rw-r--r-- 1 root root 37676320 Mar  5 12:12 zookeeper-3.4.14.tar.gz

解压

[root@b2581295b40b yum.repos.d]# tar -zxvf /root/zookeeper-3.4.14.tar.gz
zookeeper-3.4.14/
zookeeper-3.4.14/bin/
zookeeper-3.4.14/bin/README.txt
zookeeper-3.4.14/bin/zkCleanup.sh
zookeeper-3.4.14/bin/zkCli.cmd
zookeeper-3.4.14/bin/zkCli.sh
zookeeper-3.4.14/bin/zkEnv.cmd
zookeeper-3.4.14/bin/zkEnv.sh[root@b2581295b40b yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-fasttrack.repo  zookeeper-3.4.14
CentOS-CR.repo    CentOS-Media.repo      CentOS-Vault.repo    local.repo# 放到/opt目录下
[root@b2581295b40b yum.repos.d]# mv zookeeper-3.4.14 /opt
[root@b2581295b40b yum.repos.d]# cd /opt
[root@b2581295b40b opt]# ll
total 4
drwxr-xr-x 14 2002 2002 4096 Mar  6  2019 zookeeper-3.4.14

[root@b2581295b40b opt]# cd zookeeper-3.4.14/conf/
[root@b2581295b40b conf]# pwd
/opt/zookeeper-3.4.14/conf
[root@b2581295b40b conf]# mv zoo_sample.cfg zoo.cfg
[root@b2581295b40b conf]# ll
total 12
-rw-rw-r-- 1 2002 2002  535 Mar  6  2019 configuration.xsl
-rw-rw-r-- 1 2002 2002 2161 Mar  6  2019 log4j.properties
-rw-rw-r-- 1 2002 2002  922 Mar  6  2019 zoo.cfg

启动服务

[root@b2581295b40b conf]# cd ../bin/
[root@b2581295b40b bin]# pwd
/opt/zookeeper-3.4.14/bin
[root@b2581295b40b bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@b2581295b40b bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: standalone

2.7  安装kafka服务

上传kafka包到服务器或者虚拟机中,并上传到容器中

[root@wq ~]# ll
total 1169400
drwxr-xr-x 5 root root       4096 Mar  5 19:46 gpmall-repo
-rw-r--r-- 1 root root   57471165 Mar  5 20:20 kafka_2.11-1.1.1.tgz
-rw-r--r-- 1 root root   37676320 Mar  5 20:12 zookeeper-3.4.14.tar.gz# 上传到容器中
[root@wq ~]# docker cp kafka_2.11-1.1.1.tgz b2581295b40b:/root
Successfully copied 57.5MB to b2581295b40b:/root

解压

[root@b2581295b40b bin]# cd /opt
[root@b2581295b40b opt]# pwd
/opt
[root@b2581295b40b opt]#
[root@b2581295b40b opt]# tar -zxvf /root/kafka_2.11-1.1.1.tgz
kafka_2.11-1.1.1/
kafka_2.11-1.1.1/LICENSE
kafka_2.11-1.1.1/NOTICE
kafka_2.11-1.1.1/bin/
kafka_2.11-1.1.1/bin/kafka-preferred-replica-election.sh
kafka_2.11-1.1.1/bin/connect-standalone.sh
kafka_2.11-1.1.1/bin/kafka-server-start.sh

开启服务中查看

[root@b2581295b40b opt]# cd kafka_2.11-1.1.1/bin/
[root@b2581295b40b bin]# pwd
/opt/kafka_2.11-1.1.1/bin[root@b2581295b40b bin]# ./kafka-server-start.sh -daemon ../config/server.properties
[root@b2581295b40b bin]# jps
501 QuorumPeerMain
815 Kafka
879 Jps# 下载工具
[root@b2581295b40b bin]# yum install -y net-tools
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be updated
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be an update
--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================Package                    Arch                    Version                                     Repository             Size
============================================================================================================================
Updating:net-tools                  x86_64                  2.0-0.25.20131004git.el7                    base                  306 kTransaction Summary
============================================================================================================================
Upgrade  1 PackageTotal download size: 306 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                        | 306 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionUpdating   : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                1/2Cleanup    : net-tools-2.0-0.24.20131004git.el7.x86_64                                                                2/2Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                1/2Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                                                                2/2Updated:net-tools.x86_64 0:2.0-0.25.20131004git.el7Complete![root@b2581295b40b bin]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9092            0.0.0.0:*               LISTEN      815/java
tcp        0      0 0.0.0.0:2181            0.0.0.0:*               LISTEN      501/java
tcp        0      0 0.0.0.0:46029           0.0.0.0:*               LISTEN      501/java
tcp        0      0 0.0.0.0:34929           0.0.0.0:*               LISTEN      815/java
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      1/sshd

3.  开启服务

3.1  启动MariaDB数据库

[root@b2581295b40b ~]# /etc/init.d/mysql start
Starting MariaDB.240305 12:29:48 mysqld_safe Logging to '/var/lib/mysql/b2581295b40b.err'.
240305 12:29:48 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysqlSUCCESS!

进行初始化,并设置密码

[root@b2581295b40b ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.Remove anonymous users? [Y/n] y... Success!Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] n... skipping.By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.Remove test database and access to it? [Y/n] y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n] y... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!

登录数据库设置权限

[root@b2581295b40b ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.18-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.000 sec)

上传gpmall.sql文件到服务器或者虚拟机,再cp到容器中

[root@wq ~]# ll
total 1169460
drwxr-xr-x 5 root root       4096 Mar  5 19:46 gpmall-repo
-rw-r--r-- 1 root root      59239 Mar  5 20:33 gpmall.sql
-rw-r--r-- 1 root root      35095 Dec 19 16:03 install.sh
-rw-r--r-- 1 root root   57471165 Mar  5 20:20 kafka_2.11-1.1.1.tgz
-rw------- 1 root root 1102262784 Feb 27 14:49 mysql.tar
-rw-r--r-- 1 root root   37676320 Mar  5 20:12 zookeeper-3.4.14.tar.gz
[root@wq ~]# docker cp gpmall.sql b2581295b40b:/root
Successfully copied 60.9kB to b2581295b40b:/root

导入数据

MariaDB [(none)]> create database gpmall;
Query OK, 1 row affected (0.000 sec)MariaDB [(none)]> use gpmall;
Database changed
MariaDB [gpmall]> source /root/gpmall.sql
Query OK, 0 rows affected (0.000 sec)Query OK, 0 rows affected (0.000 sec)Query OK, 0 rows affected, 1 warning (0.002 sec)Query OK, 0 rows affected (0.010 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.010 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.041 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.004 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.010 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.015 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.019 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.018 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.018 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.015 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.014 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.013 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.003 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.067 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 0 rows affected, 1 warning (0.001 sec)Query OK, 0 rows affected (0.013 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.010 sec)Query OK, 0 rows affected, 1 warning (0.000 sec)Query OK, 0 rows affected (0.011 sec)Query OK, 1 row affected (0.002 sec)Query OK, 0 rows affected (0.000 sec)MariaDB [gpmall]> Ctrl-C -- exit!
Aborted

3.2  启动redis服务

[root@b2581295b40b ~]# redis-server
1446:C 05 Mar 12:39:50.357 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf_.__.-``__ ''-.__.-``    `.  `_.  ''-._           Redis 3.2.12 (00000000/0) 64 bit.-`` .-```.  ```\/    _.,_ ''-._(    '      ,       .-`  | `,    )     Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379|    `-._   `._    /     _.-'    |     PID: 1446`-._    `-._  `-./  _.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'||    `-._`-._        _.-'_.-'    |           http://redis.io`-._    `-._`-.__.-'_.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'||    `-._`-._        _.-'_.-'    |`-._    `-._`-.__.-'_.-'    _.-'`-._    `-.__.-'    _.-'`-._        _.-'`-.__.-'1446:M 05 Mar 12:39:50.359 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1446:M 05 Mar 12:39:50.359 # Server started, Redis version 3.2.12
1446:M 05 Mar 12:39:50.359 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1446:M 05 Mar 12:39:50.359 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1446:M 05 Mar 12:39:50.359 * DB loaded from disk: 0.000 seconds
1446:M 05 Mar 12:39:50.359 * The server is now ready to accept connections on port 6379

查看是否成功启动:新建终端进入容器,查看端口

[root@wq ~]# docker exec -it b2581295b40b /bin/bash
[root@b2581295b40b /]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9092            0.0.0.0:*               LISTEN      815/java
tcp        0      0 0.0.0.0:2181            0.0.0.0:*               LISTEN      501/java
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      1446/redis-server *
tcp        0      0 0.0.0.0:46029           0.0.0.0:*               LISTEN      501/java
tcp        0      0 0.0.0.0:34929           0.0.0.0:*               LISTEN      815/java
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1/sshd
tcp6       0      0 :::3306                 :::*                    LISTEN      -
tcp6       0      0 :::6379                 :::*                    LISTEN      1446/redis-server *
tcp6       0      0 :::22                   :::*                    LISTEN      1/sshd

3.3  启动Elasticsearch

添加三行内容到最上面

[root@b2581295b40b /]# vi /etc/elasticsearch/elasticsearch.yml
[root@b2581295b40b /]# head -n 3 /etc/elasticsearch/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true

找到以下内容,去掉注释,并将network.host写自己主机的ip地址

cluster.name: my-application
node.name: node-1
network.host: 172.16.51.29
http.port: 920
[root@b2581295b40b /]# adduser elasticsearch
adduser: user 'elasticsearch' already exists[root@b2581295b40b /]# mkdir /home/elasticsearch
[root@b2581295b40b /]# chown elasticsearch:elasticsearch /home/elasticsearch
[root@b2581295b40b /]# sudo chown -R elasticsearch:elasticsearch /var/log/elasticsearch/
[root@b2581295b40b /]# su - elasticsearch -s /bin/bash -c '/usr/share/elasticsearch/bin/elasticsearch'

3.4  启动nginx

[root@b2581295b40b opt]# /usr/sbin/nginx

4.  部署

将五个文件上传到服务器或虚拟机中,然后docker cp到容器中

[root@wq ~]# ll
total 1368780
drwxr-xr-x 5 root root       4096 Mar  5 19:46 gpmall-repo
-rw-r--r-- 1 root root   47765224 Mar  5 21:01 gpmall-shopping-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root      59239 Mar  5 20:33 gpmall.sql
-rw-r--r-- 1 root root   39005468 Mar  5 21:01 gpmall-user-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root   57471165 Mar  5 20:20 kafka_2.11-1.1.1.tgz
-rw-r--r-- 1 root root   54936064 Mar  5 21:01 shopping-provider-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root   62386947 Mar  5 21:01 user-provider-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root   37676320 Mar  5 20:12 zookeeper-3.4.14.tar.gz[root@wq ~]# docker cp shopping-provider-0.0.1-SNAPSHOT.jar b2581295b40b:/root
Successfully copied 54.9MB to b2581295b40b:/root[root@wq ~]# docker cp user-provider-0.0.1-SNAPSHOT.jar b2581295b40b:/root
Successfully copied 62.4MB to b2581295b40b:/root[root@wq ~]# docker cp gpmall-user-0.0.1-SNAPSHOT.jar b2581295b40b:/root
Successfully copied 39MB to b2581295b40b:/root[root@wq ~]# docker cp gpmall-shopping-0.0.1-SNAPSHOT.jar b2581295b40b:/root
Successfully copied 47.8MB to b2581295b40b:/root[root@wq ~]# docker cp  dist  b2581295b40b:/root
Successfully copied 11.5MB to b2581295b40b:/root

容器中查看

[root@b2581295b40b opt]# ll /root/
total 292324
-rw------- 1 root root     3302 May 31  2018 anaconda-ks.cfg
drwxr-xr-x 3 root root     4096 Mar  5 13:03 dist
-rw-r--r-- 1 root root       77 Mar  5 12:39 dump.rdb
drwxr-xr-x 5 root root     4096 Mar  5 11:46 gpmall-repo
-rw-r--r-- 1 root root 47765224 Mar  5 13:01 gpmall-shopping-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root 39005468 Mar  5 13:01 gpmall-user-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root    59239 Mar  5 12:33 gpmall.sql
-rw-r--r-- 1 root root 57471165 Mar  5 12:20 kafka_2.11-1.1.1.tgz
-rw-r--r-- 1 root root 54936064 Mar  5 13:01 shopping-provider-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root 62386947 Mar  5 13:01 user-provider-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root 37676320 Mar  5 12:12 zookeeper-3.4.14.tar.gz

添加hosts

[root@b2581295b40b ~]# cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2      b2581295b40b
172.17.0.2      kafka.b2581295b40b
172.17.0.2      mysql.b2581295b40b
172.17.0.2      redis.b2581295b40b
172.17.0.2      zookeeper.b2581295b40b

4.1  部署前端

[root@b2581295b40b ~]# rm -rf /usr/share/nginx/html/*
[root@b2581295b40b ~]# cp -rvf dist/* /usr/share/nginx/html/
'dist/index.html' -> '/usr/share/nginx/html/index.html'
'dist/static' -> '/usr/share/nginx/html/static'
'dist/static/fonts' -> '/usr/share/nginx/html/static/fonts'
'dist/static/fonts/element-icons.b02bdc1.ttf' -> '/usr/share/nginx/html/static/fonts/element-icons.b02bdc1.ttf'
'dist/static/svg' -> '/usr/share/nginx/html/static/svg'
'dist/static/svg/search.svg' -> '/usr/share/nginx/html/static/svg/search.svg'
'dist/static/svg/shop.svg' -> '/usr/share/nginx/html/static/svg/shop.svg'
'dist/static/svg/arrow.svg' -> '/usr/share/nginx/html/static/svg/arrow.svg'

编辑配置文件

[root@b2581295b40b ~]# vi /etc/nginx/conf.d/default.conf
[root@b2581295b40b ~]# cat /etc/nginx/conf.d/default.conf
server {listen       80;server_name  localhost;#charset koi8-r;#access_log  /var/log/nginx/host.access.log  main;location / {root   /usr/share/nginx/html;index  index.html index.htm;}location /user {proxy_pass http://127.0.0.1:8082;}location /shopping {proxy_pass http://127.0.0.1:8081;}#error_page  404              /404.html;

重启nginx服务

[root@b2581295b40b ~]# ps aux |grep nginx
root      1704  0.0  0.0  46432   976 ?        Ss   12:55   0:00 nginx: master process /usr/sbin/nginx
nginx     1705  0.0  0.1  46844  1932 ?        S    12:55   0:00 nginx: worker process
root      1719  0.0  0.0   9088   664 pts/2    S+   13:15   0:00 grep --color=auto nginx
[root@b2581295b40b ~]#
[root@b2581295b40b ~]# kill -HUP 1704
[root@b2581295b40b ~]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9092            0.0.0.0:*               LISTEN      815/java
tcp        0      0 0.0.0.0:2181            0.0.0.0:*               LISTEN      501/java
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      1446/redis-server *
tcp        0      0 0.0.0.0:46029           0.0.0.0:*               LISTEN      501/java
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1704/nginx: master
tcp        0      0 0.0.0.0:34929           0.0.0.0:*               LISTEN      815/java
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1/sshd
tcp6       0      0 :::3306                 :::*                    LISTEN      -
tcp6       0      0 :::6379                 :::*                    LISTEN      1446/redis-server *
tcp6       0      0 :::22                   :::*                    LISTEN      1/sshd

4.2  部署后端

[root@b2581295b40b ~]# nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &
[1] 1724
[root@b2581295b40b ~]# nohup: ignoring input and appending output to 'nohup.out'[root@b2581295b40b ~]# nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &
[2] 1773
[1]   Exit 1                  nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar
[root@b2581295b40b ~]# nohup: ignoring input and appending output to 'nohup.out'[root@b2581295b40b ~]#
[root@b2581295b40b ~]#
[root@b2581295b40b ~]# nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &
[3] 1821
[2]   Exit 1                  nohup java -jar user-provider-0.0.1-SNAPSHOT.jar
[root@b2581295b40b ~]# nohup: ignoring input and appending output to 'nohup.out'[root@b2581295b40b ~]# nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &
[4] 1842
[root@b2581295b40b ~]# nohup: ignoring input and appending output to 'nohup.out'

登录验证

浏览器进行访问   ip地址:端口号

 单击右上角“头像”,进行登录操作,使 用用户名/密码为test/test进行登录

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/269940.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

LeetCode Python - 36.有效的数独

目录 题目答案运行结果 题目 请你判断一个 9 x 9 的数独是否有效。只需要 根据以下规则 ,验证已经填入的数字是否有效即可。 数字 1-9 在每一行只能出现一次。数字 1-9 在每一列只能出现一次。数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。&#xff08…

【设计模式】(二)设计模式六大设计原则

一、 设计原则概述 设计模式中主要有六大设计原则,简称为SOLID ,是由于各个原则的首字母简称合并的来(两个L算一个,solid 稳定的),六大设计原则分别如下: ​ 1、单一职责原则(Single Responsibitity Principle&#…

Fiddler入门:下载、安装、配置、抓包、customize rules

一、fiddler下载安装 安装包下载链接:https://www.telerik.com/download/fiddler 随便选个用途,填写邮箱,地区选择China,勾选“I accept the Fiddler End User License Agreement”,点击“DownLoad for windows”&…

element loading遮罩层添加按钮

<el-table v-loading"loadingText" element-loading-text"拼命加载中" :data"tableData" :tableColumn"tableColumn" :span-method"objectSpanMethod" border :cell-style"cellStyle" :header-cell-style"…

备考2024年小学生古诗文大会:历年真题15题练习和独家解析

如何提高小学生古诗词的知识&#xff1f;如何激发小学生古诗词的学习兴趣&#xff1f;如何提高小学古诗词的学习成绩&#xff1f;如何备考2024年小学生古诗文大会&#xff1f;...如果你也在关心和这些问题&#xff0c;我的建议是参加每年一度的小学生古诗词大会&#xff08;免费…

安卓类加载机制

目录 一、ClassLoader介绍二、双亲委托机制三、类的加载过程 一、ClassLoader介绍 任何一个 Java 程序都是由一个或多个 class 文件组成&#xff0c;在程序运行时&#xff0c;需要将 class 文件加载到 JVM 中才可以使用&#xff0c;负责加载这些 class 文件的就是 Java 的类加…

【深圳五兴科技】Java后端面经

本文目录 写在前面试题总览1、java集合2、创建线程的方式3、对spring的理解4、Spring Boot 和传统 Spring 框架的一些区别5、springboot如何解决循环依赖6、对mybatis的理解7、缓存三兄弟8、接口响应慢的处理思路9、http的状态码 写在前面 关于这个专栏&#xff1a; 本专栏记录…

iOS消息转发流程

当向Objc对象发送消息时&#xff0c;如果找到对象对应的方法&#xff0c;就会进入消息转发流程&#xff0c;给开发者提供一些最后的机会处理消息无法发送问题&#xff0c;以免出现程序崩溃。 1. 回调对象的resolveInstanceMethod方法&#xff0c;在这个方法中&#xff0c;允许开…

LeetCode 热题 100 | 图论(二)

目录 1 基础知识 1.1 什么是拓扑排序 1.2 如何进行拓扑排序 1.3 拓扑排序举例 2 207. 课程表 3 210. 课程表 II 菜鸟做题&#xff0c;语言是 C 1 基础知识 1.1 什么是拓扑排序 含义&#xff1a;根据节点之间的依赖关系来生成一个有序的序列。 应用&#xff1a…

Mybatis实现分页查询数据(代码实操讲解)

在MyBatis中实现分页查询的常见方式有两种&#xff1a;使用MyBatis内置的分页插件如PageHelper&#xff0c;或者手动编写分页的SQL语句。下面我将为你提供两种方式的示例代码。 使用PageHelper分页插件 首先&#xff0c;确保你的项目中已经添加了PageHelper的依赖。在Maven项…

gpt批量工具,gpt批量生成文章工具

GPT批量工具在今天的数字化时代扮演着越来越重要的角色&#xff0c;它们通过人工智能技术&#xff0c;可以自动批量生成各种类型的文章&#xff0c;为用户提供了便利和效率。本文将介绍5款不同的GPT批量工具&#xff0c;并介绍一款知名的147GPT生成工具&#xff0c;以及另外一款…

js SheetJS 合并表格导出到同一个excel中

最近有个需求,我在一个页面显示了4个表格, 然后合并导出到excel文件中 四个表,四个sheet,一个excel文件 最后导出时这样: 实现: 1,页面有个导出的checkbox,勾选则导出,不勾选不处理 2,在一个函数中,集中处理四个表数据获取,并将结果返回出来 //获取数据后返回为…

代码随想录算法训练营第三十四天| 860.柠檬水找零 、406.根据身高重建队列 、452. 用最少数量的箭引爆气球

文章目录 1.柠檬水找零2.根据身高重建队列3.用最少数量的箭引爆气球 1.柠檬水找零 在柠檬水摊上&#xff0c;每一杯柠檬水的售价为 5 美元。顾客排队购买你的产品&#xff0c;&#xff08;按账单 bills 支付的顺序&#xff09;一次购买一杯。 每位顾客只买一杯柠檬水&#xf…

(四)关系模型之关系代数

4.1关系代数概述 基于集合&#xff0c;提供了一系列的关系代数操作&#xff1a;并、差、笛卡尔积(广义积)、 选择、投影和更名等基本操作以及交、 连接和关系除等扩展操作&#xff0c;是一种集合思维的操作语言。关系代数操作以一个或多个关系为输入&#xff0c;结果是一个新的…

食品加工生产污废水处理如何达标排放

食品加工行业作为一个重要的工业部门&#xff0c;在生产过程中产生大量的污废水。合理、高效地处理这些污废水&#xff0c;实现达标排放&#xff0c;是保护环境和促进可持续发展的重要举措。本文将探讨食品加工生产污废水处理的方法和措施&#xff0c;以达到达标排放的目标。 首…

FreeRTOS操作系统学习——内存管理

C库函数与FreeRTOS内存管理区别 在C语言的库函数中&#xff0c;有mallc、free等函数可以申请以及释放内存空间&#xff0c;那么这为什么不适用于FreeRTOS的内存管理呢&#xff1f; 不适合用在资源紧缺的嵌入式系统中这些函数的实现过于复杂、占据的代码空间太大并非线程安全的…

小黑长沙特种兵归来,身体比较虚弱的js逆向烧脑之路:招标网搜索数据获取

通过有道翻译逆向的初步尝试&#xff0c;这次尝试一下招标网的数据获取感觉轻松了许多!!加油小黑黑 寻找接口地址(通过响应部分&#xff0c;推断出该部分为搜索数据获取接口) 复制curl&#xff0c;构造Python请求信息 进入https://curlconverter.com/python/&#xff0c;通过c…

HarmonyOS创建项目和应用—设置数据处理位置

项目和应用介绍 关于项目 项目是资源、应用的组织实体。资源包括服务器、数据库、存储&#xff0c;以及您的应用、终端用户的数据等。在您使用部分服务时&#xff0c;您是数据的控制者&#xff0c;数据将按照您设置的数据处理位置来存储在指定区域。 通常&#xff0c;您不需…

HTTPS如何保证数据传输的安全性 以及CA签发证书验签

暴力输出&#xff1a; 越看会越深入&#xff0c;睡前难以想通&#xff0c;后深入研究。得之。 有问题 请留言。 ----------追求内心的富足与平和。日行一善。 亓苏姑娘

停止Tomcat服务的方式

运行脚本文件停止 运行Tomcat的bin目录中提供的停止服务的脚本文件 关闭命令 # sh方式 sh shutdown.sh# ./方式 ./shutdown.sh操作步骤 运行结束进程停止 查看Tomcat进程&#xff0c;获得进程id kill进程命令 # 执行命令结束进程 kill -9 65358 操作步骤 注意 kill命令是…