We investigate massive access in the Internet-of-Things (IoT) relying on multi-pair two-way amplify-and-forward (AF) relay systems using massive multiple-input multiple-output (MIMO). We utilize the approximate message passing (AMP) algorithm for joint device activity detection and channel estimation. Furthermore, we analyze the achievable rates for multiple pairs of active devices and derive the closed-form expressions for both maximum-ratio combining/maximum-ratio transmission (MRC/MRT) and zero-forcing reception/zero-forcing transmission (ZFR/ZFT)-based beamforming schemes adopted at the relay. Moreover, to improve the achievable sum rates, we propose a low-complexity algorithm for optimizing the pilot length L. Our simulation results verify the accuracy of the closed-form expressions of the MRC/MRT and ZFR/ZFT scenarios. Finally, the proposed pilot-length optimization algorithm performs well in both the MRC/MRT and ZFR/ZFT scenarios.