一键打造你的Doker矿机
从什么时候开始流行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 找了一台测试机安装一下试试: #gitclonehttps://github.com/fireice-uk/xmr-stak #cdxmr-stak/ #ls CICMakeLists.txtCONTRIBUTING.mddocDockerfileLICENSEREADME.mdscriptsTHIRD-PARTY-LICENSESxmrstak 好像没有可以执行的文件,不过我发现了Dockerfile,然后又在scripts文件夹里找到了build_xmr-stak_docker.sh难道是自动创建一个docker来挖矿?打开来看看 #vimscripts/build_xmr-stak_docker/build_xmr-stak_docker.sh #!/bin/bash-uex if[[$EUID-ne0]];then echo"Thisscriptmustberunasroot" exit1 fi if[-dxmr-stak];then git-Cxmr-stakclean-fd else gitclonehttps://github.com/fireice-uk/xmr-stak.git fi wget-chttps://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run chmoda+xcuda_*_linux-run ######################## #Fedora27 ######################## #CUDAisnotgoingtoworkonFedora27beacuseit'sonlysupportthesedistributions:http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html dockerrun--rm-it-v$PWD:/mntfedora:27/bin/bash-c" set-x; dnfinstall-y-qcmakegcc-c++hwloc-devellibmicrohttpd-devellibstdc++-staticmakeopenssl-devel; cd/mnt/xmr-stak; cmake-DCUDA_ENABLE=OFF-DOpenCL_ENABLE=OFF.; make; " test-dfedora_27||mkdirfedora_27 mvxmr-stak/bin/*fedora_27 git-Cxmr-stakclean-fd ######################## #Ubuntu(17.04) ######################## dockerrun--rm-it-v$PWD:/mntubuntu:17.04/bin/bash-c" set-x; aptupdate-qq; aptinstall-y-qqlibmicrohttpd-devlibssl-devcmakebuild-essentiallibhwloc-dev; cd/mnt/xmr-stak; /mnt/cuda_*_linux-run--silent--toolkit; cmake-DCUDA_ENABLE=OFF-DOpenCL_ENABLE=OFF.; ... 呵呵,果然不出所料,这个脚本针对CentOS和Ubuntu系列linux系统自动创建建立一个Docker镜像然后安装xmr-stak 编辑一下这个脚本,只留下一个操作系统,我这里只留下了Ubuntu17部分 原来的脚本是跑完了docker安装完成就吧容器删掉,而我现在想把这个容器留下于是就改了改,最后变成下面这个样子 #!/bin/bash-uex if[[$EUID-ne0]];then echo"Thisscriptmustberunasroot" exit1 fi if[-dxmr-stak];then git-Cxmr-stakclean-fd else gitclonehttps://github.com/fireice-uk/xmr-stak.git fi ######################## #Ubuntu(17.04) ######################## dockerrun-itd--name"xmr"-v$PWD:/mntubuntu:17.04/bin/bash dockerexec-it"xmr"/bin/bash-c" set-x; aptupdate-qq aptinstall-y-qqlibmicrohttpd-devlibssl-devcmakebuild-essentiallibhwloc-dev; cd/mnt/xmr-stak; cmake-DCUDA_ENABLE=OFF-DOpenCL_ENABLE=OFF.; makeinstall; " 我的linux 不需要CUDA 删掉 CUDA部分的代码 直接执行(运行前请确定是否已经安装Docker) #./build_xmr-stak_docker.sh +[[0-ne0]] +'['-dxmr-stak']' +gitclonehttps://github.com/fireice-uk/xmr-stak.git Cloninginto'xmr-stak'... git-remote-https:/usr/local/lib/libldap_r-2.4.so.2:noversioninformationavailable(requiredby/usr/lib/x86_64-linux-gnu/lib git-remote-https:/usr/local/lib/liblber-2.4.so.2:noversioninformationavailable(requiredby/usr/lib/x86_64-linux-gnu/libcu remote:Countingobjects:3441,done. remote:Compressingobjects:100%(29/29),done. remote:Total3441(delta16),reused16(delta3),pack-reused3409 Receivingobjects:100%(3441/3441),1.01MiB|24.00KiB/s,done. Resolvingdeltas:100%(2403/2403),done. Checkingconnectivity...done. +dockerrun-itd--namexmr-v/data1/soft:/mntupdate-ubuntu/bin/bash f88a7614bd41821be42b584f76a1892184cd06155058c25c6bbdfb8c245cb571 +dockerexec-itxmr/bin/bash-c' ..... #脚本里包含了apt-getupdate时间会比较久,如果你觉得不需要也可以去掉。如果上面这些步骤一切正常,那么就可以进入刚健的容器去试试挖矿了 #dockerexec-itxmr/bin/bash #cd/mnt/xmr-stak/bin/ #ls libxmr-stak-backend.alibxmr-stak-c.axmr-stak #./xmr-stak Pleaseenter: -Currency:'monero'or'aeon' ... 上面是选择你想挖的币种类、矿池地址、钱包地址等等设置完之后会自动执行,如果出现下面这个就说明连接成功了,我测试用的是国内的一个门罗币矿池mine.ppxxmr.com:3333 [2018-01-1211:07:21]:Fast-connectingtomine.ppxxmr.com:3333pool... [2018-01-1211:07:21]:Poolmine.ppxxmr.com:3333connected.Loggingin... [2018-01-1211:07:21]:Difficultychanged.Now:15000. [2018-01-1211:07:21]:Poolloggedin. [2018-01-1211:07:29]:Difficultychanged.Now:15000. [2018-01-1211:07:29]:Newblockdetected. [2018-01-1211:07:37]:Resultacceptedbythepool. [2018-01-1211:07:47]:Resultacceptedbythepool. [2018-01-1211:08:04]:Difficultychanged.Now:10465. [2018-01-1211:08:04]:Newblockdetected. [2018-01-1211:08:11]:Resultacceptedbythepool. [2018-01-1211:08:17]:Resultacceptedbythepool. 网站上也出现了你挖矿的进度,如下图 终止进程后发现,bin下面多了两个文件 cpu.txt 和 config.txt #ls config.txtcpu.txtlibxmr-stak-backend.alibxmr-stak-c.axmr-stak 打开来看看 #vimconfig.txt /* *pool_address-Pooladdressshouldbeintheform"pool.supportxmr.com:3333".Onlystratumpoolsaresupported. *wallet_address-Yourwallet,orpoollogin. *pool_password-Canbeemptyinmostcasesor"x". *use_nicehash-Limitthenonceto3bytesasrequiredbynicehash. *use_tls-ThisoptionwillmakeusconnectusingTransportLayerSecurity. *tls_fingerprint-Server'sSHA256fingerprint.Ifthisstringisnon-emptythenwewillchecktheserver'scertagainstit. *pool_weight-Poolweightisanumbertellingtheminerhowimportantthepoolis.Minerwillminemostlyatthepool *withthehighestweight,unlessthepoolfails.Weightmustbeanintegerlargerthan0. * *Wefeaturepoolsupto1MH/s.ForamorecompletelistseeM5M400'spoollistatwww.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}, ], /* *currencytomine *allowedvalues:'monero'or'aeon' */ "currency":"monero", /* ... 刚才的设置应该都存在这里了, #vimcpu.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