Gpmall--容器商城系统(单节点)

目录

一。应用系统基础服务安装

1.修改/etc/hosts配置文件

2.配置本地yum源

3.安装基础服务

  (1)安装Java环境

(2)安装redis缓存服务

(3)安装elastic search服务

(4)安装nginx服务

(5)安装MariaDB数据库

(6)安装ZooKeeper服务

(7)安装Kafka服务

4.启动服务

(1)启动数据库并配置

(2)启动Redis服务

(3)配置Elasticsearch服务并启动

(4)启动Nginx服务

二.应用系统部署

1.修改全局变量配置

2.部署前端

3.部署后端

4.网站访问


一。应用系统基础服务安装

1.修改/etc/hosts配置文件

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.222.154  mall

2.配置本地yum源

  将gpmall-repo包传到服务器的/root目录下,并配置本地local.repo文件

[root@mall ~]# vi /etc/yum.repos.d/local.repo 
[mall]
name=mall
baseurl=file:///root/gpmall-repo
gpgcheck=0
enabled=1
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1

  这里我使用的是1804镜像,所以还要挂载镜像

#mkdir -p /opt/centos
#mount CentOS-7.5-x86_64-DVD-(1)1804.iso  /opt/centos
#yum clean all
#yum repolist

3.安装基础服务

  (1)安装Java环境

# yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

(2)安装redis缓存服务

# yum install redis -y

(3)安装elastic search服务

#yum install elasticsearch -y

(4)安装nginx服务

# yum install nginx -y

(5)安装MariaDB数据库

# yum install mariadb mariadb-server -y

(6)安装ZooKeeper服务

将提供的zookeeper-3.4.14.tar.gz上传至云主机的/opt内

# tar -zxvf zookeeper-3.4.14.tar.gz

进入到zookeeper-3.4.14/conf目录下,将zoo_sample.cfg文件重命名为zoo.cfg

# mv zoo_sample.cfg zoo.cfg

进入到zookeeper-3.4.14/bin目录下,启动ZooKeeper服务

#./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

查看ZooKeeper状态

#./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: standalone

(7)安装Kafka服务

将提供的kafka_2.11-1.1.1.tgz包上传到云主机的/opt目录下,解压该压缩包

#tar -zxvf kafka_2.11-1.1.1.tgz

进入到kafka_2.11-1.1.1/bin目录下,启动Kafka服务

# ./kafka-server-start.sh -daemon ../config/server.properties

使用jps或者netstat –ntpl命令查看Kafka是否成功启动

#jps
6039 Kafka
1722 QuorumPeerMain
6126 Jps

并查看端口netstat -ntpl,运行结果查看到Kafka服务和9092端口,说明Kafka服务已启动。

4.启动服务

(1)启动数据库并配置

修改数据库配置文件并启动MariaDB数据库,设置root用户密码为123456,并创建gpmall数据库,将提供的gpmall.sql导入。

修改/etc/my.cnf文件

# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

启动数据库命令

# systemctl start mariadb

设置root用户的密码为123456并登录。

# mysql_secure_installation

第一个默认按回车、第二个y并输入密码123456.重复输入密码123456、第三个y、第四个n、第五个y、第六个y。

进入数据库,将gpmall.sql文件上传至云主机的/root目录下。创建数据库gpmall并导入gpmall.sql文件。

# mysql -uroot –p123456
MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;
MariaDB [(none)]> grant all privileges on *.* to root@"%" identified by '123456' with grant option;
MariaDB [(none)]> create database gpmall;
MariaDB [(none)]> use gpmall;
MariaDB [mall]> source /root/gpmall.sql
MariaDB [mall]> Ctrl-C -- exit!
Aborted
#systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

(2)启动Redis服务

修改Redis配置文件,编辑/etc/redis.conf文件。

将bind 127.0.0.1这一行注释掉;将protected-mode yes 改为 protected-mode no。

启动Redis服务命令如下

# systemctl start redis
# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

(3)配置Elasticsearch服务并启动

配置Elasticsearch服务命令

# vi /etc/elasticsearch/elasticsearch.yml

在文件最上面加入3条语句如下:

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true

将如下4条语句前的注释符去掉,并修改network.host的IP为本机IP

cluster.name: my-application
node.name: node-1
network.host: 192.168.222.154
http.port: 9200

最后修改完之后保存退出。然后启动Elasticsearch并设置开机自启

# systemctl start elasticsearch
# systemctl enable elasticsearch
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service

(4)启动Nginx服务

启动Nginx服务命令

# systemctl start nginx
# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

至此安装已全部完成。

二.应用系统部署

1.修改全局变量配置

修改/etc/hosts文件,添加IP

# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.222.154 mall
192.168.222.154 kafka.mall
192.168.222.154 mysql.mall
192.168.222.154 redis.mall
192.168.222.154 zookeeper.mall

2.部署前端

将dist目录上传至服务器的/root目录下。接着将dist目录下的文件,复制到Nginx默认项目路径

# rm -rf /usr/share/nginx/html/*
# cp -rvf dist/* /usr/share/nginx/html/

修改Nginx配置文件/etc/nginx/conf.d/default.conf,添加映射

# vi /etc/nginx/conf.d/default.conf
 #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;
        }

    location /cashier {
            proxy_pass http://127.0.0.1:8083;
        }
    #error_page  404              /404.html;

重启nginx服务

# systemctl restart nginx

3.部署后端

将提供的4个jar包上传到服务器的/root目录下,并启动

# nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &
# nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &
# nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &
# nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &

4.网站访问

http://192.168.222.154

点击头像进行登录用户名test密码test

你可能感兴趣的