1.上传软件包

image.png
2.查看

  1. [root@localhost ~]# ll
  2. total 586356
  3. -rw-------. 1 root root 1552 Oct 17 13:45 anaconda-ks.cfg
  4. -rw-r--r--. 1 root root 600423080 Oct 18 21:09 gpmall-cloud.zip

3.安装依赖解压

  1. [root@localhost ~]# yum install -y unzip
  2. [root@localhost ~]# unzip gpmall-cloud.zip
  3. [root@localhost ~]# ll
  4. total 586356
  5. -rw-------. 1 root root 1552 Oct 17 13:45 anaconda-ks.cfg
  6. drwxr-xr-x. 4 root root 105 Oct 19 2021 gpmall-cloud
  7. -rw-r--r--. 1 root root 600423080 Oct 18 21:09 gpmall-cloud.zip
  8. [root@localhost ~]# cd gpmall-cloud
  9. [root@localhost gpmall-cloud]# ll
  10. total 92924
  11. drwxr-xr-x. 5 root root 53 Oct 19 2021 gpmall-repo
  12. drwxr-xr-x. 3 root root 200 Oct 19 2021 gpmall-single
  13. -rw-r--r--. 1 root root 57471165 Apr 29 2020 kafka_2.11-1.1.1.tgz
  14. -rw-r--r--. 1 root root 37676320 Apr 29 2020 zookeeper-3.4.14.tar.gz

4.修改主机名

  1. [root@localhost ~]# hostnamectl set-hostname mall
  2. [root@localhost ~]# su
  3. [root@mall ~]#

5.添加映射

  1. [root@mall ~]# vim /etc/hosts
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 192.168.200.10 mall

6.配置yum源

  1. [root@mall ~]# cd gpmall-cloud/gpmall-repo/
  2. [root@mall gpmall-repo]# pwd
  3. /root/gpmall-cloud/gpmall-repo
  4. [root@mall gpmall-repo]# vim /etc/yum.repos.d/local.repo
  5. [centos]
  6. name=centos7
  7. baseurl=file:///opt/centos
  8. gpgcheck=0
  9. enabled=1
  10. [gpmall]
  11. name=mall
  12. baseurl=file:///root/gpmall-cloud/gpmall-repo
  13. gpgcheck=0
  14. enabled=1
  15. [root@mall gpmall-repo]# yum clean all
  16. [root@mall gpmall-repo]# yum repolist

7.安装jdk、数据库、缓存、nginx服务

  1. [root@mall ~]# yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel redis nginx mariadb mariadb-server

8.关闭防火墙以及selinux

  1. // 关闭防火墙并设置开机不自启
  2. [root@mall ~]# systemctl stop firewalld && systemctl disable firewalld
  3. // 临时关闭selinux
  4. [root@mall ~]# setenforce 0
  5. // 查看jdk版本号
  6. [root@mall ~]# java -version
  7. openjdk version "1.8.0_242"
  8. OpenJDK Runtime Environment (build 1.8.0_242-b08)
  9. OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

