This paper focuses on analyzing the thermal environment and optimizing energy consumption in data centers, which has largely omitted from previous studies. The thermal environmental of data centers is simulated and analyzed by utilizing the established “server-rack-room” multi-scale heat transfer numerical model. Based on this, the coupling simulation model of thermal environment and energy consumption in data centers is proposed to explore the relationship between them, and the corresponding optimization strategy is put forward. The energy consumption simulated by energy-environment coupled model and non-coupled model can reach a discrepancy of over 30 %, which indicates that the thermal environment impacts the power consumption of the data center significantly. Besides, the effect of several operational parameters of air conditioning system on the thermal environment and energy consumption of data center is analyzed. Through the particle swarm optimization algorithm, the optimal system parameters, which meet the requirements of thermal environment and lead to the lowest energy consumption, are found for typical cities in different climatic regions. The recommended settings include the supply air temperature of about 24 ∼ 26 ℃, the air supply volume of 8 m3/s, and the temperature difference of about 3.5 ℃ between the supply air temperature and the supply chilled water temperature. Under the optimized parameter setting, the highest temperature of server decreases to below 71 ℃, and the energy saving rate is more than 6 %.