Snipa22 / nodejs-pool

Other
479 stars 422 forks source link

Creating leaf node - instruction #174

Open ArqTras opened 6 years ago

ArqTras commented 6 years ago

Is there an instruction how to create second node on next vps to connect to one pool. Except deploy script I can’t find info how to connect to existing pool

mxjoe commented 6 years ago

As far as I know there is no documentation for installing a leaf node, just the bash file.

mxjoe commented 6 years ago

I am currently having trouble setting a leaf node up. The leaf.bash installation worked but the steps after that (files to edit, daemons to start ...) are unknown to me and I am currently doing trial and error.

ArqTras commented 6 years ago

Any success ?

mxjoe commented 6 years ago

Not yet. But I recognized that several errors are shown when installing and opened a bug report. #240

bobbieltd commented 6 years ago

I’m interested in this, too. Will leaf node use remotely the main server’s database ?

jredwine2857 commented 6 years ago

Looks like it uses the local db for some things related to blocks etc, but payments etc are handled at whatever you pick as your main node. At the moment I've had some issues getting the leaf node to communicate with the main node. I can see the tcp connection from the leaf node but it doesn't appear to be doing much.

ArqTras commented 6 years ago

Put leafApi public domain address in mysql

mxjoe commented 6 years ago

@ArqTras Could you go a bit more in detail, please.

bobbieltd commented 6 years ago

@ArqTras We put shareHost at same leafApi. What about modules ? Which modules do we need to run at leaf ? Do we still need same pool_db at leaf ? Thanks.

ArqTras commented 6 years ago

remoteShare and pool should be on node started. They need to connect to main database. You need to add id and ip and domain name in pools (mysql) also set it as active You need to add ports to mine to on id 1 (example) You need to configure node as id 1 with public ip in config.json and mysql connection to main database. Remember to secure Mysql connection. Remember that daemon should be on rpc mode in node.

jredwine2857 commented 6 years ago

So this part is a little wild west since there isn't much documentation on it. My assumption was that all leafnodes would simply communicate with the DB via the leafAPI. According to ArqTras it appears you actually have to open MySQL up to the leafnode as well. Seems redundant, but I'll try it out and see how it goes.

So far, just with pointing the leaf node's remoteshare setting to the main node, I can see communication via tcp and the pool starts ok, but if I mine to the leafnode, I do not see that reflected on the main node. I.e. Things like connected miners, pool hashrate, all stay at 0.

Snipa, if you're looking at this, can you clear this up once and for all? Does all comm from leafnode to main node happen over the leafAPI, or do we need to expose MySQL to the leafnode as well?

ArqTras commented 6 years ago

If you look at : https://github.com/Snipa22/nodejs-pool/blob/master/deployment/leaf.bash Line 15 there is installation of nodejs so it should be configured like : https://github.com/Snipa22/nodejs-pool/blob/master/config_example.json

"mysql": { "connectionLimit": 20, "host": "127.0.0.1", "database": "pool", "user": "pool", "password": "98erhfiuehw987fh23d" } That is how node communicate to pool (ip and credentials) I think but if you have proof of work using only leafApi please share Your solution

jredwine2857 commented 6 years ago

yeah, i dont have this working at all. I've tried using just the leaf.bash to install a leafnode, and I assume (without documentation, i'm guessing here) that you would only need the Pool module started. I set it up so that the config.json file points to the external IP of the MySQL server (and yes it's locked down to just the source IP of the leaf node). Still no go. The only logging I see is in the pool module error log and it's talking about an error parsing the JSON info which I assume is being sent from the leafAPI. See below.

I have also tried installing using the full install script, though I haven't tried with opening up MySQL and pointing it at the MySQL server. Going to try that next, but so far it's snake eyes on getting it to work using the lightweight leaf.bash script.

Could definitely use a little documentation on this process. If I end up figuring it out, I'll post it here.

2018-01-06 07:50 +00:00: SyntaxError: Unexpected string in JSON at position 132 at Object.parse (native) at Object. (/home/ubuntu/nodejs-pool/init.js:11:22) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Object. (/home/ubuntu/.nvm/versions/node/v6.9.2/lib/node_modules/pm2/lib/ProcessContainerFork.js:78:21) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9)

ArqTras commented 6 years ago

https://github.com/ArqTras/nodejs-pool/wiki/Leaf-Node-Wiki

bobbieltd commented 6 years ago

Great guide. Thank you ArqTras, I’ll practice to install a leaf next week when I have time.

ArqTras commented 6 years ago

Remember to add firewall rules on your server and allow connect to mysql This is my solution witch I use, but if anyone have better working please share info

