将MySQL迁移到Oracle(一)_MySQL
1、导言
如你可能想象的,迁移一个数据库和使用它的应用程序是一件不小的事。要迁移数据库平台和使用它的应用程序必然会需要做很多工作。在这个包含两部分的文档里,我们将讨论围绕这个过程的所有步骤,问问你自己,要注意些什么,和怎样在有限的停机时间窗口中进行所有这些事情。最后,你的技术将获得提高,无论是通过书籍和刊物、论坛、培训或是认证。
2、评估移植计划
在你做任何事情之前,你将需要制定出一个要做什么的计划或提纲。我知道,我知道,大家都不喜欢写文档。但是这是很重要的一步,因为在技术方面,它将使你决定需要做些什么,而在管理方面,它将按部就班地描述这个过程,所以他们可以看到这个复杂性,考虑业务影响、必备系统的成本、进行这个移植所需要的资源和整个时间进度表。
这个评估应该包括哪些内容呢?首先,你应该确定你现在用的是哪个版本的MySQL。浏览一下你现在在使用哪些特性,例如数据类型(numeric、character、enumerated等等),你在使用什么类型的存储引擎,例如MyISAM、Innodb等等。想想你在使用什么索引类型和额外的功能,例如你可能在你的数据库中使用了视图和触发器。还有,检查一下你数据库中的存储过程,因为这些将需要进行重写。还要仔细地考虑MySQL复制。如果它是为整个数据库建立的,那么它将更加趋向于使用Oracle的备用数据库或DataGuard特性,而如果你使用表复制和你的my.cnf文件里的通配符语法来使用表,那么这更有可能是使用Oracle中的物化视图(以前被称为快照)来做的。
在Oracle方面,你将需要考虑你所运行的版本下的情况、MySQL丰富的数据类型和对象怎么匹配到Oracle中。考虑主键上的自动增加属性。尽管Oracle具有序列,但是它的序列和MySQL中的自动增加稍稍有些不同。例如它不保证数字的连续性。因此,你可能会在基于Oracle缓存序列方式的键值上遇到问题。思考一下这将怎样影响你的应用程序的行为。尽管不是移植过程的直接部分,但是你还是需要考虑一下你想怎样备份你的Oracle系统。输出工具使用MySQL的mysqldump非常适合,而RMAN当然提供了你在像innobackup或MySQL中可用的ibbackup这样的工具中可能找到的所有热备份功能。
在你的评估文档中,记录所有这些发现,并尽可能地深入。现在你工作得越勤奋,在之后的移植过程中你遇到的问题就越少。
3、 开发移植和建立
a、准备
准备工作将涉及到建立你的开发环境。这包括申请合适的硬件、建立数据中心、安装Oracle 软件,和建立你的启动数据库。在建立这些时,考虑一下Oracle 的最优方法,例如使用RAID 10作为你的基础磁盘存储。布局你的重复记录、分配足够的系统和sysaux表空间,等等。你还将要考虑你的新数据库的字符设置。注意到US7ASCII 限制欧洲的和带重音的字符。最好使用WE8ISO8859P1。如果你可能会在你的数据库中使用亚洲字符,那么你要看看Oracle 的National Language Services (NLS)功能,并考虑多字节字符集。你还要为数据和索引创建表空间。考虑一下你的源对象的规模。在文件系统上你可以在数据目录下使用“du -sm dir_name”。留出25-50%的空间用于将来的发展。
b、 数据库结构移植
在MySQL 方面,提取数据库的结构(在Oracle中是一个schema)你可以使用下面的方式:
$ mysqldump --no-data my_db_name > my_db_name.mysql
因为在语法方面有一些不同,你不能在Oracle 中直接运行这个脚本。你所要做的是你自己重写这些CREATE TABLE 和CREATE INDEX 语句。很显然,如果在你的数据库中有大量的对象,那么你需要考虑采用一种自动的方式来进行这项工作。我们将在这篇文章的第二部分中讨论Oracle的移植工作台(Migration Workbench),但是现在我们推荐逐个地重写这些对象。这也将为你提供数据库中对象的一个排序目录,并使你对它们更加了解和将它们都移植过来。开发人员在这个过程中也要保持谨慎。通过将表和对象逐个地改变它们的语法,一方面它们将获得更新,或换成Oracle 语法,另一方面,真正地浏览了这些对象,从而考虑在它们的应用程序代码中可能需要做哪些改动。
最终,应用程序的变更将是移植到一个新数据库引擎上的庞大的一部分,不论你的开发人员在编写数据库独立代码方面是多么的勤快。所以,这个手动过程将使你很好地了解你错综复杂的数据库。
4、总结
是的,将一个数据库应用程序移植到一个新的平台上例如Oracle 上不是一个简单的工作,但是它是可以实现的,而且通过适当的准备工作,它也可以被管理起来。在建立任何系统之前,对你目前的系统进行恰当的评估,并在移植之前检查和管理时间、硬件、软件和人员所需。
在这篇文章的第二部分,我们将讨论从产品中移植实际的数据,检查Oracle的移植工作台(Migration Workbench),它可以为你节省时间,并讨论潜在的应用程序问题和挑战。然后我们将回顾整个过程,并仔细地计划你产品数据库和应用程序的最终移植

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Oracle views can be exported through the EXP utility: Log in to the Oracle database. Start the EXP utility, specifying the view name and export directory. Enter export parameters, including target mode, file format, and tablespace. Start exporting. Verify the export using the impdp utility.

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
