Understanding the CAP Theorem

Background The CAP theorem has become one of the hottest theorems in recent years; when discussing distributed systems, CAP is inevitably mentioned. However, I feel that I haven’t thoroughly understood it, so I wanted to write a blog post to record my understanding. I will update the content as I gain new insights. Understanding I read the first part of this paper. The CAP theorem [Bre12] says that you can only have two of the three desirable properties of: ...

December 20, 2017 · 3 min · 511 words · Jack Yu

How to Execute Git Push in Travis CI

Background Travis CI is generally used for automating tests without needing to update the repository with the test outputs. This article explains how to automatically commit the results from Travis CI. Process The basic process references this gist. Below is the .travis.yml from the gist. language: ruby rvm: - 2.0.0 env: global: - USER="username" - EMAIL="[email protected]" - REPO="name of target repo" - FILES="README.md foo.txt bar.txt" - GH_REPO="github.com/${USER}/${REPO}.git" - secure: "put travis gem output here => http://docs.travis-ci.com/user/encryption-keys/" script: - ruby test.rb after_success: - MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT) - git clone git://${GH_REPO} - mv -f ${FILES} ${REPO} - cd ${REPO} - git remote - git config user.email ${EMAIL} - git config user.name ${USER} - git add ${FILES} - git commit -m "${MESSAGE}" - git push "https://${GH_TOKEN}@${GH_REPO}" master > /dev/null 2>&1 Note here that MESSAGE should be quoted when committing, which the original gist did not include. ...

October 16, 2017 · 4 min · 659 words · Jack Yu

How to Implement MySQL X Protocol on TiDB

Some Documents on MySQL Client Usage Guide MySQL Shell User Guide Server Configuration Guide Using MySQL as a Document Store Application Development API Guide X DevAPI User Guide Introduction to Server Internal Implementation X Protocol. Implementation Principle Communication between client and server is over TCP and the protocol uses protobuf. After the server receives a message, it decodes and analyzes it. The protocol includes a concept called namespace, which specifically refers to whether the namespace is empty or “sql”, in which case the message content is executed as a SQL statement; if it is “xplugin” or “mysqlx,” the message is handled in another way. The other ways can be divided into: Administrative commands CRUD operations “xplugin” and “mysqlx” have the same function, with the latter being the new name for the former, retained temporarily for compatibility. The content of “mysqlx” messages, apart from explicit command content like kill_client, are mostly transformed into SQL statements which the server processes, essentially turning most into a form where the namespace is “sql”. Implementation Steps Start a new server for TiDB. The relevant configuration parameters such as IP, port, and socket need to be set. Implement the reading and writing functionality for message communication. Write a process for this new server to establish connections, including authentication, that follows the protocol. Use tcpdump to capture messages between MySQL and the client to derive protocol content, implementing the process by understanding MySQL source code. The server should include contents like the Query Context from the original TiDB server, as it primarily translates into SQL for execution. Implement the decoding and handling of messages. Although only a sentence, the workload included is substantial. In mysqlx_all_msgs.h, all messages are initialized ...

August 16, 2017 · 4 min · 798 words · Jack Yu

How to Configure CentOS 6 NFS Service

Server Side Disable SeLinux Edit the configuration file: vi /etc/selinux/config Modify as follows: #SELINUX=enforcing # Comment out #SELINUXTYPE=targeted # Comment out SELINUX=disabled # Add this line Then reboot the system: reboot # Restart the system Create a Directory Using the root user, create a directory named /nfs. Note: It’s best to check which partition has the most space by running df, as the root (/) partition may not have the most space. In some automatic partitioning setups, the /home partition may have the most space. ...

June 5, 2014 · 2 min · 297 words · Jack Yu

How to Configure CentOS KVM Network Bridging Mode

What Is Bridging Bridging highly simulates a network card, making the router believe that the virtual machine’s network card truly exists. Personally, I feel it’s similar to resistors connected in parallel, whereas NAT (another common virtual machine network connection method) is more like parasitizing on the host’s network card. Why Use Bridging It allows you to treat the virtual machine as a completely independent machine, enabling mutual access with the external network (which is not possible with NAT). ...

June 5, 2014 · 3 min · 575 words · Jack Yu

How to Install CentOS as a Virtualization Host

Installation Process Installed Version: CentOS 6.3 Using Win32DiskImager to create a USB flash drive image was unsuccessful; installing from an external USB optical drive was successful. During the installation process, make sure to select the “Virtual Host” installation mode. The rest can be set to default or slightly modified, such as choosing the time zone. After installation, it will include the KVM suite and SSH. Installation Notes No internet connection is needed throughout the process, which is much better than Debian and Ubuntu. You’re not forced to set up a non-root user. Before installation, be sure to check whether your CPU supports virtualization and enable the motherboard’s virtualization setting. If the motherboard supports virtualization but doesn’t have a virtualization option, you can still use virtualization as it’s definitely enabled by default. There’s a saying that Intel CPUs with a ‘K’ cannot perform virtualization. ‘K’ means Intel CPUs that can be overclocked. It seems that faster and newer CPUs are not necessarily better.

June 5, 2014 · 1 min · 162 words · Jack Yu

How to Practice Using SQL

The text provided is a detailed set of instructions and queries for practicing SQL using PostgreSQL 9.4 BETA 2, focusing on creating and querying tables related to students, courses, scores, and teachers. Here’s a summary: Database Structure The database consists of four tables: STUDENT: Contains student number (SNO), name (SNAME), gender (SSEX), birthday (SBIRTHDAY), and class (CLASS). COURSE: Includes course number (CNO), name (CNAME), and teacher number (TNO). SCORE: Records student number (SNO), course number (CNO), and degree (DEGREE). TEACHER: Holds teacher number (TNO), name (TNAME), gender (TSEX), birthday (TBIRTHDAY), professional title (PROF), and department (DEPART). Sample Data Students such as Zeng Hua, Kang Ming, and Wang Fang are stored with specific details, including their class and gender. Courses like “Introduction to Computers” and “Operating Systems” are associated with teacher numbers. Scores are recorded for students across various courses. Teachers are described with their professional roles and departments. Query Problems Several SQL queries are suggested for practice, such as: ...

June 5, 2014 · 3 min · 472 words · Jack Yu