The functional parts of a machine tool determine its reliability level to a great extent. The failure prediction of the functional part is helpful to prepare the maintenance scheme in time, in order to ensure a stable manufacturing process and the required production quality. Due to the rise of digital twin (DT), which has the characteristics of virtual reality interaction and real-time mapping, a DT-based real-time prediction method of the remaining useful life (RUL) and preventive maintenance scheme is proposed in this study. In this method, a DT model of the manufacturing workshop is established based on real-time perceptual information obtained by the proposed acquisition method. Subsequently, the real-time RUL of the functional part is predicted by establishing a RUL prediction model based on the nonlinear-drifted Brownian motion, which takes the working conditions and measurement errors into consideration. On this basis, the optimal preventive maintenance scheme can be determined and fed back to the manufacturing workshop, in order to guide the maintenance of relevant parts. Finally, an example case study is presented to illustrate the feasibility and effectiveness of the proposed method.