首页 > 系统相关 >阿里云Centos环境部署springboot项目

阿里云Centos环境部署springboot项目

时间:2023-07-29 22:46:47浏览次数:38  
标签:service springboot Centos ip 阿里 mysql rpm MINIO minio

JDK安装

直接云安装即可 yum install -y java-1.8.0-openjdk, java -version 查看.

MySQL安装

下载~~ 选择 Compressed TAR Archive 选择Linux -通用 ; x86 64~~
云安装5.7版本 推荐!

  1. 卸载mariadb
如下命令以此执行

rpm -qa|grep mari
rpm -e --nodeps mariadb-libs
rpm -qa|grep mari
  1. Wget安装mysql5.7 , 确定好安装目录后
wget -c http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar

解压

tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar

顺序安装依赖
rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm
  1. 启动mysql5.7 systemctl start mysqld.service 查看mysql状态: systemctl status mysqld.service
  2. 初始化mysql
    1. 查看密码 grep "password" /var/log/mysqld.log
    2. mysql -uroot -p 修改密码:set password for 'root'@'localhost' = password('自定义密码');
    3. 方便远程连接 grant all privileges on . to 'root'@'%' identified by '自定义密码' with grant option;

MinIO的安装

  1. 安装MinIO操作文档 Binary下载 , 按照官网的路径配置比较快
下载minio
wget https://dl.min.io/server/minio/release/linux-amd64/minio

修改minio的权限
chmod +x minio

移动下载的文件 到此文件夹下
sudo mv minio /usr/local/bin/
  1. 创建minio.service 放到/etc/systemd/system/ 目录下 推荐使用MobaXterm操作方便,可视化操作
[Unit]
Description=MinIO
Documentation=https://min.io/docs/minio/linux/index.html
Wants=network-online.target
After=network-online.target
# 指的是下载的压缩 minio 文件路径 最后一个指的是文件
AssertFileIsExecutable=/usr/local/bin/minio

# 添加用户和分组后面会操作无需改动
[Service]
WorkingDirectory=/usr/local

User=minio-user
Group=minio-user

# 此文件需要注释掉 不识别此标识
# ProtectProc=invisible

#环境配置 需要创建一个minio文件 位置在 /etc/default/ 下
EnvironmentFile=-/etc/default/minio
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"

# 启动命令
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES

# MinIO RELEASE.2023-05-04T21-44-30Z adds support for Type=notify (https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=)
# This may improve systemctl setups where other services use `After=minio.server`
# Uncomment the line to enable the functionality
# Type=notify

# Let systemd restart this service always
Restart=always

# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536

# Specifies the maximum number of threads this process can create
TasksMax=infinity

# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

# Built for ${project.name}-${project.version} (${project.name})
  1. 创建环境变量 **minio 文件无后缀只是个文件类型, 位置在/etc/default/ **下

f3eaa17c999e7c2bdaa111e0dc60e29.png

# MINIO_ROOT_USER and MINIO_ROOT_PASSWORD sets the root account for the MinIO server.
# This user has unrestricted permissions to perform S3 and administrative API operations on any resource in the deployment.
# Omit to use the default values 'minioadmin:minioadmin'.
# MinIO recommends setting non-default values as a best practice, regardless of environment

# 配置登录账号和密码
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin

# MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.
# 注意自己创建的文件,权限设置为777要不然报 file access denied ; 用来存放minio上传的文件,也可自行设置路径
MINIO_VOLUMES="/mnt/data"

# MINIO_SERVER_URL sets the hostname of the local machine for use with the MinIO Server
# MinIO assumes your network control plane can correctly resolve this hostname to the local machine
# 该值替换为本地计算机的正确主机名和 MinIO 服务器的端口(默认为 9000)查看端口 ip addr list xxx/20的就是
MINIO_SERVER_URL="http://本地服务器ip:9000"

添加权限

  1. 启动程序, ** 通过 journalctl -f -u minio.service **命令实时查看输出日志情况.
#  配置完后重新加载
systemctl daemon-reload

#启动minio
systemctl start minio.service

#  查看运行状态
sudo systemctl status minio.service

#  开启日志查看
journalctl -f -u minio.service

关闭minio
#  systemctl stop minio.service

#开启开机自启
systemctl enable minio.service
  1. 连接minio ,运行成功后Console如下图 后面的ip地址后的端口添加到,安全组, 然后用公网ip+此端口访问minio的管理平台页面

0997a8990dd0500bc29202c84c5dfc3.png
下面的错误是 自己创建的data没有设置777权限,所以运行失败 ,一直调试好久,看着日志才能更好的定位问题;

Error: unable to rename (/mnt/data/.minio.sys/tmp -> /mnt/data/.minio.sys/tmp-old/47f17c32-df74-49d3-8151-a079655e2557) file access denied, drive may be faulty please investigate (*fmt.wrapError)

TomCat安装和项目部署时注意问题

