一鍵打造你的Doker礦機
阿新 • • 發佈:2018-01-12
cer static inf lda pen update 圖片 telling enable 從什麽時候開始流行CPU挖礦了?記得以前不都是用GPU嗎?原來現在虛擬幣的種類已經這麽多了!大概研究了一下,目前CPU算力有優勢的有這麽幾種虛擬幣,貌似還都是匿名幣
ZEC(零幣)算法 Equihash 目前市場價格4000+
XMR(門羅幣) 算法CryptoNight 目前價格4000+
BCN(字節幣?) 算法CryptNote 目前價格 幾分...
近期公司有幾臺機器被種了挖礦木馬,清除之余研究了一下有關CPU挖礦的工具,發現了 xmr-stak-cpu 這個東西
上網搜了搜,找到了GITHUB上的主頁,好像剛升級不久
https://github.com/fireice-uk/xmr-stak
還有個早先點的版本地址為:https://github.com/fireice-uk/xmr-stak-cpu
找了一臺測試機安裝一下試試:
# git clone https://github.com/fireice-uk/xmr-stak # cd xmr-stak/ # ls CI CMakeLists.txt CONTRIBUTING.md doc Dockerfile LICENSE README.md scripts THIRD-PARTY-LICENSES xmrstak 好像沒有可以執行的文件,不過我發現了Dockerfile,然後又在 scripts文件夾裏找到了build_xmr-stak_docker.sh 難道是自動創建一個docker 來挖礦?打開來看看 # vim scripts/build_xmr-stak_docker/build_xmr-stak_docker.sh #!/bin/bash -uex if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi if [ -d xmr-stak ]; then git -C xmr-stak clean -fd else git clone https://github.com/fireice-uk/xmr-stak.git fi wget -c https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run chmod a+x cuda_*_linux-run ######################## # Fedora 27 ######################## # CUDA is not going to work on Fedora 27 beacuse it's only support these distributions: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html docker run --rm -it -v $PWD:/mnt fedora:27 /bin/bash -c " set -x ; dnf install -y -q cmake gcc-c++ hwloc-devel libmicrohttpd-devel libstdc++-static make openssl-devel; cd /mnt/xmr-stak ; cmake -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF . ; make ; " test -d fedora_27 || mkdir fedora_27 mv xmr-stak/bin/* fedora_27 git -C xmr-stak clean -fd ######################## # Ubuntu (17.04) ######################## docker run --rm -it -v $PWD:/mnt ubuntu:17.04 /bin/bash -c " set -x ; apt update -qq ; apt install -y -qq libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev ; cd /mnt/xmr-stak ; /mnt/cuda_*_linux-run --silent --toolkit ; cmake -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF . ; ... 呵呵,果然不出所料,這個腳本針對 CentOS 和 Ubuntu系列linux系統自動創建建立一個Docker鏡像然後安裝xmr-stak 編輯一下這個腳本,只留下一個操作系統,我這裏只留下了 Ubuntu 17部分 原來的腳本是跑完了docker 安裝完成就吧容器刪掉,而我現在想把這個容器留下於是就改了改,最後變成下面這個樣子 #!/bin/bash -uex if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi if [ -d xmr-stak ]; then git -C xmr-stak clean -fd else git clone https://github.com/fireice-uk/xmr-stak.git fi ######################## # Ubuntu (17.04) ######################## docker run -itd --name "xmr" -v $PWD:/mnt ubuntu:17.04 /bin/bash docker exec -it "xmr" /bin/bash -c " set -x ; apt update -qq apt install -y -qq libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev ; cd /mnt/xmr-stak ; cmake -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF . ; make install; "
我的linux 不需要CUDA 刪掉 CUDA部分的代碼
直接執行(運行前請確定是否已經安裝Docker)
# ./build_xmr-stak_docker.sh + [[ 0 -ne 0 ]] + '[' -d xmr-stak ']' + git clone https://github.com/fireice-uk/xmr-stak.git Cloning into 'xmr-stak'... git-remote-https: /usr/local/lib/libldap_r-2.4.so.2: no version information available (required by /usr/lib/x86_64-linux-gnu/lib git-remote-https: /usr/local/lib/liblber-2.4.so.2: no version information available (required by /usr/lib/x86_64-linux-gnu/libcu remote: Counting objects: 3441, done. remote: Compressing objects: 100% (29/29), done. remote: Total 3441 (delta 16), reused 16 (delta 3), pack-reused 3409 Receiving objects: 100% (3441/3441), 1.01 MiB | 24.00 KiB/s, done. Resolving deltas: 100% (2403/2403), done. Checking connectivity... done. + docker run -itd --name xmr -v /data1/soft:/mnt update-ubuntu /bin/bash f88a7614bd41821be42b584f76a1892184cd06155058c25c6bbdfb8c245cb571 + docker exec -it xmr /bin/bash -c ' ..... #腳本裏包含了 apt-get update 時間會比較久,如果你覺得不需要也可以去掉。如果上面這些步驟一切正常,那麽就可以進入剛健的容器去試試挖礦了 # docker exec -it xmr /bin/bash # cd /mnt/xmr-stak/bin/ # ls libxmr-stak-backend.a libxmr-stak-c.a xmr-stak # ./xmr-stak Please enter: - Currency: 'monero' or 'aeon' ... 上面是選擇你想挖的幣種類、礦池地址、錢包地址等等設置完之後會自動執行,如果出現下面這個就說明連接成功了,我測試用的是國內的一個門羅幣礦池mine.ppxxmr.com:3333
[2018-01-12 11:07:21] : Fast-connecting to mine.ppxxmr.com:3333 pool ... [2018-01-12 11:07:21] : Pool mine.ppxxmr.com:3333 connected. Logging in... [2018-01-12 11:07:21] : Difficulty changed. Now: 15000. [2018-01-12 11:07:21] : Pool logged in. [2018-01-12 11:07:29] : Difficulty changed. Now: 15000. [2018-01-12 11:07:29] : New block detected. [2018-01-12 11:07:37] : Result accepted by the pool. [2018-01-12 11:07:47] : Result accepted by the pool. [2018-01-12 11:08:04] : Difficulty changed. Now: 10465. [2018-01-12 11:08:04] : New block detected. [2018-01-12 11:08:11] : Result accepted by the pool. [2018-01-12 11:08:17] : Result accepted by the pool. 網站上也出現了你挖礦的進度,如下圖
終止進程後發現,bin下面多了兩個文件 cpu.txt 和 config.txt
# ls config.txt cpu.txt libxmr-stak-backend.a libxmr-stak-c.a xmr-stak
打開來看看
# vim config.txt /* * pool_address - Pool address should be in the form "pool.supportxmr.com:3333". Only stratum pools are supported. * wallet_address - Your wallet, or pool login. * pool_password - Can be empty in most cases or "x". * use_nicehash - Limit the nonce to 3 bytes as required by nicehash. * use_tls - This option will make us connect using Transport Layer Security. * tls_fingerprint - Server's SHA256 fingerprint. If this string is non-empty then we will check the server's cert against it. * pool_weight - Pool weight is a number telling the miner how important the pool is. Miner will mine mostly at the pool * with the highest weight, unless the pool fails. Weight must be an integer larger than 0. * * We feature pools up to 1MH/s. For a more complete list see M5M400's pool list at www.moneropools.com */ "pool_list" : [ {"pool_address" : "mine.ppxxmr.com:3333", "wallet_address" : "xxxxxxxxxqC4PTWdaAZ3V15d83kCEEGRiXVXeQwsS1PGd7s7wDjigA2grkxcsDfxEDtuDomBzpFiGtNyPMy+$NUMBER", "pool_password" : "", "use_nicehash" : false, "use_tls" : false, "tls_fingerprint" : "", "pool_weight" : 1 }, ], /* * currency to mine * allowed values: 'monero' or 'aeon' */ "currency" : "monero", /* ...
剛才的設置應該都存在這裏了,
# vim cpu.txt ... "cpu_threads_conf" : [ { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 0 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 2 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 4 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 6 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 8 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 10 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 1 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 3 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 5 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 7 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 9 }, { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 11 }, ],
cpu.txt是我們調整CPU使用效率的文件,如果覺得資源耗太多可以減少一些
好了,再次執行的時候就不用進行設置了
# nohup ./xmr-stak & [1] 714
看一下資源消耗,瞬間就上10了哈哈,看看這點算力和這麽高的負載,咱們就測測就得了 hoho
一鍵打造你的Doker礦機