Energy harvesting (EH) has recently emerged as an effective way to solve the lifetime challenge of wireless sensor networks, as it can continuously harvest energy from the environment. Unfortunately, it is challenging to guarantee a satisfactory short-term performance in EH communication systems because the harvested energy is sporadic. In this paper, we consider the channel training optimization problem in EH communication systems, i.e., how to obtain accurate channel state information to improve the communication performance. In contrast to conventional communication systems, the optimization of the training power and training period in EH communication systems is a coupled problem, which makes such optimization very challenging. We shall formulate the optimal training design problem for EH communication systems, and propose two solutions that adaptively adjust the training period and power based on either the instantaneous energy profile or the average energy harvesting rate. Numerical and simulation results will show that training optimization is important in EH communication systems. In particular, it will be shown that for short block lengths, training optimization is critical. In contrast, for long block lengths, the optimal training period is not too sensitive to the value of the block length nor to the energy profile. Therefore, a properly selected fixed training period value can be used.