With the continuous growth of cloud computing services, the high energy consumption of cloud data centers has become an urgent problem to be solved. Virtual machine consolidation (VMC) is an important way to optimize energy consumption, however excessive consolidation may lead to local hotspots and increase the risk of equipment failure. Thermal-aware scheduling can solve this problem, but it is difficult to strike a balance between SLA and energy consumption. To solve the above problems, we propose a method for scheduling cloud data center resources based on thermal management (TM-VMC), which optimizes total energy consumption and proactively prevents hotspots from a global perspective. It includes four phases of the VM consolidation process, dynamically schedules VMs by detecting server temperature and utilization status in real time, and finds suitable target hosts based on an improved ant colony algorithm (UACO) for the VMs. We compare the TM-VMC approach with several existing mainstream VM consolidation algorithms under workloads from real-world data centers. Simulation experimental results show that the TM-VMC approach can proactively avoid data center hotspots and significantly reduce energy consumption while maintaining low SLA violation rates.