$ wget https://dl.google.com/go/go1.15.5.linux-amd64.tar.gz
$ tar -C /usr/local -xvzf go1.15.5.linux-amd64.tar.gz

$ cat /usr/local/go/VERSION
go1.15.5

$ vim .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/go/bin
export PATH

$ source .bash_profile

$ go version
go version go1.15.5 linux/amd64

During database load phase with go-ycsb, the load process is terminated and the message ‘Got signal [hangup] to exit’ is reported.

$ nohup ./bin/go-ycsb load cockroach -P workloads/workloadd --threads 96 -p pg.host=<cockroach-host-ip> -p pg.port=26257 -p pg.user=root -p pg.db=test -p pg.sslmode=disable -p dropdata=true  &

INSERT - Takes(s): 6150.0, Count: 66394363, OPS: 10795.9, Avg(us): 8167, Min(us): 1515, Max(us): 28655, 99th(us): 26815, 99.9th(us): 28447, 99.99th(us): 28623
INSERT - Takes(s): 6160.0, Count: 66504914, OPS: 10796.3, Avg(us): 8166, Min(us): 1515, Max(us): 28655, 99th(us): 26815, 99.9th(us): 28447, 99.99th(us): 28623

Got signal [hangup] to exit.
Run finished, takes 1h42m46.015270222s
INSERT - Takes(s): 6166.0, Count: 66570612, OPS: 10796.4, Avg(us): 8166, Min(us): 1515, Max(us): 28655, 99th(us): 26815, 99.9th(us): 28447, 99.99th(us): 28639

To resolve this, after running nohup command, type “exit” to exit the current shell instead of closing the shell session directly.

Reference

In one case, I need to limit the usable memory size to 128GB from a system which has 1TB memory.

$ cat /proc/meminfo | grep MemTotal
MemTotal:       1056493068 kB

Edit /etc/default/grub file

Add “mem=128G” to the end of line “GRUB_CMDLINE_LINUX”.

$ cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet mem=128G"
GRUB_DISABLE_RECOVERY="true"

Generate new grub.cfg file

$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ reboot

Verify the usable memory

$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-5.7.12-1.el7.elrepo.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8 mem=128G

$ cat /proc/meminfo | grep MemTotal
MemTotal:       129486812 kB

Reference

Intro to go-ycsb

go-ycsb is a Go port of YCSB. It fully supports all YCSB generators and the Core workload so we can do the basic CRUD benchmarks with Go.

Install golang package

$ wget https://dl.google.com/go/go1.19.2.linux-amd64.tar.gz
$ tar -C /usr/local -xvzf go1.19.2.linux-amd64.tar.gz
$ cat /usr/local/go/VERSION
go1.19.2

$ vim /root/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/go/bin
export PATH

$ source /root/.bash_profile
$ go version
go version go1.19.2 linux/amd64

Install go-ycsb

$ git clone https://github.com/pingcap/go-ycsb.git
$ cd go-ycsb

$ make
go build -tags " libsqlite3" -o bin/go-ycsb cmd/go-ycsb/*
# github.com/mattn/go-sqlite3
/root/go/pkg/mod/github.com/mattn/go-sqlite3@v2.0.1+incompatible/backup.go:12:21: fatal error: sqlite3.h: No such file or directory
 #include <sqlite3.h>
                     ^
compilation terminated.
make: *** [build] Error 2

$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

$ yum install sqlite-devel.x86_64
$ rpm -qa | grep sqlite
sqlite-3.7.17-8.el7_7.1.x86_64
sqlite-devel-3.7.17-8.el7_7.1.x86_64

$ make
go build -tags " libsqlite3" -o bin/go-ycsb cmd/go-ycsb/*

$ ./bin/go-ycsb --help
Go YCSB

Usage:
  go-ycsb [command]

Available Commands:
  help        Help about any command
  load        YCSB load benchmark
  run         YCSB run benchmark
  shell       YCSB Command Line Client

Flags:
  -h, --help   help for go-ycsb

Use "go-ycsb [command] --help" for more information about a command.

YCSB workloads

YCSB includes a set of core workloads that define a basic benchmark for cloud systems. Of course, you can define your own workloads, as described in Implementing New Workloads. However, the core workloads are a useful first step, and obtaining these benchmark numbers for a variety of different systems would allow you to understand the performance tradeoffs of different systems.

The core workloads consist of six different workloads:

[root@cockroach-db-host go-ycsb]# ls db
aerospike  basic   cassandra      etcd          minio    mysql    pg     rocksdb  sqlite
badger     boltdb  elasticsearch  foundationdb  mongodb  pegasus  redis  spanner  tikv

[root@cockroach-db-host go-ycsb]# ls workloads/
minio  workloada  workloadb  workloadc  workloadd  workloadd.orig  workloade  workloadf  workload_template

Workload A: Update heavy workload

$ cat go-ycsb/workloads/workloada
# Workload A: Update heavy workload
#   Application example: Session store recording recent actions
#
#   Read/update ratio: 50/50
#   Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
#   Request distribution: zipfian

recordcount=1000
operationcount=1000
workload=core

readallfields=true

readproportion=0.5
updateproportion=0.5
scanproportion=0
insertproportion=0

requestdistribution=uniform

Workload B: Read mostly workload

$ cat go-ycsb/workloads/workloadb
# Yahoo! Cloud System Benchmark
# Workload B: Read mostly workload
#   Application example: photo tagging; add a tag is an update, but most operations are to read tags
#
#   Read/update ratio: 95/5
#   Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
#   Request distribution: zipfian

recordcount=1000
operationcount=1000
workload=core

readallfields=true

readproportion=0.95
updateproportion=0.05
scanproportion=0
insertproportion=0

requestdistribution=uniform

Workload C: Read only

$ cat go-ycsb/workloads/workloadc
# Yahoo! Cloud System Benchmark
# Workload C: Read only
#   Application example: user profile cache, where profiles are constructed elsewhere (e.g., Hadoop)
#
#   Read/update ratio: 100/0
#   Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
#   Request distribution: zipfian

recordcount=1000
operationcount=1000
workload=core

readallfields=true

readproportion=1
updateproportion=0
scanproportion=0
insertproportion=0

requestdistribution=uniform

Workload D: Read latest workload

$ cat go-ycsb/workloads/workloadd
# Yahoo! Cloud System Benchmark
# Workload D: Read latest workload
#   Application example: user status updates; people want to read the latest
#
#   Read/update/insert ratio: 95/0/5
#   Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
#   Request distribution: latest

# The insert order for this is hashed, not ordered. The "latest" items may be
# scattered around the keyspace if they are keyed by userid.timestamp. A workload
# which orders items purely by time, and demands the latest, is very different than
# workload here (which we believe is more typical of how people build systems.)

recordcount=1000
operationcount=1000
workload=core

readallfields=true

readproportion=0.95
updateproportion=0
scanproportion=0
insertproportion=0.05

requestdistribution=latest

Workload E: Short ranges

$ cat go-ycsb/workloads/workloade
# Yahoo! Cloud System Benchmark
# Workload E: Short ranges
#   Application example: threaded conversations, where each scan is for the posts in a given thread (assumed to be clustered by thread id)
#
#   Scan/insert ratio: 95/5
#   Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
#   Request distribution: zipfian

# The insert order is hashed, not ordered. Although the scans are ordered, it does not necessarily
# follow that the data is inserted in order. For example, posts for thread 342 may not be inserted contiguously, but
# instead interspersed with posts from lots of other threads. The way the YCSB client works is that it will pick a start
# key, and then request a number of records; this works fine even for hashed insertion.

recordcount=1000
operationcount=1000
workload=core

readallfields=true

readproportion=0
updateproportion=0
scanproportion=0.95
insertproportion=0.05

requestdistribution=uniform

maxscanlength=1

scanlengthdistribution=uniform

Workload F: Read-modify-write

$ cat go-ycsb/workloads/workloadf
# Yahoo! Cloud System Benchmark
# Workload F: Read-modify-write workload
#   Application example: user database, where user records are read and modified by the user or to record user activity.
#
#   Read/read-modify-write ratio: 50/50
#   Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
#   Request distribution: zipfian

recordcount=1000
operationcount=1000
workload=core

readallfields=true

readproportion=0.5
updateproportion=0
scanproportion=0
insertproportion=0
readmodifywriteproportion=0.5

requestdistribution=uniform

Load the data to database

The database needs to be created before data load.

root@cockroach-db-host-ip:26257/defaultdb> create database test;
CREATE DATABASE

Time: 16ms total (execution 16ms / network 0ms)

root@cockroach-db-host-ip:26257/defaultdb> show databases;
  database_name | owner | primary_region | regions | survival_goal
----------------+-------+----------------+---------+----------------
  defaultdb     | root  | NULL           | {}      | NULL
  postgres      | root  | NULL           | {}      | NULL
  system        | node  | NULL           | {}      | NULL
  test          | root  | NULL           | {}      | NULL
(4 rows)

Time: 6ms total (execution 5ms / network 1ms)

Load the database as below:

[root@cockroach-db-host go-ycsb]# ./bin/go-ycsb load --help
YCSB load benchmark

Usage:
  go-ycsb load db [flags]

Flags:
  -h, --help                    help for load
      --interval int            Interval of outputting measurements in seconds (default 10)
  -p, --prop stringArray        Specify a property value with name=value
  -P, --property_file strings   Spefify a property file
      --table string            Use the table name instead of the default "usertable"
      --target int              Attempt to do n operations per second (default: unlimited) - can also be specified as the "target" property
      --threads int             Execute using n threads - can also be specified as the "threadcount" property (default 1)

$ ./bin/go-ycsb load cockroach -P workloads/workloadd -p pg.host=cockroach-db-host-ip -p pg.port=26257 -p pg.user=root -p pg.db=test -p pg.sslmode=disable -p dropdata=true
***************** properties *****************
"insertproportion"="0.05"
"dropdata"="true"
"scanproportion"="0"
"workload"="core"
"recordcount"="1000"
"pg.port"="26257"
"dotransactions"="false"
"updateproportion"="0"
"pg.user"="root"
"requestdistribution"="latest"
"readallfields"="true"
"pg.sslmode"="disable"
"command"="load"
"pg.host"="cockroach-db-host-ip"
"operationcount"="1000"
"pg.db"="test"
"readproportion"="0.95"
**********************************************
Run finished, takes 2.794042708s
INSERT - Takes(s): 2.8, Count: 1000, OPS: 361.7, Avg(us): 2734, Min(us): 1794, Max(us): 29903, 99th(us): 3557, 99.9th(us): 10999, 99.99th(us): 29903

The “–threads” option can be specified to increase the number of threads for data load.

$ ./bin/go-ycsb load cockroach -P workloads/workloadd --threads 96 -p pg.host=cockroach-db-host-ip -p pg.port=26257 -p pg.user=root -p pg.db=test -p pg.sslmode=disable -p dropdata=true

Verify the loaded data

root@cockroach-db-host-ip:26257/defaultdb> use test;
SET

Time: 1ms total (execution 1ms / network 0ms)

root@cockroach-db-host-ip:26257/test> show tables;
  schema_name | table_name | type  | owner | estimated_row_count | locality
--------------+------------+-------+-------+---------------------+-----------
  public      | usertable  | table | root  |                1000 | NULL
(1 row)

Time: 39ms total (execution 38ms / network 0ms)

root@cockroach-db-host-ip:26257/test> show columns from usertable;
  column_name |  data_type   | is_nullable | column_default | generation_expression |     indices      | is_hidden
--------------+--------------+-------------+----------------+-----------------------+------------------+------------
  ycsb_key    | VARCHAR(64)  |    false    | NULL           |                       | {usertable_pkey} |   false
  field0      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field1      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field2      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field3      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field4      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field5      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field6      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field7      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field8      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
  field9      | VARCHAR(100) |    true     | NULL           |                       | {usertable_pkey} |   false
(11 rows)

Time: 56ms total (execution 55ms / network 1ms)

root@cockroach-db-host-ip:26257/test> show ranges from table usertable;
  start_key | end_key | range_id |     range_size_mb     | lease_holder | lease_holder_locality | replicas | replica_localities
------------+---------+----------+-----------------------+--------------+-----------------------+----------+---------------------
  NULL      | NULL    |       45 | 1.0670000000000000000 |            1 |                       | {1,2,3}  | {,,}
(1 row)

Time: 26ms total (execution 25ms / network 1ms)

root@cockroach-db-host-ip:26257/test> select count(*) from usertable;
  count
---------
   1000
(1 row)

Time: 3ms total (execution 2ms / network 0ms)

root@cockroach-db-host-ip:26257/test> select * from usertable limit 2;
         ycsb_key         |                                                field0                                                |                                                field1                                                |                                                field2                                                |                                                field3                                                |                                                field4                                                |                                                field5                                                |                                                field6                                                |                                                field7                                                |                                                field8                                                |                                                
         field9

  user6282602628620641459 | CRvLzkeCGxHtROFZjmDBFtRGwQigtZAPNCOSMdNXgDNsmpONJsVKRyJpleAmmigBbLoCUvtqDwPNYNoipLCXFqrEvBLnIoDrHSVq | dmhlgvUykChQAJzTfgSwBwEuWwBhLgcYUkBFAObtredxAUHWkCVaWfgMQCKIYUUrnHbguWZGrZXmYVRKAoZHVOnKdBsMYYaUqCWC | UtVaaGeRrAoupCumOJNesfunCVXnJhFoWBlKqebBYFZyooDIaYHPeQVgvCqEfCdmGpVtcLZJYhjvMSyFBZixzyMiykEoTZXMbFic | VmmyYkAgPawZuSqZmSiIEoEnssZHuLfbBhcpFixthpYsZUHgbxfpiffrgOFSlIYgejLLQuXMaGDxBbKHegWaHXpDBdxUUHZgJSLx | cCRKTqdUukzOdPwxqTBKyBEQPkIyIgAkxdaqXAiYbNwhuJVCoEqpBPSUApjLyvSXdyAqovEwSnsiIVvuviUCTiqcelbJuwvnCGyx | JuggBRLaLLqWhcCNoxEpbJZsXhcxSGyaPNRUrLoqrnKvpJfLvABueeZQOsmCERRMXasJIIJazBQoqLKVHfELiOwzolwgcXfOtLco | DJrJlWIgICwWgOuEQjnzUiZoCnGnKYXcJtrrgEYznFnKsOEmapuWzuwFVekgElVlYuwOoruMKqHoIOjHqLYZCUzoiSsIbPHZscaq | MOZiEsuFeHnouWlGmBcvNNZvXuOWqHlHKBDEFfYXcsaHNUGJPLUWpEGeHOKOilztleethxYoHLdAFBZdClYRRApEDoezGpuEvpwa | YvdqeMSnQPLoXYfExfduQrNSFRiTVKFPZdGATDpQMvtCHAdqTqMYjMpElQgcRjUuJUBMqwXJDzcVWlGiQSAirgVVDBGoAHqyzgdA | mkKBHtYOEsdXlpndKPOYHTQiqkFbTAsDbESpWeYXVSiBximrDHhjBARBZHkjWQjzZGITkqjecazQeCHvmkePqefSNieJtFTdbvRI

  user6282603728132269670 | DSNUAvAFJxstogmWRPJmbNikPspeilFAZQJKzLRdxJpyOQJeQbltpxqnYJQtWwihrPbvZoOzbaMrMlLKBiAWjttcMskyfguSFidf | pSYiwZdqValtHyYGoYwkVYGawNErokKdMTiNCJUrcKTQWSQWKGixRVDxJTcaCfUXHMLxSSvDdFTVjTuxqWGWkWlxKocypFUGupqH | YBoLQdTXAQpjUgZReUGUfAOzsrBMKZyoZCdwxWJrOBkRlbbpXUmZLQxHHnDgnLNCNEnxozGPFCGEOVilyqLCixqDIsPNhccTdhbq | UQNzeZJXzbvwwupufEHeacjxxrTGCYfppLsbOCxLyfvuhZYPmoSyhKupkGRkHsYSnQVCFHCokWmHFWnLbYctVGdAunsPnkDjQAPk | HkqgViwhjGaBGUXJikhpwPMFCxqtOxoIunZQjmeKcytoItvGrfvcztncPzUukauoovIoQRmBCcQhJpoZxDLmXcpQJgFAbDYsbBGc | VDazXEFSiKZSKoSPMpAnFNAzqbrGcZwwrSMjFIJoEJPfvDzdwWwiVmHRkRGuFzwrXTOAKOiazelzsQFMAARAZdreFMWzKIwXieCP | lwbhKgtyTCZYJZmeRbVmWzkmPsWvdURifyZgGuSwVRrcCDCmrwvEdnFTWgCsYmcqzFgziAjgakhSuJjyixzoNThbtIgTkPuzAMVX | cKRURxsRlJvcKgrRQwMFeRLKCWfiavzTKqTJbYbWKZgOkZuutCIltPbwufcIMPDRWdgAZVaPqGCussiIxcFjMHMioVNLLQklptbG | OzGsnjbnnUtzsxjSVLpukwOcdegoTYrBLhOISwiNdNMGzKXBbDIRpBQqvNFEUEVfMPPJIWGSVzvSGTyAazIOvSMnWeEdKnEuggge | aHOwSIrvztvWYhrsdYaYGjtdjLTiVgfZluTgohVwNABYlZyiYPdrZgmMCFTQLOXqcbBbtahLNzPxdtoeqxrCBAussTPjmJrIzxns
(2 rows)

Time: 2ms total (execution 1ms / network 1ms)

Run the YCSB benchmark

[root@cockroach-db-host go-ycsb]# ./bin/go-ycsb run --help
YCSB run benchmark

Usage:
  go-ycsb run db [flags]

Flags:
  -h, --help                    help for run
      --interval int            Interval of outputting measurements in seconds (default 10)
  -p, --prop stringArray        Specify a property value with name=value
  -P, --property_file strings   Spefify a property file
      --table string            Use the table name instead of the default "usertable"
      --target int              Attempt to do n operations per second (default: unlimited) - can also be specified as the "target" property
      --threads int             Execute using n threads - can also be specified as the "threadcount" property (default 1)

[root@cockroach-db-host go-ycsb]# ./bin/go-ycsb run cockroach -P workloads/workloadd --threads 96 -p pg.host=cockroach-db-host-ip -p pg.port=26257 -p pg.user=root -p pg.db=test -p pg.sslmode=disable
Run finished, takes 41m57.357806424s
INSERT - Takes(s): 2517.3, Count: 4992285, OPS: 1983.2, Avg(us): 5053, Min(us): 1214, Max(us): 32863, 99th(us): 26719, 99.9th(us): 31471, 99.99th(us): 32671
READ   - Takes(s): 2517.3, Count: 94554325, OPS: 37561.2, Avg(us): 2131, Min(us): 389, Max(us): 20687, 99th(us): 11543, 99.9th(us): 19695, 99.99th(us): 20591

Reference

It was ten o’clock at night when James heard a violent knock on his glass door. He was currently resting on his couch watching my TV when this happened. His first thought was that it was the mailman. But then, the mailman only came in the morning and had already delivered mail that very same day. James looked through his window and saw a man wearing a black hoodie. He hesitated and then opened the door. At first, the man did not say anything. He just stared at him. He creeped James out without even talking. Then, he held up a red envelope.

Read more »

Currently, there are two managed disk types that can burst, premium SSDs, and standard SSDs. Other disk types cannot currently burst. There are two models of bursting for disks:

An on-demand bursting model, where the disk bursts whenever its needs exceed its current capacity. This model incurs additional charges anytime the disk bursts. On-demand bursting is only available for premium SSDs larger than 512 GiB.

A credit-based model, where the disk will burst only if it has burst credits accumulated in its credit bucket. This model does not incur additional charges when the disk bursts. Credit-based bursting is only available for premium SSDs 512 GiB and smaller, and standard SSDs 1024 GiB and smaller.

Azure premium SSDs can use either bursting model, but standard SSDs currently only offer credit-based bursting.

On-demand bursting

Premium SSDs using the on-demand bursting model of disk bursting can burst beyond original provisioned targets, as often as needed by their workload, up to the max burst target. For example, on a 1-TiB P30 disk, the provisioned IOPS is 5000 IOPS. When disk bursting is enabled on this disk, your workloads can issue IOs to this disk up to the max burst performance of 30,000 IOPS and 1,000 MBps. For the max burst targets on each supported disk, see Scalability and performance targets for VM disks.

If you expect your workloads to frequently run beyond the provisioned perf target, disk bursting won’t be cost-effective. In this case, we recommend that you change your disk’s performance tier to a higher tier instead, for better baseline performance. Review your billing details and assess that against the traffic pattern of your workloads.

Before you enable on-demand bursting, understand the following:

  • On-demand bursting cannot be enabled on a premium SSD that has less than or equal to 512 GiB. Premium SSDs less than or equal to 512 GiB will always use credit-based bursting.
  • On-demand bursting is only supported on premium SSDs. If a premium SSD with on-demand bursting enabled is switched to another disk type, then disk bursting is disabled.
  • On-demand bursting doesn’t automatically disable itself when the performance tier is changed. If you want to change your performance tier but do not want to keep disk bursting, you must disable it.
  • On-demand bursting can only be enabled when the disk is detached from a VM or when the VM is stopped. On-demand bursting can be disabled 12 hours after it has been enabled.

Reference

1
2
3
4
5
6
7
$ while [ 1 ]; do netstat -s | grep 'segments retransmited' ; sleep 1; done
2500906 segments retransmited
2500912 segments retransmited
2501072 segments retransmited
2501102 segments retransmited
2501191 segments retransmited

Mid-Autumn Festival is a traditional festival in Chinese culture, having its history dating to 3000 years ago. The festival is held on the 15th day of the 8th month of the lunisolar calendar. The Chinese believe that the moon is at its brightest and largest size that night.

There are multiple legends of the Mid-Autumn Festival, the most popular of them being the story of Hou Yi and Chang’e. The legend says that there once were 10 fiery suns raging in the sky, burning down all the plants and humans. Seeing his people suffering, Hou Yi used his bow to kill 9 of the suns. As a reward, he was given the elixir of immortality, which granted him the ability to live forever. Since he wanted to spend more time with his wife Chang’e, Hou Yi asked her to keep it safe for him. The people asked him to be their master, and he agreed to teach most of them. But one particular greedy disciple Pang Meng wanted the elixir for himself, so one day he pretended to be ill. After Hou Yi left to hunt, Pang Meng went to his house and forced Chang’e to give him the elixir. Since she couldn’t defeat him, Chang’e drank the elixir and was lifted up into the heavens, becoming the moon goddess. After returning, Hou Yi was heartbroken and offered Chang’e some fruit and cakes that she loved to eat. Since then, people have always offered the Moon Goddess fruits and moon cakes to worship the moon.

There are multiple ways to celebrate the Mid-Autumn Festival. The most representative way is to eat moon cakes, which often have red bean, egg yolk, five kernel, or lotus seed. Other ways include making colorful lanterns,  enjoying fire dragon dances, and worshiping the moon. These ways of celebration are believed to bring good luck.

In conclusion, the Mid-Autumn festival is a very important and popular festival that you don’t want to miss. It is a time for family reunion and giving gifts that both children and adults enjoy.

Build preparations

To perform a successful kernel build, the following packages need to be installed:

  • yum groupinstall “Development Tools”
  • yum install ncurses-devel
  • yum install qt3-devel (This is only necessary if you wish to use “make xconfig” instead of “make gconfig” or “make menuconfig”.) In the following example, we use “make menuconfig”.
  • yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel

Download kernel source

Download kernel source from The Linux kernel archives.

[root@host1 ~]# mkdir ~/rpmbuild/
[root@host1 ~]# cd ~/rpmbuild/
[root@host1 rpmbuild]# pwd
/root/rpmbuild

[root@host1 rpmbuild]# wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.18.12.tar.xz
[root@host1 rpmbuild]# tar xvf linux-5.18.12.tar.xz
[root@host1 rpmbuild]# cd linux-5.18.12

Configure the new kernel

Note: If you do not intend to modify the distributed kernel configuration file, you may omit this section.

Copy the config file from the current running kernel to the new kernel source directory:

[root@host1 linux-5.18.12]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

[root@host1 linux-5.18.12]# uname -r
5.18.10-1.el7.elrepo.x86_64

[root@host1 linux-5.18.12]# cp /boot/config-5.18.10-1.el7.elrepo.x86_64 .config

Modify the kernel config with the “make menuconfig” command:

[root@host1 linux-5.18.12]# make menuconfig
  HOSTCC  scripts/basic/fixdep
  UPD     scripts/kconfig/mconf-cfg
  HOSTCC  scripts/kconfig/mconf.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/menu.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/mconf


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

The following window should be seen. You can enable or disable certain kernel features as needed. Here we just leave everything the defaults.

Image

Once it’s configured, go to “< Save >” and press “< Ok >” to save it.

Image

Now we can open the file “.config” to verify the content based on the previous modification.

[root@host1 linux-5.18.12]# head .config
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.18.12 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=70301
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=22800

Install multiple gcc versions

Depending on the gcc version included in the system, you may encounter errors when to run “make menuconfig” which requires a higher version of gcc.

[root@host1 linux-5.18.12]# make menuconfig
<...>
***
*** Compiler is too old.
***   Your GCC version:    4.8.5
***   Minimum GCC version: 5.1.0
***
scripts/Kconfig.include:44: Sorry, this compiler is not supported.

Software Collections, also known as SCL is a community project that allows you to build, install, and use multiple versions of software on the same system, without affecting system default packages. By enabling Software Collections, you gain access to the newer versions of programming languages and services which are not available in the core repositories. The SCL repositories provide a package named Developer Toolset, which includes newer versions of the GNU Compiler Collection, and other development and debugging tools.

To check the already installed gcc version:

[root@host1 linux-5.18.12]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

To install the newer version of gcc:

[root@host1 linux-5.18.12]# sudo yum install centos-release-scl
[root@host1 linux-5.18.12]# sudo yum install devtoolset-7

To access gcc version 7, a new shell instance using the Software Collection scl tool needs to be launched.

[root@host1 linux-5.18.12]# scl enable devtoolset-7 bash
149 packages can be updated.
0 updates are security updates.

[root@host1 linux-5.18.12]# gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@host1 linux-5.18.12]# make menuconfig

For more detail, please refer to Developer Toolset 7 or a different version.

Compile the kernel

Before start compiling the new kernel, make sure more than 20GB of free space on the filesystem is available.

[root@host1 linux-5.18.12]# df -h | egrep "Filesystem|root"
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/vgroot-lvroot  1.5T   21G  1.4T   2% /

Now, we can compile the kernel. We run the compilation process in the background since it takes long time.

[root@host1 linux-5.18.12]# nohup make rpm-pkg &
[root@host1 linux-5.18.12]# tail -f nohup.out
[root@host1 linux-5.18.12]# more nohup.out
  SYNC    include/config/auto.conf.cmd
  HOSTCC  scripts/kconfig/conf.o
  HOSTLD  scripts/kconfig/conf
  UPD     include/config/kernel.release
make clean
sh ./scripts/package/mkspec >./kernel.spec
  TAR     kernel-5.18.12.tar.gz
rpmbuild  --target x86_64 -ta kernel-5.18.12.tar.gz \
--define='_smp_mflags %{nil}'
Building target platforms: x86_64
Building for target x86_64
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.nOAadM

Note that the kernel.spec file is created automatically by “sh ./scripts/package/mkspec >./kernel.spec”.

Upon completion, the following output shows the location of the generated rpms.

[root@host1 linux-5.18.12]# tail -15 nohup.out
Obsoletes: kernel-headers
Processing files: kernel-devel-5.18.12-1.x86_64
Provides: kernel-devel = 5.18.12-1 kernel-devel(x86-64) = 5.18.12-1
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/kernel-5.18.12-1.x86_64
Wrote: /root/rpmbuild/SRPMS/kernel-5.18.12-1.src.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/kernel-5.18.12-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/kernel-headers-5.18.12-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/kernel-devel-5.18.12-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.DiAd0f
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd kernel-5.18.12
+ rm -rf /root/rpmbuild/BUILDROOT/kernel-5.18.12-1.x86_64
+ exit 0

To check the generated kernel rpms:

[root@host1 rpmbuild]# pwd
/root/rpmbuild

[root@host1 rpmbuild]# ls RPMS/x86_64/
kernel-5.18.12-1.x86_64.rpm  kernel-devel-5.18.12-1.x86_64.rpm  kernel-headers-5.18.12-1.x86_64.rpm
[root@host1 rpmbuild]# ls SRPMS/
kernel-5.18.12-1.src.rpm

Install the new kernel

Now you can run the following command to install the rpm packages:

[root@host1 rpmbuild]# rpm -iUv ~/rpmbuild/RPMS/x86_64/*.rpm

Once the installation is complete, run the following command to reboot the system:

[root@host1 rpmbuild]# reboot

Once the system starts, run the following command to check the kernel version:

[root@host1 ~]# uname -r

Reference

0%