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
- Deploy Ubuntu 16.04 LTS image on it (typically it’d take couple of minutes)
- You can find it under Linode -> Dashboard -> Deploy Image
- Note the IP address of the machine
- Once deployed – Open PuTTY and run SSH for “root@{machine IP}” eg : “
root@173.225.189.17
“ - Enter password
- Run the following in terminal
curl -s https://packagecloud.io/install/repositories/realm/realm/script.deb.sh | sudo bash
sudo apt-get update
sudo apt-get install realm-object-server-developer
- Press Y and press Enter
sudo systemctl enable realm-object-server
sudo systemctl start realm-object-server
sudo ufw allow 9080/tcp
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
Setup the admin user and use it
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)
Leave a comment