应用系统基础服务安装

IPHostname备注
192.168.88.50mall内存:6G

环境说明:firewalld关闭,selinux关闭。
1.修改主机名

[root@localhost ~]# hostnamectl set-hostname mall
[root@localhost ~]# bash
[root@mall ~]# hostname
mall
[root@mall ~]# vi /etc/hosts		//添加解析
192.168.88.50   mall

2.配置本地yum源

[root@mall ~]# vi /etc/yum.repos.d/local.repo 
[gpmall]
name=gpmall
baseurl=file:///root/gpmall-repo/
enabled=1
gpgcheck=0
[root@mall ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.nju.edu.cn
repo id                                      repo name                                       status
base/7/x86_64                                CentOS-7 - Base                                 10,097
extras/7/x86_64                              CentOS-7 - Extras                                  335
gpmall                                       gpmall                                             165
updates/7/x86_64                             CentOS-7 - Updates                               1,774
repolist: 12,371

3.安装基础服务,包括Java JDK环境、数据库、Redis、elasticsearch、Nginx、zookeeper、Kafka。

安装Java JDK环境
[root@mall ~]# yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
[root@mall ~]# java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

安装redis缓存服务
[root@mall ~]# yum -y install redis

安装elasticsearch
[root@mall ~]# yum -y install elasticsearch 

安装Nginx服务
[root@mall ~]# yum -y install nginx 

安装Mariadb数据库
[root@mall ~]# yum -y install mariadb mariadb-server

安装zookeeper服务
[root@mall ~]# tar -zxvf zookeeper-3.4.14.tar.gz 
[root@mall ~]# mv zookeeper-3.4.14/conf/zoo_sample.cfg zookeeper-3.4.14/conf/zoo.cfg		//将zoo_sample.cfg文件重命名为zoo.cfg
[root@mall ~]# cd zookeeper-3.4.14/bin/
[root@mall bin]# ./zkServer.sh start		//启动zookeeper
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@mall bin]# ./zkServer.sh status		//查看状态
ZooKeeper JMX enabled by default	
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: standalone

安装kafka服务
[root@mall ~]# tar -zxvf kafka_2.11-1.1.1.tgz 
[root@mall ~]# cd kafka_2.11-1.1.1/bin/		
[root@mall bin]# ./kafka-server-start.sh -daemon ../config/server.properties 	//启动kafka服务
[root@mall bin]# jps		//查看kafka是否启动成功
2864 Jps
2504 QuorumPeerMain
2827 Kafka
[root@mall bin]# netstat -lnt			//查看kafka服务的9092端口是否开启
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN     
tcp6       0      0 :::9092                 :::*                    LISTEN     
tcp6       0      0 :::42213                :::*                    LISTEN     
tcp6       0      0 :::2181                 :::*                    LISTEN     
tcp6       0      0 :::35429                :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN    

4.配置启动mariadb、redis、elasticsearch、nginx服务

配置启动mariadb服务
[root@mall ~]# vi /etc/my.cnf   //在末尾行添加
[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
[root@mall ~]# systemctl start mariadb		//启动mariadb
[root@mall ~]# systemctl enable mariadb		//设置开机自启动mariadb
[root@mall ~]# mysqladmin -uroot password 123456	//设置mariadb root密码
[root@mall ~]# mysql -uroot -p123456		
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)

MariaDB [(none)]> create database gpmall;		//创建数据库
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> use gpmall;
Database changed
MariaDB [gpmall]> source /root/gpmall/gpmall.sql;	//导入数据
MariaDB [gpmall]> quit
Bye

配置启动redis服务
[root@mall ~]# vi /etc/redis.conf 		//修改以下两处
#bind 127.0.0.1				//注释此行
protected-mode no			//yes改为no
[root@mall ~]# systemctl start redis		//启动redis
[root@mall ~]# systemctl enable redis		//设置开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

配置启动elasticsearch服务
[root@mall ~]# vi /etc/elasticsearch/elasticsearch.yml 
  //最上行添加3行配置
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true

cluster.name: my-application		//去掉注释
node.name: node-1					//去掉注释
network.host: 192.168.88.50			//去掉注释,改为本机ip
http.port: 9200						//去掉注释
[root@mall ~]# systemctl start elasticsearch		//启动elasticsearch
[root@mall ~]# systemctl enable elasticsearch		//设置开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

启动nginx服务
[root@mall ~]# systemctl start nginx
[root@mall ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

5.实施部署

前端部署
[root@mall ~]# vi /etc/hosts			//重新修改/etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.88.50   kafka.mall
192.168.88.50   mysql.mall
192.168.88.50   redis.mall
192.168.88.50   zookeeper.mall
[root@mall ~]# rm -rf /usr/share/nginx/html/*		//删除nginx默认项目根目录下的文件
[root@mall ~]# cp -rvf /root/gpmall/dist/* /usr/share/nginx/html/	//将前端文件cp到默认项目根目录下
[root@mall ~]# vi /etc/nginx/conf.d/default.conf 
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }									//在此行下面添加3条配置
 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;
[root@mall ~]# systemctl restart nginx			//重启nginx

后端部署
[root@mall ~]# cd gpmall
[root@mall gpmall]# nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &
[1] 12290
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’

[root@mall gpmall]# nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &    
[2] 12306
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’

[root@mall gpmall]# nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &
[3] 12352
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’

[root@mall gpmall]# nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &    
[4] 12379
[root@mall gpmall]# nohup: ignoring input and appending output to ‘nohup.out’

[root@mall gpmall]# jps			//4个jar
12352 jar
11553 QuorumPeerMain
11842 Kafka
12290 jar
12306 jar
12071 Elasticsearch
12379 jar
12397 Jps

网页效果:
在这里插入图片描述

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值