hostnamectl set-hostname mall //修改主机名
bash
vim /etc/hosts //修改主机hosts,将以下信息输入
[ip] mall
#添加mall源
vim /etc/yum.repos.d/local.repo 配置本地源,添加mall源
[mall]
name=mall
baseurl=file:///root/gpmall-repo
gpgcheck=0
enabled=1
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel //安装java
java -version //查看java是否安装成功&java版本
yum install redis -y //安装reids服务
yum install nginx -y //安装nginx
yum install mariadb mariadb-server -y //安装mariadb服务
systemctl start mariadb //启动mariadb服务
mysql_secure_installation
mysql -uroot -p123456 //进入数据库
create database gpmall; //创建gpmall数据表
use gpmall; //选择gpmall数据表
source /root/gpmall-single/gpmall.sql //导入数据库
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; //添加用户并授权
flush privileges; //刷新权限
#修改mariadb配置文件
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 restart mariadb //重启mariadb服务
systemctl enable mariadb //将mariadb服务加入自启
tar xzvf kafka_2.11-1.1.1.tgz //解压
tar xzvf zookeeper-3.4.14.tar.gz //解压
cd zookeeper-3.4.14/conf //进入zookeeper配置目录
mv zoo_sample.cfg zoo.cfg //单节点,将zoo_sample.cfg改为zoo.cfg
cd ../bin/ //进入同级目录bin
./zkServer.sh start //启动服务
cd root/kafka_2.11-1.1.1/bin/ //进入kafka目录
./kafka-server-start.sh -daemon ../config/server.properties //启动kafka服务
netstat -ntpl| grep 9092 //查看端口
vim /etc/redis.conf //配置redis配置文件
将第二个`bind 127.0.0.1` 注销掉;将protected-mode yes 改为protected-mode no
systemctl restart redis //重启redis服务
查询服务器端口
netstat -ntpl //查看所有端口
vim /etc/hosts //修改hosts文件
[ip] kafka.mall
[ip] mysql.mall
[ip] redis.mall
[ip] zookeeper.mall
#部署前端
rm -rf /usr/share/nginx/html/* //删除原有的前端文件
cp -rvf root/gpmall-single/dist/* /usr/share/nginx/html/ //把商城前端文件复制过去
vi /etc/nginx/conf.d/default.conf //修改nginx的默认配置文件,将以下内容放进去
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
#启动后端
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 &
#访问
http://[ip]
版权属于:kenvie
本文链接:https://cloud.tencent.com/developer/article/1937666
商业转载请联系作者获得授权,非商业转载请注明出处。