Pages:
Author

Topic: Avalon users: bitcoind and slush's/generalfaults mining pool setup - page 9. (Read 39219 times)

legendary
Activity: 1764
Merit: 1002
quick question.

everything you posted should go well on a new server specifically for solo pool mining with Ubuntu 12.10, ssd=64GB, and 8MiB RAM, correct?

you sir are a gentleman and a blessing to this community.  thank you.  Cheesy
full member
Activity: 176
Merit: 100
Just a note on security, its  out of the depth of this tute.
But if the machine is a virtual one or a real one on your home network behind a router running nat and its on a internal ip address, its not a huge problem. If its directly connected to the internet with a real ip. You at least want to use ssh keys for login.

Some information below.
 
https://help.ubuntu.com/community/SSH/OpenSSH/Keys
http://www.electrictoolbox.com/putty-rsa-dsa-keys/

Once you get them working, there is a option in sshd config file to turn of password logins..

You may want to encrypt the bitcoind wallet on the server as well even though its not used to store coins

Code:
bitcoind encryptwallet 
Write your passphrase down somwhere Smiley

On the linux not being mainstream if you looking for a desktop try Linux mint or Ubuntu Desktop.
Shrug, each to their own for their needs.

Because the mining server is written in python it "may" be able to be run on windows.



full member
Activity: 176
Merit: 100
Is this similar to bitcoind + eloipool configuration? Can I run it on virtual machine so I don't need to have a dedicated computer acting as a server? Thanks for the hard work  Smiley

Similar yes, but different pool server software. Virtual machine instructions are above for virtual box.
Not sure how it will go with  cpu loading/memory etc depends on what pc your running it on.

Works ok on testnet with a two gpu setup connected to it.
full member
Activity: 176
Merit: 100
install virtualbox it free you can get it from here

http://download.virtualbox.org/virtualbox/4.2.10/VirtualBox-4.2.10-84105-Win.exe
Install virtual box

Then download the extentions pack

http://download.virtualbox.org/virtualbox/4.2.10/Oracle_VM_VirtualBox_Extension_Pack-4.2.10-84104.vbox-extpack

then install that.

http://releases.ubuntu.com/quantal/ubuntu-12.10-server-i386.iso

download ubuntu server iso from here.

run virtualbox

click new

put a name in

under the type drop box select linux

under the version drop box select ubuntu

click next

Memory needs to be 2gig at least move the slider or type 2048 in the box

click next, then click create, then click next and next again.

Change the size of the virtual drive to 20GB, then click create.

You should have a new virtual machine listed, select it then click the the settings button.

Click storage select the cd icon that says emtpy. on the right hand side of this window it will say cd/DVD drive IDE secondary master then a cd icon.

Click the icon, and select choose a virtual disk, in the window that pops up browse to where you saved the ubuntu iso you downloaded. Select the iso then click ok.

Under controller: IDE, next to the first cd icon it should say ubuntu-12.10-server-i386.iso

Under network click the drop down box next to attached to: and select Bridged adapter.
Under the Name: drop downbox select the network adapter that you use to connect to the internet.

Click ok.

Then click the green start arrow.

It should load the virtual machine.

Follow the onscreen prompts to install ubuntu or look at one of the tutorials on ubuntu.com (do make sure you select the openssl server when it lists the packages to install)


Once its installed it will ask to reboot then select unbuntu from the black and white menu when it pops up.

Login with the user name and password you created.

then type
Code:
ifconfig
on the command line

it should display something like this

Code:
eth0      Link encap:Ethernet  HWaddr 08:00:27:d2:75:22
          inet addr:192.168.1.54  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed2:7522/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:18545 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14016 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:20850978 (20.8 MB)  TX bytes:4551612 (4.5 MB)

the ip after inet addr: is the one you are looking for.

Open up putty a windows ssh client and connect to that ip and login.



sr. member
Activity: 310
Merit: 250
Nice tutorial but Jesus... this is why Linux isn't mainstream

Yes, my own personal opinion.

/flamesuit on.

Still, good job.
legendary
Activity: 1610
Merit: 1000
tiktoc,
I am impressed very nice tutorial

What about merged mining can you put a word on two just basics for guidelines?

10X

newbie
Activity: 34
Merit: 0
Is this similar to bitcoind + eloipool configuration? Can I run it on virtual machine so I don't need to have a dedicated computer acting as a server? Thanks for the hard work  Smiley
sr. member
Activity: 336
Merit: 251
Avalon ASIC Team
thank you, much appreciated
legendary
Activity: 1764
Merit: 1002
i almost had a boner reading this  Wink

