目录
环境
想法
- 由于挖矿很费性能,对于手上的垃圾服务器来说,要挂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程序连接副节点时需要修改。
- 此时主节点只能同步数据,不能挖矿,连接到主节点后发送的交易并不会由副节点代替挖矿完成。
Look at the general market direction, the industry group, the tandem comparison, and the actual stock you are considering.
india pharmacy mail order: Online medicine home delivery – online shopping pharmacy india
I like reading through an article that can make men and women think. Also, thank you for allowing for me to comment.
magnificent issues altogether, you just gained a brand new reader. What may you recommend in regards to your put up that you made some days ago? Any positive?
Right here is the right web site for anyone who wants to find out about this topic. You understand so much its almost tough to argue with you (not that I really would want to…HaHa). You definitely put a fresh spin on a subject which has been written about for many years. Great stuff, just wonderful.
Когда деньги нужны прямо сейчас, а банки не идут навстречу, канал https://t.me/s/zaim_bez_otkaza_srochno спасет ситуацию! Здесь вы найдете список МФО, которые выдают срочные займы без отказа и проверки кредитной истории. Независимо от вашего прошлого, деньги могут быть у вас на карте в считанные минуты. Подписывайтесь и забудьте о проблемах – с нами все возможно!
purple pharmacy mexico price list: mexico pharmacies prescription drugs – mexican online pharmacies prescription drugs
Good post. I learn something new and challenging on blogs I stumbleupon on a daily basis. It will always be useful to read through content from other writers and practice a little something from other websites.
In that sense, futures contracts work just manager would be able to hedge against any increase in the interest rates.
Юридический портал Соцправ.ру
узнать задолженность по алиментам по фамилии
– окажет вам помощь в решении сложных правовых проблем. У нас вы найдете качественную и грамотную юридическую поддержку в любой ситуации. Основной целью нашего проекта является помощь в защите ваших прав. Наши специалисты позаботятся о том, чтобы вы могли защитить свои интересы в любой проблемной ситуации. Мы предоставляем актуальную юридическую информацию по вопросам жилищного и земельного права, разделу имущества и алиментам, наследству, опеке и усыновлению. Если ваши права нарушены, специалисты нашего сайта всегда придут на помощь. Мы готовы оказать вам юридическую поддержку онлайн или по телефону в круглосуточном режиме.
This post is highly informative. I genuinely appreciated reading it. The content is extremely structured and straightforward to comprehend.
Excellent post. I absolutely appreciate this website. Stick with it!
From the earliest stages of Elvis Presley’s career, his manager, Colonel Tom Parker, hit on collectibles as a way to market his client.
Адвокаты Москвы
юридическая консультация бесплатная москва
Мы успешно защищаем права и свободы юридических и физических лиц. Колоссальный и зачастую уникальный опыт, а также высокая квалификация наших сотрудников позволяют нам достигать результата, в максимальной степени отвечающего интересам клиента. Наши специалисты состоят в адвокатской палате которая на сегодняшний день является наиболее авторитетной в России. Благодаря многочленным блистательным победам в громких и, по мнению многих, бесперспективных делах, наши сотрудники снискали уважение не только в РФ, но и за рубежом.
Если вам нужен адвокат в Москве просто обратитесь к нам и вы получите квалифицированную помощь в решении ваших проблем. Как показывает практика, в большинстве дел, в которых принимали участие наши адвокаты, суд выносил решение в пользу их клиентов. Кроме того, мы осуществляем страхование своей ответственности на 5 млн рублей. Такие гарантии вам не предложит ни одна юридическая компания.
Стоит отметить, что за все то время, что работает наша компания не было прецедента, когда в результате действий наших специалистов клиенту был бы нанесен ущерб и возникла необходимость в страховой поддержке.
Адвокатские услуги
Адвокаты и юристы Москвы оказывают услуги в различных областях права: гражданского, арбитражного, уголовного и др. Нашими клиентами являются жители как столицы, так и других городов России. Для решения задач, которые стоят перед нашим клиентом, мы готовы оказать разовую помощь правового характера или сотрудничать на постоянной основе.
Explore a curated collection of fashion at fjallraven outlet.
buying from online mexican pharmacy: mexico pharmacy win – purple pharmacy mexico price list
http://edpillpharmacy.store/# ed treatments online
This website truly has all the information I needed concerning this subject and didn’t know who to ask.
In January 2005, Stefan Karlsson of the Ludwig von Mises Institute challenged the usefulness of the Index due to the fuzziness of many of the categories used to determine freedom.
A smaller bundle of innovative products in sync with rural needs and perception and an efficient delivery system are the two aspects that have to be developed in order to penetrate the rural markets.
I love it when folks come together and share views. Great blog, continue the good work!
I’d like to thank you for the efforts you’ve put in writing this blog. I am hoping to view the same high-grade blog posts from you in the future as well. In truth, your creative writing abilities has inspired me to get my own, personal blog now 😉
indianpharmacy com: indian pharmacy – world pharmacy india
The plan of health insurance works in a simple manner, where the financial institution will pay regular premiums to a financial institution in return of which the institution promises the customer to cover him financially in any case of a medical emergency.
Through regression models, scientists can assess the impact of human activities on climate change and make predictions about future trends, aiding in the development of effective environmental policies.
This is really interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I’ve shared your website in my social networks! Thanks Seo specialists India view https://andyaocp53198.life3dblog.com
cheapest online pharmacy india: Online pharmacy – pharmacy website india
https://indiapharmacy.shop/# india pharmacy
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
cheap ed medicine: cheap ed drugs – cheapest erectile dysfunction pills
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
Thank you great post. Hello Administ .Seo Paketi Skype: By_uMuT@KRaLBenim.Com -_- live:by_umut
I like it whenever people come together and share thoughts. Great blog, continue the good work!
Thank you for great article. Hello Administ .Seo Paketi Skype: By_uMuT@KRaLBenim.Com -_- live:by_umut
I really love to read such an excellent article. Helpful article. Hello Administ . Seo Paketi Skype: By_uMuT@KRaLBenim.Com -_- live:by_umut
Shop now for premium styles at STAUD Official Site.
Excellent article. I definitely love this website. Keep it up!
http://edpillpharmacy.store/# erectile dysfunction online
buy medicines online in india: Online pharmacy USA – india pharmacy
online pharmacy india: reputable indian online pharmacy – buy medicines online in india
This website was… how do I say it? Relevant!! Finally I have found something that helped me. Thanks a lot!
That is a very good tip particularly to those fresh to the blogosphere. Simple but very precise information… Many thanks for sharing this one. A must read article!
Hi, I do believe this is a great website. I stumbledupon it 😉 I will return once again since i have saved as a favorite it. Money and freedom is the greatest way to change, may you be rich and continue to help other people.
This article is wonderful. I discovered the details very useful and well-written. Thanks for sharing such beneficial details.
http://indiapharmacy.shop/# top 10 pharmacies in india
online ed medicine
Discover exclusive collections at Z SUPPLY Clothing.
how to get ed pills: ed pills online – online ed meds
Aw, this was a very nice post. Taking a few minutes and actual effort to create a good article… but what can I say… I procrastinate a lot and don’t manage to get anything done.
https://indiapharmacy.shop/# top 10 online pharmacy in india
online erectile dysfunction
Oh my goodness! Awesome article dude! Thank you so much, However I am experiencing problems with your RSS. I don’t know why I cannot subscribe to it. Is there anybody else getting identical RSS issues? Anybody who knows the answer will you kindly respond? Thanx.