9.配置zookeeper服务
image.png

  1. [root@mall ~]# cd gpmall-cloud
  2. [root@mall gpmall-cloud]# ll
  3. total 92924
  4. drwxr-xr-x. 5 root root 53 Oct 19 2021 gpmall-repo
  5. drwxr-xr-x. 3 root root 200 Oct 19 2021 gpmall-single
  6. -rw-r--r--. 1 root root 57471165 Apr 29 2020 kafka_2.11-1.1.1.tgz
  7. -rw-r--r--. 1 root root 37676320 Apr 29 2020 zookeeper-3.4.14.tar.gz
  8. // 解压zookeeper压缩包
  9. [root@mall gpmall-cloud]# tar -zxvf zookeeper-3.4.14.tar.gz
  10. [root@mall gpmall-cloud]# ll
  11. total 92928
  12. drwxr-xr-x. 5 root root 53 Oct 19 2021 gpmall-repo
  13. drwxr-xr-x. 3 root root 200 Oct 19 2021 gpmall-single
  14. -rw-r--r--. 1 root root 57471165 Apr 29 2020 kafka_2.11-1.1.1.tgz
  15. drwxr-xr-x. 14 2002 2002 4096 Mar 6 2019 zookeeper-3.4.14
  16. -rw-r--r--. 1 root root 37676320 Apr 29 2020 zookeeper-3.4.14.tar.gz
  17. // 进入zookeeper/conf目录下
  18. [root@mall gpmall-cloud]# cd zookeeper-3.4.14
  19. [root@mall zookeeper-3.4.14]# cd conf/
  20. // 给zoo_sample文件改名
  21. [root@mall conf]# ll
  22. total 12
  23. -rw-rw-r--. 1 2002 2002 535 Mar 6 2019 configuration.xsl
  24. -rw-rw-r--. 1 2002 2002 2161 Mar 6 2019 log4j.properties
  25. -rw-rw-r--. 1 2002 2002 922 Mar 6 2019 zoo_sample.cfg
  26. [root@mall conf]# mv zoo_sample.cfg zoo.cfg
  27. // 进入到zookeeper/bin目录下
  28. [root@mall conf]# cd ../bin/
  29. // 启动zookeeper服务
  30. [root@mall bin]# ./zkServer.sh start
  31. ZooKeeper JMX enabled by default
  32. Using config: /root/gpmall-cloud/zookeeper-3.4.14/bin/../conf/zoo.cfg
  33. Starting zookeeper ... STARTED
  34. // 查看zookeeper服务状态
  35. [root@mall bin]# ./zkServer.sh status
  36. ZooKeeper JMX enabled by default
  37. Using config: /root/gpmall-cloud/zookeeper-3.4.14/bin/../conf/zoo.cfg
  38. Mode: standalone

10.配置kafka
image.png

  1. // 进入root目录
  2. [root@mall bin]# cd
  3. [root@mall ~]# cd gpmall-cloud
  4. [root@mall gpmall-cloud]# ll
  5. total 92928
  6. drwxr-xr-x. 5 root root 53 Oct 19 2021 gpmall-repo
  7. drwxr-xr-x. 3 root root 200 Oct 19 2021 gpmall-single
  8. -rw-r--r--. 1 root root 57471165 Apr 29 2020 kafka_2.11-1.1.1.tgz
  9. drwxr-xr-x. 14 2002 2002 4096 Mar 6 2019 zookeeper-3.4.14
  10. -rw-r--r--. 1 root root 37676320 Apr 29 2020 zookeeper-3.4.14.tar.gz
  11. // 解压kafka压缩包
  12. [root@mall gpmall-cloud]# tar -zxvf kafka_2.11-1.1.1.tgz
  13. // 进入bin目录
  14. [root@mall gpmall-cloud]# cd kafka_2.11-1.1.1/bin/
  15. // 启动kafka服务
  16. [root@mall bin]# ./kafka-server-start.sh -daemon ../config/server.properties
  17. // 进入root目录,使用命令查看进程,有kafka服务证明启动无误
  18. [root@mall bin]# cd
  19. [root@mall ~]# jps
  20. 2768 Kafka
  21. 2833 Jps
  22. 2442 QuorumPeerMain
  23. // 安装net-tools(此工具用来查看端口号)
  24. [root@mall ~]# yum -y install net-tools
  25. // 查询到端口9092,对应的服务为kafka
  26. [root@mall ~]# netstat -ntpl
  27. Active Internet connections (only servers)
  28. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  29. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 967/sshd
  30. tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1188/master
  31. tcp6 0 0 :::37601 :::* LISTEN 2768/java
  32. tcp6 0 0 :::9092 :::* LISTEN 2768/java
  33. tcp6 0 0 :::2181 :::* LISTEN 2442/java
  34. tcp6 0 0 :::22 :::* LISTEN 967/sshd
  35. tcp6 0 0 ::1:25 :::* LISTEN 1188/master
  36. tcp6 0 0 :::42174 :::* LISTEN 2442/java

