A 6.7 magnitude earthquake has hit Japan, sparking a tsunami warning and evacuations in some parts of the country.