programmium

From Isham Mohamed


Realm Object Server on Linode – Quick and Easy Setup

Intro

The beauty in Realm is, its totally free if its hosted in your web server. Even though Azure supports Realm machines, where you can create a Realm Object Server in few clicks on Azure. But the least price is higher than 15 USD/mo. So Linode is a wise choice.

Linode offers 1GB – 20GB – 1TB machine for 5 USD/mo, which is relatively cheaper and, you can resize the machine whenever you need (usually when you’re about to shift to production). One drawback in resizing is, its not like the scalability in Azure, it’d take around 15+mins off time.

Action

Once you purchase a Linode

  1. Deploy Ubuntu 16.04 LTS image on it (typically it’d take couple of minutes)
    1. You can find it under Linode -> Dashboard -> Deploy ImageLinode deploy
  2. Note the IP address of the machine
  3. Once deployed – Open PuTTY and run SSH for “root@{machine IP}” eg : “root@173.225.189.17
  4. Enter password
  5. Run the following in terminal
    1. curl -s https://packagecloud.io/install/repositories/realm/realm/script.deb.sh | sudo bash
    2. sudo apt-get update
    3. sudo apt-get install realm-object-server-developerrealm server developer installation
    4. Press Y and press Enter
    5. sudo systemctl enable realm-object-server
    6. sudo systemctl start realm-object-server
    7. sudo ufw allow 9080/tcp
    8. sudo ufw reload

That’s all, you’ve successfully installed Realm Object Server – If you want to understand the commands, have a look at here.

Now open web browser, navigate to {linode machine IO}:9080 (eg : 173.225.189.17:9080) to see the dashboard

realm dashboard first launch

Setup the admin user and use it

realm obj serv dashboard

Further Client Side Development 

If you use Realm on Xamarin.Android where your machine IP is, 173.225.189.17 the code for loggin to the realm object server will be similar to the below

login.Click += async delegate
{
	var authURL = new Uri("http://173.225.189.17:9080");
	var serverURL = new Uri("realm://173.225.189.17/~/carsRealm");
	var credentials = Credentials.UsernamePassword("user_name", "password", createUser: false);
	var user = await User.LoginAsync(credentials, authURL);

	var config = new SyncConfiguration(User.Current, serverURL)
	{
		ObjectClasses = new [] {typeof (Car)}
	};
	_realm = Realm.GetInstance(config);

	try
	{
		var perm = await user.GetGrantedPermissionsAsync(Recipient.CurrentUser, millisecondTimeout: 2000);
	}
	catch (Exception ex)
	{
		var a = ex.Message;
	}


	Toast.MakeText(this, "Logged in", ToastLength.Short).Show();
};

For further things on development refer the realm documentation.

Happy Realm-ing! (not realming)



2 responses to “Realm Object Server on Linode – Quick and Easy Setup”

  1. Exactly what I was expecting. Thanks alot.

Leave a comment