11.配置数据库

  1. [root@mall ~]# vi /etc/my.cnf
  2. #
  3. # This group is read both both by the client and the server
  4. # use it for options that affect everything
  5. #
  6. [client-server]
  7. #
  8. # include all files from the config directory
  9. #
  10. !includedir /etc/my.cnf.d
  11. [mysqld] // 从此行开始插入
  12. init_connect='SET collation_connection = utf8_unicode_ci'
  13. init_connect='SET NAMES utf8'
  14. character-set-server=utf8
  15. collation-server=utf8_unicode_ci
  16. skip-character-set-client-handshake
  17. // 重启数据库服务
  18. [root@mall ~]# systemctl restart mariadb
  19. // 设置数据库开机自启
  20. [root@mall ~]# systemctl enable mariadb
  21. // 初始化数据库服务,使用此命令必须保证数据库已经启动否则无效
  22. [root@mall ~]# mysql_secure_installation
  23. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
  24. SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
  25. In order to log into MariaDB to secure it, we'll need the current
  26. password for the root user. If you've just installed MariaDB, and
  27. you haven't set the root password yet, the password will be blank,
  28. so you should just press enter here.
  29. Enter current password for root (enter for none):
  30. OK, successfully used password, moving on...
  31. Setting the root password ensures that nobody can log into the MariaDB
  32. root user without the proper authorisation.
  33. Set root password? [Y/n] y
  34. New password: // 设置密码为123456,必须设置为123456,否则后面对接jar包不成功,造成商城页面不可弹出
  35. Re-enter new password: // 再输入一遍
  36. Password updated successfully!
  37. Reloading privilege tables..
  38. ... Success!
  39. By default, a MariaDB installation has an anonymous user, allowing anyone
  40. to log into MariaDB without having to have a user account created for
  41. them. This is intended only for testing, and to make the installation
  42. go a bit smoother. You should remove them before moving into a
  43. production environment.
  44. Remove anonymous users? [Y/n] y //询问是否移除匿名用户--y
  45. ... Success!
  46. Normally, root should only be allowed to connect from 'localhost'. This
  47. ensures that someone cannot guess at the root password from the network.
  48. Disallow root login remotely? [Y/n] n //询问是否禁止远程登陆--n
  49. ... skipping.
  50. By default, MariaDB comes with a database named 'test' that anyone can
  51. access. This is also intended only for testing, and should be removed
  52. before moving into a production environment.
  53. Remove test database and access to it? [Y/n] y //询问是否移除匿名用户--y
  54. - Dropping test database...
  55. ... Success!
  56. - Removing privileges on test database...
  57. ... Success!
  58. Reloading the privilege tables will ensure that all changes made so far
  59. will take effect immediately.
  60. Reload privilege tables now? [Y/n] y //询问是否刷新权限--y
  61. ... Success!
  62. Cleaning up...
  63. All done! If you've completed all of the above steps, your MariaDB
  64. installation should now be secure.
  65. Thanks for using MariaDB!
  66. // 登录数据库,用户为root,密码为123456
  67. [root@mall ~]# mysql -uroot -p123456
  68. Welcome to the MariaDB monitor. Commands end with ; or \g.
  69. Your MariaDB connection id is 15
  70. Server version: 10.3.18-MariaDB MariaDB Server
  71. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  72. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  73. MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;
  74. Query OK, 0 rows affected (0.000 sec) //授权所有用户拥有本地数据库的所有权限
  75. MariaDB [(none)]> grant all privileges on *.* to root@"%" identified by '123456' with grant option;
  76. Query OK, 0 rows affected (0.000 sec) //赋予任何远程主机用root用户连接到mysql 所有库的权限,密码为123456
  77. MariaDB [(none)]> create database gpmall;
  78. Query OK, 1 row affected (0.000 sec)
  79. MariaDB [(none)]> use gpmall;
  80. Database changed
  1. // 将本地数据导入到数据库中
  2. MariaDB [gpmall]> source /root/gpmall-cloud/gpmall-single/gpmall.sql
  3. Query OK, 0 rows affected (0.000 sec)
  4. Query OK, 0 rows affected (0.000 sec)
  5. Query OK, 0 rows affected, 1 warning (0.001 sec)
  6. Query OK, 0 rows affected (0.003 sec)
  7. Query OK, 1 row affected (0.001 sec)
  8. Query OK, 1 row affected (0.001 sec)
  9. Query OK, 1 row affected (0.001 sec)
  10. Query OK, 0 rows affected, 1 warning (0.000 sec)
  11. Query OK, 0 rows affected (0.004 sec)
  12. Query OK, 1 row affected (0.001 sec)
  13. Query OK, 0 rows affected, 1 warning (0.000 sec)
  14. Query OK, 0 rows affected (0.004 sec)
  15. Query OK, 0 rows affected, 1 warning (0.000 sec)
  16. Query OK, 0 rows affected (0.003 sec)
  17. Query OK, 0 rows affected, 1 warning (0.000 sec)
  18. Query OK, 0 rows affected (0.003 sec)
  19. Query OK, 0 rows affected, 1 warning (0.000 sec)
  20. Query OK, 0 rows affected (0.002 sec)
  21. Query OK, 1 row affected (0.001 sec)
  22. Query OK, 1 row affected (0.000 sec)
  23. Query OK, 1 row affected (0.001 sec)
  24. Query OK, 0 rows affected, 1 warning (0.000 sec)
  25. Query OK, 0 rows affected (0.003 sec)
  26. Query OK, 1 row affected (0.001 sec)
  27. Query OK, 0 rows affected, 1 warning (0.000 sec)
  28. Query OK, 0 rows affected (0.004 sec)
  29. Query OK, 1 row affected (0.001 sec)
  30. Query OK, 1 row affected (0.001 sec)
  31. Query OK, 1 row affected (0.001 sec)
  32. Query OK, 1 row affected (0.001 sec)
  33. Query OK, 1 row affected (0.000 sec)
  34. Query OK, 1 row affected (0.001 sec)
  35. Query OK, 1 row affected (0.041 sec)
  36. Query OK, 1 row affected (0.001 sec)
  37. Query OK, 1 row affected (0.001 sec)
  38. Query OK, 1 row affected (0.001 sec)
  39. Query OK, 1 row affected (0.000 sec)
  40. Query OK, 1 row affected (0.001 sec)
  41. Query OK, 1 row affected (0.000 sec)
  42. Query OK, 1 row affected (0.001 sec)
  43. Query OK, 1 row affected (0.000 sec)
  44. Query OK, 1 row affected (0.001 sec)
  45. Query OK, 1 row affected (0.000 sec)
  46. Query OK, 1 row affected (0.001 sec)
  47. Query OK, 1 row affected (0.000 sec)
  48. Query OK, 1 row affected (0.001 sec)
  49. Query OK, 1 row affected (0.000 sec)
  50. Query OK, 1 row affected (0.001 sec)
  51. Query OK, 1 row affected (0.001 sec)
  52. Query OK, 0 rows affected, 1 warning (0.000 sec)
  53. Query OK, 0 rows affected (0.003 sec)
  54. Query OK, 1 row affected (0.001 sec)
  55. Query OK, 1 row affected (0.000 sec)
  56. Query OK, 1 row affected (0.001 sec)
  57. Query OK, 1 row affected (0.000 sec)
  58. Query OK, 1 row affected (0.001 sec)
  59. Query OK, 1 row affected (0.000 sec)
  60. Query OK, 1 row affected (0.001 sec)
  61. Query OK, 1 row affected (0.001 sec)
  62. Query OK, 1 row affected (0.001 sec)
  63. Query OK, 1 row affected (0.000 sec)
  64. Query OK, 1 row affected (0.001 sec)
  65. Query OK, 1 row affected (0.001 sec)
  66. Query OK, 1 row affected (0.001 sec)
  67. Query OK, 1 row affected (0.000 sec)
  68. Query OK, 1 row affected (0.001 sec)
  69. Query OK, 1 row affected (0.001 sec)
  70. Query OK, 1 row affected (0.001 sec)
  71. Query OK, 1 row affected (0.000 sec)
  72. Query OK, 1 row affected (0.001 sec)
  73. Query OK, 1 row affected (0.000 sec)
  74. Query OK, 1 row affected (0.000 sec)
  75. Query OK, 1 row affected (0.001 sec)
  76. Query OK, 1 row affected (0.000 sec)
  77. Query OK, 1 row affected (0.001 sec)
  78. Query OK, 1 row affected (0.000 sec)
  79. Query OK, 1 row affected (0.001 sec)
  80. Query OK, 0 rows affected, 1 warning (0.000 sec)
  81. Query OK, 0 rows affected (0.002 sec)
  82. Query OK, 1 row affected (0.001 sec)
  83. Query OK, 1 row affected (0.000 sec)
  84. Query OK, 1 row affected (0.001 sec)
  85. Query OK, 1 row affected (0.001 sec)
  86. Query OK, 1 row affected (0.001 sec)
  87. Query OK, 1 row affected (0.000 sec)
  88. Query OK, 1 row affected (0.000 sec)
  89. Query OK, 1 row affected (0.001 sec)
  90. Query OK, 1 row affected (0.000 sec)
  91. Query OK, 1 row affected (0.001 sec)
  92. Query OK, 1 row affected (0.000 sec)
  93. Query OK, 1 row affected (0.001 sec)
  94. Query OK, 1 row affected (0.001 sec)
  95. Query OK, 1 row affected (0.001 sec)
  96. Query OK, 1 row affected (0.000 sec)
  97. Query OK, 1 row affected (0.001 sec)
  98. Query OK, 1 row affected (0.000 sec)
  99. Query OK, 1 row affected (0.001 sec)
  100. Query OK, 1 row affected (0.000 sec)
  101. Query OK, 1 row affected (0.001 sec)
  102. Query OK, 1 row affected (0.000 sec)
  103. Query OK, 1 row affected (0.001 sec)
  104. Query OK, 1 row affected (0.000 sec)
  105. Query OK, 0 rows affected, 1 warning (0.000 sec)
  106. Query OK, 0 rows affected (0.002 sec)
  107. Query OK, 0 rows affected, 1 warning (0.000 sec)
  108. Query OK, 0 rows affected (0.003 sec)
  109. Query OK, 1 row affected (0.001 sec)
  110. Query OK, 1 row affected (0.001 sec)
  111. Query OK, 1 row affected (0.000 sec)
  112. Query OK, 0 rows affected, 1 warning (0.000 sec)
  113. Query OK, 0 rows affected (0.015 sec)
  114. Query OK, 1 row affected (0.001 sec)
  115. Query OK, 0 rows affected, 1 warning (0.000 sec)
  116. Query OK, 0 rows affected (0.004 sec)
  117. Query OK, 0 rows affected, 1 warning (0.000 sec)
  118. Query OK, 0 rows affected (0.003 sec)
  119. Query OK, 1 row affected (0.001 sec)
  120. Query OK, 0 rows affected, 1 warning (0.000 sec)
  121. Query OK, 0 rows affected (0.003 sec)
  122. Query OK, 1 row affected (0.000 sec)
  123. Query OK, 1 row affected (0.001 sec)
  124. Query OK, 1 row affected (0.000 sec)
  125. Query OK, 1 row affected (0.001 sec)
  126. Query OK, 1 row affected (0.001 sec)
  127. Query OK, 1 row affected (0.000 sec)
  128. Query OK, 1 row affected (0.000 sec)
  129. Query OK, 0 rows affected, 1 warning (0.000 sec)
  130. Query OK, 0 rows affected (0.004 sec)
  131. Query OK, 1 row affected (0.000 sec)
  132. Query OK, 1 row affected (0.001 sec)
  133. Query OK, 1 row affected (0.006 sec)
  134. Query OK, 1 row affected (0.001 sec)
  135. Query OK, 1 row affected (0.001 sec)
  136. Query OK, 1 row affected (0.000 sec)
  137. Query OK, 1 row affected (0.001 sec)
  138. Query OK, 1 row affected (0.000 sec)
  139. Query OK, 1 row affected (0.000 sec)
  140. Query OK, 1 row affected (0.001 sec)
  141. Query OK, 1 row affected (0.000 sec)
  142. Query OK, 1 row affected (0.001 sec)
  143. Query OK, 1 row affected (0.000 sec)
  144. Query OK, 1 row affected (0.001 sec)
  145. Query OK, 1 row affected (0.000 sec)
  146. Query OK, 1 row affected (0.001 sec)
  147. Query OK, 1 row affected (0.000 sec)
  148. Query OK, 1 row affected (0.001 sec)
  149. Query OK, 1 row affected (0.001 sec)
  150. Query OK, 1 row affected (0.001 sec)
  151. Query OK, 1 row affected (0.000 sec)
  152. Query OK, 1 row affected (0.001 sec)
  153. Query OK, 1 row affected (0.000 sec)
  154. Query OK, 1 row affected (0.001 sec)
  155. Query OK, 1 row affected (0.000 sec)
  156. Query OK, 1 row affected (0.001 sec)
  157. Query OK, 1 row affected (0.000 sec)
  158. Query OK, 1 row affected (0.001 sec)
  159. Query OK, 1 row affected (0.000 sec)
  160. Query OK, 1 row affected (0.001 sec)
  161. Query OK, 1 row affected (0.000 sec)
  162. Query OK, 1 row affected (0.001 sec)
  163. Query OK, 1 row affected (0.000 sec)
  164. Query OK, 1 row affected (0.001 sec)
  165. Query OK, 1 row affected (0.001 sec)
  166. Query OK, 1 row affected (0.001 sec)
  167. Query OK, 1 row affected (0.000 sec)
  168. Query OK, 1 row affected (0.000 sec)
  169. Query OK, 1 row affected (0.000 sec)
  170. Query OK, 0 rows affected, 1 warning (0.000 sec)
  171. Query OK, 0 rows affected (0.002 sec)
  172. Query OK, 0 rows affected, 1 warning (0.000 sec)
  173. Query OK, 0 rows affected (0.003 sec)
  174. Query OK, 0 rows affected, 1 warning (0.000 sec)
  175. Query OK, 0 rows affected (0.002 sec)
  176. Query OK, 0 rows affected, 1 warning (0.000 sec)
  177. Query OK, 0 rows affected (0.003 sec)
  178. Query OK, 1 row affected (0.001 sec)
  179. Query OK, 0 rows affected (0.000 sec)