this looks to be an extraordinary set of instructions like i've never seen before and i can't wait to try them.  awaiting an ssd and my batch 2 avalons.

congrats on the line by line code and explanations as to what each does.  it all makes sense and is exceedingly clear.  i'll send you a tip once i get everything running.
full member
Activity: 176
Merit: 100
This is use at your own risk. I'm not a expert. I don't have asic miner so I cant test it on real btc, works on testnet though and gives shares to gpu miner fine and testnet coins fine.
So I am not responsible if you lose your real coins.

Re the major pools.
They seem to be good people and the amount of work they do and investment over the years including writing the software below, should be worth the 1 to 3 percent they ask. But in the name of diversity..

You can do this in virtual box to give it a try out first.

So you have yourself a ubuntu 12.10 32bit (see a post further down on what changes are needed for 64bit) linux server install and you want to setup a pool server for solo mining on it.

I have added a part for ubuntu 12.04 32bit its in blue.

I normally do this from windows box using putty to ssh into the ubuntu box.
Things you need

Make sure your login is in the sudoers list (this will be automatic if you installed from dvd and created your login name with the installer).

Then at the command prompt first thing we are going to do is update and upgrade the system to the latest packages
with all the sudos you have to put your login password in when it asks for it.
with the apt-get installs hit y and enter whenever it asks you.
Code:
sudo apt-get update
once its complete

Code:
sudo apt-get upgrade

now to install bitcoind

make sure git is installed first

Code:
sudo apt-get install git

now make directory under you home one called like so

Code:
mkdir git

change the directory you just made

Code:
cd git

get the source for bitcoind instructions to build it are also here

Code:
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
git checkout v0.8.6

Install the build dependencies
Code:
sudo apt-get install build-essential
sudo apt-get install libssl-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libminiupnpc-dev

wget https://launchpad.net/~bitcoin/+archive/bitcoin/+files/libdb4.8_4.8.30-quantal2_i386.deb
wget https://launchpad.net/~bitcoin/+archive/bitcoin/+files/libdb4.8-dev_4.8.30-quantal2_i386.deb
wget https://launchpad.net/~bitcoin/+archive/bitcoin/+files/libdb4.8%2B%2B_4.8.30-quantal2_i386.deb
wget https://launchpad.net/~bitcoin/+archive/bitcoin/+files/libdb4.8%2B%2B-dev_4.8.30-quantal2_i386.deb

sudo dpkg -i libdb4.8_4.8.30-quantal2_i386.deb
sudo dpkg -i libdb4.8-dev_4.8.30-quantal2_i386.deb
sudo dpkg -i libdb4.8++_4.8.30-quantal2_i386.deb
sudo dpkg -i libdb4.8++-dev_4.8.30-quantal2_i386.deb

*********************
This is the libdb4.8 packages for only fo ubuntu 12.04  dont use these if you are using ubuntu 12.10

wget https://launchpad.net/ubuntu/+source/db4.8/4.8.30-11ubuntu1/+build/3392254/+files/libdb4.8-dev_4.8.30-11ubuntu1_i386.deb
wget https://launchpad.net/ubuntu/+source/db4.8/4.8.30-11ubuntu1/+build/3392254/+files/libdb4.8_4.8.30-11ubuntu1_i386.deb
wget https://launchpad.net/~bitcoin/+archive/bitcoin/+files/libdb4.8%2B%2B_4.8.30-10precise1_i386.deb
wget https://launchpad.net/~bitcoin/+archive/bitcoin/+files/libdb4.8%2B%2B-dev_4.8.30-10precise1_i386.deb


sudo dpkg -i libdb4.8_4.8.30-11ubuntu1_i386.deb
sudo dpkg -i libdb4.8-dev_4.8.30-11ubuntu1_i386.deb
sudo dpkg -i libdb4.8++_4.8.30--10-precise1_i386.deb
sudo dpkg -i libdb4.8++-dev_4.8.30-10precise1_i386.deb
*********************

then to build
Code:
cd src/
make -f makefile.unix
once its finished building without errors, copy it into /usr/local/bin
Code:
sudo cp ./bitcoind /usr/local/bin/

then run it by typing
Code:
bitcoind
it will output

