In this paper, an optimized analog beamforming scheme for millimeter-wave (mmWave) massive MIMO system is presented. This scheme aims to achieve the near-optimal performance by searching for the optimized combination of analog precoder and combiner. In order to compensate the occurrence of attenuation in the magnitude of mmWave signals, the codebook dependent analog beamforming in conjunction with precoding at transmitting end and combining signals at the receiving end is utilized. Nonetheless, the existing and traditional beamforming schemes involve more difficult and complicated search for the optimal combination of analog precoder/combiner matrices from predefined codebooks. To solve this problem, we have referred to a modified Bat Algorithm to find the optimal combination value. This algorithm will explore the possible pairs of analog precoder/ combiner as a way to come up with the best match in order to attain near-optimal performance. The analysis shows that the optimized beamforming scheme presented in this paper can improve the performance that is very close to the beam steering benchmark that we have considered.