# Ironfish铁鱼挖矿教程 CentOS 8 

By [sddcg](https://paragraph.com/@sddcg) · 2021-12-07

---

Ironfish 铁鱼挖矿已经开始了，但官方的教程实在不敢恭维，官方建议的docker我觉得性能会低，所以在CentOS下，基于源码自行编译。经过测试CentOS7存在大量问题，安装很不方便，强烈建议使用CentOS8.

> 首先准备一台服务器，CPU核心数要多一些，8核+，内存要求不高，8G就差不多
> 
> 提供付费安装服务（微信：t52861700 注明付费装铁鱼）， 200元一台（量大从优）

1.  安装 node.js 16
    
        dnf module install nodejs:16
        
    
    > centos8以前的版本没有dnf ，也可以手动下载安装 nodejs
    > 
    >     wget https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz 
    >     xz -d node-v16.13.1-linux-x64.tar.xz 
    >     tar -xvf node-v16.13.1-linux-x64.tar
    >     ln -s /root/node-v16.13.1-linux-x64/bin/node /usr/bin/node
    >     ln -s /root/node-v16.13.1-linux-x64/bin/npm /usr/bin/npm
    >     ln -s /root/node-v16.13.1-linux-x64/bin/npx /usr/bin/npx
    >     export PATH=/root/node-v16.13.1-linux-x64/bin/:$PATH
    >     echo 'export PATH=/root/node-v16.13.1-linux-x64/bin/:$PATH' >> ~/.bashrc 
    >     source ~/.bashrc
    >     
    
2.  安装gcc
    
        yum install gcc gcc-c++ make 
        
    
3.  安装rust
    
        curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
        source $HOME/.cargo/env
        
    
4.  安装 yarn
    
        npm install --global yarn
        
    
5.  下载官方源代码
    
        cd /root
        git clone https://github.com/iron-fish/ironfish.git
        chown -R root ironfish
        
    
    > 如果没有git，通过一下命令安装
    > 
    > yum install git
    > 
    > clone较慢的话，也可以自己下载后解压缩
    > 
    >     wget https://github.com/iron-fish/ironfish/archive/refs/heads/master.zip 
    >     yum install -y unzip zip 
    >     unzip ironfish-master.zip
    >     mv ironfish-master ironfish
    >     
    
6.  编译源码
    
        cd /root/ironfish
        yarn install 
        yarn build
        
        cd /root/ironfish/ironfish-cli/
        yarn build
        
    
    > 有些系统没有自带python，如果提示python错误，请安装python3.6
    
    > 感谢老毕反馈的问题，如果编译源码后，在执行ironfish的相关命令出现 xxx is not a ironfish command 这类错误，可以执行
    > 
    >     cd /root/ironfish
    >     yarn install 
    >     yarn build
    >     
    
7.  启动节点（初次启动要同步数据比较慢）
    
        cd /root/ironfish/ironfish-cli/
        yarn ironfish start
        
    
    > 窗口不要关闭，或者把启动命令修改为后台方式
    > 
    > nohup yarn ironfish start >nohup.log &
    
8.  配置帐号（与官网注册一致）
    
        yarn ironfish config:set blockGraffiti "sddcg"
        
    
    > 双引号能填写自己在官网注册的帐号
    
9.  再开一个终端窗口开启挖矿
    
        cd /root/ironfish/ironfish-cli/
        yarn ironfich miners:start -t CPU核心数
        或
        yarn ironfich miners:start -t -1
        
    
    > 窗口不要关闭，或者把启动命令修改为后台方式 nohup yarn ironfich miners:start -t -1 >mine.log &
    
10.  官网查看积分
    
    [https://testnet.ironfish.network/leaderboard](https://testnet.ironfish.network/leaderboard)
    
    > 每次登录都会发邮件，需要到邮箱点击链接完成登录
    > 
    > 在search框输入自己的帐号后就能过滤自己的帐号，然后点击进入就可以查看积分情况
    
11.  水龙头领币
    
    > 目前水龙头好像有问题，领不到
    
        cd /root/ironfish/ironfish-cli/
        yarn ironfish faucet
        
    
12.  关于服务器，大家可以去白嫖一些云服务器厂商的免费试用款
    
    如华为云，就提供4核8G 15天免费用
    
13.  查看状态
    
        cd /root/ironfish/ironfish-cli/  
        yarn ironfish status -f
        
    
    下图的 mined前的数字表示你挖到的数量
    

![挖矿状态](https://storage.googleapis.com/papyrus_images/48f23e83dd60854919845af20f154e7b587314ada523e91dc74991604efc6edb.png)

挖矿状态

Cmake问题
-------

    
    yum install centos-release-scl devtoolset-8-gcc*
    scl enable devtoolset-8 bash
    source /opt/rh/devtoolset-8/enable
    yum install cmake3
    alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \
    --slave /usr/local/bin/ctest ctest /usr/bin/ctest \
    --slave /usr/local/bin/cpack cpack /usr/bin/cpack \
    --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \
    --family cmake
    
    alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
    --slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
    --slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
    --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
    --family cmake
    
    alternatives --config cmake
    

openssl问题
---------

    yum install openssl11
    export OPENSSL_ROOT_DIR='/usr/lib64/openssl11'
    echo 'export OPENSSL_ROOT_DIR=/usr/lib64/openssl11' >> ~/.bashrc 
    export OPENSSL_INCLUDE_DIR='/usr/include/openssl11/openssl'
    echo 'export OPENSSL_INCLUDE_DIR=/usr/lib64/openssl11/openssl' >> ~/.bashrc 
    source ~/.bashrc
    

Updating crates.io index 速度慢的解决办法
=================================

修改 $HOME/.cargo/config

    # 放到 `$HOME/.cargo/config` 文件中
    [source.crates-io]
    #registry = "https://github.com/rust-lang/crates.io-index"
    
    # 替换成你偏好的镜像源
    replace-with = 'ustc'
    #replace-with = 'sjtu'
    
    # 清华大学
    [source.tuna]
    registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
    
    # 中国科学技术大学
    [source.ustc]
    registry = "git://mirrors.ustc.edu.cn/crates.io-index"
    
    # 上海交通大学
    [source.sjtu]
    registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
    
    # rustcc社区
    [source.rustcc]
    registry = "https://mirrors.ustc.edu.cn/crates.io-index"
    

github下载慢问题
-----------

可以使用代理 git clone [https://ghproxy.com/https://github.com/iron-fish/ironfish.git](https://ghproxy.com/https://github.com/iron-fish/ironfish.git)

在/etc/hosts增加

    # GitHub520 Host Start
    140.82.114.26                 alive.github.com
    140.82.114.25                 live.github.com
    185.199.108.154               github.githubassets.com
    140.82.112.21                 central.github.com
    185.199.108.133               desktop.githubusercontent.com
    185.199.108.153               assets-cdn.github.com
    185.199.108.133               camo.githubusercontent.com
    185.199.108.133               github.map.fastly.net
    199.232.69.194                github.global.ssl.fastly.net
    140.82.113.3                  gist.github.com
    185.199.108.153               github.io
    140.82.113.3                  github.com
    192.0.66.2                    github.blog
    140.82.112.5                  api.github.com
    185.199.108.133               raw.githubusercontent.com
    185.199.108.133               user-images.githubusercontent.com
    185.199.108.133               favicons.githubusercontent.com
    185.199.108.133               avatars5.githubusercontent.com
    185.199.108.133               avatars4.githubusercontent.com
    185.199.108.133               avatars3.githubusercontent.com
    185.199.108.133               avatars2.githubusercontent.com
    185.199.108.133               avatars1.githubusercontent.com
    185.199.108.133               avatars0.githubusercontent.com
    185.199.108.133               avatars.githubusercontent.com
    140.82.112.10                 codeload.github.com
    52.216.16.160                 github-cloud.s3.amazonaws.com
    52.217.172.41                 github-com.s3.amazonaws.com
    52.216.28.148                 github-production-release-asset-2e65be.s3.amazonaws.com
    52.216.152.124                github-production-user-asset-6210df.s3.amazonaws.com
    52.216.169.171                github-production-repository-file-5c1aeb.s3.amazonaws.com
    185.199.108.153               githubstatus.com
    64.71.144.202                 github.community
    23.100.27.125                 github.dev
    185.199.108.133               media.githubusercontent.com
    

centos7中gcc版本问题导致yarn install失败
-------------------------------

    yum install centos-release-scl scl-utils-build
    yum install devtoolset-8-gcc*
    scl enable devtoolset-8 bash
    

账户创建及导入导出、余额查看
==============

    # 创建账号 create 时可以设置账号名字
    yarn ironfish accounts:create
    
    # 修改使用某个账号进行挖矿，账号对应钱包
    yarn ironfish accounts:use xxx
    
    # 账号导出
    yarn ironfish accounts:export xxx /root/xxx.accounts
    
    # 账号导入
    yarn ironfish accounts:import /root/xxx.accounts
    
    # 查看余额
    yarn ironfish accounts:balance
    

本教程更新说明
-------

将 svn下载源码的方式调整为使用 git安装

1.  安装subversion
    
2.  下载官方源代码
    
        cd /root
        svn checkout "https://github.com/iron-fish/ironfish.git"

---

*Originally published on [sddcg](https://paragraph.com/@sddcg/ironfish-centos-8)*