Code:
Error: To use bitcoind, you must set a rpcpassword in the configuration file:
/home/yourusername/.bitcoin/bitcoin.conf
It is recommended you use the following random password:
rpcuser=bitcoinrpc
rpcpassword=EjkjenJHJhhfdkwemkjmnkk37883njn37hfdkjn38n
(you do not need to remember this password)
The username and password MUST NOT be the same.
If the file does not exist, create it with owner-readable-only file permissions.
cut and past the rpcuser and rpcpassword lines to a temporary text file and save it for later.

now create the bitcoin.conf file
Code:
cd
cd .bitcoin
open up bitcoin.conf in a text editor like pico
Code:
pico bitcoin.conf
add the lines



and cut and past the two lines from above that you saved from above from the temporary text file into the bitcoin.conf

server=1
rpcport=8332
rpctimeout=30

so it should look like this once finsihed

server=1
rpcport=8332
rpctimeout=30
rpcuser=bitcoinrpc
rpcpassword=EjkjenJHJhhfdkwemkjmnkk37883njn37hfdkjn38n

Code:
then press cntrl x
hit y to save
hit enter to save it to bitcoin.conf
then change the permissions on bitcoin.conf to user only read permissions

Code:
chmod go-rwx bitcoin.conf

now start bitcoind  on the testnet

Code:
bitcoind -testnet -daemon

it should show

Bitcoin server starting
hit enter again to get back to shell prompt

after a couple of minutes

on the command line type
Code:
bitcoind getinfo
you get something similar to

Code:
blah@ks3098647:~$ bitcoind getinfo
{
    "version" : 80000,
    "protocolversion" : 70001,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 32935,
    "timeoffset" : -5,
    "connections" : 17,
    "proxy" : "",
    "difficulty" : 11.90472507,
    "testnet" : True,
    "keypoololdest" : 1364506205,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "errors" : ""
}
it will take about 10 to 20 minutes to download the testnet coin chain.

Now onto the pool server which is at https://github.com/generalfault/stratum-mining/blob/master/INSTALL

Code:
cd
cd git
git clone https://github.com/slush0/stratum.git
git clone https://github.com/generalfault/stratum-mining.git

sudo apt-get install python-dev
sudo apt-get install python-setuptools
sudo apt-get install python-crypto
sudo easy_install -U distribute
sudo easy_install stratum
sudo easy_install simplejson

cd stratum-mining/conf
cp config_sample.py config.py

now get the testnet wallet address from bitcoind

Code:
bitcoind getaccountaddress "" 
copy this adddress to the clipboard

now edit the config.py file by

Code:
pico config.py
edit the line that says central wallet

delete the text between the ' '

then past you key from the clipboard inbetween the ' '

so it should look like this

CENTRAL_WALLET = 'mv9mpc6xLEZNYpXJtodRrfjbyF3kbbr7CL'   # local bitcoin address where money goes

this has to be correct as this is where your coins that you mine go not so bad for the testnet ones we do first, very bad if you get it wrong and you mine real

btc.

The BITCOIN_TRUSTED_USER = 'bitcoinrpc' should be the same as in the trusted user you saved to a text file ealier if you lost it its the same on as in the

bitcoin.conf file.

The BITCOIN_TRUSTED_PASSWORD = 'some password'  line should be edited to become BITCOIN_TRUSTED_PASSWORD = ''  then paste your trusted password from the tempory

text file from earlier if you lost it its the same on as in the bitcoin.conf file.

it should look something like this

BITCOIN_TRUSTED_PASSWORD = 'BRqw9gB78hcm6qSZ7DHvuTPWxCPVHzE9BY9gkFTddBNH'

Code:
cntrl x and hit y to save then enter to save to that file name
then

Code:
cd ..

start the server by running this on the command line

Code:
twistd -ny launcher.tac -l -
the output should be like this

