Consensus has been a problem for a long time. Leslie Lamport's 1989 paper "The Part-Time Parliament" described an island named Paxos, and used it to describe a theoretical solution to distributed consensus. In 2001, Lamport got tired of people telling him his original paper and algorithm were too complicated, and rewrote it as "Paxos Made Simple". Hilariously, according to Lamport, that paper has a bug, and GitHub implementations often implement the algorithm incorrectly. That being said, Paxos is one of the most commonly-used algorithms in distributed systems. For example, Paxos is used by Zookeeper and Chubby.
Another solution to Consensus comes to us from the infamous Bitcoin. In his influential paper, Satoshi Nakamoto described and built the bitcoin blockchain. The blockchain is a log, or history, of every piece of data attached to it, along with a "proof of work" that lets every computer that reads or modifies the blockchain validate every piece of data in the blockchain. Imagine an array, where everyone agrees on each item in the array, and anyone who comes to look at the array can validate what everyone else is saying about the array. There are many similar but different implementations of this out there, including Ethereum and others.