I Lessen Data

Thursday, April 27, 2017

if you want to attach an existing EBS volume to the instance, make sure it's in the same Availability Zone (like "us-east-1c")

To SSH at all:
download that private key that they make you create as part of the setup consolessh -i (thatkey.pem) -l ubuntu
(there's one user created at the start, called ubuntu)sudo adduser dantassesudo vim /etc/group # and add dantasse to sudo groupsudo vim /etc/ssh/sshd_config # and set PasswordAuthentication to yessudo /etc/init.d/ssh reload
Now you should be able to SSH.

Attach the EBS volume on the AWS console. For example, attach it as /dev/sdf. Because it's Ubuntu, it will be attached as /dev/xvdf instead. (because reasons :P) You have to mount it still, though. Say you want to mount it at /data:sudo mkdir /datasudo mount /dev/xvdf /data

Thursday, December 15, 2016

(Detailing this more as a historical artifact than anything else, but it might help someone.)

I had an EC2 Ubuntu 14.04 Trusty machine running PostgreSQL 9.3 and PostGIS 2.1 that I had to upgrade. For whatever reason.sudo do-release-upgrade

but PostGIS was holding it back. I don't remember how I found this out but I think it was a simple google. So I did:sudo apt-get remove postgresql-9.3-postgis-2.1 # turns out this was a mistakesudo do-release-upgrade

ok, now I'm on Ubuntu 16.04 Xenial. Now to upgrade postgres:sudo pg_upgradecluster 9.3 main /data/db/postgresql/9.5/main
ugh but wait, can't do it without PostGIS. hold on --psql tweettweet=#select * from tweet_pgh limit 1;
(some kind of error because I don't have PostGIS installed anymore.)

Huh. I guess I have to 1. get PostGIS back, 2. give it an "update path" to 2.3.1.
Getting PostGIS back:sudo apt-get install postgresql-9.3-postgis-2.1
(not found)

Huh. I flailed here for a while and then downloaded 2.1.2 from source, and did the old./configuremakemake install
But of course it wasn't that easy! Got one compile error about json and using this old ticket, realized I had to go into liblwgeom/lwin_geojson.c and edit "#include " to "#include "
Got another compile error and had to like #IFDEF out references to AggState and WindowAggState in lwgeom_accum.c (as in this old ticket) and assume it'll work (sure did). Or rather, I was able to configure and make it, then I just symlinked it into the right place:sudo ln -s /home/dantasse/postgis-2.1.2/postgis/postgis-2.1.so /usr/lib/postgresql/9.3/lib

THEN, I could do this:tweet=# select * from tweet_pgh limit 1;

but I couldn't do this:tweet=# ALTER EXTENSION postgis UPDATE TO "2.3.1";

Still getting the "no update path" error, until I found this old post, and then:

sudo yum localinstall https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-3.noarch.rpm # figure out what rpm you need here; if you just yum install postgresql you'll get an old versionsudo yum install postgresql94 postgresql94-server

sudo service postgresql-9.4 initdb # one-time initialization

sudo service postgresql-9.4 start # make the postgres server go

sudo service postgresql-9.4 on # make the postgres server go every time I log on

Note: on RHEL 7, you have to do these 3 lines instead of those last 3:

sudo /usr/pgsql-9.4/bin/postgresql94-setup initdb

sudo systemctl start postgresql-9.4.service

systemctl enable postgresql-9.4.service # so it starts at boot

sudo yum install postgresql94-contrib # for hstore

sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm # to get the right EPEL rpm for RHEL 6; it's like adding a new APT repository in Ubuntu I thinksudo yum install postgis2_94 # more help here if you need

sudo su - postgres

psql

CREATE USER (myusername) WITH SUPERUSER;

CREATE DATABASE (dbname);
(go to that new database)CREATE EXTENSION hstore;CREATE EXTENSION postgis;
(quit postgres, e.g. with ctrl-d)
(log out of being the postgres user; e.g. with ctrl-d again)

Double note: I have 2 cloud machines, one on RHEL 6 and one on RHEL 7. The RHEL 7 one killed me at the "install postgis" step; adding the EPEL rpm didn't make all the build errors go away. (when I poked around for other EPEL rpms, I eventually found one that fixed most of the build errors, but then gave me another error where it was missing libpoppler.so-46. I think I was the first person ever to have this error. In a turn of lunacy, I spent part of the day building GDAL from source. Surprisingly, it kinda worked. But didn't get me to PostGIS.) So, if you googled this and are looking for an answer, I'm afraid I can't help. Sorry!

Thursday, February 11, 2016

CREATE USER foo;
(or equivalently: CREATE ROLE foo WITH login;)GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO foo;orGRANT SELECT ON ALL TABLES IN SCHEMA public TO foo;

I think these are all pretty self explanatory. Then the new user is up and running!If you want the user to have a password:CREATE USER foo WITH PASSWORD 'bar';To get rid of the user: REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM foo;

Thursday, January 14, 2016

Dear Future Dan,
I know you are trying to convert a shapefile to a GeoJSON file. I know this because you googled "site:ilessendata.blogspot.com ogr2ogr". Here is what you want to do:ogr2ogr -t_srs EPSG:4326 -f GeoJSON output.json input.shp