安装go-ceph库
1.基础环境
CentOS 7.5
golang 1.11
gcc 4.8.5
2.安装golang开发环境
(1)进入golang下载页面,下载golang程序包(go1.11.linux-amd64.tar.gz)。
URL:https://studygolang.com/dl
(2)解压golang程序包并拷贝go目录至/usr/local目录下。
[root@localhost rados]# tar -zxvf go1.11.linux-amd64.tar.gz
[root@localhost rados]# cp -rf go /usr/local/
【注】拷贝时使用root帐号。
(3)设置环境变量。
# 使用vi编辑器向/etc/profile文件尾部增加如下内容:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/home/iapcloud/workspace/coderepository/go
export GOBIN=/home/iapcloud/workspace/coderepository/go/bin
【注】GOPATH与GOBIN可以自定义设置。
(4)查看golang版本。
[root@localhost rados]# go version
go version go1.11 linux/amd64
至此,golang开发环境安装完成。
3.安装librados2-devel库
[root@localhost rados]# yum -y install librados2-devel
4.安装ceph-common
【目的】获取rbd库,否则go-ceph将因缺少librbd.so而安装失败。
CentOS7系统配置国内yum源和epel源
(1)首先进入/etc/yum.repos.d/
目录下,新建一个repo_bak目录,用于保存系统中原来的repo文件。
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir repo_bak
[root@localhost yum.repos.d]# mv *.repo repo_bak/
(2)在CentOS中配置使用网易和阿里的开源镜像。
前往网易和阿里开源镜像站点下载系统对应版本的repo文件。
[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@localhost yum.repos.d]# ls
Centos-7.repo CentOS-Base-163.repo repo.bak
或者手动下载repo文件并上传到/etc/yum.repos.d/
目录。
# 网易开源镜像站URL
# http://mirrors.163.com/.help/centos.html
# 阿里开源镜像站URL
# https://opsx.alibaba.com/mirror?lang=zh-cn
(3)清除系统yum缓存并生成新的yum缓存。
[root@localhost yum.repos.d]# ls # 列出/etc/yum.repos.d/目录下的文件
Centos-7.repo CentOS-Base-163.repo repo.bak
[root@localhost yum.repos.d]# yum clean all # 清除系统所有的yum缓存
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache # 生成yum缓存
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/12): base/7/x86_64/filelists_db | 6.7 MB 00:00:02
(2/12): base/7/x86_64/group_gz | 156 kB 00:00:02
(3/12): base/7/x86_64/other_db | 2.5 MB 00:00:01
(4/12): base/7/x86_64/primary_db | 5.7 MB 00:00:02
(5/12): extras/7/x86_64/prestodelta | 51 kB 00:00:01
(6/12): extras/7/x86_64/filelists_db | 494 kB 00:00:02
(7/12): extras/7/x86_64/other_db | 86 kB 00:00:00
(8/12): extras/7/x86_64/primary_db | 130 kB 00:00:01
(9/12): updates/7/x86_6