inotify

Real-time Data Synchronization

In production, there is a need to back up data to a backup server when the file data in the directory changes. The realization of such requirements requires the following two points:

  • Use the monitoring service (inotify) to monitor changes to the directory files of the server to be synchronized
    When the directory data is changed.
  • Use the rsync service to send the data to the backup server. Therefore, real-time data synchronization can be achieved by using rsync + inotify.

rsync and xinetd

default
For rsync daemon, with the first glance of the above picture we would think there is no rsync server running. But the fact is not that simple, it could be managed by xinetd.

A xinetd, the eXtended InterNET Daemon, manages Internet-based connectivity. It offers a more secure extension to or version of inetd, the Internet daemon.

xinetd starts programs that provide Internet services. Instead of having such servers started at system initialization time, and be dormant until a connection request arrives, xinetd is the only daemon process started and it listens on all service ports for the services listed in its configuration file. When a request comes in, xinetd starts the appropriate server. Because of the way it operates, xinetd (as well as inetd) is also referred to as a super-server.

Nginx Tuning

Check System Resources

By tuning a software, the first thing is to figure out how many resources are there available and then check if system have limitation to restrict you from using them.

CPUs provides main resources for how many processes can be running simultaneously, it means a lot for web server as http connections really depend on it.

CPUs = Threads per core * cores per socket * sockets

Two commands to check:

  • nproc - print the number of processing units available
  • lscpu - display information about the CPU architecture
  • ulimit - get and set user limits

Apache enable mpm-event and PHP Config

CentOS

First of all, it’s better to check the required packages are available in the system by using following commands:

1
2
3
rpm -qa | grep {package-name}
# On a CentOS/RHEL version 6.x/7.x and above
yum list installed {PACKAGE_NAME_HERE}

And then install dependencies.

1
yum install httpd httpd-tools mod_ssl php-fpm

WiFi Cracker in Mac OS X

Mac OS X comes with a suite of wireless diagnostic tools. To open them, hold down the option key on your keyboard and click on the Wi-Fi icon in the menu bar. Then click “Open Wireless Diagnostics…” and then click on Window > Scan. Find the target network, note its channel and width.

Nginx

Config Nginx as Load Balancer

The entrance url is http://192.168.1.108:8080/moodle, with two servers behind, both open port 80 to accept incoming requests. This is an test environment, do not worry about the path behind the IP and port, because in production environment, DNS and server_name will solve the domain name and path.

Nginx config script lists below:

NFS

Network File System (NFS) is a popular distributed filesystem protocol that enables users to mount remote directories on their server. It does not require client to have big disk space to store all files. NFS lets you leverage storage space in a different location and allows you to write onto the same space from multiple servers or clients in an effortless manner. Following commands are used to config CentOS 7.6 server.