Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^11: Help with Geo::IP output

by Anonymous Monk
on Jun 24, 2020 at 21:26 UTC ( [id://11118470]=note: print w/replies, xml ) Need Help??


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

So I need to create an SQLite database called geoip?

Replies are listed 'Best First'.
Re^12: Help with Geo::IP output
by Anonymous Monk on Jun 24, 2020 at 21:44 UTC
    $ geoip -Ddsn dbi:SQLite:geoip -w 103.2.106.33 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".

      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 GeoLite2-ASN-CSV.zip 304 2020-06-22 21:16:39 4689345 GeoLite2-ASN-CSV.zip 2020-06-16 13:13:32 1805947 GeoLite2-Country-CSV.zip 304 2020-06-16 13:13:32 1805947 GeoLite2-Country-CSV.zip 2020-06-16 13:19:50 41827687 GeoLite2-City-CSV.zip 304 2020-06-16 13:19:50 41827687 GeoLite2-City-CSV.zip 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
      geoip -Ddsn dbi:SQLite:geoip -w 103.2.106.33

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

      $ geoip -Ddbi:SQLite:geoip -w 103.2.106.33

      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.

      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 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 geoip.gb 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 GeoLite2-ASN-CSV.zip 304 2020-06-22 19:16:39 4689345 GeoLite2-ASN-CSV.zip 2020-06-16 11:13:32 1805947 GeoLite2-Country-CSV.zip 304 2020-06-16 11:13:32 1805947 GeoLite2-Country-CSV.zip 2020-06-16 11:19:50 41827687 GeoLite2-City-CSV.zip 304 2020-06-16 11:19:50 41827687 GeoLite2-City-CSV.zip 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 103.2.106.33 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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found