A strong 7.1 magnitude earthquake has hit near Tonga, prompting a tsunami warning for the Pacific island country.