A data storage method, wherein at least M virtual machines are deployed on a plurality of physical servers, the M virtual machines are respectively deployed as M data nodes SNs in a distributed storage system, M is a positive integer greater than or equal to 2, and the method comprises: receiving, by a metadata node MDS, identifiers of the M virtual machines sent by a virtual machine manager; grouping, by the MDS, the M virtual machines into a plurality of anti-affinity groups, and recording, in grouping information, a mapping relationship between the plurality of anti-affinity groups and the identifiers of the M virtual machines, wherein the virtual machines in each anti-affinity group have anti-affinity with each other in that the virtual machines in each anti-affinity group are separately deployed on different servers; sending, by the MDS, the grouping information to the virtual machine manager, so that the virtual machine manager deploys the M virtual machines based on the grouping information; receiving, by the MDS, in the distributed storage system, a data storage request of a client; determining, by the MDS, that a quantity of storage copies of data specified in the data storage request is N, wherein N is a positive integer greater than or equal to 1; determining, by the MDS, identifiers of N virtual machines based on the grouping information, wherein the N virtual machines corresponding to the identifiers of the N virtual machines belong to at least one anti-affinity group of the plurality of anti-affinity groups, and the M virtual machines comprise the N virtual machines; and sending, by the MDS, response information of the data storage request to the client, wherein the response information comprises the identifiers of the N virtual machines, and the response information instructs the client to store, in the N virtual machines, N copies of the data specified in the data storage request. receiving, by a metadata node MDS, identifiers of the M virtual machines sent by a virtual machine manager; grouping, by the MDS, the M virtual machines into a plurality of anti-affinity groups, and recording, in grouping information, a mapping relationship between the plurality of anti-affinity groups and the identifiers of the M virtual machines, wherein the virtual machines in each anti-affinity group have anti-affinity with each other in that the virtual machines in each anti-affinity group are separately deployed on different servers; sending, by the MDS, the grouping information to the virtual machine manager, so that the virtual machine manager deploys the M virtual machines based on the grouping information; receiving, by the MDS, in the distributed storage system, a data storage request of a client; determining, by the MDS, that a quantity of storage copies of data specified in the data storage request is N, wherein N is a positive integer greater than or equal to 1; determining, by the MDS, identifiers of N virtual machines based on the grouping information, wherein the N virtual machines corresponding to the identifiers of the N virtual machines belong to at least one anti-affinity group of the plurality of anti-affinity groups, and the M virtual machines comprise the N virtual machines; and sending, by the MDS, response information of the data storage request to the client, wherein the response information comprises the identifiers of the N virtual machines, and the response information instructs the client to store, in the N virtual machines, N copies of the data specified in the data storage request.