12.配置redis服务

  1. // 编辑redis配置文件
  2. [root@mall ~]# vi /etc/redis.conf
  3. 进入文件后,不要做任何操作,直接输入:set nu显示行号,然后将文本改为插入模式,将第61行前加#进行注释,再将第80行中的yes改为no,最后保存退出
  4. // 更改文件后,重启redis服务
  5. [root@mall ~]# systemctl restart redis
  6. // 设置redis服务开机自启
  7. [root@mall ~]# systemctl enable redis
  8. Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
  9. // 查看端口号,找到6379端口,对应的服务为redis
  10. [root@mall ~]# netstat -ntpl
  11. Active Internet connections (only servers)
  12. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  13. tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 3030/redis-server *
  14. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 967/sshd
  15. tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1188/master
  16. tcp6 0 0 :::37601 :::* LISTEN 2768/java
  17. tcp6 0 0 :::9092 :::* LISTEN 2768/java
  18. tcp6 0 0 :::2181 :::* LISTEN 2442/java
  19. tcp6 0 0 :::3306 :::* LISTEN 2902/mysqld
  20. tcp6 0 0 :::6379 :::* LISTEN 3030/redis-server *
  21. tcp6 0 0 :::22 :::* LISTEN 967/sshd
  22. tcp6 0 0 ::1:25 :::* LISTEN 1188/master
  23. tcp6 0 0 :::42174 :::* LISTEN 2442/java

