Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^12: Help with Geo::IP output

by Anonymous Monk
on Jun 24, 2020 at 21:44 UTC ( #11118473=note: print w/replies, xml ) Need Help??

in reply to Re^11: Help with Geo::IP output
in thread Help with Geo::IP output

$ geoip -Ddsn dbi:SQLite:geoip -w Cannot continue without a working database

I created an SQLite database named "geoip" and then called geoip as shown above. It says "Cannot continue without a working database".

Replies are listed 'Best First'.
Re^13: Help with Geo::IP output
by Tux (Canon) on Jun 24, 2020 at 22:24 UTC

    Can you please indicate what is unclear in the README?

    $ perl ./geoip --fetch --DB=dbi:SQLite:dbname=geoip.db

    Will do everything for you if you have a working DBD::SQLite.

    A demo:

    $ ls -l geoip.db /bin/ls: cannot access 'geoip.db': No such file or directory Exit 2

    Be patient on the next one, it'll take a while to finish (my demo took 5 minutes). You will need enough memory and disk space. My process took 13 Gb of ram.

    $ perl ./geoip --fetch --DB=dbi:SQLite:dbname=geoip.db Create table stamps Create table continent Create table country Create table ipv4 Create table provider Create table city Create table ipc4 2020-06-22 21:16:39 4689345 304 2020-06-22 21:16:39 4689345 2020-06-16 13:13:32 1805947 304 2020-06-16 13:13:32 1805947 2020-06-16 13:19:50 41827687 304 2020-06-16 13:19:50 41827687 Reading Country info ... Reading Country IPv4 info ... Reading Provider IPv4 info ... Reading City info ... Reading City IPv4 info ...
    $ ls -l geoip.db -rw-r--r-- 1 501100544 Jun 25 00:30 geoip.db

    So there you go, 501 Mb of SQLite database.

    Enjoy, Have FUN! H.Merijn
Re^13: Help with Geo::IP output
by hippo (Chancellor) on Jun 24, 2020 at 22:16 UTC
    geoip -Ddsn dbi:SQLite:geoip -w

    That's not how to specify the DSN on the command line.

    $ geoip -Ddbi:SQLite:geoip -w

    might get you farther but since you haven't detailed how you created the database, who can say?

      I have never used SQLite so I'm totally new to it. At the command line, I entered:

      $ sqlite3 geoip SQLite version 3.7.17 2013-05-20 00:56:22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .save geoip.db Error: unknown command or invalid arguments: "save". Enter ".help" fo +r help sqlite> .quit

      The command .save doesn't work so it seems I can't create a database.

        You first said:

        I created an SQLite database named "geoip"

        and now you've said:

        The command .save doesn't work so it seems I can't create a database.

        I think you ought to spend just a little time to find out which of these statements is true because they can't both be.

Re^13: Help with Geo::IP output
by marto (Cardinal) on Jun 25, 2020 at 06:38 UTC

    Ensure you have DBD::SQLite installed (cpan DBD::SQLite or cpanm DBD::SQLite), ensure your maxmind licence key is valid and listed in the config file, from the command line run:

    geoip --fetch --DB=dbi:SQLite:dbname=geoip.db

    The program will create a new database called geoip.db, create the required schema and populate it with the data from maxmind.

      Ok I'm getting close.

      I created a directory called "dat" (/home/user/dat) and ran the command from the "dat" directory. I got the error message:

      geoip --fetch --DB=dbi:SQLite:dbname=geoip.db No license key in config file Issuing rollback() due to DESTROY without explicit disconnect() of DBD +::SQLite::db handle dbname=geoip.db at /home/user/perl5/bin/geoip lin +e 229

      So I went to get my license key and wrote the two lines in a file and saved it as geoip.rc (as well as geoip):

      license-id : myID icense-key : MyLicenseKey

      Then I uploaded geoip.rc to "/home/" and ran the command. I got the same error message. I tried uploading "geoip" (which is the same as geoip.rc) to "/home/.config" and ran the geoip command again.

      Still the same thing. Where should I place the config file (geoip.rc) and are my two lines sufficient?

        The documentation shows you $home not /home, but to avoid confusion:

        echo $HOME /home/marto

        Copy this config file in the home directory of the user running the script.

Re^13: Help with Geo::IP output
by Anonymous Monk on Jun 25, 2020 at 11:34 UTC

    The config file (geoip.rc) wasn't read because of permission. It was 644 but it must be 600 - sought help from the hosting.

    I finally managed to create the file with the total size of 510,100,144 (someone posted this size too) so I think the db is complete. I say this because when I ran the --fetch command, there was no success message when it ended:

    user@myhost ~]$ geoip --fetch --DB=dbi:SQLite:dbname=geoip.db 2020-06-22 19:16:39 4689345 304 2020-06-22 19:16:39 4689345 2020-06-16 11:13:32 1805947 304 2020-06-16 11:13:32 1805947 2020-06-16 11:19:50 41827687 304 2020-06-16 11:19:50 41827687 Reading City info ... Reading City IPv4 info .. user@myhost ~]$

    So I thought I should be able to run the command below now that the geoip.db is set up:

    [user@myhost ~]$ geoip -w FATAL: no pg_hba.conf entry for host "[local]", user "user", database + "geoip", SSL off Cannot continue without a working database

    What am I still missing?

      pg_hba.conf sounds like Postgres, but geoip --fetch --DB=dbi:SQLite:dbname=geoip.db sounds like SQLite.

      Maybe you need to make both consistent?

      In the create example you provided a dsn, which worked. When you ran it again you didn't so the program has no idea where to look (you didn't tell it, and haven't got an entry in your config file), and once again, the default is Pg. Just add the dsn to your config file.

        THANK YOU SO MUCH marto!

        I had thought it wouldn't be possible to get this geoip thing to work - there were so many things missing in the puzzle:

        1) The default SQLite was 2013 version and I had no idea this could be an issue. Had to download the source and compile my own binaries.

        2) I didn't have DBD::SQLite installed until someone mentioned it.

        3) Then there was the config file which I didn't now I could get - thought it was only for paid users.

        4) And then there was the memory usage thing at the server end that stopped the --fetch processes because it was using too much RAM (someone did warn about this). The hosting made an exception for an hour to allow the command to run.

        So it was an not *easy thing* to do especially for someone not too familiar with Unix.

        But it's finally done now - thank you everyone for your patience and help. Thank you.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11118473]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2021-09-23 21:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found