一、说明
- 前端技术体系:Vue3 + Nuxt3 + Vite5 + Vue-Router + Element-Plus + Pinia + Axios
- 后端技术体系:Spring Cloud Alibaba2021 + MySQL8 + Nacos + Seata + Mybatis + Druid + redis
- 后端系统:roncoo-education(核心框架:Spring Cloud Alibaba):码云 | Github
- 门户系统:roncoo-education-web(核心框架:Nuxt3):码云 | Github
- 管理系统:roncoo-education-admin(核心框架:Vue3):码云 | Github
- 部署系统centos 7(改为ubuntu---推荐替代centos7方案)
- 在线教育网站项目第二步 :学习roncoo-education,服务器为ubuntu22.04.05-优快云博客
https://blog.youkuaiyun.com/jiangkp/article/details/145995259
二、 配置环境
1、安装centos 7
centos 7太老了,连个nodejs装起来都麻烦死了,准备换别的系统--改为ubuntu
见新帖子
2、初始化系统
# 查看
uname -a // 查看操作系统# 系统更新
yum update -y#出现错误
Cannot find a valid baseurl for repo: base/7/x86_64
# 下面是解决问题,来源于deepseek
# 查看仓库配置文件
cat /etc/yum.repos.d/CentOS-Base.repo# 确保 `baseurl` 或 `mirrorlist` 有效(示例如阿里云镜像)
sudo vi /etc/yum.repos.d/CentOS-Base.repo# 所有内容替换为
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7# 禁用
fastestmirror
插件,该插件可能导致镜像选择失败# 临时禁用插件
sudo yum clean all --disableplugin=fastestmirror# 永久禁用(编辑配置文件)
sudo vi /etc/yum/pluginconf.d/fastestmirror.conf将
enabled=1
改为enabled=0
# 清理旧缓存
sudo yum clean all
#生成新缓存
sudo yum makecache
sudo yum update# 关闭SELINUX
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config# 调大服务器所支持的最大文件句柄数(云服务器一般已经默认已经设置)
echo "* hard nofile 65536" >> /etc/security/limits.conf
echo "* soft nofile 65536" >> /etc/security/limits.conf# 配置
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
sysctl -p# 安装基础工具
yum install -y lrzsz unzip git wget
3、新增用户并初始化
# 新增一个普通用户,系统应用都由这个普通用户来运行
useradd education
passwd education输入密码 123456
# 用户密码自行管理# 设置sudo权限
sed -i '/OPASSWD: ALL/a\education ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
三、MySQL-8.0的安装
1、安装
# mysql8.0
yum install -y https://repo.mysql.com/mysql80-community-release-el7.rpm
# 禁用默认的 MariaDB 模块(避免冲突,可能没安装mariadb)
which mariadb 看是否安装
systemctl disable mariadb
# 安装mysql
yum install -y mysql-community-server#安装完成之后,默认已设置开机启动。
5、关键配置优化(编辑 /etc/my.cnf
)
cat >> /etc/my.cnf << 'EOF'
# 默认时区
default-time_zone='+8:00'
# 性能优化(若有单独是数据库服务器,推荐innodb_buffer_pool_size设置为系统内存的60%到80%)
innodb_buffer_pool_size=4G
innodb_log_file_size=256M
max_allowed_packet=64M
# 关闭log-bin(8.0默认是开启的)
disable-log-bin
# 设置身份认证插件(兼容低版本的认证方式)
default_authentication_plugin=mysql_native_password
# 最大连接数
max_connections=10240
# 需要启用only_full_group_by SQL模式
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
EOF
2、启动服务并设置开机自启
# 启动服务并设置开机自启
sudo systemctl start mysqld
sudo systemctl enable mysqld
3、初始化与启动
# 启动
systemctl restart mysqld# 查看初始化密码
cat /var/log/mysqld.log | grep passwordxs_UCrpZu5Tj
# 初始化,按需进行确认即可(注意密码的强度,不满足无法设置密码)
mysql_secure_installation# 登录设置授权(这里新增用户:roncoo,密码为:RonCoo.123)
mysql -uroot -p
> create user roncoo@'%' identified by 'RonCoo.123';
> GRANT ALL PRIVILEGES ON *.* TO 'roncoo'@'%' WITH GRANT OPTION;
> FLUSH PRIVILEGES;
> exit;
# 启动
systemctl start mysqld
# 关闭
systemctl stop mysqld
# 重启
systemctl restart mysqld配置文件位置:/etc/my.cnf
软件安装位置:/var/lib/mysql
应用日志位置:/var/log/mysqld.log
4、配置外网连接
# 查看当前开放的端口
firewall-cmd --list-ports
# 开放或关闭特定端口(例如开放端口 3306):
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reloadfirewall-cmd --zone=public --remove-port=3306/tcp --permanent
firewall-cmd --reload# 错误Public Key Retrieval is not allowed
dbeaver连接时解决方案
编辑连接-编辑驱动属性-allowPublicKeyRetrieval设置为true
5、创建几个数据库 (使用DBeaver)
education_course
education_system
education_user
education_nacos
education_job
6、导入数据
四、Redis-6.2.9的安装
1、安装redis
yum install -y gcc tcl
mdkir /opt/tools
cd /opt/tools
wget https://download.redis.io/releases/redis-6.2.9.tar.gz
tar zxvf redis-6.2.9.tar.gz && cd redis-6.2.9
make install PREFIX=/opt/redis# 添加配置文件
cp -r /opt/tools/redis-6.2.9/redis.conf /opt/redis/redis.conf