Cooperative communication techniques promise the advantages of MIMO (multi-input multi-output) communications for wireless scenarios with single-antenna terminals. A main assumption in majority of the existing literature on cooperative communications is the availability of channel state information at the receiver. In practice, knowledge of the channel is obtained by sending known training (pilot) symbols to the receiver. In this paper, we study the effect of training on the system performance for an amplify-and-forward relaying cooperative system with pilot-assisted channel estimator over quasi-static Rayleigh fading channels. Considering average received signal-to-noise ratio at the destination node as the objective function, we formulate an optimization problem for a single-relay scenario to answer the following fundamental questions: 1) How should the overall transmit power be shared between training and data transmission periods?; 2) How should training power be allocated to broadcasting and relaying phases?; 3) How should data power be allocated to broadcasting and relaying phases? Our simulation results demonstrate that optimized scheme significantly outperforms the original scheme with equal power allocation. Depending on the relay location, performance gains up to 5.5dB are reported.