1.节点规划
Ip地址 | 主机名 | 节点 |
192.168.119.219 | server | 单节点服务器 |
2.基础配置
2.1更改主机名
[root@server ~]# hostnamectl set-hostname server
[root@server ~]# bash
2.2配置yum源
将提供的gpmall包上传至虚拟机中,然后在/etc/yum.repos.d/local.repo添加如下配置
[server]
name=server
baseurl=file:///root/gpmall-repo
gpgcheck=0
enabled=1
2.3安装java环境
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
2.4安装redis
[root@server ~]# yum install -y redis
2.5安装mariadb数据库
yum install mariadb mariadb-server -y
2.6安装nginx
yum install -y nginx
3.启动服务
3.1redis服务
编辑 vim /etc/redis.conf文件
将bind 127.0.0.1注释掉,将protecte-mode yes改为no
systemctl start redis;systemctl enable redis
3.2mariadb数据库
修改配置文件vim /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
启动数据库并初始化
systemctl start mariadb;
mysql_secure_installation
进入数据库并设置权限
grant all privileges on *.* to root@localhost identified by '123456' with grant option;
grant all privileges on *.* to root@"%" identified by '123456' with grant option;
将gpmall.sql上传至/root,创建gpmall数据库并导入数据
Create database gpmall;
use gpmall;
source /root/gpmall.sql
3.3zookeeper
将提供的zookeeper包上传至/root,并解压
tar -zxvf zookeeper-3.4.14.tar.gz
进入/bin目录启动zookeeper服务和查看服务状态
./zkServer.sh start;./zkServer.sh status
3.4kafka
上传提供的kafka到/root,并解压
tar -zxvf kafka_2.11-1.1.1.tgz
进入kafka_2.11-1.1.1/bin并启动
./kafka-server-start.sh -daemon ../config/server.properties
使用jps查看是否开启
3.5nginx
将提供的dist文件上传到/root目录,先清空默认路径下的文件在进行复制
rm -rf /usr/share/nginx/html/*;
cp -rvf dist/* /usr/share/nginx/html/
修改nginx配置文件,vim /etc/nginx/conf.d/default.conf
添加如下信息
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;
}
重启nginx
Systemctl restart nginx
3.6全局变量
配置vim /etc/hosts文件
3.7运行jar包
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 &
3.8登录网页
在浏览器访问http://192.168.119.219
显示出如图界面,表示企业单节点部署gpmall商城成功