13.配置nginx服务

  1. // 删除Nginx服务站点目录下所有内容
  2. [root@mall ~]# rm -rf /usr/share/nginx/html/*
  3. // 将本地web包拷贝到站点目录下
  4. [root@mall ~]# cp -rvf gpmall-cloud/gpmall-single/dist/* /usr/share/nginx/html/
  5. // 编辑nginx的配置文件(进入配置文件后找到第一个location,将下面内容添加进去)
  6. [root@mall ~]# vi /etc/nginx/conf.d/default.conf
  7. location /user {
  8. proxy_pass http://127.0.0.1:8082;
  9. }
  10. location /shopping {
  11. proxy_pass http://127.0.0.1:8081;
  12. }
  13. location /cashier {
  14. proxy_pass http://127.0.0.1:8083;
  15. }
  16. // 添加完成后重启nginx服务,如果遇到服务报错,则检查Nginx配置文件是否正确
  17. [root@mall ~]# systemctl restart nginx
  18. // 查看端口号,有无80端口暴露,对应服务为nginx
  19. [root@mall ~]# netstat -ntpl
  20. Active Internet connections (only servers)
  21. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  22. tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 3030/redis-server *
  23. tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3068/nginx: master
  24. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 967/sshd
  25. tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1188/master
  26. tcp6 0 0 :::37601 :::* LISTEN 2768/java
  27. tcp6 0 0 :::9092 :::* LISTEN 2768/java
  28. tcp6 0 0 :::2181 :::* LISTEN 2442/java
  29. tcp6 0 0 :::3306 :::* LISTEN 2902/mysqld
  30. tcp6 0 0 :::6379 :::* LISTEN 3030/redis-server *
  31. tcp6 0 0 :::22 :::* LISTEN 967/sshd
  32. tcp6 0 0 ::1:25 :::* LISTEN 1188/master
  33. tcp6 0 0 :::42174 :::* LISTEN 2442/java

