Tomcat
项目做完了,要发布了,而Java的特长之一就是移植性好,面对着微软的XP的停止服务,Windows系统的“独裁”,越来越多的商家选择了开源的免费的linux系统作为服务器。因为linux系统也有图形界面(虽然和Windows比起来很不一样),所以在图形界面中操作相对来说还是容易的,这就好比我们在Windows系统上部署项目一样,大部分人都是小Case。但是真正工作中,服务器都会在固定的机房,而且往往只有一台主机,更规模大一些的就是使用单片机,像摆书一样摆到机房的机器架上,而我们操作它的最常用的方式就成为了远程访问。就像在控制台一样进行命令输入控制,从而使人们操作电脑又回到了几十年代前(不知道这种方式什么时候能改革了),所以还是需要些技术的。这篇博客,简单讲述一下在linux部署项目需要注意的事项,以及常用命令。
好,简单讲述Java项目+Tomcat+mysql的部署过程。
一,首先就是如何远程连接linux系统:
1,在linux端创建可支持远程访问的用户;
2,利用相应的远程访问软件:SecureFXPortable(窗口)+SecureCRTPortable(控制台)或者PUTTY(控制台)+RealVNCsetup(窗口)等。
3,在一块,还有ssh等各种端口协议等,一大块知识需要我们研究,这里不再给出。我也是刚刚接触。大家网上都搜资料。
二,MySql相关
1,如果服务器没有MySql,需要进行安装,安装可以下载绿色版的进行解压缩即可,也可以在线安装。
a,解压缩:
zip:
zip-r myfile.zip ./*
将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件.
unzip -q myfile.zip 解压myfile.zip压缩包,-q是将不显示解压过程。
tar:
tar命令可以用来压缩打包单文件、多个文件、单个目录、多个目录。
常用格式:
单个文件压缩打包tar czvf my.tar file1
多个文件压缩打包tar czvf my.tar file1 file2,...
单个目录压缩打包tar czvf my.tar dir1
多个目录压缩打包tar czvf my.tar dir1 dir2
解包至当前目录:tar xzvf my.tar
解释:
tar命令
[root@linux~]# tar [-cxtzjvfpPN] 文件与目录 ....
参数:
-c:建立一个压缩文件的参数指令(create 的意思);
-x:解开一个压缩文件的参数指令!
-t:查看 tarfile 里面的文件!
特别注意,在参数的下达中,c/x/t 仅能存在一个!不可同时存在!
因为不可能同时压缩与解压缩。
-z:是否同时具有 gzip 的属性?亦即是否需要用 gzip 压缩?
-j:是否同时具有 bzip2 的属性?亦即是否需要用 bzip2 压缩?
-v:压缩的过程中显示文件!这个常用,但不建议用在背景执行过程!
-f:使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!
例如使用『tar -zcvfP tfile sfile』就是错误的写法,要写成
『tar -zcvPf tfile sfile』才对喔!
-p:使用原文件的原来属性(属性不会依据使用者而变)
-P:可以使用绝对路径来压缩!
-N:比后面接的日期(yyyy/mm/dd)还要新的才会被打包进新建的文件中!
--exclude FILE:在压缩的过程中,不要将 FILE 打包!
b,在线安装:sudo apt-get installmysql-server,在安装过程中会提示输入Root密码及密码确认等。
2,当然后边还需要添加角色,编写配置文件,建库,建表,备份,还原等等操作,每个操作都有很多的对应的代码,这里不再一一给出,看下这个链接:在Linux下安装和使用MySQL
三,Tomcat使用,
1,安装Tomcat,也是解压利用unzip或者tar等命令。
a,前边我们可能会建文件夹利用Mkdir,建目录,建文件夹等:
b,复制粘贴,移动等常用命令
cp拷贝:
sudo cp~/toInstall/apache-tomcat-6.0.37.tar.gz ./ 管理员拷贝到当前目录
mv移动 [选项] 源文件或目录 目标文件或目录
-b :若需覆盖文件,则覆盖前先行备份。
-f :force 强制的意思,如果目标文件已经存在,不会询问而直接覆盖;
-i :若目标文件 (destination) 已经存在时,就会询问是否覆盖!
-u :若目标文件已经存在,且 source 比较新,才会更新(update)
-t : --target-directory=DIRECTORYmove all SOURCE arguments into DIRECTORY,即指定mv的目标目录,该选项适用于移动多个源文件到一个目录的情况,此时目标目录在前,源文件在后。
2,其次我们进行Tomcat的开启和关闭:
开启:shstartup.sh
关闭:sh shutdown.sh
查看进程:ps -ef|grep tomcat(进程名称即可)
杀死进程:kill -9 进程号
3,对于一些辅助服务的开启,例如nginx:
server nginx(服务名)start
server nginx(服务名)stop
等,也是linux命令来实现,我们以前点击实现的功能。
四,项目部署,其实直接将项目拷贝到Tomcat webapps Root目录下,或者指定的目录下,解压即可,只是这里还需要修改其中的一些配置文件,使mysql+tomcat+各种辅助服务(nginx)+Java程序配套起来。
这里提一下文件的修改,Tomcat目录下的可以通过窗口远程,下载修改上传覆盖的形式进行简易操作,如果非得再linux远程界面上修改操作文件的话,可以利用VI编辑器命令进行实现,简单命令:
:set nu 显示行号
:dd删除当前行
:wq 保存退出
:q 退出
:q! 强制退出
i 开始编辑文件
esc 退出编辑
综上为在linux系统项目部署的大概流程,这里仅仅是梳理了下思路,具体知识写的不够详细,还需要大家上网多查多搜索。内容不够丰富,还望大家多多包含……

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor
