In MySQL jargon that is called "multi-source replication" and that is a supported configuration in MySQL 5.7.
The MySQL manual comes with a complete tutorial:
https://dev.mysql.com/doc/refman/5.7/en/replication-multi-source.html
MySQL Multi-Source Replication enables a replication slave to receive transactions from multiple sources simultaneously. Multi-source replication can be used to:
- back up multiple servers to a single server,
- to merge table shards,
- consolidate data from multiple servers to a single server.
Multi-source replication does not implement any conflict detection or resolution when applying the transactions, and those tasks are left to the application if required. In a multi-source replication topology, a slave creates a replication channel for each master that it should receive transactions from.
etc.