In view of high energy consumption of dynamic virtual machine placement in data centers, a two-phase placement algorithm with energy efficiency optimization for virtual machines, named DVMP_VMMA, was proposed based on data center. The first phase was the initial placement, a Dynamic Virtual Machine Placement (DVMP) algorithm was presented to limit the optimal number of deployed hosts, which reduced the idle energy consumption. Meanwhile, for responding to the dynamic changes of loads, Virtual Machine Migration Algorithm (VMMA) was put forward to further optimize the initial placement with the migration constraints through the dynamic VM (Virtual Machine) migration in second phase, which not only got lower energy consumption of the system, but also ensured Quality of Service (QoS) of applications. Comparison experiments with FL (Full Load), FT (Fixed Threshold), MAD (Median Absolute Deviation), QD (Quartile Deviation), MTM (Migration Time Minimum) and MIU (Minimum Utilization) were given. The experimental results show that DVMP_VMMA not only considers the energy consumption optimization to increase the resource utilization, but also avoids frequent migration of VMs to improve the performance, it gets good effect in optimization of data center energy consumption, SLA (Service Level Agreement) violation, VM migration quantity and loss of performance, its comprehensive performance is better than compared algorithms.