Code:
2013-03-31 00:04:32,584 INFO mining # Connecting to bitcoind...
2013-03-31 00:04:32+0100 [-] Log opened.
2013-03-31 00:04:32+0100 [-] twistd 12.3.0 (/usr/bin/python 2.7.3) starting up.
2013-03-31 00:04:32+0100 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2013-03-31 00:04:33,353 INFO mining # Connected to bitcoind - Ready to GO!
2013-03-31 00:04:33,372 INFO coinbaser # Coinbase address 'yourwalletkeyhere' is valid
2013-03-31 00:04:33,375 INFO mining # MINING SERVICE IS READY
2013-03-31 00:04:33+0100 [HTTPPageGetter,client] Loading of signing key 'None' failed, protocol messages cannot be signed.
2013-03-31 00:04:33+0100 [HTTPPageGetter,client] Cannot initiate SSL context, are SSL_PRIVKEY or SSL_CACERT missing?
2013-03-31 00:04:33+0100 [HTTPPageGetter,client] This will skip all SSL-based transports.
2013-03-31 00:04:33+0100 [HTTPPageGetter,client] SocketTransportFactory starting on 3333
2013-03-31 00:04:33+0100 [HTTPPageGetter,client] Starting factory
2013-03-31 00:04:33+0100 [HTTPPageGetter,client] Site starting on 8889
2013-03-31 00:04:33+0100 [HTTPPageGetter,client] Starting factory
2013-03-31 00:04:34,107 INFO template_registry # New template for 00000000000000e272aaab8803cb27f73563f3accd373f6cc838be7e10d886ae
2013-03-31 00:04:34,108 INFO subscription # BROADCASTED to 0 connections in 0.000 sec
2013-03-31 00:04:34,108 INFO template_registry # Update finished, 0.256 sec, 297 txes
you should be able to point your miner at

http://YOURHOSTNAMEORIPADDRESS:3333

eg cgminer -o yourhostnameORIPADRESS:3333 -u guest -p guest

(the guest can bereplaced by any username/password you want)

you should see it connect and be given work

Once your miner has mined some blocks check the transactions are showing in the wallet by running this

Code:
bitcoind listtransactions

it should show the incoming blocks you have mined (the testnet balamce wont show in getinfo till they are confirmed 120 times)

Now to setup blocknofity so bitcoind will tell the pool software when a new block is deteced instead of having the pool server poll bitciond every 5 seconds.

there is script to generate the hash of the password to put in the pool servers config.py generate it by using the command below replace somepassword with the password you wish to use.

Code:
./scripts/generateAdminHash.sh somepassword
it should outsomething like this
Code:
blah@ks3098644:~/git/stratum-mining$ ./scripts/generateAdminHash.sh somepassword1
37bc885f08c043f1cb9852956e01ca0d07ba664a5eee14fc417408c01aae063d
copy the hash(the long sequence of letters and numbers) and past it into the config.py file

by editing via
Code:
pico ./conf/config.py
then find the

ADMIN_PASSWORD_SHA256 = none

line in the config.py file

and change that line to

ADMIN_PASSWORD_SHA256 = 'youhashhere'

so using the hash i made above I  should end up with something like this below, the hash you paste in must be surround by these ' '

ADMIN_PASSWORD_SHA256 = '37bc885f08c043f1cb9852956e01ca0d07ba664a5eee14fc417408c01aae063d'

Code:
save it by hitting cntrl x then y then enter
now to test it

restart the pool server or run it again if you stopped it before

to start it again run

Code:
twistd -ny launcher.tac -l -
at a new command prompt

Code:
./scripts/blocknotify.sh --password somepassword1 --host localhost --port 3333
if its working it should display something like below (the amount of time it takes to notify will change each time)

blocknotify: done in 0.012 sec

now to add blocknotify to bitcoind
stop the bitcoin server by

Code:
bitcoind stop
wait for it to stop then type in the following line replace yourusername with your username you log into ubuntu with and replace somepassword1 with the password you used to create the admin hash before.

Code:
bitcoind -blocknotify="/home/yourusername/git/stratum-mining/scripts/blocknotify.sh --password somepassword1 --host localhost --port 3333" -testnet -daemon

if it starts up check the output from the pool server for and if you see the blocknotify notifications coming in then edit config.py with

Code:
pico ./conf/config.py
and find the line below

PREVHASH_REFRESH_INTERVAL =

edit it to the same as the line below

PREVHASH_REFRESH_INTERVAL = 60

Code:
save it by hitting cntrl x then y then enter
restart the pool again switch to the command prompt that has the pool running  and hit control c which will stop the server.

Then enter to start it again run
Code:
twistd -ny launcher.tac -l -
it should run and it should show when new blocks are found.

If all is working we can change over to the real btc network

first stop the pool server using cntrl c on the command prompt with its output.

Then stop bitcoind with
Code:
bitcoind stop

If you dont want to wait the 8 to 24 hours to download the real bitcoin chain

