With the application of cloud computing services in more and more fields, it will undertake more computing tasks and storage tasks. The problem of high energy consumption in data centers will become more serious. Virtualization technology is very important in cloud computing, which can improve the utilization rate of resources. At the same time, it has flexibility in resource scheduling and can integrate multiple virtual machines to achieve power efficiency. Using online virtual machine migration technology for energy-saving planning in cloud environment is a hot research topic in academic circles. The scheduling strategy proposed in this paper can reduce the server downtime and the number of server hosts, so as to achieve the maximum use of resources. The main research work of this paper includes the following aspects: Firstly, the energy consumption in the process of virtual machine energy-saving design is modeled, and the relationship between energy consumption and resource usage under different load conditions is analyzed, and the problems are abstracted, e.g., packaging box problem. Secondly, this paper uses genetic algorithm to solve the problem of high energy consumption. Finally, based on the target allocation scheme of virtual machines obtained by the above method, the migration problem of virtual machines is abstracted as the problem of finding the maximum weighted independent set of graphs. And a greedy algorithm is designed to solve this problem. In this paper, CloudSim simulation platform is used to verify the effectiveness of the proposed algorithm. Experiments show that the proposed algorithm can reduce data energy consumption and avoid frequent migration of virtual machines.