Skip to content

Creating a Network of Map Searchers (MySQL, SSH Tunnel, Linux Debian)

pir2 edited this page Aug 2, 2016 · 1 revision

###Spreading Search Resources over Multiple Computers on Different Networks

Since Niantic is cracking down on mapping, it might be a good idea to spread searchers over a network of computers, especially from different IP Address ranges.

This guide will help you create an SSH tunnel from a remote computer back to your main mapping server and upload the data to the MySQL Server.

Requirements

  • 2 servers
  • 1 running your maps and also hosts the MySQL Database
  • 1 being the new server that will map more areas
  • Server 2
  • You won't need grunt build for the second server since it won't be serving any webpages

Steps

  1. Set up PokemonGo-Maps on first server - wiki
  2. Set up PokemonGo-Maps on Server 2 - same as above, but don't run python runserver.py yet (i.e. only git clone the repository, pip install requirements and nothing else)
  3. Follow instructions here to set up SSH Tunnel between the two servers - Permanent SSH Tunnel
  • My final script below for reference (it differs slightly from the post and uses a correction from one of the comments)
createTunnel() {
  /usr/bin/ssh -f -N -L13306:127.0.0.1:3306 -L19922:127.0.0.1:22 tunnel@hostb -p 22
  if [[ $? -eq 0 ]]; then
      echo Tunnel to hostb created successfully
  else
      echo An error occurred creating a tunnel to hostb RC was $?
  fi
}
## Run the 'ls' command remotely.  If it returns non-zero, then create a new connection
/usr/bin/ssh -p 19922 tunnel@localhost ls
if [[ $? -ne 0 ]]; then
  echo Creating new tunnel connection
  createTunnel
fi
  1. Have crontab check the connection every 5 minutes to make sure the tunnel is still up (make sure it's running under the new tunnel user on Server 2):
crontab -e

#Add the below into your crontab
*/5 * * * * /home/tunnel/check_ssh_tunnel.sh >/dev/null 2>&1
  1. Change the port in pogom/models.py on Server 2 so that Server 2 can access Server 1's MySQL DB
def init_database(app):
   if args.db_type == 'mysql':
       log.info('Connecting to MySQL database on %s', args.db_host)
       db = MyRetryDB(
           args.db_name,
           user=args.db_user,
           password=args.db_pass,
           host=args.db_host,
           port=13306, ## <----- Add this line without the ## and comment to models.py
           max_connections=args.db_max_connections,
           stale_timeout=300)
   else:
       log.info('Connecting to local SQLLite database')
       db = SqliteDatabase(args.db)
  1. Modify your config/config.ini file to use MySQL
# Authentication settings
#auth-service:          # ptc (default) or google
#username:
#password:
username: [username]
password: [password]

# Database settings
db-type: mysql
db-host: 127.0.0.1              # required for mysql
db-name: pokemongomapdb              # required for mysql
db-user: user               # required for mysql
db-pass: pw              # required for mysql

# Search settings
#location:
#no-gyms:               # disables gym scanning (default false)
#no-pokemon:            # disables pokemon scanning (default false)
#no-pokestops:          # disables pokestop scanning (default false)
#scan-delay:            # default 5
#step-limit:            # default 12

# Misc
#gmaps-key:             # your Google Maps API key
#webhook:               # webhook URL (including http://)

# Webserver settings
#host:                  # address to listen on (default 127.0.0.1)
#port:                  # port to listen on (default 5000)

#Uncomment a line when you want to change its default value (Remove # at the beginning)
#username, password, location and gmaps-key are required
  1. Run your PokemonGo-Map on Server 2 python runserver.py -st 10 -sd 5 -ns -ng -nk -l "xx.yy, yy.xx" -k xxxxxxxxxxxxxxxxxxxxxxxx using the new tunnel user
  2. If everything is set up correctly, Server 2 should now be sending data to Server 1