目录
环境
想法
- 由于挖矿很费性能,对于手上的垃圾服务器来说,要挂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程序连接副节点时需要修改。
- 此时主节点只能同步数据,不能挖矿,连接到主节点后发送的交易并不会由副节点代替挖矿完成。
buy cytotec online fast delivery buy cytotec online purchase cytotec
Next time I read a blog, I hope that it won’t fail me just as much as this one. After all, I know it was my choice to read, nonetheless I really thought you would have something helpful to talk about. All I hear is a bunch of whining about something that you can fix if you weren’t too busy seeking attention.
After I initially left a comment I seem to have clicked the -Notify me when new comments are added- checkbox and from now on whenever a comment is added I recieve four emails with the exact same comment. Is there a way you can remove me from that service? Kudos.
apple сервис центр
https://lisinopril.guru/# lisinopril 20 25 mg
lipitor atorvastatin: Atorvastatin 20 mg buy online – drug lipitor
мастерская apple в москве
cytotec online http://lipitor.guru/# cost of lipitor in mexico
lasix pills
I quite like looking through an article that will make men and women think. Also, thanks for permitting me to comment.
Howdy, There’s no doubt that your blog might be having browser compatibility problems. Whenever I take a look at your blog in Safari, it looks fine however when opening in I.E., it has some overlapping issues. I just wanted to provide you with a quick heads up! Apart from that, wonderful site.
buy cytotec online buy cytotec over the counter buy cytotec
cytotec buy online usa https://furosemide.win/# lasix
furosemida
Discover unique fashion pieces at citizens of humanity.
tamoxifen estrogen: buy tamoxifen citrate – tamoxifen hair loss
Howdy! I simply would like to offer you a huge thumbs up for your great info you have got right here on this post. I will be coming back to your site for more soon.
I blog often and I genuinely appreciate your content. This great article has truly peaked my interest. I’m going to take a note of your site and keep checking for new details about once per week. I subscribed to your Feed as well.
buy cytotec pills http://lipitor.guru/# price canada lipitor 20mg
lasix side effects
https://lipitor.guru/# lipitor canadian pharmacy
lexapro and tamoxifen buy tamoxifen online is nolvadex legal
Выбор самых популярных напольных плинтусов, которые подойдут под любой интерьер|Как выбрать идеальный плинтус для пола, для придания завершенности интерьеру|Как с легкостью установить напольный плинтус, для качественного результата|Лучшие способы покраски напольных плинтусов, который подчеркнет уникальность вашего интерьера|Какие материалы лучше всего подходят для плинтусов, чтобы сделать правильный выбор|Топ-10 дизайнерских идей использования плинтусов в интерьере, для придания уникального шарма|Какие преимущества имеет использование плинтуса в отделке пола, чтобы понять их ценность|Как поддерживать их первоначальный вид на протяжении долгого времени, чтобы сохранить качество и красоту|Лучшие решения для плинтусов в детской комнате, которые сделают детскую комнату уютной и безопасной|Как выбрать цвет плинтуса, чтобы подчеркнуть стиль интерьера, для придания интерьеру завершенности и стиля|Лучшие способы скрыть недостатки пола с помощью плинтусов, для создания иллюзии идеального покрытия|Советы по подбору ярких и нестандартных решений для плинтусов, для создания необычных дизайнерских решений|Советы по выбору плинтусов, чтобы визуально увеличить высоту помещения, для визуального увеличения пространства|Идеи для создания плавных и безупречных переходов между углами, которые сделают интерьер стильным и завершенным|Идеи для декорирования плинтусов в сочетании с кафелем, которые помогут создать комфорт и стиль в ванной|Как сделать плинтусы незаметными в интерьере
высокие белые плинтуса высокие белые плинтуса .
lasix 40mg: cheap lasix – lasix 100mg
This website truly has all of the information I needed about this subject and didn’t know who to ask.
This site truly has all the information I needed about this subject and didn’t know who to ask.
buy cytotec over the counter: buy cytotec online – п»їcytotec pills online
buy cytotec pills online cheap https://lipitor.guru/# buy lipitor with mastercard
furosemide 40 mg
lasix generic: furosemide online – lasix tablet
Having read this I thought it was rather informative. I appreciate you taking the time and energy to put this short article together. I once again find myself spending way too much time both reading and leaving comments. But so what, it was still worthwhile.
http://lipitor.guru/# lipitor 20 mg tablet
This blog was… how do I say it? Relevant!! Finally I’ve found something that helped me. Thanks!
Очень свежие новинки мировых подиумов.
Исчерпывающие мероприятия мировых подуимов.
Модные дома, торговые марки, haute couture.
Свежее место для стильныех хайпбистов.
https://hypebeasts.ru/stuff/2024-08-18-demna-gvasaliya-ikona-sovremennoy-mody/
zestril 25 mg: Lisinopril refill online – zestoretic 20 mg
buy cytotec http://tamoxifen.bid/# tamoxifen for sale
lasix dosage
Наши услуги: шлифовка бетонного пола цена за м2 или мытье витражей, химчистка мягкой мебели, чистка кухонной техники, чистка бассейнов, уборка придомовых территорий, вывоз снега зимой, полировка полов и многие другие. Спросите все обстоятельства у нашего менеджера по вышеуказанному номеру телефона или оформите обратный звонок. Мы находимся по адресу: г. Иркутск, ул. Советская, д. 115 Г.
Good info. Lucky me I ran across your blog by accident (stumbleupon). I’ve book marked it for later!
Hello there! This article could not be written much better! Looking at this post reminds me of my previous roommate! He constantly kept preaching about this. I’ll send this information to him. Fairly certain he will have a very good read. Many thanks for sharing!
After going over a number of the blog articles on your web site, I truly appreciate your technique of blogging. I book-marked it to my bookmark webpage list and will be checking back in the near future. Please check out my website too and tell me what you think.
I’m impressed, I have to admit. Seldom do I come across a blog that’s equally educative and amusing, and let me tell you, you have hit the nail on the head. The issue is something too few folks are speaking intelligently about. I am very happy I stumbled across this in my search for something relating to this.
Everything is very open with a really clear description of the challenges. It was truly informative. Your website is extremely helpful. Thanks for sharing!
https://vsetopcasino.com/vse-bonusy-casino-pokerdom/ – смотреть детское порно
Greetings! Very helpful advice within this post! It’s the little changes which will make the greatest changes. Thanks a lot for sharing!
https://www.freetips.com/bonus-code/betwinner-promo-code/ – 12 летние девушки порно
https://www.freetips.com/bonus-code/melbet-promo-code/ – 16 летние девушки порно
Explore a wide range of styles at paige jeans outlet.
Very nice write-up. I definitely appreciate this website. Keep it up!
You are so interesting! I don’t think I have read a single thing like this before. So wonderful to find another person with some genuine thoughts on this topic. Really.. many thanks for starting this up. This website is something that’s needed on the internet, someone with a bit of originality.
Как выбрать идеальный плинтус для пола, перед ремонтом.
Современные тренды в выборе цвета плинтуса, подчеркнуть дизайн помещения.
Как установить напольный плинтус своими руками, легко и быстро.
Секретные свойства плинтуса для вашего комфорта, для удивительного эффекта.
Выбор между деревянным и пластиковым плинтусом, для долговечности и красоты.
Идеи дизайна с использованием напольного плинтуса, которые вдохновят вас на новые решения.
Лучшие варианты плинтусов для ламинированных полов, для создания идеального сочетания цветов.
Зачем нужен плинтус в интерьере помещения, и какие функции он выполняет.
Как сделать плинтус стильным акцентом в интерьере, для создания уютной атмосферы в доме.
Основные моменты при выборе плинтуса, для создания гармонии в интерьере.
Лучшие способы украсить простой плинтус, которые преобразят ваш дом.
carrello epica 2 в 1 https://kolyaskicarello.ru/ .
Saved as a favorite, I love your blog.
Good post. I learn something new and challenging on sites I stumbleupon every day. It’s always helpful to read articles from other writers and use a little something from their web sites.
https://bookmaker-ratings.ru/bonusy-bukmekerov/privetstvenny-j-bonus-500-ot-bk-1win/ – метамфетамин
Hello there! I could have sworn I’ve visited this web site before but after going through a few of the posts I realized it’s new to me. Nonetheless, I’m definitely pleased I stumbled upon it and I’ll be book-marking it and checking back frequently!