1、修改主机名[root@xnode1 ~]# hostnamectl set-hostname mall //修改主机名,修改完成使用ctrl+d退出登录2、添加主机名映射文件[root@mall ~]# vi /etc/hosts //编辑主机名映射文件127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.200.11 mall192.168.200.11 redis.mall192.168.200.11 kafka.mall192.168.200.11 zookeeper.mall192.168.200.11 mysql.mall3、配置Yum源[root@mall ~]# vi /etc/yum.repos.d/local.repo //编辑yum源文件[centos] //源IDname=centos //源名称baseurl=file:///opt/centos //源路径gpgcheck=0 //校验为0enabled=1 //自启[mall]name=mallbaseurl=file:///root/gpmall-repogpgcheck=0enabled=14、安装服务[root@mall ~]# yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel redis nginx mariadb mariadb-server //安装jdk、数据库、缓存、nginx服务5、关闭防火墙以及selinux[root@mall ~]# systemctl stop firewalld && systemctl disable firewalld //关闭防火墙并设置开机不自启Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.[root@mall ~]# setenforce 0 //临时关闭selinux6、查看jdk版本[root@mall ~]# java -version //查看jdk版本号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)7、配置zookeeper服务[root@mall ~]# tar -zxvf zookeeper-3.4.14.tar.gz //解压zookeeper压缩包[root@mall ~]# cd zookeeper-3.4.14/conf/ //进入zookeeper/conf目录下[root@mall conf]# mv zoo_sample.cfg zoo.cfg //给zoo_sample文件改名[root@mall conf]# cd ../bin/ //进入到zookeeper/bin目录下[root@mall bin]# ./zkServer.sh start //启动zookeeper服务ZooKeeper JMX enabled by defaultUsing config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg Starting zookeeper ... STARTED[root@mall bin]# ./zkServer.sh status //查看zookeeper服务状态ZooKeeper JMX enabled by defaultUsing config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfgMode: standalone8、配置kafkaroot@mall bin]# cd //进入root目录[root@mall ~]# tar -zxvf kafka_2.11-1.1.1.tgz //解压kafka压缩包[root@mall ~]# cd kafka_2.11-1.1.1/bin/ //进入bin目录[root@mall bin]# ./kafka-server-start.sh -daemon ../config/server.properties //启动kafka服务[root@mall bin]# cd //进入root目录[root@mall ~]# jps //使用命令查看进程,有kafka服务证明启动无误3456 QuorumPeerMain3771 Kafka3836 Jps[root@mall ~]# yum -y install net-tools //安装net-tools(此工具用来查看端口号)[root@mall ~]# netstat -ntpl //查询到端口9092,对应的服务为kafkaActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1467/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1970/master tcp6 0 0 :::36141 :::* LISTEN 3456/java tcp6 0 0 :::22 :::* LISTEN 1467/sshd tcp6 0 0 ::1:25 :::* LISTEN 1970/master tcp6 0 0 :::47043 :::* LISTEN 3771/java tcp6 0 0 :::9092 :::* LISTEN 3771/java tcp6 0 0 :::2181 :::* LISTEN 3456/java 9、配置数据库[root@mall ~]# vi /etc/my.cnf //编辑数据库配置文件## This group is read both both by the client and the server# use it for options that affect everything#[client-server]## 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=utf8collation-server=utf8_unicode_ciskip-character-set-client-handshake[root@mall ~]# systemctl restart mariadb //重启数据库服务[root@mall ~]# systemctl enable mariadb //设置数据库开机自启[root@mall ~]# mysql_secure_installation //初始化数据库服务,使用此命令必须保证数据库已经启动否则无效NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] yNew password: //设置密码为123456,必须设置为123456,否则后面对接jar包不成功,造成商城页面不可弹出Re-enter new password: //再输入一遍Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y //询问是否移除匿名用户--y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] n //询问是否禁止远程登陆--n ... skipping.By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y //询问是否移除匿名用户--y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y //询问是否刷新权限--y ... Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB![root@mall ~]# mysql -uroot -p123456 //登录数据库,用户为root,密码为123456Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 15Server version: 10.3.18-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.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; //赋予任何远程主机用root用户连接到mysql 所有库的权限,密码为123456Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> create database gpmall; //创建数据库,名为gpmallQuery OK, 1 row affected (0.000 sec)MariaDB [(none)]> use gpmall; //进入数据库Database changedMariaDB [gpmall]> source /root/gpmall-single/gpmall.sql //将本地数据导入到数据库中10、配置redis服务[root@mall ~]# vi /etc/redis.conf //编辑redis配置文件进入文件后,不要做任何操作,直接输入:set nu显示行号,然后将文本改为插入模式,将第61行前加#进行注释,再将第80行中的yes改为no,最后保存退出[root@mall ~]# systemctl restart redis //更改文件后,重启redis服务[root@mall ~]# systemctl enable redis //设置redis服务开机自启[root@mall ~]# netstat -ntpl //查看端口号,找到6379端口,对应的服务为redis11、配置nginx服务[root@mall ~]# rm -rf /usr/share/nginx/html/* //删除Nginx服务站点目录下所有内容[root@mall ~]# cp -rvf gpmall-single/dist/* /usr/share/nginx/html/ //将本地web包拷贝到站点目录下[root@mall ~]# vi /etc/nginx/conf.d/default.conf //编辑nginx的配置文件进入配置文件后找到第一个location,将下面内容添加进去 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; }[root@mall ~]# systemctl restart nginx //添加完成后重启nginx服务,如果遇到服务报错,则检查Nginx配置文件是否正确[root@mall ~]# netstat -ntpl //查看端口号,有无80端口暴露,对应服务为nginx12、部署后端jar包[root@mall ~]# cd gpmall-single/ //进入存放后端jar包文件目录[root@mall ~]# gpmall-single]# nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar & //分别在后台,启动下面四个jar包[root@mall ~]# gpmall-single]# nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &[root@mall ~]# gpmall-single]# nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &[root@mall ~]# gpmall-single]# nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &[root@mall gpmall-single]# jobs[1] Running nohup java -jar shopping-provider-0.0.1-SNAPSHOT.jar &[2] Running nohup java -jar user-provider-0.0.1-SNAPSHOT.jar &[3]- Running nohup java -jar gpmall-shopping-0.0.1-SNAPSHOT.jar &[4]+ Running nohup java -jar gpmall-user-0.0.1-SNAPSHOT.jar &注意:如果在命令启动过程中遇到EXIT字样,则为jar包出现闪退,检查前面所部署的服务是否运行正常,以及主机名映射文件是否书写正确13、浏览器登录验证如果前面每个服务都运行正常,且jar包没有出现闪退,那么使用浏览器输入192.168.200.11进行验证,如果发现有图片并且有文字出现,则gpmall商城部署正常。