Updated schemarouter documentation.
This commit is contained in:
@ -14,18 +14,24 @@ In almost all the cases these can be avoided by proper server configuration and
|
||||
|
||||
Here is an example configuration of the schemarouter router:
|
||||
|
||||
[Shard Router]
|
||||
type=service
|
||||
router=schemarouter
|
||||
servers=server1,server2
|
||||
user=myuser
|
||||
passwd=mypwd
|
||||
```
|
||||
Shard Router]
|
||||
type=service
|
||||
router=schemarouter
|
||||
servers=server1,server2
|
||||
user=myuser
|
||||
passwd=mypwd
|
||||
auth_all_servers=1
|
||||
```
|
||||
|
||||
The module generates the list of databases based on the servers parameter using the connecting client's credentials. The user and passwd parameters define the credentials that are used to fetch the authentication data from the database servers. The credentials used only require the same grants as mentioned in the configuration documentation.
|
||||
|
||||
The list of databases is built by sending a SHOW DATABASES query to all the servers. This requires the user to have at least USAGE and SELECT grants on the databases that need be sharded.
|
||||
|
||||
If you are connecting directly to a database or have different users on some of the servers, you need the `auth_all_servers=1` parameter to fetch authentication data from all the backend servers. This way MaxScale forms a union of all the users and their grants from all the servers.
|
||||
|
||||
For example, if two servers have the database 'shard' and the following rights are granted only on one server, all queries targeting the database 'shard' would be routed to the server where the grants were given.
|
||||
|
||||
```
|
||||
# Execute this on both servers
|
||||
CREATE USER 'john'@'%' IDENTIFIED BY 'password';
|
||||
@ -33,13 +39,14 @@ CREATE USER 'john'@'%' IDENTIFIED BY 'password';
|
||||
# Execute this only on the server where you want the queries to go
|
||||
GRANT SELECT,USAGE ON shard.* TO 'john'@'%';
|
||||
```
|
||||
|
||||
This would in effect allow the user 'john' to only see the database 'shard' on this server. Take notice that these grants are matched against MaxScale's hostname instead of the client's hostname. Only user authentication uses the client's hostname and all other grants use MaxScale's hostname.
|
||||
|
||||
## Limitations
|
||||
|
||||
The schemarouter router currently has some limitations due to the nature of the sharding implementation and the way the session variables are detected and routed. Here is a list of the current limitations.
|
||||
|
||||
- Cross-database queries (e.g. SELECT column FROM database1.table UNION select column FROM database2.table) are not supported and are routed either to the first explicit database in the query, the current database in use or to the first available database, if none of the previous conditions are met.
|
||||
- Cross-database queries (e.g. `SELECT column FROM database1.table UNION select column FROM database2.table`) are not supported and are routed either to the first explicit database in the query, the current database in use or to the first available database, if none of the previous conditions are met.
|
||||
|
||||
- Queries without explicit databases that are not session commands in them are either routed to the current or the first available database. This means that, for example when creating a new database, queries should be done directly on the node or the router should be equipped with the hint filter and a routing hint should be used.
|
||||
|
||||
|
Reference in New Issue
Block a user