Eric Guo's blog.cloud-mes.com

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

Fix vm_core.h Error Ruby_current_ec Undeclared When Install Ruby 3.1.3 or 3.0.5

Permalink

Today ruby core team release the 3.1.3 and 3.0.5 patch version, but when I install it on CentOS 7, I got the below errors:

make: *** [miniinit.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from vm_core.h:83:0,
from iseq.h:14,
from ast.c:6:
thread_pthread.h:108:43: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
^
In file included from iseq.h:14:0,
from ast.c:6:
vm_core.h: In function ‘rb_current_execution_context’:
vm_core.h:1870:34: error: ‘ruby_current_ec’ undeclared (first use in this function)
rb_execution_context_t *ec = ruby_current_ec;
^
vm_core.h:1870:34: note: each undeclared identifier is reported only once for each function it appears in
ast.c: At top level:
cc1: warning: unrecognized command line option "-Wno-tautological-compare" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-self-assign" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-cast-function-type" [enabled by default]
make: *** [ast.o] Error 1

After do some research, I found it works in AWS linux (gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-15)) and Ubuntu (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0) smoothly, but CentOS 7 will always failed. (gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44))

So I guess probably it’s relative with the old stock gcc version of CentOS 7, luckily new gcc can be installed in CentOS 7 easily.

yum list | grep gcc
yum install centos-release-scl-rh
yum install llvm-toolset-7-clang
yum install centos-release-scl
yum install devtoolset-7-gcc.x86_64 && yum install devtoolset-7-gcc-c++.x86_64
# or yum install devtoolset-7-toolchain
scl enable devtoolset-7 bash
rbenv install 3.1.3 # now can successully install ruby!

Hoping this article can save you at least half day time and having a nice day!

蜗牛和蚕宝宝成了朋友

Permalink

蜗牛和蚕宝宝成了朋友

一天,蜗牛和蚕宝宝在窗台上偶然相遇了,蚕宝宝问蜗牛,“你是谁?为啥你的身上有个难看的壳?“蜗牛愤怒的说:”那是我的家,我累了倦了可以休息的地方,你又是谁?不会连住的地方也没有吧?“蚕宝宝想了想,好像自己吃了那么多桑叶,长了这么大,从来也没想过要在哪里住这个问题。不过既然蜗牛那么说,好像住的地方也挺重要的,那就不妨……

”我住在仙人掌的顶上,看到没?不比你的房子漂亮?!“

蜗牛顿时有点傻眼,有点不相信,但是又说不出哪里有问题:“好宝宝,能不能带我上去看看?我看这颗仙人掌好高啊!”,蚕宝宝有点紧张,自己好像也没爬过那么高大的仙人掌,不过既然大话已经说出去了,也只能……

“那我带你,你跟我来!”蚕宝宝在蜗牛之前,就开始爬起了仙人掌,蜗牛则紧跟在后,蚕宝宝当然不熟路,爬到一半一不注意一头撞上了仙人掌的一根刺,顿时头疼浑身一卷滚下了仙人掌。蜗牛也没好到哪里,由于他不愿意放弃他的壳,完全就跟不上蚕宝宝,不过好在他及时的接住了滚下来的蚕宝宝。

蚕宝宝很感激蜗牛的救命之恩,有点不好意思的说,“蜗牛哥,我说谎了,其实我也没住的地方,平时我都是吃桑叶吃累了,随便就地睡觉的。”蜗牛也有点惭愧,说:“好宝宝,我背了一个大壳,其实限制了我的行动力,我其实刚刚压根就爬不了仙人掌。”

蚕宝宝突然发现自己太虚荣了,蜗牛哥还是很可爱的,于是两个人最终成了很好的朋友。

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 git-lfs 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