You can get a bootstrap chain  bootstrap file which is on  source forge and can  downloaded via a torrent file which you can download and then upload to the ubuntu server and put it in the .bitcoin directory under your home directory before you start bitcoind.

Information here http://sourceforge.net/projects/bitcoin/files/Bitcoin/blockchain/

link to the torrent file below

http://downloads.sourceforge.net/project/bitcoin/Bitcoin/blockchain/bootstrap.dat.torrent

If your downloading it all or using bootstrap file

start bitcoind replace yourusername with your username you log into ubuntu with and replace somepassword1 with the password you used to create the admin hash

before.
Code:
bitcoind -blocknotify="/home/yourusername/git/stratum-mining/scripts/blocknotify.sh --password somepassword1 --host localhost --port 3333" -daemon
*notice the -testnet flag has been removed from the line above

wait for it sync up to the current blocks. (It MUST be synced before you can mine on the pool)

On the command line you can check the current blocks by

Code:
bitcoind getblockcount
you can check the current blocks on the normall bitcoind-qt client by hovering over the green check mark it will pop up the current block. When these two numbers are the same or very close then your wallet on bitcoind is synced up.

Now we have to edit config.py to put a real Bitcoin address in there so you get your coins when you mine them!

on the command line
Code:
cd
cd git/stratum-mining/
pico conf/config.py
find the line
CENTRAL_WALLET = 'mv9mpc6xLEZNYpXJtodRrfjbyF3kbbr7CL'   # local bitcoin address where money goes

replace the wallet address with a real one generated from whatever wallet software you use.

It should look something like this

CENTRAL_WALLET = '1jxc4KgRXCkn2JD7QjmgMrDKqM2yQtPAp'   # local bitcoin address where money goes

(DO NOT USE THE WALLET ADDRESS IN THE ABOVE LINE)

The address MUST have the ' ' chars around it like above.

If this line is not correct you will lose your coins!
(The pool will warn you if its not a valid address, but a vaild one can still be a wrong address i.e not one you own)


further down in the config.py file find this line ALLOW_NONLOCAL_WALLET = True                            # Allow valid, but NON-Local wallet's

change ALLOW_NONLOCAL_WALLET = False
to

ALLOW_NONLOCAL_WALLET = True

Code:
save it by hitting cntrl x then y then enter
start the pool by typing on the command line

Code:
twistd -ny launcher.tac -l -

The pool server will tell you if bitcoind is not synced when you start it as well.

does it show the btc wallet address is valid?
does it show that bitcoin is synced?

if so cntrl c

then started the server again using

twistd -ny launcher.tac -l - &

(On headless servers, You can use screen to run the server in so you can rettach back to screen and see the output of the server. just type screen on the command

line and it will lod up to a new command prompt, start the server as usal. when you done before you disccount or close your ssh session do a cntrl d  which will

detach screen. When you login next and want to look at the pool server output type screen -r on the command line.)
Mine away Smiley

You can set the config.py to its unwriteable(can be changed by root or your user login) on the command prompt type
Code:
cd
cd git/stratum-mining/conf
chmod a-w config.py
If you find a block it and the wallet address you used is in a bitcoin-qt client it will notify you and show up under the label imature until it has been confirmed 120 times.

You can check some basic server stats at(this works when you are mining testnet as well).

http://yourserveripaddress:8889/

For asic miners you might need to increase the threads in this line in config.py

THREAD_POOL_SIZE = 30

give this a try

THREAD_POOL_SIZE = 150

Dont own a asic miner so I cannot try it out, some of pool owners might be able to give recommendations.

If the machine is rebooted for some reason you will have to start bitcoind and the pool server again. This can be automated if you want.
The blocknotify I assume can be moved from the command line into the bitcoin.conf file.
Eg add this to bitcoin.conf replacing the bits you need.
Code:
blocknotify=/home/yourusername/git/stratum-mining/scripts/blocknotify.sh --password somepassword1 --host localhost --port 3333
then just running bitcoind  like this

Code:
bitcoind -daemon

Cheers and good luck with your mining.

edit: fixed a cut and paste Smiley
edit:6/4 Removed quotes on line to put in bitcoin.conf
edit:9/4 Changed git repository, and changing to current stable version 0.8.1
edit:9/6 Added part for ubuntu 12.04 also changed bitcoin version to 0.8.2
Tips: 1MivVoqttGDpqK8qZzJcfQdkwUG91bGC7G
Pages:
Jump to: