The present invention proposes a compound represented by formula (I) or a pharmaceutically acceptable salt or prodrug thereof. The compound has a novel structure, high efficiency and low toxicity, and has excellent CXCR4 antagonistic activity, which can block HIV from invading and infecting human target cells or treat or prevent AIDS or mobilize human bone marrow hematopoietic cells, mesenchymal stem cells and stem cells or interfere with CXCL12 / CXCR4-mediated Cell migration and adhesion or prevention, treatment of tumor metastasis, invasion and growth mediated by CXCR4 or block CXCL12 / CXCR4 mediated autoimmunity and inflammatory response; and this type of compound can be used as an effective drug in the pharmaceutical composition The components can be used in combination with other anti-HIV drugs to prevent and treat HIV or in combination with other drugs used for treatment or prevention of leukemia, lymphoma, myeloma and solid tumors to prevent and treat tumors.