The energy-efficient and secure allocation of virtual machines (VMs) plays an important role at the data center. As cloud computing continues to expand rapidly and the number of cloud users increases day by day, the issue of high energy consumption in complex cloud data centers has become a significant concern. To address this challenge, the consolidation of virtual machines (VMs) emerges as a crucial strategy for optimizing cloud resources efficiently. In this study, a novel security evaluation method is proposed to assist the model available for the virtualized system. A multi-objective model-based firefly algorithm (FA) and harmony search (HS) algorithm are used for the system configuration in VM migration is proposed to measure the security threats such as denial of service (DoS), distributed denial of service (DDoS) and Man-in-the-middle attack. The proposed method also decreases the power consumption, network usage and resource wastage in virtual machines. The proposed algorithm achieves better results compared to other existing methods by utilizing the number of virtual machine blocks with cost migration. The experimental results shows that the proposed FA+HS delivers the performance metrics such as makespan, execution cost and resource utilization and achieved at the 1000VMS of 950, 0.001 and 62 respectively, which ensures the better results compared with the existing methods such as whale optimization genetic algorithm (WOGA), multi-objective whale optimization algorithm-based differential evolution (M-WODE) and joint task scheduling and virtual machine placement (JTSVMP).