Beschrijving
HyperDB is a very advanced database class that replaces a few of the WordPress built-in database functions. The main differences are:
* HyperDB can be connect to an arbitrary number of database servers,
* HyperDB inspects each query to determine the appropriate database.
Het ondersteunt:
- Lezen en schrijven van servers (replicatie)
- Configureerbare prioriteit voor lezen en schrijven
- Lokale en externe datacenters
- Privé en openbare netwerken
- Verschillende tabellen op verschillende databases/hosts
- Smart post-write master reads
- Failover for downed host
- Geavanceerde statistieken voor profilering
- WordPress multisite
Het is gebaseerd op de code die momenteel wordt gebruikt in de productie op WordPress.com met veel MySQL servers die meerdere datacenters omvatten.
Installatie
Er gaat niets in de plugins folder.
-
Voer een configuratie in
db-config.php
. -
Deploy
db-config.php
in the directory that holdswp-config.php
. This may be the WordPress root or one level above. It may also be anywhere else the web server can see it; in this case, defineDB_CONFIG_FILE
inwp-config.php
. -
Deploy
db.php
to the/wp-content/
directory. Simply placing this file activates it. To deactivate it, move it from that location or move the config file.
Elke waarde van WP_USE_MULTIPLE_DB
zal worden genegeerd door HyperDB.
FAQ
-
Wat kan ik met HyperDB doen dat ik niet met WPDB kan doen?
-
WordPress.com, the most complex HyperDB installation, manages millions of tables spanning thousands of databases. Dynamic configuration logic allows HyperDB to compute the location of tables by querying a central database. Custom scripts constantly balance database server resources by migrating tables and updating their locations in the central database.
Stretch your imagination. You could create a dynamic configuration using persistent caching to gather intelligence about the state of the network. The only constant is the name of the configuration file. The rest, as they say, is PHP.
-
Hoe ondersteunt HyperDB replicatie?
-
HyperDB biedt geen replicatiediensten. Dat gebeurt door het configureren van MySQL-servers voor replicatie. HyperDB kan vervolgens worden geconfigureerd om deze servers op de juiste manier te gebruiken, bijvoorbeeld door verbinding te maken met masterservers om schrijfquery’s uit te voeren.
-
Hoe ondersteunt HyperDB load balancing?
-
HyperDB selecteert willekeurig databaseverbindingen van prioriteitsgroepen die je configureert. De meest voordelige verbindingen worden als eerste geprobeerd. Zo kun je je configuratie optimaliseren voor netwerktopologie, hardwarecapaciteiten of elk ander schema dat je verzint.
-
How does HyperDB support failover?
-
Failover describes how HyperDB deals with connection failures. When HyperDB fails to connect to one database, it tries to connect to another database that holds the same data. If replication hasn’t been set up, HyperDB tries reconnecting a few times before giving up.
-
Hoe ondersteunt HyperDB partitionering?
-
HyperDB allows tables to be placed in arbitrary databases. It can use callbacks you write to compute the appropriate database for a given query. Thus you can partition your site’s data according to your own scheme and configure HyperDB accordingly.
-
Is er een voordeel aan het gebruik van HyperDB met slechts één databaseserver ?
-
Geen die is gemeten. HyperDB probeert het op zijn minst opnieuw voordat hij de verbinding verbreekt, dus het kan helpen in gevallen waarin de webserver tijdelijk geen verbinding kan maken met de databaseserver .
Eén manier waarop HyperDB verschilt van WPDB is dat HyperDB niet probeert verbinding te maken met een database totdat er een query is gemaakt. Zo kan een site met voldoende agressieve persistente caching alleen-leesbaar blijven, ondanks dat de database onbereikbaar wordt.
-
What if all database servers for a dataset go down?
-
Since HyperDB attempts a connection only when a query is made, your WordPress installation will not kill the site with a database error, but will let the code decide what to do next on an unsuccessful query. If you want to do something different, like setting a custom error page or kill the site, you need to define the ‘db_connection_error’ callback in your db-config.php.
Beoordelingen
Bijdragers & ontwikkelaars
“HyperDB” is open source software. De volgende personen hebben bijgedragen aan deze plugin.
BijdragersVertaal “HyperDB” naar jouw taal.
Interesse in ontwikkeling?
Bekijk de code, haal de SVN repository op, of abonneer je op het ontwikkellog via RSS.
Changelog
1.9
- Restore the behavior where we retry failed connection attempts to masters;
- Unbreak the logic for marking servers as down – in r2625068 the key for marking server as down was mistakenly changed to “server_readonly_$host$port” instead of “server_state_$host$port”
- If all masters are marked as read-only, ignore the read-only flag and still try to connect; otherwise we might end up incorrectly breaking the master connections for 2 minutes (APCu cache time) if we had temporarily set read-only on them;
- Fix a bug where having $dbhname in the server state keys can delay marking server as down or read_only by doing it once for all possible datasets and operations instead of once for the host+port;
- Fix a bug where we could mark server as read-only even though the ER_OPTION_PREVENTS_STATEMENT error was returned for a different reason; now we match to make sure we actually have ‘read-only’ in the returned error;
- Fix a bug where the correct tracking of the unique read-only servers or lagged slaves might fail if we have duplicate servers for the same dataset;
- Fix a bug where we would not mark masters as read-only in HyperDB if they were set read-only on the server side after we already opened a connection;
- Fix a bug where we might stop respecting the minimum configured amount of retries per dataset;
- Revert the persistent unused_servers logic which was added in HyperDB 1.8 because: it can cause connection failures when the available servers are exhausted, we might use servers with wrong priorities, and not see newly added servers to HyperDB. Some examples of conditions which would trigger these behaviors include: server-side disconnects on timeout; when we manually disconnect open connections in long-running scripts; when we switch between different datasets on the same remote MySQL server; we’ve gone over the configured max_connections and started disconnecting existing connections to accomodate new ones;
- Make sure the read_only and the downed logic still works in environments which don’t have APCu or APCu is badly fragmented by adding local caching
- Correct the dbh property type
- PHP 8.0 compatibility for call_user_func_array() and db_connections attribute
1.8
- Support for fallback master connections
- Add support for marking servers read-only
- Fix the issue when
do_action()
is not available - Use APCu to cache the results of server responsiveness
- Add support for the
utf8mb4
server capability
1.7
- Add support for information_schema and transactions
- Requires WordPress 4.2 for wpdb::get_table_from_query()
1.6
- Add support for MYSQL_CLIENT_FLAGS which was added to wpdb in [21609]
- Fix PHP 7.3 Notice
1.5
- Fix WordPress 4.8.3 SQLi vulnerability
- Add action for SQL logging
- Nooit db_connect voor SELECT FOUND_ROWS()
- Betere opschoning bij het verbreken van db-verbindingen
1.4
- Additional logging for HyperDB failures and do not save “null” queries.
1.3
- Improved failed query tracking
1.2
- PHP7 compatibiliteit
- MySQLi ondersteuning
- utf8mb4 tekenset toestaan
1.1
- Callbacks functionaliteit uitgebreid
- Toegevoegd verbinding fout callback
- Added replication lag detection support
1.0
- Ondersteuning voor WPMU en BackPress verwijderd.
- New class with inheritance: hyperdb extends wpdb.
- Nieuw schema voor instantiatie: $wpdb = new hyperdb(); sluit dan config in. Geen $db_* globals meer.
- Nieuwe configuratie bestandsnaam (db-config.php) en logica voor het lokaliseren ervan. (ABSPATH, dirname(ABSPATH) of vooraf gedefinieerd)
- Added fallback to wpdb in case database config not found.
- Renamed servers to databases in config in an attempt to reduce ambiguity.
- Added config interface functions to hyperdb: add_database, add_table, add_callback.
- Refactored db_server array to simplify finding a server.
- Removed native support for datacenters and partitions. The same effects are accomplished by read/write parameters and dataset names.
- Removed preg pattern support from $db_tables. Use callbacks instead.
- Removed delay between connection retries and avoid immediate retry of same server when others are available to try.
- Added connection stats.
- Added save_query_callback for custom debug logging.
- Refined SRTM granularity. Now only send reads to masters when the written table is involved.
- Improved connection reuse logic and added mysql_ping to recover from “server has gone away”.
- Added min_tries to configure the minimum number of connection attempts before bailing.
- Added WPDB_PATH constant. Define this if you’d rather not use ABSPATH . WPINC . ‘/wp-db.php’.