目录
环境
想法
- 由于挖矿很费性能,对于手上的垃圾服务器来说,要挂nginx和tomcat还要挖矿实在是难为它了。
- 因此想把挖矿的任务分给另一台服务器。
- 目标效果即为:
- 副节点连上主节点,两者的数据同步。
- 主节点关闭挖矿,节省性能,由副节点挖矿。
开搞
让副节点连上主节点
- 注意:
- 不要在副节点上直接打开geth执行
- $ geth attach http://your_ip:8545
- 这样相当于远程连接控制主节点了,就像我们在windows上用ssh远程连接linux去控制geth挖矿的开启和关闭一样,链上仍然只有主节点一个,只不过有主节点本机和另一台机可以去控制主节点。
- 不要在副节点上直接打开geth执行
- 副节点需要和主节点用一样的创世块文件
- 这里就用和之前的文章(以太坊私链搭建)所用的创世块一致
- genesis.json
{
"config":{
"chainId":7,
"homesteadBlock":0,
"eip150Block":0,
"eip155Block":0,
"eip158Block":0,
"byzantiumBlock":0,
"constantinopleBlock":0,
"petersburgBlock":0,
"istanbulBlock":0,
"ethhash":{}
},
"alloc":{},
"coinbase":"0x0000000000000000000000000000000000000000",
"difficulty":"0x2",
"extraData":"",
"gasLimit":"0xffffffff",
"nonce":"0x0000000000000042",
"mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp":"0x00"
}
- 还要准备启动脚本,这里也保持和主节点一致
- rungeth.sh
geth --datadir ./data --networkid 7 --http --http.addr 0.0.0.0 --http.vhosts "*" --http.api "admin,debug,web3,eth,txpool,personal,ethash,miner,net" --http.corsdomain "*" --snapshot --mine --miner.threads 1 --allow-insecure-unlock console 2> 1.log
- 在副节点所在机新建一个用户
- $ geth --datadir ./data account new
- 然后在副节点所在机初始化创世块
- $ sudo geth --datadir ./data init ./genesis.json
- 启动geth
- $ sudo ./rungeth.sh
- 如果是在一台机子上搞两个节点,则要修改他们的运行端口,使之不要重复,不然其中一个会启动不起来。
- 至此,副节点就部署完成了,接下来要在主节点中添加副节点。
- 首先查看一下副节点的enode
- > admin.nodeInfo.enode
- 首先查看一下副节点的enode
- -
- 在主节点添加副节点的enode
- >admin.addPeer("encode")
- 在主节点添加副节点的enode
- 查看是否添加成功
- 方法1:
- 直接对比两者的块高度看看是否相等,如果块比较多,可能需要等待一下同步。
- > eth.blockNumber
- 方法2:
- net.peerCount
- admin.peers
- 方法1:
- 让副节点代替主节点挖矿
- 把主节点挖矿停掉,在主节点所在机执行:
- > miner.stop()
- 让副节点挖矿,在副节点所在机执行:
- > miner.start()
- 把主节点挖矿停掉,在主节点所在机执行:
修改java程序连接副节点
- 上一篇的文章:java使用web3j调用以太坊私链上的智能合约
- 上文中讲到,java程序连接单节点(主节点)的私链去调用智能合约。
- 注意:
- 如果不修改的话,此时主节点虽然开着geth,但关闭了挖矿,只能和副节点进行数据同步,而连接主节点发送的请求都是不能执行的。
- 而且主节点的geth不能关闭,否则副节点也会出问题。
- 不要在开着geth的时候直接关闭ssh窗口,否则会导致链的数据丢失,要在geth里执行> exit 退出。
- 复制副节点的用户私钥文件到java程序执行的机子上,
- 修改java程序使用这个私钥文件,并把用户地址也改成这个私钥文件的用户。
- 修改java程序连接副节点所在的服务器ip地址。
- 到这里就可以了,如此就实现了让副节点代替主节点挖矿的任务了。
存在的问题
- 主节点的账号是不能在连接副节点后使用的,也就是说,两个节点实际上只有链上的数据是互通的,账号是不互通的。因此java程序连接副节点时需要修改。
- 此时主节点只能同步数据,不能挖矿,连接到主节点后发送的交易并不会由副节点代替挖矿完成。
farmaci senza ricetta elenco: kamagra oral jelly – Farmacia online miglior prezzo
http://cialisgenerico.life/# farmacie online autorizzate elenco
Link pyramid, tier 1, tier 2, tier 3
Tier 1 – 500 references with inclusion within writings on writing domains
Middle – 3000 URL +Redirect links
Lower – 20000 connections combination, remarks, posts
Employing a link structure is useful for web crawlers.
Require:
One reference to the domain.
Key Phrases.
True when 1 key phrase from the website subject.
Remark the complementary service!
Important! First-level hyperlinks do not overlap with Tier 2 and Tertiary-tier hyperlinks
A link hierarchy is a mechanism for boosting the circulation and inbound links of a digital property or social media platform
farmacie online sicure: kamagra gel – comprare farmaci online all’estero
Hmm is anyone else encountering problems with the images on this blog loading? I’m trying to determine if its a problem on my end or if it’s the blog. Any suggestions would be greatly appreciated.
https://hackmd.io/@wN_tPiPlSU6k7l2fQcw0Vg/B1Eru5FgR
п»їFarmacia online migliore: kamagra gel – acquisto farmaci con ricetta
Hey, just looking around some blogs, seems a pretty nice platform you are using. I’m currently using WordPress for a few of my sites but looking to change one particular of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?
Oh my goodness! Awesome article dude! Thanks, However I am having troubles with your RSS. I don’t understand why I am unable to join it. Is there anybody getting identical RSS problems? Anyone that knows the answer will you kindly respond? Thanks.
Excellent article! We will be linking to this great content on our website. Keep up the good writing.
You should be a part of a contest for one of the finest sites on the internet. I will highly recommend this blog!
This is the right site for anybody who hopes to understand this topic. You understand a whole lot its almost hard to argue with you (not that I actually would want to…HaHa). You definitely put a brand new spin on a subject which has been discussed for years. Excellent stuff, just excellent.
May I simply say what a comfort to find someone that genuinely understands what they’re talking about on the net. You definitely know how to bring a problem to light and make it important. A lot more people need to read this and understand this side of your story. I was surprised you are not more popular given that you most certainly have the gift.
http://cytotecbestprice.pro/# cytotec online
I like it when individuals come together and share opinions. Great site, keep it up.
You are so cool! I don’t suppose I’ve read through a single thing like that before. So good to discover another person with unique thoughts on this subject. Really.. thank you for starting this up. This site is something that is needed on the web, someone with a bit of originality.
Сравнение стоимости натяжных потолков
відгуки про натяжні стелі https://naryazhnistelifrtg.kiev.ua/ .
I really love your blog.. Pleasant colors & theme. Did you build this amazing site yourself? Please reply back as I’m attempting to create my own blog and would like to find out where you got this from or what the theme is called. Many thanks.
cytotec buy online usa: buy cytotec online fast delivery – buy cytotec in usa
https://zithromaxbestprice.pro/# zithromax without prescription
order cytotec online: buy misoprostol over the counter – cytotec online
cytotec buy online usa: buy cytotec online – Abortion pills online
Good post. I learn something new and challenging on websites I stumbleupon on a daily basis. It will always be useful to read through articles from other authors and practice something from other websites.
This page really has all the info I needed about this subject and didn’t know who to ask.
Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across.Seo Paketi Skype: By_uMuT@KRaLBenim.Com -_- live:by_umut
buy prednisone 50 mg: order prednisone 10 mg tablet – prednisone cost canada
https://nolvadexbestprice.pro/# tamoxifen brand name
Explore a curated collection of fashion at fjallraven outlet.
zithromax azithromycin: zithromax drug – how to get zithromax online
Good blog you have got here.. It’s difficult to find good quality writing like yours nowadays. I seriously appreciate people like you! Take care!!
That is a good tip particularly to those new to the blogosphere. Brief but very accurate info… Many thanks for sharing this one. A must read post.
You’ve done a fantastic job of breaking down this topic. Thanks for the clarity!
Лебедки Golden Power http://goldenpower4x4.ru/lebedki.html
buy misoprostol over the counter: buy cytotec over the counter – Misoprostol 200 mg buy online
Hi, I do believe this is an excellent site. I stumbledupon it 😉 I’m going to revisit yet again since i have saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to guide others.
Greetings! Very helpful advice within this article! It’s the little changes that make the greatest changes. Thanks a lot for sharing!
https://zithromaxbestprice.pro/# buy zithromax canada
Спортивная серия лебедок Goldenpower http://goldenpower4x4.ru/lebedki/sportivnaya-seriya.html
Can I just say what a comfort to discover somebody who truly understands what they are talking about over the internet. You actually know how to bring a problem to light and make it important. More people should check this out and understand this side of the story. It’s surprising you’re not more popular since you surely possess the gift.
cytotec pills buy online: buy cytotec online fast delivery – buy cytotec online
A fascinating discussion is definitely worth comment. I think that you should publish more about this subject matter, it might not be a taboo subject but generally people do not speak about such subjects. To the next! Cheers.
Pretty! This was a really wonderful post. Thank you for providing these details.
This is the right web site for anybody who hopes to understand this topic. You realize a whole lot its almost tough to argue with you (not that I actually will need to…HaHa). You definitely put a new spin on a subject which has been written about for ages. Excellent stuff, just great.
I truly love your website.. Great colors & theme. Did you build this site yourself? Please reply back as I’m looking to create my own personal blog and would like to learn where you got this from or just what the theme is called. Appreciate it!
tamoxifen 20 mg: how does tamoxifen work – tamoxifen headache
After exploring a handful of the blog articles on your web page, I really like your way of blogging. I book-marked it to my bookmark site list and will be checking back soon. Please visit my website too and tell me how you feel.
This is a great tip especially to those new to the blogosphere. Brief but very accurate information… Thanks for sharing this one. A must read article!
Can I simply say what a relief to discover an individual who genuinely understands what they are talking about on the internet. You definitely know how to bring a problem to light and make it important. A lot more people need to read this and understand this side of your story. It’s surprising you are not more popular because you certainly have the gift.
Explore a curated collection of fashion at fjallraven outlet.
Полностью актуальные новости модного мира.
Исчерпывающие мероприятия всемирных подуимов.
Модные дома, торговые марки, haute couture.
Приятное место для стильныех хайпбистов.
https://qrmoda.ru/fashion/361-manzoni-24-italyanskiy-mehovoy-shik/
400 mg prednisone: can i buy prednisone online without prescription – prednisone price canada