16
Migration to Firebird 3.x Fabio Codebue Firebird Foundation Committe Member

Firebird 3.x guida alla migrazione

Embed Size (px)

Citation preview

Migration to Firebird 3.x

Fabio CodebueFirebird Foundation

Committe Member

REALLY WE NEED ANOTHER FIREBIRD VERSION?

WHY MIGRATION

• WHY MIGRATION

• Because we have a new logo?• Because we have written marvellous code?• Because we have lowest price of the market?• Because you have nothing else todo?

MIGRATION CHECKS

• USEFUL TIPS• New features in Firebird often require changes to the

storage format of the database. Maintaining the ability to access many different old versions of the database structure complicates the code of the Firebird server.

• In order to use existing databases under Firebird 3, you must convert them to the new storage format.

• FIRST check you can backup and restore DB• Firebird 3 can access only ODS 12 databases

CHANGE ODS TO 12.0• CHECKS

• Test the database integrity with gbakgbak -user <user> -pas <password> -b -v -g -se <service_mgr> <database> <backupfile>• If the gbak backup fails indicating a possible corruption gfix -v -full -user <user> -pas <password> <database>• If gfix reports transactions in limbo gfix -v -full –mend <user> -pas <password> <database> • Once you have a good backup, restore itgbak -user <user> -pas <password> -c -v -se <service_mgr> <backupfile> <database>

CHARACTER ENCODING

• PROBLEM WITH CHARACTER ENCODING• If you currently run Firebird 2.1 or later • You should perform this check before starting to migrate

to Firebird 3• Firebird uses the character set UNICODE_FSS to store the

data in the system tables (RDB$...)• To solve the problem use gbak during restore

• -fix_fss_metadata or -fix_fss_data

METADATA CHECKS

• VALIDATING METADATA• Firebird 3 has added reserved words• The gbak restore recognizes table and column names that

are reserved words • and changes them to quoted identifiers.

• However, triggers, stored procedures, validity constraints, and even view definitions

• And gbak doesn’t recognize them

• EXPORT DATABASE TO SQL and run… so check errors!

BACKUP/RESTORE PROCESS

• SPEED UP BACKUP/RESTORE PROCESS• Use the -g switch during the backup – no garbage

collection• Use the -se service_mgr switch, for both the backup and

the restore - eliminating communication time• Use SSD … naturally.. .or not?• Increase the parameter SortMemSize in firebird.conf

temporarily

USERS ARE CHANGED!

• USERS ARE NOT MORE THE SAME!• Firebird 3 have centralized users database• The default name for the security database in Firebird 3 is

security3.fdb • PRO: user management can be simpler • CONS: all user can access to all DB on server…

• If he know path and name!• You cannot migrate the security database of older

Firebird versions to Firebird 3.

LOCAL USERS• LOCAL USERS

• Introduced the concept of local, per database, users• You can change name of user database• SecurityDatabase can also be set per database in the

databases.confbase1 = c:\databases\base1.fdb { SecurityDatabase = c:\dbUsers\users_base1.fdb } base2 = c:\dbs\base2.fdb { SecurityDatabase = base2 } base3 = c:\dbs\base3.fdb

PASSWORDS

• USER PASSWORDS• Firebird does not store users' passwords ….in the security database • Firebird stores a hash of the password • Remember that up to Firebird 2.5only the first eight bytes of a password are considered in the hash calculation • Firebird 3 uses up to 255 bytes of a password for hash

calculation!

INITIALIZING SECURITY DB

• Initializing the security database • There are two ways

• Make sure that the Firebird process is not running• Open a command prompt and, in the Firebird 3 root

directory, type:

gsec -user SYSDBA gsec>add SYSDBA -pw masterkeygsec>quit• But… gsec is deprecated in firebird 3.0

INITIALIZING SECURITY DB

• Initializing the security database • 2 mode

• Make sure that the Firebird process is not running• Open a command prompt, and call isql like this: isql -user SYSDBA employee SQL>create user SYSDBA password 'masterkey'; SQL>commit; SQL>quit;• 3. Start Firebird

MANAGING USERS WITH SQL• Managing users using SQL

CREATE USER name {PASSWORD ‘apassword’} [ options ] [ TAGS ( tag [, tag [, tag ...]] ) ] [USING PLUGIN name]

ALTER USER name SET [PASSWORD ‘apassword’] [ options ] [ TAGS ( tag [, tag [, tag ...]] ) ] [USING PLUGIN name]

ALTER CURRENT USER SET [PASSWORD ‘apassword’] [ options ] [ TAGS ( tag [, tag [, tag ...]] ) ] [USING PLUGIN name]

CREATE OR ALTER USER name SET [PASSWORD ‘apassword’] [options] [ TAGS ( tag [, tag [, tag ...]] ) ] [USING PLUGIN name]

DROP USER nome [USING PLUGIN name];

LEGACY APPLICATION• Firebird 3 introduces a new C++ object oriented API• While maintaining full compatibility with the legacy API.• .NET applications

• NET Provider did not yet support the new communication protocol encryption or SRP authentication

• set the following parameters in firebird.conf:WireCrypt = enabled (accept unenctpted connection)

• Jaybird applications• Java Provider did not yet support the new communication protocol encryption or SRP

authenticationWireCrypt = EnabledAuthServer = Srp, Win_Sspi, Legacy_AuthUserManager = Srp, Legacy_UserManager

Thanks…

Fabio CodebueFirebird Foundation

Committe Member

[email protected]

Firebird Optimization www.ibsurgeon.it