TomCat安装

  1. tomcat 服务器 添加 docBase是项目名称, <Connector port="80" ..../> 端口修改为80 以便访问时不需要带上端口号,前端请求ip也要设置为80端口
  2. 前端请求后端ip地址 VITE_APP_API_BASEURL = http://ip:80/blog; **/blog **指的是tomcat的war包名称 因为tomcat访问时 需要加上项目名称.
  3. vite.config.js 添加 base: '/dist/', 通过项目名称才能访问到前端资源.
  4. 访问前端index.html页面, 配置后端, 编写一个@Controller 方法上@GetMapping("/") 表示访问ip地址 , 通过重定向 , 访问服务器下的前端dist包下index.html; return"redirect:/dist/index.html".

项目部署时注意问

  1. minio访问出错问题

浏览器访问图片提示Net::ERR_CONNECTION_RESET,查看地址是127.0.0.1, 部署云以后 只能通过公网ip才可以访问到minio的资源,所以修改minio配置文件, 修改,minio的ip地址 endpoint: http://公网ip : 端口(默认9000), 这样上传文件时前缀名字存储时就是公网ip了,访问时通过公网访问minio资源.

  1. 前端请求后端ip出错

前端封装的axios.js 的ip修改为 [ 公网ip:80/项目名称 **] **端口就可以访问后端了.

  1. 阿里云 安全组 需要注意一些外部访问的权限,比如minio平台管理页面端口

minio和tomcat 提取码:6ms8

标签:service,springboot,Centos,ip,阿里,mysql,rpm,MINIO,minio
From: https://www.cnblogs.com/july7/p/17590698.html

相关文章

  • springboot启动中ccs样式和图片找不到, 报net::ERR_ABORTED 404
    1、 net::ERR_ABORTED404  项目结构 3、css错误的:<linkhref="/static/iconfont/style.css"type="text/css"rel="stylesheet">正确的:<linkhref="iconfont/style.css"type="text/css"rel="stylesh......
  • springboot访问页面
    结构 1.引入依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency> 2.在yml文件配置spring:thymeleaf:......
  • centos7 k8s 三节点 全二进制部署 1.23.15
    主机名IP地址Pod网段Service网段master192.168.1.60172.16.0.0/1210.96.0.0/16node01192.168.1.70172.16.0.0/1210.96.0.0/16node02192.168.1.80172.16.0.0/1210.96.0.0/16[root@master~]#cat/etc/redhat-releaseCentOSLinuxrelease7.9.2......
  • Centos7.9版本安装collectd并开启写入rrd文件功能
    文章目录一、背景介绍二、为什么用这个三、安装Collectd3.1尝试docker安装3.2尝试执行linux命令一步一步安装安装collectd设置将数据写入日志文件设置将数据写入rrd文件。一、背景介绍Collectd官网:https://collectd.org/Collectd是一款开源的系统统计守护进程,用于收集、处理和存......
  • Centos8 中文语言配置支持
    安装中文语言包如果不知道中文语言包,使用以下命令查看[09:39:51]root@ive:~#yumsearchChinese加载插件"osmsplugin"失败:Nomodulenamed'librepo'上次元数据过期检查:0:26:02前,执行于2023年07月29日星期六09时14分49秒。==================================......
  • 学习springboot之yml
    格式注意每次冒号后面需要一个空格,yml编译区分大小写。调用yml内容有三种方法第一种方法:直接用注释@value(“${内容}”),然后创建引用类型,引用信息,然后输出  第二种方法:利用@autowired注解,用Environment方法创建对象,随后直接调用方法创建对象获取属性,输出该对象即可@Autowire......
  • SpringBoot——常用扩展点
    前言Spring对于每个Java后端程序员来说肯定不陌生,日常开发和面试必备的。本文就来盘点Spring/SpringBoot常见的扩展点,同时也来看看常见的开源框架是如何基于这些扩展点跟Spring/SpringBoot整合的。FactoryBean提起FactoryBean,就有一道“著名”的面试题“说一说FactoryBean和Bean......
  • 2023.07 WSL2 CentOS 使用桥接网卡固定IP/加入局域网
    WSL2CentOS使用桥接网卡固定IP/加入局域网参考资料https://zhuanlan.zhihu.com/p/593263088https://www.cnblogs.com/lic0914/p/17003251.html进入Hyper-V管理器新建桥接网卡进入%USERPROFILE%目录新建.wslconfig文件[wsl2]vmIdleTimeout=-1networkingMo......
  • 在SpringBoot 和 Vue的项目中使用SpringBoot-email
    在SpringBoot+Vue的项目中使用SpringBoot-email发送验证码,具体步骤如下:添加依赖首先需要在pom.xml文件中添加依赖:<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></dependency>配置邮箱信息在applicat......
  • CentOS 7 mini安装完配置
    背景CentOS8系统2021年12月31日已停止维护服务,CentOS7系统将于2024年06月30日停止维护服务。CentOS官方不再提供CentOS9及后续版本,不再支持新的软件和补丁更新。所以我们如果要安装服务器操作系统就需要安装centos7。这里我是用虚拟机安装的centos7mini版,mini版本是最小化安......