bw logo

Chapter 11. MySQL Support

Following is described the minimal set of steps required to enable MySQL support for a server cluster. They assume that a MySQL database has been installed and configured as outlined in the Server Installation Guide's chapter Simple Installation, section Installing, Configuring and Starting MySQL.

11.1. Compiling DBMgr with MySQL Support

The DBMgr binary provided with the default BigWorld package does not contain any database engines built in. Database engines are provided via a plugin interface and are loaded from the bigworld/bin/Hybrid64/dbmgr-extensions directory.

BigWorld provides implementations for two database engines, MySQL and XML. The implementation for the engine plugins are separated into two components, the plugin wrapper source code that registers with the DBMgr engine factory, and the back end library implementing the core functionality for that engine type. The source code for the plugin wrappers can be found in bigworld/src/server/dbmgr_extensions/bwengine_<engine_type>. The source code for the back end libraries for each engine type can be found in bigworld/src/lib/dbmgr_<engine_type>.

By default BigWorld ships with the XML database engine plugin compiled and ready for use. This allows users to quickly start using BigWorld Technology without having to configure a production database to test a simple package. See the licensing_information.txt document for MySQL licensing considerations.

To enable compilation of the MySQL DBMgr engine plugin, make sure that the MySQL development files are installed on the build system. To do this, as root, run the following command:

# yum install mysql-devel

Next, in order to compile the MySQL DBMgr engine plugin and other support tools for the MySQL implementation, change directory to the DBMgr source code:

$ cd bigworld/src/server/dbmgr

Now type make.

$ make

This step will also potentially rebuild DBMgr, however as it will compile all the required tools at the same time, it is much easier than individually entering every directory to recompile.

11.2. Update bw.xml To Use MySQL

Once DBMgr has been compiled to communicate with a MySQL server, the game resource configuration file <res>/server/bw.xml needs to be updated with details on username, password and the host machine the MySQL server is running on.

The example below illustrates FantasyDemo configuration (via fantasydemo/res/server/bw.xml):

<dbMgr>
    <type>     mysql                     </type>
    <host>     my_mysql_server_machine </host>
    <username> bigworld </username>
    <password> my_pass </password>
    <databaseName>     fantasydemo </databaseName>
</dbMgr>

Example fantasydemo/res/server/bw.xml

For details on these fields and other relevant configuration options for your production environment, see Server Configuration with bw.xml.

11.3. Synchronise Database With Entity Definitions

DBMgr requires the MySQL database table structure to be synchronised with the current entity definitions. To initialise the MySQL database with the correct table structure run the sync_db tool:

$ $MF_ROOT/bigworld/bin/Hybrid64/commands/sync_db

This tool will not run if there are unconsolidated secondary databases. For details on data consolidation, see Data Consolidation Tool.

Note

A SyncDB binary is not shipped by default with BigWorld releases. In order to use SyncDB you will need to compile the binary from bigworld/src/server/tools/sync_db, or have already built DBMgr with MySQL support enabled.

11.4. Enabling Secondary Databases

Secondary databases can only be enabled when MySQL support is enabled. Please see the document Server Programming Guide's chapter Secondary Databases for details about secondary databases.

To enable secondary database support, you must:

  • Enable MySQL support (see above).

  • Build the data consolidation tool by issuing the make command from within the bigworld/src/server/tools/consolidate_dbs directory.

  • Set the bw.xml option <baseApp>/<secondaryDB>/<enable> to true.

11.5. Privileges

Below are the MySQL privileges required for each BigWorld component that communicates with a MySQL database.

Component Required Privileges User
DBMgr SELECT, INSERT, UPDATE, DELETE

dbMgr/username

(bw.xml)

sync_db UPDATE, ALTER, CREATE, DROP, INDEX

dbMgr/username

(bw.xml)

snapshot.py SELECT

dbMgr/username

(bw.xml)

snapshot_helper RELOAD

dbMgr/username

(bw.xml)

StatLogger SELECT, INSERT, UPDATE, DELETE, CREATE

preferences/options/dbUser

(bigworld/tools/server/stat_logger/preferences.xml)

WebConsole SELECT, INSERT, UPDATE, DELETE, CREATE

sqlobject.dburiame

(bigworld/tools/server/web_console/[dev|prod].cfg)

Use MySQL's GRANT command to set privileges for a user.

$ mysql -u root
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON fantasydemo.* TO 'bigworld'@'localhost' IDENTIFIED BY 'bigworld_passwd';

11.6. The ClearAutoLoad tool

Over the course of a server run, entities may be marked for auto-loading so that subsequent server startups will automatically create these entities and the spaces that they inhabited, with the entity data and space data that was present in those spaces at the time that the server was shut down. Additionally, the server game time is persistent.

It is sometimes desirable to clear that data so that the server starts from a clean slate without auto-loading any entity data, and reset the server game time to 0. There is a command tool called clear_auto_load which can clear this data. It is located in bigworld/bin/Hybrid64/commands/clear_auto_load. Running it without command line arguments will clear the auto-load data in the database specified in the bw.xml for the current user.

$ bigworld/bin/Hybrid64/commands/clear_auto_load

You cannot run this tool while there is an instance of DBMgr or other BigWorld tool accessing the database.

Note

A ClearAutoLoad binary is not shipped by default with BigWorld releases. In order to use ClearAutoLoad you will need to compile the binary from bigworld/src/server/tools/clear_auto_load.