1、下载并安装 Maven
(mvn下令对应的软件包)(确认 Java 环境已安装,在上面安装Hadoop环境的时候已经安装好Java环境)Hadoop安装、配置与管理_centos环境下hadoop的安装与配置-CSDN博客
可以在内里找到java安装
[root@hadoop ~]# java -version //查看java的版本
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
//从 Apache Maven 的官方网站下载最新版本的 Maven。通常会下载一个二进制压缩包。使用wget下令来下载//
[root@hadoop ~]# wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
--2025-03-21 00:15:06-- https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
正在剖析主机 dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
正在连接 dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... 已连接。
已发出 HTTP 哀求,正在等待回应... 200 OK
长度:9102945 (8.7M) [application/x-gzip]
正在保存至: “apache-maven-3.9.9-bin.tar.gz”
apache-maven-3.9.9-bin.tar.gz 100%[=============================================================================>] 8.68M 1.38MB/s 用时 3m 26s
2025-03-21 00:18:32 (43.2 KB/s) - 已保存 “apache-maven-3.9.9-bin.tar.gz” [9102945/9102945])
//下载完成后,使用tar下令解压压缩包:
[root@hadoop ~]# tar -zxvf apache-maven-3.9.9-bin.tar.gz
apache-maven-3.9.9/README.txt
apache-maven-3.9.9/LICENSE
apache-maven-3.9.9/NOTICE
apache-maven-3.9.9/lib/
apache-maven-3.9.9/lib/aopalliance.license
.
.
.
//将解压的文件移动到/opt目录,便于背面管理
[root@hadoop ~]# sudo mv maven-3.9.9 /opt/
[root@hadoop ~]# cd /opt
[root@hadoop opt]# ll
总用量 0
drwxr-xr-x. 6 root root 99 3月 21 00:30 maven-3.9.9
//编辑文件,添加以下内容
vim /etc/profile
添加:
export MAVEN_HOME=/opt/apache-maven-3.9.9
export PATH=$PATH MAVEN_HOME/bin
使配置收效
source /etc/profile
验证安装是否成功,若成功安装,会显示 Maven 的版本信息。
mvn -version
2、安装MySQL
安装MySQL: yum install mysql-server -y
查看MySQL状态: sudo systemctl status mysqld
启动MySQL
sudo systemctl start mysqld
sudo systemctl enable mysqld
确保MySQL用户拥有数据目录权限:
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod -R 755 /var/lib/mysql
初始化安全配置(设置 root 密码) sudo mysql_secure_installation
登录 MySQL sudo mysql -u root -p
- [root@hadoop ~]# sudo mysql_secure_installation
- Securing the MySQL server deployment.
- Connecting to MySQL using a blank password.
- The 'validate_password' component is installed on the server.
- The subsequent steps will run with the existing configuration
- of the component.
- Please set the password for root here.
- New password: //输入密码,尽量有大写字母,小写字母,数字,符号
- Re-enter new password: //再次输入
- Estimated strength of the password: 100
- Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
- By default, a MySQL installation has an anonymous user,
- allowing anyone to log into MySQL without having to have
- a user account created for them. This is intended only for
- testing, and to make the installation go a bit smoother.
- You should remove them before moving into a production
- environment.
- Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
- Success. //是否删除匿名用户,建议y
- Normally, root should only be allowed to connect from
- 'localhost'. This ensures that someone cannot guess at
- the root password from the network.
- Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
- Success. //是否禁止root远程登陆,跟随自己的情况,我是y
- By default, MySQL comes with a database named 'test' that
- anyone can access. This is also intended only for testing,
- and should be removed before moving into a production
- environment.
- Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- - Dropping test database... //是否删除test数据库,y
- Success.
- - Removing privileges on test database...
- Success.
- Reloading the privilege tables will ensure that all changes
- made so far will take effect immediately.
- Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
- ... skipping. //是否重新加载权限表,y
- All done!
复制代码
- [root@hadoop ~]# sudo mysql -u root -p //进入MySQL
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 12
- Server version: 8.0.26 Source distribution
- Copyright (c) 2000, 2021, Oracle and/or its affiliates.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- # 创建数据库和用户表
- mysql> CREATE DATABASE cloud_disk;
- Query OK, 1 row affected (0.01 sec)
- mysql> USE cloud_disk;
- Database changed
- mysql> CREATE TABLE users (
- -> id INT PRIMARY KEY AUTO_INCREMENT,
- -> username VARCHAR(50) UNIQUE NOT NULL,
- -> password VARCHAR(100) NOT NULL,
- -> role ENUM('user', 'admin') DEFAULT 'user',
- -> status ENUM('active', 'blocked') DEFAULT 'active'
- -> );
- Query OK, 0 rows affected (0.02 sec)
- # 创建文件元数据表
- mysql> CREATE TABLE files (
- -> id INT PRIMARY KEY AUTO_INCREMENT,
- -> user_id INT NOT NULL,
- -> hdfs_path VARCHAR(255) NOT NULL,
- -> filename VARCHAR(255) NOT NULL,
- -> upload_time DATETIME DEFAULT CURRENT_TIMESTAMP,
- -> FOREIGN KEY (user_id) REFERENCES users(id)
- -> );
- Query OK, 0 rows affected (0.01 sec)
复制代码 3、安装Tomcat9
#Tomcat 依赖 Java,需先安装 JDK:
yum install java-11-openjdk-devel -y
#创建Tomcat专用用户:
sudo useradd -r -s /bin/nologin tomcat
#下载Tomcat压缩包
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.102/bin/apache-tomcat-9.0.102.tar.gz
# 3. 验证校验和
sha512sum apache-tomcat-9.0.102.tar.gz
# 4. 解压到:
sudo tar -xzf apache-tomcat-9.0.102.tar.gz -C /opt/
# 5. 查抄效果:
ls /opt/apache-tomcat-9.0.102
# 确保用户所有权
sudo chown -R tomcat:tomcat /opt/tomcat9
# 设置目录权限
sudo chmod -R 755 /opt/tomcat9
#创建systemd配置文件
vim /etc/systemd/system/tomcat9.service
#在内里添加配置
[Unit]
Description=Apache Tomcat 9
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
# 环境变量配置
Environment=CATALINA_PID=/opt/tomcat9/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat9
Environment=CATALINA_BASE=/opt/tomcat9
Environment=JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-4.el8_5.x86_64 # 根据实际路径调整
# 启动/停止下令
ExecStart=/opt/tomcat9/bin/startup.sh
ExecStop=/opt/tomcat9/bin/shutdown.sh
# 失败时主动重启
Restart=on-failure
[Install]
WantedBy=multi-user.target
#查看JAVA_HOME路径,根据自己的位置所在地,背面的/bin/java不需要
readlink -f $(which java)
#重载systemd系统
sudo systemctl daemon-reload # 加载新服务配置
sudo systemctl start tomcat9 # 启动服务
sudo systemctl enable tomcat9 # 设置开机自启
#查抄启动状态
systemctl status tomcat9
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |