---
title: 安装Protobuf
description: "1. 查询Protobuf版本。若环境的Protobuf版本不是2.5.0，请删除环境的Protobuf后重新安装 。若环境的Protobuf版本是2.5.0，则跳过该章节。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengbds/ecosystemEnable/HBase/topic_0270747418.html
sourcePath: /source/zh/kunpengbds/ecosystemEnable/HBase/topic_0270747418.html
indexId: abb3517f204f2cb0068bee14eff9591d213246795d541134dbd24942f4aabea565
---
# 安装Protobuf

#### CentOS操作系统

1. 查询Protobuf版本。若环境的Protobuf版本不是2.5.0，请删除环境的Protobuf后重新安装 。若环境的Protobuf版本是2.5.0，则跳过该章节。
  1 protoc --version

2. 可选：删除Protobuf。
  1 yum remove -y protobuf protobuf-devel

3. 安装Protobuf 2.5.0。
  1 yum install -y protobuf protobuf-devel

4. 验证Protobuf是否安装成功。
  1 protoc --version

  回显如下所示即为安装成功。

5. Maven安装。
  1 mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=2.5.0 -Dclassifier=linux-aarch_64 -Dpackaging=exe -Dfile=/usr/bin/protoc


#### openEuler操作系统

1. 查询Protobuf版本。若环境的Protobuf版本不是2.5.0，请删除环境的Protobuf后再重新安装 。若环境的Protobuf版本是2.5.0，则跳过该章节。
  1 protoc --version

2. 可选：删除Protobuf。
  1 yum remove -y protobuf protobuf-devel

3. 查询Protobuf路径，并删除Protobuf软链接。

  a. 查询Protobuf路径。
    1 which protoc

  b. 如上图所示，进入“/usr/local/bin”目录，删除“/protoc”目录。
    1 2 cd /usr/local/bin rm -rf /protoc

4. 进入“/opt/tools/installed/”目录。
  1 cd /opt/tools/installed

5. 下载并解压源码。
  1 2 wget https://github.com/protocolbuffers/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz --no-check-certificate tar -zxf protobuf-2.5.0.tar.gz

6. 下载protoc.zip(https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/bigdata/Patch/protoc.zip)并解压得到protoc.patch文件，其中protoc.patch存放的路径可自己指定（例如：“/opt/tools/installed/protobuf-2.5.0/src/google/protobuf/stubs/”）。
  1 2 3 wget https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/bigdata/Patch/protoc.zip --no-check-certificate unzip protoc.zip cp ./protoc/protoc.patch ./protobuf-2.5.0/src/google/protobuf/stubs/

7. 进入“/opt/tools/installed/protobuf-2.5.0/src/google/protobuf/stubs/”目录安装补丁。
  1 2 cd protobuf-2.5.0/src/google/protobuf/stubs/ patch -p1 < protoc.patch

8. 回到protobuf-2.5.0根目录，编译并安装到系统默认目录。
  1 2 cd /opt/tools/installed/protobuf-2.5.0 ./autogen.sh && ./configure CFLAGS='-fsigned-char' && make -j8 && make install

9. 将protoc可执行文件部署在本地Maven仓库中。
  1 mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=2.5.0 -Dclassifier=linux-aarch_64 -Dpackaging=exe -Dfile=/usr/local/bin/protoc

10. 重新加载环境变量。
  1 source /etc/profile

11. 检查Protobuf版本。
  1 protoc --version

  若版本不是2.5.0，请重新执行安装Protobuf。