14.部署后端jar包

  1. // 进入存放后端jar包文件目录
  2. [root@mall ~]# cd gpmall-cloud/gpmall-single/
  3. [root@mall gpmall-single]#
  4. // 编辑映射
  5. [root@mall gpmall-single]# vi /etc/hosts
  6. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.lo
  7. caldomain4
  8. ::1 localhost localhost.localdomain localhost6 localhost6.lo
  9. caldomain6
  10. 192.168.200.10 mall
  11. 192.168.200.10 redis.mall
  12. 192.168.200.10 kafka.mall
  13. 192.168.200.10 zookeeper.mall
  14. 192.168.200.10 mysql.mall
  15. // 分别在后台,启动下面四个jar包
  16. [root@mall gpmall-single]# nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &
  17. [root@mall gpmall-single]# nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &
  18. [root@mall gpmall-single]# nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &
  19. [root@mall gpmall-single]# nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &
  20. 注意:如果在命令启动过程中遇到EXIT字样,则为jar包出现闪退,检查前面所部署的服务是否运行正常,以及主机名映射文件是否书写正确

15.浏览器验证
如果前面每个服务都运行正常,且jar包没有出现闪退,那么使用浏览器输入192.168.200.11进行验证,如果发现有图片并且有文字出现,则gpmall商城部署正常。
image.png
16.将gpmall前端页面使用命令获取

  1. [root@mall ~]# curl http://192.168.200.10/#/home
  2. <!DOCTYPE html><html><head><meta charset=utf-8><title>1+x-示例项目</title><meta name=keywords content=""><meta name=description content=""><meta http-equiv=X-UA-Compatible content="IE=Edge"><meta name=wap-font-scale content=no><link rel="shortcut icon " type=images/x-icon href=/static/images/favicon.ico><link href=/static/css/app.8d4edd335a61c46bf5b6a63444cd855a.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2d17a82764acff8145be.js></script><script type=text/javascript src=/static/js/vendor.4f07d3a235c8a7cd4efe.js></script><script type=text/javascript src=/static/js/app.81180cbb92541cdf912f.js></script></body></html><style>body{
  3. min-width:1250px;
  4. }</style>[root@mall ~]#