目录
环境
想法
- 由于挖矿很费性能,对于手上的垃圾服务器来说,要挂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程序连接副节点时需要修改。
- 此时主节点只能同步数据,不能挖矿,连接到主节点后发送的交易并不会由副节点代替挖矿完成。
clomid nolvadex: buy tamoxifen citrate – tamoxifen medication
качественный ремонт айфонов в москве
Misoprostol 200 mg buy online http://furosemide.win/# lasix 100 mg tablet
lasix
tamoxifen therapy: buy tamoxifen citrate – tamoxifen brand name
buy cytotec in usa: buy misoprostol over the counter – buy cytotec online
You are so cool! I do not suppose I’ve truly read something like that before. So nice to find somebody with a few genuine thoughts on this topic. Seriously.. thanks for starting this up. This website is one thing that’s needed on the web, someone with some originality.
Then only you can obtain the best service from these experts.
Oh my goodness! Awesome article dude! Thanks, However I am experiencing troubles with your RSS. I don’t know why I cannot join it. Is there anybody else getting identical RSS problems? Anyone that knows the answer will you kindly respond? Thanks.
Credit scores are based on your payment history, how much outstanding debt you have, the length of your credit history, what type of credit you’ve received and the frequency with which you fill out new credit applications.
furosemide 100mg: cheap lasix – furosemida 40 mg
buy cytotec online http://cytotec.pro/# buy cytotec online fast delivery
buy lasix online
They will be the same throughout the year, unlike crops which keep on changing the price with season and supply and demand.
Oh my goodness! Awesome article dude! Many thanks, However I am experiencing difficulties with your RSS. I don’t know why I cannot join it. Is there anybody else having identical RSS issues? Anyone who knows the solution will you kindly respond? Thanks!
After going over a few of the blog posts on your web site, I truly appreciate your way of blogging. I added it to my bookmark webpage list and will be checking back in the near future. Take a look at my website too and let me know how you feel.
Psychotherapy, specifically, offers a safe place for people to express their anger — and any other feelings that may need to be acknowledged and understood, as well as an opportunity to learn how to recognize negative thought patterns and behaviors and learn emotion-regulation skills.
order cytotec online https://lipitor.guru/# lipitor brand price
furosemide 100 mg
Трудно представить себе, через что приходится проходить пайщикам кооператива “Бест Вей” и их семьям. Особенно это касается участников СВО, которые, рискуя жизнью, защищают нашу страну. Они заслуживают лучшего, но вместо этого сталкиваются с невозможностью получить свои квартиры. Мой брат, к примеру, два года назад приобрел квартиру через кооператив. Внес все нужные суммы, но из-за заморозки счетов не может оформить жилье в собственность. Такая ситуация подрывает доверие к государственным институтам, которые, казалось бы, должны защищать наших героев. Надеюсь, что руководство страны вмешается и поможет разрешить эту несправедливость.
Моя сестра вступила в кооператив “Бест Вей” ещё в 2018 году, когда её муж получил предложение поработать в другом городе. Они не могли позволить себе ипотеку, и кооператив стал для них единственным шансом обзавестись жильём. Всё шло хорошо, пока два года назад не арестовали счета кооператива. Теперь их квартира, за которую они заплатили все взносы, всё ещё не оформлена в собственность. Мой зять сейчас участвует в СВО, и сестре приходится справляться со всеми проблемами в одиночку. Она пишет жалобы, обращается в различные инстанции, но пока всё безрезультатно. Для них кооператив был надеждой на лучшее будущее, а теперь это бесконечный источник стресса и переживаний. Я надеюсь, что ситуация скоро разрешится, ведь таких, как моя сестра, много. Люди просто хотят жить в своих домах, за которые честно заплатили.
buy cytotec over the counter: buy misoprostol tablet – purchase cytotec
Good write-up. I definitely love this website. Stick with it!
Hello there, I think your website might be having internet browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in IE, it has some overlapping issues. I just wanted to give you a quick heads up! Besides that, wonderful site.
In 1932, the new Municipal Corporation Building, Thrissur was constructed.
ремонт смартфонов в москве
Interaction captures the value added that is not attributable solely to the asset allocation and stock selection decisions.
lasix generic: buy furosemide – lasix generic
ABBC Foundation’s Alibabacoin is soon going to become one of the few coins to offer a highly secure multi cryptocurrency HD wallet that will support 8 types of cryptocurrencies including ABBC, Bitcoin, Ethereum, Dash, Litecoin, Qtum, Bitcoin Cash, and Ripple.
Для бронирования на услуги и узнавания исчерпывающей информации посетите наш веб-сайт или свяжитесь с нами по номеру +7(909)167-47-46. Наш адрес: Москва, Гурьянова 30 (2 этаж). Дайте себе возможность наслаждение релаксации в Термбурге!
ремонт телефонов в москве
In the last few years, the hedge fund industry has been investing more in compliance management, such as SOX compliance software, reporting platforms, and accounting software.
With the high degree of economic globalization and the increasingly competitive market, the individual enterprise competition gradually evolve industrial chain and industrial cluster competition.
сервис по ремонту телефонов
Лучшие варианты колясок для вашей погодки, доставят комфорт и удовольствие.
Экспертные советы по выбору коляски для погодки, и удовлетворит все потребности вашего питомца.
Топовые модели колясок для погодок, порадуют вас своими инновационными решениями.
Простые советы по уходу за коляской для погодки, и радовала вас своим идеальным состоянием.
Новинки в мире аксессуаров для колясок погодок, и подчеркнут индивидуальность вашего питомца.
Инновационные функции, которые делают коляски для погодок уникальными, для активных владельцев погодок, ценящих комфорт и безопасность.
Какие коляски для погодок выбирают знаменитости, чтобы и ваша погодка могла чувствовать себя звездой.
Лучшие модели колясок для погодок, для безопасных и комфортных прогулок с любимцем.
Секреты комфортных прогулок с погодкой в коляске, и принесут не только удовольствие, но и пользу.
Топ-3 самых практичных колясок для погодок, чтобы сделать прогулки с погодкой еще более приятными.
Инновации в сфере колясок для погодок, для безопасных и комфортных прогулок.
Преимущества использования коляски для погодки, и как это сделает ваши прогулки приятными и комфортными.
Новые тенденции в мире колясок для погодки, чтобы сделать прогулки с погодкой приятными и безопасными.
Какая коляска для погодки станет лучшим выбором для вашего питомца, для тех, кто ценит комфорт и качество.
Удобные и стильные коляски для погодок, и добавят вашей погодке комфорта.
Как подобрать идеальную коляску для погодки
коляска трость для погодок коляска трость для погодок .
cytotec abortion pill http://cytotec.pro/# buy cytotec pills
generic lasix
Oh my goodness! Amazing article dude! Thank you so much, However I am encountering troubles with your RSS. I don’t understand the reason why I am unable to subscribe to it. Is there anyone else getting similar RSS problems? Anybody who knows the answer can you kindly respond? Thanks!
Dividend Mutual Funds are schemes where investors invest their money, with the idea of getting regular dividend payments.
Pretty! This was an incredibly wonderful post. Thanks for supplying these details.
lisinopril 20mg tablets price: Lisinopril refill online – lisinopril 10 12.5 mg tablets
Discover the perfect blend of style and comfort at marmot clothing.
ремонт айфона в москве недорого
lipitor cost canada: buy atorvastatin online – generic lipitor 10mg
Aw, this was an extremely nice post. Taking a few minutes and actual effort to generate a top notch article… but what can I say… I put things off a lot and never seem to get anything done.
сервисный центр iphone в москве
cytotec pills buy online https://lipitor.guru/# lipitor 80
furosemide
центр ремонта айфонов
tamoxifen medication: tamoxifen hair loss – tamoxifen therapy
I’d like to thank you for the efforts you’ve put in penning this website. I really hope to check out the same high-grade content by you later on as well. In truth, your creative writing abilities has motivated me to get my very own blog now 😉
bookmarked!!, I like your web site!
buy misoprostol over the counter http://furosemide.win/# lasix dosage
lasix pills
lipitor 5 mg tablet: buy lipitor 20mg – lipitor generic canada
https://lipitor.guru/# lipitor 10