MIYAKO, Japan — Modern seawalls failed to protect coastal towns from Japan’s destructive tsunami last month. But in the hamlet of Aneyoshi, a single centuries-old tablet saved the day.

“High dwellings are the peace and harmony of our descendants,” the stone slab reads. “Remember the calamity of the great tsunamis. Do not build any homes below this point.”

It was advice the dozen or so households of Aneyoshi heeded, and their homes emerged unscathed from a disaster that flattened low-lying communities elsewhere and killed thousands along Japan’s northeastern shore.

Hundreds of such markers dot the coastline, some more than 600 years old. Collectively they form a crude warning system for Japan, whose long coasts along major fault lines have made it a repeated target of earthquakes and tsunamis over the centuries.

The markers don’t all indicate where it’s safe to build. Some simply stand — or stood, until they were washed away by the tsunami — as daily reminders of the risk.

“If an earthquake comes, beware of tsunamis,” reads one.

In the bustle of modern life, many forgot.

“People had this crucial knowledge, but they were busy with their lives and jobs, and many forgot,” said Yotaru Hatamura, a scholar who has studied the tablets.

One stone marker warned of the danger in the coastal city of Kesennuma: “Always be prepared for unexpected tsunamis. Choose life over your possessions and valuables.” Earlier generations also left warnings in place names, calling one town “Octopus Grounds” for the sea life washed up by tsunamis and naming temples after the powerful waves, said Fumihiko Imamura, a professor in disaster planning at Tohoku University in Sendai, a tsunami-hit city.

“It takes about three generations for people to forget. Those that experience the disaster themselves pass it to their children and their grandchildren, but then the memory fades,” he said.