`

linux 下 MySQL 启动与关闭 说明 (转载)

 
阅读更多

一.启动

1.1  MySQL 进程

可以用ps 命令查看进程:

[root@rac2 ~]# ps -ef|grep mysql

root     2161     1  0 09:38 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe--datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rac2.pid

mysql    2418  2161  0 09:38 ?        00:00:00 /usr/sbin/mysqld--basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin--user=mysql --log-error=/var/lib/mysql/rac2.err--pid-file=/var/lib/mysql/rac2.pid --socket=/var/lib/mysql/mysql.sock--port=3306

root     3628  3596  0 09:57 pts/1    00:00:00 grep mysql

 

1.1.1 mysqld — The MySQL Server

mysqld, also known as MySQL Server, is the main program that does most of the work in aMySQL installation. MySQL Server manages access to the MySQL data directorythat contains databases and tables. The data directory is also the defaultlocation for other information such as log files and status files.

When MySQLserver starts, it listens for network connections from client programs andmanages access to databases on behalf of those clients.

The mysqld programhas many options that can be specified at startup. For a complete list ofoptions, run this command:

shell> mysqld--verbose --help

MySQL Serveralso has a set of system variables that affect its operation as it runs. Systemvariables can be set at server startup, and many of them can be changed atruntime to effect dynamic server reconfiguration. MySQL Server also has a setof status variables that provide information about its operation. You canmonitor these status variables to access runtime performance characteristics.

-- mysqld 进程是MySQL Server 最核心的进程。mysqld 进程crash 或者出现异常,MySQLServer 基本上也就无法正常提供服务了。

 

1.1.2 mysqld_safe — MySQL Server Startup Script

mysqld_safe is the recommended way to start a mysqld server on Unix. mysqld_safe adds somesafety features such as restarting the server when an error occurs and loggingruntime information to an error log file. A description of error logging isgiven later in this section.

mysqld_safe triesto start an executable named mysqld. To override the default behavior andspecify explicitly the name of the server you want to run, specify a --mysqld or--mysqld-version option to mysqld_safe. You can also use --ledir to indicate thedirectory where mysqld_safe should look for the server.

 mysqld_safe readsall options from the [mysqld], [server], and [mysqld_safe] sections in optionfiles. For example, if you specify a [mysqld] section like this, mysqld_safe willfind and use the --log-error option:

[mysqld]

log-error=error.log

For backwardcompatibility, mysqld_safe also reads [safe_mysqld] sections, although youshould rename such sections to [mysqld_safe] in MySQL 5.5 installations.

--mysqld_safe 会帮助我们来监控mysqld 进程的状态,当mysqld 进程crash 之后,mysqld_safe会马上帮助我们重启mysqld 进程。但前提是我们必须通过mysqld_safe 来启动MySQLServer,这也是MySQL AB 强烈推荐的做法。

 

1.1.3 mysql.server — MySQL Server Startup Script

MySQLdistributions on Unix include a script named mysql.server. It can be used onsystems such as Linux and Solaris that use System V-style run directories tostart and stop system services. It is also used by the Mac OS X Startup Itemfor MySQL.

mysql.server canbe found in the support-files directory under your MySQL installation directoryor in a MySQL source distribution.

--mysql.server 脚本放在support-files 目录下。 即:/usr/share/mysql

If you use theLinux server RPM package (MySQL-server-VERSION.rpm), the mysql.server scriptwill be installed in the /etc/init.d directory with the name mysql. You neednot install it manually. See Section 2.5.1, “Installing MySQL from RPM Packages on Linux”, for more information onthe Linux RPM packages.

       --如果我们使用RPM 包来安装的MySQL,那么mysql.server 脚本会自动安装到/etc/init.d目录下,并且重名为mysql。 我们不需要手工的来安装

 

[root@rac2 mysql]# ls /etc/init.d/mysql 

/etc/init.d/mysql

 

Some vendorsprovide RPM packages that install a startup script under a different name suchas mysqld.

If you installMySQL from a source distribution or using a binary distribution format thatdoes not install mysql.server automatically, you can install it manually.Instructions are provided in Section 2.10.1.2, “Starting and Stopping MySQLAutomatically”.

mysql.server readsoptions from the [mysql.server] and [mysqld] sections of option files. Forbackward compatibility, it also reads [mysql_server] sections, although youshould rename such sections to [mysql.server] when using MySQL 5.5.

       --mysql.server 从参数文件里读取[mysql.server]和[mysqld]段的的信息。 

 

1.1.4 mysqld_multi — Manage Multiple MySQL Servers

mysqld_multi is designedto manage several mysqld processes that listen for connections on differentUnix socket files and TCP/IP ports. It can start or stop servers, or reporttheir current status.

--如果我们的一个节点上有多个mysql,可以使用mysqld_multi 来管理。

 

mysqld_multi searchesfor groups named [mysqldN] in my.cnf (or in the file named by the --config-fileoption). N can be any positive integer. This number is referred to in thefollowing discussion as the option group number, or GNR. Group numbersdistinguish option groups from one another and are used as arguments to mysqld_multito specify which servers you want to start, stop, or obtain a status reportfor. Options listed in these groups are the same that you would use in the [mysqld]group used for starting mysqld. (See, for example, Section 2.10.1.2, “Startingand Stopping MySQL Automatically”.) However, when using multiple servers, it isnecessary that each one use its own value for options such as the Unix socketfile and TCP/IP port number. For more informationon which options must beunique per server in a multiple-server environment, see Section 5.6, “RunningMultiple MySQL Instances on One Machine”.

       -- mysqld_multi 会在my.cnf 里搜索mysqldN的参数配置。

 

以上都是相关进程的大概内容,详细内容可以参考MySQL 5.5的官方文档的4.3 小节:MySQLServer and Server-Startup Programs

 

1.2  启动进程的参数

The MySQL servermaintains many system variables that indicate how it is configured. Each systemvariable has a default value. System variables can be set at server startupusing options on the command line or in an option file. Most of them can bechanged dynamically while the server is running by means of the SET statement,which enables you to modify operation of the server without having to stop andrestart it. You can refer to system variable values in expressions

 

在启动MySQL 时,我们可以手工的在命令后面指定相关的参数, 如上面ps 的命令显示的一样:

/usr/sbin/mysqld --basedir=/usr--datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql--log-error=/var/lib/mysql/rac2.err --pid-file=/var/lib/mysql/rac2.pid--socket=/var/lib/mysql/mysql.sock --port=3306

 

这里是我们的默认的一个参数值,我们可以通过如下命令来查看MySQL的默认参数的具体值:

(1)To see the values that a serverwill use based on its compiled-in defaults and any option files that it reads,use this command:

mysqld --verbose--help

(2)To see the values that a serverwill use based on its compiled-in defaults, ignoring the settings in any optionfiles, use this command:

mysqld --no-defaults --verbose --help

       

如果每次启动都手工的指定参数比较麻烦,我们可以把相关的参数配置到参数文件里,在MySQL启动时会读取这些文件,参数文件的位置:

 

On Unix, Linux and Mac OS X, MySQL programsread startup options from the following files, in the specified order (topitems are used first).

 

 

注意上表中参数文件的顺序,MySQL 会按照从上往下的顺序优先使用上面的参数文件,这个就类似与Oracle的SPFILE,PFILE和 init 文件的读取顺序一样。

 

~ representsthe current user's home directory (the value of $HOME).

SYSCONFDIR representsthedirectory specified with the SYSCONFDIR option to CMake when MySQL wasbuilt. By default, this is the etc directory located under the compiled-ininstallation directory.

 

MYSQL_HOME is anenvironment variable containing the path to the directory in which theserver-specific my.cnf file resides. If MYSQL_HOME is not set and you start theserver using the mysqld_safe program, mysqld_safe attempts to set MYSQL_HOME asfollows:

(1)Let BASEDIR and DATADIR representthe path names of the MySQL base directory and data directory, respectively.

(2)If there is a my.cnf file in DATADIRbut not in BASEDIR, mysqld_safe sets MYSQL_HOME to DATADIR.

(3)Otherwise, if MYSQL_HOME is not setand there is no my.cnf file in DATADIR, mysqld_safe sets MYSQL_HOME to BASEDIR.

 

In MySQL 5.5,use of DATADIR as the location for my.cnf is deprecated.

       --在MySQL 5.5中,my.cnf 文件已经不放在DATADIR目录下。

 

Typically, DATADIRis /usr/local/mysql/data for a binary installation or /usr/local/var for asource installation. Note that this is the data directory location that wasspecified at configuration time, not the one specified with the --datadir optionwhen mysqld starts. Use of --datadir at runtime has no effect on where theserver looks for option files, because it looks for them before processing anyoptions.

 

我的测试版本:

mysql> selectversion(),current_user(); 

+------------+----------------+

| version()  | current_user() |

+------------+----------------+

| 5.5.15-log |root@localhost |

+------------+----------------+

1 row in set(0.02 sec)

 

里并没有my.cnf 文件,只在/usr/share/mysql目录下面有几个类似的文件:


[root@rac2 mysql]# pwd

/usr/share/mysql

[root@rac2 mysql]# ls my*

my-huge.cnf             my-small.cnf         mysql_system_tables_data.sql

my-innodb-heavy-4G.cnf  mysqld_multi.server  mysql_system_tables.sql

my-large.cnf            mysql-log-rotate     mysql_test_data_timezone.sql

my-medium.cnf           mysql.server

 

我们copy 一个到/etc 目录下:

[root@rac2 mysql]#cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

 

从上面了解到,MySQL 在启动时会先使用/etc/my.cnf的配置文件,如果没有在使用其他的文件,所以我们修改该配置文件里的相关参数即可。 

 

二.关闭

2.1 官网对shutdown的说明

The server shutdown process takes place asfollows:

1. The shutdown processis initiated.

This can occurinitiated several ways. For example, a user with the SHUTDOWN privilege canexecute a mysqladmin shutdown command. mysqladmin can be used on any platformsupported by MySQL. Other operating system-specific shutdown initiation methodsare possible as well: The server shuts down on Unix when it receives a SIGTERM signal.A server running as a service on Windows shuts down when the services managertells it to.

 

2. The server creates ashutdown thread if necessary.

Depending on howshutdown was initiated, the server might create a thread to handle the shutdownprocess. If shutdown was requested by a client, a shutdown thread is created.If shutdown is the result of receiving a SIGTERM signal, the signal threadmight handle shutdown itself, or it might create a separate thread to do so. Ifthe server tries to create a shutdown thread and cannot (for example, if memoryis exhausted), it issues a diagnostic message that appears in the error log: 

Error: Can't create thread to kill server

 

3. The server stopsaccepting new connections.

To prevent newactivity from being initiated during shutdown, the server stops accepting newclient connections by closing the handlers for the network interfaces to whichit normally listens for connections: the TCP/IP port, the Unix socket file, theWindows named pipe, and shared memory on Windows.

 

4. The server terminatescurrent activity.

For each threadassociated with a client connection, the server breaks the connection to theclient and marks the thread as killed. Threads die when they notice that theyare so marked. Threads for idle connections die quickly. Threads that currentlyare processing statements check their state periodically and take longer todie. For additional information about thread termination, see Section 12.7.6.4,“KILL Syntax”, in particular for the instructions about killed REPAIR TABLE or OPTIMIZETABLE operations on MyISAM tables.

For threads thathave an open transaction, the transaction is rolled back. Note that if a threadis updating a nontransactional table, an operation such as a multiple-row UPDATEor INSERT may leave the table partially updated because the operation canterminate before completion. If the server is a master replication server, ittreats threads associated with currently connected slaves like other clientthreads. That is, each one is marked as killed and exits when it next checksits state. 

If the server isa slave replication server, it stops the the I/O and SQL threads, if they areactive, before marking client threads as killed. The SQL thread is permitted tofinish its current statement (to avoid causing replication problems), and thenstops. If the SQL thread was in the middle of a transaction at this point, thetransaction is rolled back. 

If the slave isupdating a non-transactional table when it is forcibly killed, the slave's datamay become inconsistent with the master.

 

5. The server shuts downor closes storage engines.

At this stage,the server flushes the table cache and closes all open tables. Each storageengine performs any actions necessary for tables that it manages. For example, MyISAMflushes any pending index writes for a table. InnoDB flushes its buffer pool todisk (unless innodb_fast_shutdown is 2), writes the current LSN to the tablespace,and terminates its own internal threads.

 

6. The server exits.

 

三.相关示例

3.1 部署MySQL自启动

To start andstop MySQL automatically on your server, you need to add start and stopcommands to the appropriate places in your /etc/rc* files.

--如果配置MySQL的自动启用和关闭,需要讲相关命令添加到/etc/rc*目录里。

If you use theLinux server RPM package (MySQL-server-VERSION.rpm), or a native Linux packageinstallation, the mysql.server script may be installed in the /etc/init.d directorywith the name mysql. See Section 2.5.1, “Installing MySQL from RPM Packages onLinux”, for more information on the Linux RPM packages.Some vendors provide RPMpackages that install a startup script under a different name such as mysqld.

--如果是使用RPM包来安装的,已经部署到/etc/init.d/mysql了脚本,不需要其他配置。

If you installMySQL from a source distribution or using a binary distribution format thatdoes not install mysql.server automatically, you can install it manually. Thescript can be found in the support-files directory under the MySQL installationdirectory or in a MySQL source tree.

 

To install mysql.servermanually, copy it to the /etc/init.d directory with the name mysql, and thenmake it executable. Do this by changing location into the appropriate directorywhere mysql.server is located and executing these commands:

       --如果手工的部署启动启动脚本,执行如下2个命令:

shell> cp mysql.server /etc/init.d/mysql

shell> chmod +x /etc/init.d/mysql

 

Note:

Older Red Hatsystems use the /etc/rc.d/init.d directory rather than /etc/init.d. Adjust thepreceding commands accordingly. 

--老版本的Redhat 使用/etc/rc.d/init.d 代替/etc/init.d,所以需要创建一个link。

Alternatively,first create /etc/init.d as a symbolic link that points to /etc/rc.d/init.d:

shell> cd /etc

shell> ln -s rc.d/init.d .

 

After installingthe script, the commands needed to activate it to run at system startup dependon your operating system. 

       --脚本安装完之后,需要激活自启动。

 

On Linux, you can use chkconfig:

shell> chkconfig --add mysql

On some Linux systems, the followingcommand also seems to be necessary to fully enable the mysql script:

shell>chkconfig --level 345 mysql on

 

 

3.2 手工启动和关闭MySQL 示例

[root@rac2 /]#/usr/share/mysql/mysql.server stop

Shutting down MySQL.                                       [  OK  ]

[root@rac2 /]#/usr/share/mysql/mysql.server start

Starting MySQL....                                         [  OK  ]

[root@rac2 /]# service mysql stop

Shutting down MySQL.                                       [  OK  ]

[root@rac2 /]# service mysql start

Starting MySQL......                                       [ OK  ]

 

mysql.server stop stops the server by sending a signal to it. You can also stop the servermanually by executing mysqladmin shutdown.

 

[root@rac2 run]# mysqladmin shutdown

[root@rac2 run]# ps -ef|grep mysql  

root    30997  3596  0 14:51 pts/1    00:00:00 grep mysql

 

Mysqladmin 不能用来启动mysql。只能用来关闭。没有对应的启动语法。这个具体可以通过如下命令查看:

[root@rac2 run]# mysqladmin --help

 

另一个需要注意的问题,/var/lib/mysql/mysql.sock 文件仅在mysql 进程启动时才有,一旦mysql关闭,改文件也就自动清除。

 

[root@rac2 run]# ls /var/lib/mysql/mysql.sock

ls: /var/lib/mysql/mysql.sock: No such fileor directory

[root@rac2 run]# service mysql start

Starting MySQL.....                                        [  OK  ]

[root@rac2 run]# ls/var/lib/mysql/mysql.sock

/var/lib/mysql/mysql.sock

分享到:
评论

相关推荐

    Linux常见服务功能

    知识点: bootparamd 是一个老的 Sun 工作站从 Linux 网络启动服务,能够允许老的 Sun 工作站从 Linux 网络启动,提高系统的兼容性。 8. crond:周期地运行用户调度的任务服务。 知识点: crond 是一个周期地运行...

    MYSQL培训经典教程(共两部分) 1/2

    数据库的基本操作 46 3.1 MYSQL的启动与终止 47 3.1.1 直接运行守护程序 47 3.1.2 使用脚本mysql.server启动关闭数据库 48 3.1.3 使用mysqladmin实用程序关闭、重启数据库 49 3.1.4 启动或停止NT平台...

    MYSQL培训经典教程(共两部分) 2/2

    数据库的基本操作 46 3.1 MYSQL的启动与终止 47 3.1.1 直接运行守护程序 47 3.1.2 使用脚本mysql.server启动关闭数据库 48 3.1.3 使用mysqladmin实用程序关闭、重启数据库 49 3.1.4 启动或停止NT平台...

    【数据分析与科学计算】Anaconda安装与环境管理教程:Python数据科学平台快速入门指南

    内容概要:本文档详细介绍了Anaconda的安装、环境管理和包管理的方法。Anaconda是一个强大的Python数据科学平台,提供了包管理器和环境管理器。安装部分包括了从官网或国内镜像源下载并安装Anaconda,安装时建议修改安装路径并勾选添加环境变量。环境管理方面,涵盖了创建、激活、退出、查看和删除虚拟环境的具体命令。包管理则讲解了在虚拟环境中安装、卸载以及查看已安装包的操作。此外,还提供了配置国内镜像源以提高下载速度的方法,以及一些常用命令与技巧,如更新所有包、导出环境和从配置文件创建环境等。; 适合人群:对Python数据科学感兴趣的初学者,以及需要使用Anaconda进行环境和包管理的开发者。; 使用场景及目标:①帮助用户快速完成Anaconda的安装;②让用户掌握虚拟环境的创建与管理,确保不同项目之间的依赖隔离;③使用户能够熟练地进行包的安装、卸载和更新操作;④提高用户在国内网络环境下获取资源的速度。; 阅读建议:阅读时可结合自身需求重点学习环境管理和包管理的相关命令,对于配置镜像源的内容,可根据自己的网络情况选择是否配置。

    计算机图形学实验一(基本图形生成(一))

    基于visualstudio2010,包括所有源代码,可以运行, 编程实现直线的 DDA 算法及 Bresenham 算法绘制任意斜率的直线。 设计一个图形并调用 1 中的 Bresenham 算法程序绘制。

    3D空间避障与路径规划:RRT与RRT算法的MATLAB实现及应用 3D建模 基于RRT和RRT算法的3D场景路径规划与障碍物距离分析

    内容概要:本文详细介绍了RRT(快速随机树)和RRT*算法在3D场景下的应用,重点在于如何绕过两个圆柱障碍物到达目标点。文中通过MATLAB代码实现了路径规划的具体步骤,包括初始化参数、随机采样、寻找最近节点、扩展树结构、判断是否绕过障碍物以及输出路径图和路径点与障碍物最小距离变化图。此外,还对算法进行了简要介绍,指出了其优点和局限性。 适合人群:从事机器人技术、自动化控制、机械臂路径规划的研究人员和技术人员,尤其是对3D空间避障与路径规划感兴趣的开发者。 使用场景及目标:①帮助研究人员理解和实现RRT和RRT*算法在3D环境中的具体应用;②为移动机器人和机械臂的路径规划提供理论支持和实践指导;③通过图示和代码示例,使读者能够更好地掌握算法的实现细节。 其他说明:虽然RRT和RRT*算法在处理复杂环境下的路径规划问题时表现出色,但也存在一些局限性,如可能陷入局部最优解等问题。未来可以通过改进算法来提升其性能和适用性。

    科普内容创作者科普文章AI写作提示词科普论文写作提示词(AI提示词Prompt)

    科普内容创作者科普文章AI写作提示词科普论文写作提示词(AI提示词Prompt)

    一种新型具有多陷波特性的超宽带天线.zip

    一种新型具有多陷波特性的超宽带天线.zip

    cmd-bat-批处理-脚本-vcvars32.zip

    cmd-bat-批处理-脚本-vcvars32.zip

    模块化SOC主动均衡模型:六节电池串联系统的充放电均衡解决方案 电池管理系统

    内容概要:本文介绍了一种专为六节电池串联设计的模块化SOC主动均衡模型。该模型采用底层双向反激变换器和顶层buck-boost均衡的双重策略,旨在解决电池组中各节电池SOC不一致的问题。通过模块化设计,模型实现了灵活性和扩展性,适用于不同类型的电池组。文章详细介绍了模型的工作原理、设计思路以及仿真实验结果,验证了模型的有效性。 适合人群:从事电池管理系统的研发人员、电力电子工程师、科研工作者。 使用场景及目标:①研究电池组充放电均衡技术;②优化电池管理系统的设计;③作为论文创新和仿真实验的基础。 阅读建议:重点理解双向反激变换器和buck-boost均衡的具体实现方法及其协同工作的机制,结合仿真实验数据进一步验证模型效果。

    cmd-bat-批处理-脚本-LaunchDevCmd.zip

    cmd-bat-批处理-脚本-LaunchDevCmd.zip

    digital-clock-top.bit文件

    南邮数字钟设计实验最终生成的digital_clock_top.bit文件

    2025年系统集成项目管理工程师考试大纲及培训指南2.doc

    2025年系统集成项目管理工程师考试大纲及培训指南2.doc

    校园网络课程设计项目全面规划

    校园网络课程设计

    实证数据-1995-2022年网络媒体关注度、报刊媒体关注度与媒体监督相关数据-社科经管.rar

    该数据集收录了1995-2022年期间中国网络媒体与报刊媒体关注度及媒体监督相关的实证研究数据,适用于社会科学与经济管理领域研究。数据内容包含以下三方面指标: 媒体关注度指标:包括标题及内容中出现特定主体的新闻总数,按正、中、负面情感分类统计,并区分原创与非原创内容。例如,标题提及主体的新闻总量、内容提及主体的新闻总量,以及正面/中性/负面新闻的原创数量。 媒体监督指标:采用Janis-Fadner系数(J-F系数)量化媒体监督力度,基于媒体报道的正面与负面内容比例计算,反映媒体对企业、事件或话题的舆论监督强度。 数据类型与结构:提供原始数据、参考文献、统计代码(Do文件)及处理后的结构化数据,覆盖时间跨度达28年。数据来源于公开新闻报道及第三方平台监测,涵盖网络媒体(如门户网站、社交媒体)与报刊媒体的多维信息。 该数据集可用于分析媒体舆论对经济主体行为的影响、风险抑制机制研究(如企业违规行为与媒体曝光的关联性)、舆情传播特征与社会治理等领域,为实证研究提供基础数据支持。数据格式兼容主流统计软件,便于直接应用于计量模型分析。

    cmd-bat-批处理-脚本-showWLAN.zip

    cmd-bat-批处理-脚本-showWLAN.zip

    F0C-stm32f103c8t6-DRV8313-AS5600-2804无刷电机.rar

    @吾乃周树人中人 【自制】STM32无刷电机FOC驱动一体板---无刷电机能放歌?【FOC三环控制】 (https://www.bilibili.com/video/BV17FUeYQEXa/?spm_id_from=333.1387.favlist.content.click&vd_source=b344881caf56010b57ef7c87acf3ec92) 这是一块集成驱动、控制、CAN通信、磁编码器、还有电流检测的无刷电机驱动板 功能1:低速高扭矩模式 功能2:双电机同步模式 功能3:力反馈模式 功能4:速度环+位置环模式 功能5:速度环+电流环模式 功能6:指尖陀螺模式 功能7:指尖陀螺plus模式 功能8:阻尼旋钮模式 功能9:多档开关模式 功能10:播放音乐 主控:STM32F103C8T6 使用Hal库 磁编码芯片:AS5600 IIC通信 电流检测芯片:两路 INA240 模拟量输入 can芯片:TJA1050 有感电机:需要在电机轴上固定径向磁铁 供电电压:12V

    NVIDIA DLI 深度学习基础课程证书领取答案

    NVIDIA深度学习学院(DLI)是一个专注于深度学习、加速计算和人工智能领域的培训与认证平台。通过其丰富的学习资源,学员可以掌握构建、训练和部署神经网络等核心技能。本文将重点介绍NVIDIA DLI深度学习基础课程中的关键知识点,包括深度学习模型的构建、数据预处理等。 模型构建 在代码示例中,使用TensorFlow的Keras模块导入了预训练的VGG16模型作为基础架构。 关键点包括: 使用keras.applications.VGG16加载VGG16模型,其中weights="imagenet"表示使用基于ImageNet数据集的预训练权重;input_shape=(224,224,3)指定了输入图像的尺寸为224×224像素,且为三通道(RGB);include_top=False意味着不包含原始模型的顶层全连接层。 通过base_model.trainable = False冻结基础模型的所有层,确保在后续训练中这些层的权重不会更新。 构建新模型时,创建输入层inputs = keras.Input(shape=(224,224,3)),利用基础模型提取特征x = base_model(inputs, training=False),随后添加全局平均池化层x = keras.layers.GlobalAveragePooling2D()(x),并在最后添加一个具有6个节点的分类层outputs = keras.layers.Dense(6, activation="softmax")(x),适用于多分类任务。 使用model.summary()查看模型的结构细节。 编译模型时,选择交叉熵损失函数loss="categorical_crossentropy"、Adam优化器optimizer="adam"以及准确率metrics=["accuracy"]作为评估指标

    基于变值测量模型的心电信号可视化研究.zip

    基于变值测量模型的心电信号可视化研究.zip

    基于Java与SQL Server的学生成绩管理应用开发

    《Java+SQL Server学生成绩管理系统》是一款融合了Java编程语言与SQL Server数据库技术的软件,专为高校或教育机构设计,用于高效管理学生的考试成绩。它具备数据录入、查询、统计分析等功能,旨在提升教学管理效率。 该系统的核心技术包括:一是Java后端开发。Java承担后端任务,处理HTTP请求、实现业务逻辑以及与数据库交互。项目可能借助Spring框架,利用其依赖注入、AOP等特性,简化开发流程。Spring MVC则助力实现MVC模式,处理Web请求。二是JSP技术。JSP是一种动态网页技术,页面融合HTML、CSS、JavaScript和Java代码,用于呈现用户界面及处理前端简单逻辑。三是SQL Server数据库。作为数据存储后端,SQL Server支持通过SQL语句完成表的创建、数据的增删改查等操作,还可借助存储过程和触发器提升功能与安全性。四是数据库设计。系统数据库设计关键,包含“学生”“课程”“成绩”等表,通过主外键关联数据,如“学生”表与“成绩”表通过学生ID关联,“课程”表与“成绩”表通过课程ID关联。五是B/S架构。采用浏览器/服务器架构,用户经Web浏览器访问系统,计算与数据处理在服务器端完成,降低客户端硬件要求。六是安全性。系统设置身份验证与授权机制,如登录验证,确保信息访问安全。同时,为防范SQL注入等威胁,采用预编译语句或ORM框架处理SQL命令。七是异常处理。Java的异常处理机制可捕获运行时问题,保障系统稳定性与用户体验。八是报表统计功能。系统具备成绩统计功能,如计算平均分、排名、及格率等,常使用聚合函数(SUM、AVG、COUNT等)和GROUP BY语句。九是设计模式。开发中可能运用单例模式、工厂模式等,提升代码可维护性和复用性。十是版本控制。项目可能使用Git等版本控制系统,便于团队协作与代码管理。 该学生成绩管理

Global site tag (gtag.js) - Google Analytics