In this paper, we derive the optimal transmitter/ receiver beamforming vectors and relay weighting matrix for the multiple-input multiple-output amplify-and-forward relay channel. The analysis is accomplished in two steps. In the first step, the direct link between the transmitter (Tx) and receiver (Rx) is ignored and we show that the transmitter and the relay should map their signals to the strongest right singular vectors of the Tx-relay and relay-Rx channels. Based on the distributions of these vectors for independent identically distributed (i.i.d.) Rayleigh channels, the Grassmannian codebooks are used for quantizing and sending back the channel information to the transmitter and the relay. The simulation results show that even a few number of bits can considerably increase the link reliability in terms of bit error rate. For the second step, the direct link is considered in the problem model and we derive the optimization problem that identifies the optimal Tx beamforming vector. For the i.i.d Rayleigh channels, we show that the solution to this problem is uniformly distributed on the unit sphere and we justify the appropriateness of the Grassmannian codebook (for determining the optimal beamforming vector), both analytically and by simulation. Finally, a modified quantizing scheme is presented which introduces a negligible degradation in the system performance but significantly reduces the required number of feedback bits.