Now that I would like to monitor resources on Oracle Linux for this blog host, I wanted to install htop. top does its job but I prefer htop. htop has more features I would like to utilize.
From what I see, I guess there are 2 cores in one CPU and memory is 687 MB though the OCI UI says 1 GB. That said, this site is running OK without resource contention.
I’ve migrated my blog to yet another host on OCI‘s free tier host. It was much easier this time because I had all my contents into one zip file and expanded it on the new host. By Dockerizing the whole site, it completely separates data and server and makes the migration so much easier.
As a blogger (though a mediocre one) who maintains the whole thing by himself, I cannot live without this anymore. It’s really convenient and much more maintainable.
You may have hosts that you SSH into often and you get tired of typing password every time. You can skip typing password by having hosts remember your public key.
Make sure you’ve already created key pair by using ssh-keygen on your client machine, which generates id_rsa (private key) and id_rsa.pub (public key) under ~/.ssh directory.
Next, execute the following command to have the host remember your public key.
The command above writes out the public key generated on the client machine to the remote hosts’s ~/.ssh/authorized_keys file. If you just try to SSH into the host again, you won’t be promoted to enter password again.
sqlite3 module provides nice ways to deal with Sqlite database. We will cover a way to create a table and pump data into the table with a right way.
I’d recommend this nice tool called DB Browser for SQLite. This tool is very useful when you browse the data in the database and execute SQL scripts.
First, let’s create a sample table.
def create_table_hoge(self, conn):
cur = conn.cursor()
cur.execute('''CREATE TABLE HOGE (
id INTEGER PRIMARY KEY AUTOINCREMENT,
col1 text,
col2 VARCHAR(10)
)''')
We will pump bunch of dummy data into the table using the following code.
conn = sqlite3.connect(self.db_name)
cur = conn.cursor()
for i in range(1000):
cur.execute('''INSERT INTO HOGE (col1, col2)
VALUES (?, ?);
''', (f"test{i}",f"test{i+1}"))
conn.commit()
print(cur.lastrowid)
Note that cursor.execute method takes SQL statement and the parameter values as tuple. You can see the values are being accepted with question marks and actual values are in the tuple. I haven’t tried it but it probably prevents SQL injection rather than using a straight SQL like INSERT INTO HOGE (col1, col2) VALUES (‘test1’, ‘test2’).
When I browse HOGE table with DB Browser for SQLite, it looks like the following.
This tech blog has been hosted at OCI free tier for a few weeks and Oracle has not changed me a dime. It really has been free. My WordPress site is much faster on OCI than being hosted at iPage.com now.
One caveat is that I still have to pay for my own domain and hosting at iPage.com but it’s a cheap service so it doesn’t hurt me too much.
It has been running very well on all Dockerized components, so this is very cool. Much faster and I have control over every single details of my site. As an engineer, this is exactly what I wanted. Though it was quite a bit of work to figure out how to get it to work, it has been totally worth it.