Modern industry 4.0 applications are shifting towards decentralized automation of computing and cyber-physical systems (CPS), which necessitates building a robust, secure, and efficient system that performs complex interactions with other physical processes. To handle complex interactions in CPS, trust and consensus among various stakeholders is a prime concern. In a similar direction, consensus algorithms in blockchain have evolved over the years that focus on building smart, robust, and secure CPS. Thus, it is imperative to understand the key components, functional characteristics, and architecture of different consensus algorithms used in CPS. Many consensus algorithms exist in the literature with a specified set of functionalities, performance, and computing services. Motivated from these facts, in this survey, we present a comprehensive analysis of existing state-of-the-art consensus mechanisms and highlight their strength and weaknesses in decentralized CPS applications. In the first part, we present the scope of the proposed survey and identify gaps in the existing surveys. Secondly, we present the review method and objectives of the proposed survey based on research questions that address the gaps in existing studies. Then, we present a solution taxonomy of decentralized consensus mechanisms for various CPS applications. Then, open issues and challenges are also discussed in deploying various consensus mechanisms in the CPS with their merits and demerits. The proposed survey will act as a road-map for blockchain developers and researchers to evaluate and design future consensus mechanisms, which helps to build an efficient CPS for industry 4.0 stakeholders.