Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

My Maintain PostgreSQL Commands

Permalink

SELECT schemaname AS table_schema,
relname AS table_name,
PG_SIZE_PRETTY(PG_TOTAL_RELATION_SIZE(relid)) AS total_size,
PG_SIZE_PRETTY(PG_RELATION_SIZE(relid)) AS data_size,
PG_SIZE_PRETTY(PG_TOTAL_RELATION_SIZE(relid) - PG_RELATION_SIZE(relid))
AS external_size
FROM pg_catalog.pg_statio_user_tables
ORDER BY PG_TOTAL_RELATION_SIZE(relid) DESC,
PG_RELATION_SIZE(relid) DESC
LIMIT 100;

List all table size. origin

Upgrade Redis to 6.x on Ubuntu 20.04

Permalink

Add the official beta apt source

curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

Do install && restart

sudo apt-get update
sudo apt-get install redis
sudo systemctl restart redis

Original post

Fix core.fsyncObjectFiles Is Deprecated; Use core.fsync Instead in Gitlab

Permalink

After upgrade to higher version of Gitlab, when I push the repository to Gitlab, it gives warning like:

The warning when you push
remote: warning: core.fsyncObjectFiles is deprecated; use core.fsync instead
remote: Resolving deltas: 100% (2654/2654), completed with 614 local objects.
remote: warning: core.fsyncObjectFiles is deprecated; use core.fsync instead
remote: warning: core.fsyncObjectFiles is deprecated; use core.fsync instead

More recent commit fix it, but maybe due to I upgrade from 14.6 source code installation, so the setting is not apply.

Running below command to fix it.

sudo su - git
git config -l
git config --global --unset core.fsyncObjectFiles
git config --global --add core.fsync objects,derived-metadata,reference
git config --global --add core.fsyncMethod fsync

Compare with before setting and after FYI:

Before
core.autocrlf=input
gc.auto=0
repack.writebitmaps=true
receive.advertisepushoptions=true
receive.fsckobjects=true
After
core.autocrlf=input
core.fsync=objects,derived-metadata,reference
core.fsyncmethod=fsync
gc.auto=0
repack.writebitmaps=true
receive.advertisepushoptions=true
receive.fsckobjects=true

Deploy Homeland Forum Rails App on Rocky Linux 8

Permalink

Install htop and atop

sudo dnf update
sudo dnf install epel-release
sudo dnf install htop
sudo dnf install atop

Install nginx

sudo dnf install nginx

Install node.js v18

Using nodesource distribution

curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -
dnf install -y nodejs
yum install gcc-c++ make
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum install yarn

Install postgresql

Following DO manual

dnf module list postgresql
sudo dnf module enable postgresql:13
sudo dnf install postgresql-server
sudo dnf install postgresql-devel
sudo postgresql-setup --initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo -i -u postgres
psql

Install homeland other depends

yum install redis
yum install memcached
yum install ImageMagick
yum install ghostscript

Setup thape_forum user account

adduser thape_forum
cd /etc/sudoers.d/
echo "thape_forum ALL=(ALL) NOPASSWD:ALL" > 20-thape_forum-user
sudo su - thape_forum
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys # and paste your public key
chmod 600 .ssh/authorized_keys

Install rbenv & ruby

sudo dnf -y install git make gcc curl openssl-devel zlib-devel libffi-devel readline-devel sqlite-devel
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
rbenv -v
rbenv install -l
rbenv install 3.1.2
ruby --version
echo "gem: --no-document" > ~/.gemrc
gem update --system

Prepare the capistrano deploy folder

cd /var
sudo mkdir -p www/thape_forum
cd www
sudo chown -R thape_forum:thape_forum thape_forum/
bundle exec cap production puma:config

Create postgresql db user and import DB

sudo su - postgres
createuser thape_forum
psql
ALTER ROLE thape_forum LOGIN;
CREATE DATABASE thape_forum_prod WITH ENCODING='UTF8' OWNER=thape_forum;
logout
psql -d thape_forum_prod -f thape_forum_db.sql

Install nginx-mod-http-image-filter

sudo dnf makecache --refresh
sudo dnf -y install nginx-mod-http-image-filter

Original post

Using the NFS Drive in Ubuntu 20.04

Permalink

Run as root
apt-get install nfs-common
mkdir -p /mnt/codebase_backup
chown root:root codebase_backup/
mount -t nfs 172.17.0.1:/ifs/NFS-Directory/codebase_backup-NFS /mnt/codebase_backup
echo '172.17.0.1:/ifs/NFS-Directory/codebase_backup-NFS /mnt/codebase_backup nfs defaults 0 0' >> /etc/fstab

Clean Xcode Disk Usage

Permalink

xcode-select -p # default /Library/Developer/CommandLineTools
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
xcrun simctl delete unavailable
sudo xcode-select --switch /Library/Developer/CommandLineTools