jredwine2857 commented 6 years ago

Thanks arqtras! Huge contribution!

ArqTras commented 6 years ago

Working for me setup few hours ago ;)

mxjoe commented 6 years ago

Great guide but mine XMR leaf isn't working yet, I think I managed to connect to the master node via MySQL and added the entries for leaf node in pool.ports and pool.pools. But I still get following error:

4|pool | 2018-01-10 20:43 +00:00: TypeError: Cannot read property 'height' of undefined 4|pool | at Timeout._onTimeout (/home/user/nodejs-pool/lib/pool.js:833:115) 4|pool | at ontimeout (timers.js:475:11) 4|pool | at tryOnTimeout (timers.js:310:5) 4|pool | at Timer.listOnTimeout (timers.js:270:5)

Any ideas?

mxjoe commented 6 years ago

Thank you so much for the guide, @ArqTras ! Now it worked, the only thing I did was wait two days (no kidding) and upgrade my mailgun account. Strange, very strange...

ArqTras commented 6 years ago

@mxjoe you need to add credit card and put limit to 10000 emails :D

mxjoe commented 6 years ago

That's what I did and that seemed to have fixed my not working leaf node. :)

ArqTras commented 6 years ago

Also if you see I removed 9000 port with ssl because this making error for pool But it depend of configuration

bobbieltd commented 6 years ago

I don’t understand why 9000 doesn’t work when some others got in work (SSL, not TCP), and why it makes error with 9000 ?

ArqTras commented 6 years ago

multi node configuration (separate api, separate leaf node and other stuff) ;) read carefully whole readme and wiki from Snippa

ghost commented 6 years ago

Thanks @ArqTras for the great wiki, but why my leaf doesn't listen on any pool port?

/home/pooldaemon/.pm2/logs/pool-error-2.log You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: Error: Cannot find module 'cryptonote-util' at Function.Module._resolveFilename (module.js:536:15) at Function.Module._load (module.js:466:25) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object. (/home/pooldaemon/nodejs-pool/lib/coins/xmr.js:3:16) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at /home/pooldaemon/nodejs-pool/init.js:46:15 at tryCatcher (/home/pooldaemon/nodejs-pool/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/pooldaemon/nodejs-pool/node_modules/bluebird/js/release/promise.js:510:31) at Promise._settlePromise (/home/pooldaemon/nodejs-pool/node_modules/bluebird/js/release/promise.js:567:18)

/home/pooldaemon/.pm2/logs/blockManager-error-1.log You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: Error: libboost_system.so.1.58.0: cannot open shared object file: No such file or directory at Object.Module._extensions..node (module.js:664:18) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at bindings (/home/pooldaemon/nodejs-pool/node_modules/bindings/bindings.js:76:44) at Object. (/home/pooldaemon/nodejs-pool/node_modules/cryptonote-util/index.js:1:99) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object. (/home/pooldaemon/nodejs-pool/lib/coins/xmr.js:3:16)

jredwine2857 commented 6 years ago

Sounds like your leaf node isn't pulling the port config from the mysql db. Check to make sure of the following:

-you have mysql access allowed inbound to your MySQL db

-that you are using a MySQL account with proper access (test doing a remote connection to your MySQL db using that account and verify you can 'select * from pool.config')

-that your global.json has the proper IP for your mysql server

Good luck!

ghost commented 6 years ago

I did those, all is setup fine :/

jredwine2857 commented 6 years ago

Could try a sudo reboot just to see if it will trigger something. I had to do some rebooting to kick it in the but after making a lot of changes.

Also, check the nodejspool folder and see if any error logs are showing up. Then check the pm2 logs by doing a 'pm2 show pool' and open the 2 logs it shows in nano. See if that sheds any light.

ArqTras commented 6 years ago

Mysql on master must allow remote connection. You need to grant access from wan and secure that connection ex using iptables to allow connect from node public ip. It is really danger to open mysql to world so remember that connection between servers must be as much secure as you can. And you need to know that in myslq is default user with default password if you dont change it and open your mysql server everyone can connect using default credentials

ArqTras commented 6 years ago

On node: "mysql": { "connectionLimit": 20, "host": "master pool ip", "database": "pool", "user": "pool", "password": "98erhfiuehw987fh23d" } read carefully leaf wiki updated at last

ghost commented 6 years ago

I found the issue, i cloned uaktags's repo by mistake instead of Snipa's for my xmr pool. Thanks for the help guys.

ArqTras commented 6 years ago

Yes that's really old wiki. Anyone can use actual version of Snipa's code and correct that values in leaf.bash and deploy.bash or simply use master branch to run.