Hyperledger indy 阿里云CentOS 7 indy-node环境搭建(VirtualBox 版本)

CentOS7 安装VirtualBox 

在 CentOS 上安装及使用 VirtualBox

安装vagrant

yum install -y https://releases.hashicorp.com/vagrant/2.1.2/vagrant_2.1.2_x86_64.rpm

选择 2 

安装失败

  • git clone https://github.com/chef/bento
  • cd bento/ubuntu
  • packer build ubuntu-16.04-amd64.json # adjust for your environment
  • vagrant box add ../builds/ubuntu-16.04.virtualbox.box --name bento/ubuntu-16.04

使用root用户执行成功

下载Vagrant 脚本 and bash 脚本

$ git clone https://github.com/hyperledger/indy-node.git
$ cd indy-node/environment/vagrant/training/vb-multi-vm
$ git checkout stable

 

 

建立Indy验证器节点集群

       当前目录下的 Vagrantfile,包含了 vagrant说明,virtualbox指令会在你的虚拟机中执行,另外,它指示Vagrant执行 bash文件scripts/validator.sh,在每个虚拟机上来检查验证必要的软件,它还提供了三个代理vm的配置说明,以及一个用作CLI客户端的指令,其中包含了所需的bash配置文件。

       该脚本假定在您的pc中可以创建10.20.30.00/24虚拟网络,而不需要与外部网络配置相冲突。将要供应的vm的地址将从这个网络的地址范围中获取。它假设你在美国:Mountain timezone。可以使用文本编辑器对Vagrantfile内容进行更改。您可以按原样运行这个脚本,或者您可能想要:

      1)修改时区。对于一个候选列表,请参考/usr/share/zoneinfoon一个Ubuntu系统。

      2)修改VM的ip地址

          *  修改Vagrantfile中validator、agent中的ip地址

          *  修改scripts/validator.sh 第48行对应的validator IP地址列表

          *  同样地,在scripts/agent.sh的第42行更改avalidator IP地址的列表。

             *  在etc/hosts文件中更改模板主机文件中的IP地址

配置文件有正确的设置之后,提供验证器和CLI客户机节点:

[chain@iz2zeivrkckulq2dtidztmz vb-multi-vm]$ vagrant up
VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage --version` or open the VirtualBox GUI to see the error

message which should contain instructions on how to fix this error.

[chain@iz2zeivrkckulq2dtidztmz vb-multi-vm]$ VBoxManage --version
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (3.10.0-693.2.2.el7.x86_64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.
5.2.14r123301

执行 

[chain@iz2zeivrkckulq2dtidztmz vb-multi-vm]$ sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-693.2.2.el7.x86_64
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-693.2.2.el7.x86_64

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.

sudo yum install kernel-devel gcc

[chain@iz2zeivrkckulq2dtidztmz vb-multi-vm]$ sudo yum install kernel-devel gcc
Loaded plugins: fastestmirror, priorities
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
Loading mirror speeds from cached hostfile
Package gcc-4.8.5-28.el7_5.1.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:3.10.0-862.3.3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================
 Package                                        Arch                                     Version                                                Repository                                 Size
================================================================================================================================================================================================
Installing:
 kernel-devel                                   x86_64                                   3.10.0-862.3.3.el7                                     updates                                    16 M

Transaction Summary
================================================================================================================================================================================================
Install  1 Package

Total download size: 16 M
Installed size: 37 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
kernel-devel-3.10.0-862.3.3.el7.x86_64.rpm                                                                                                                               |  16 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-devel-3.10.0-862.3.3.el7.x86_64                                                                                                                                       1/1 
  Verifying  : kernel-devel-3.10.0-862.3.3.el7.x86_64                                                                                                                                       1/1 

Installed:
  kernel-devel.x86_64 0:3.10.0-862.3.3.el7                                                                                                                                                      

Complete!

设置环境变量KERN_DIR目录
KERN_DIR=/usr/src/kernels/3.10.0-862.3.3.el7.x86_64/

export KERN_DIR

安装kernel-devel
yum install kernel-devel

ln -s /usr/src/kernels/3.10.0-862.3.3.el7.x86_64/ /usr/src/linux

4)安装virtualbox增强功能,一般会提示缺少gcc、make、perl和其他库文件,需安装和系统内核版本一致的库文件,否则不能安装virtualbox增强功能,例如:

Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.6 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-693.el7.x86_64
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-693.el7.x86_64
Press Return to close this window...
按照提示信息,安装所需的工具和库:

# yum install gcc make perl
# yum install kernel-devel-$(uname -r)
# rpm -qa kernel\*
kernel-3.10.0-693.el7.x86_64
kernel-tools-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-693.el7.x86_64
kernel-devel-3.10.0-693.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64

还是不成功

绝招

reboot 重启系统后正常运行

 

[root@iz2zeivrkckulq2dtidztmz vb-multi-vm]# vagrant up
Bringing machine 'cli01' up with 'virtualbox' provider...
Bringing machine 'validator01' up with 'virtualbox' provider...
Bringing machine 'validator02' up with 'virtualbox' provider...
Bringing machine 'validator03' up with 'virtualbox' provider...
Bringing machine 'validator04' up with 'virtualbox' provider...
==> cli01: Importing base box 'bento/ubuntu-16.04'...
==> cli01: Matching MAC address for NAT networking...
==> cli01: Checking if box 'bento/ubuntu-16.04' is up to date...
==> cli01: Setting the name of the VM: cli01
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

  https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

  VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

  config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
==> cli01: Clearing any previously set network interfaces...
==> cli01: Preparing network interfaces based on configuration...
    cli01: Adapter 1: nat
    cli01: Adapter 2: hostonly
==> cli01: Forwarding ports...
    cli01: 22 (guest) => 2222 (host) (adapter 1)
==> cli01: Running 'pre-boot' VM customizations...
==> cli01: Booting VM...
==> cli01: Waiting for machine to boot. This may take a few minutes...
    cli01: SSH address: 127.0.0.1:2222
    cli01: SSH username: vagrant
    cli01: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

解决:

编辑Vagrantfile ,添加如下文件

config.ssh.username = "vagrant" config.ssh.password = "vagrant"

然后重启vagrant 重新加载配置文件

vagrant halt
vagrant up

vagrant destory

阿里云本身就是虚拟系统,不能再安装 virtualBox了

参考资料:

https://blog.csdn.net/u013510614/article/details/50260167

https://www.howtoing.com/how-to-install-vagrant-on-centos-7

https://cloud.tencent.com/developer/article/1123072

http://www.511yj.com/centos-yum-kernel.html

https://stackoverflow.com/questions/29320577/vagrant-virtualbox-timed-out-while-waiting-for-the-machine-to-boot

vagrant-安装教程及常见问题

欢迎大家一起加入讨论!!!

https://blog.csdn.net/ty_hf/article/details/78314583?locationNum=4&fps=1

猜你喜欢

转载自blog.csdn.net/wxb880114/article/details/80938292