### Install and Manage Privoxy Service Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Fedora-Shadowsocks客户端的配置.md Commands to install Privoxy, enable it for auto-start on boot, immediately start the service, and check its current running status. ```bash yum -y install privoxy systemctl enable privoxy systemctl start privoxy systemctl status privoxy ``` -------------------------------- ### Install System Dependencies using Yum Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/vim中文乱码.md This command installs essential system libraries such as cjkun and wqy using the yum package manager. The -y flag automatically confirms all prompts. ```Shell yum install cjkun* wqy* -y ``` -------------------------------- ### Start Elasticsearch Server Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS7-ElasticSearch安装.md This snippet navigates into the Elasticsearch binary directory and executes the main Elasticsearch script to start the server instance. This command initiates the Elasticsearch service, making it ready to accept requests. ```shell cd elasticsearch-6.2.4/bin ./elasticsearch ``` -------------------------------- ### Verify Flume Installation and Version Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md This snippet shows how to verify the Flume installation by running the `flume-ng version` command. A successful output will display the Flume version and build details, for example: Flume 1.6.0 Source code repository: https://git-wip-us.apache.org/repos/asf/flume.git Revision: 2561a23240a71ba20bf288c7c2cda88f443c2080 Compiled by hshreedharan on Mon May 11 11:15:44 PDT 2015 From source with checksum b29e416802ce9ece3269d34233baf43f ```shell flume-ng version ``` -------------------------------- ### Install Flume by Extracting Archive Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md This snippet shows how to extract the Flume binary archive using tar. ```shell tar -zxvf apache-flume-1.6.0-bin.tar.gz ``` -------------------------------- ### Start Spark Cluster Services using start-all.sh Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Spark/2. Spark-安装和集群搭建.md This snippet shows the command and its output for starting the Spark Master and Worker services across the configured nodes using `start-all.sh`. It demonstrates the successful initiation of Spark daemons on both master and slave machines. ```Shell [root@s166 spark]# ./sbin/start-all.sh starting org.apache.spark.deploy.master.Master, logging to /home/fantj/download/spark-1.5.1-bin-hadoop2.4/sbin/../logs/spark-root-org.apache.spark.deploy.master.Master-1-s166.out localhost: starting org.apache.spark.deploy.worker.Worker, logging to /home/fantj/download/spark-1.5.1-bin-hadoop2.4/sbin/../logs/spark-root-org.apache.spark.deploy.worker.Worker-1-s166.out localhost: starting org.apache.spark.deploy.worker.Worker, logging to /home/fantj/download/spark-1.5.1-bin-hadoop2.4/sbin/../logs/spark-root-org.apache.spark.deploy.worker.Worker-1-s167.out localhost: starting org.apache.spark.deploy.worker.Worker, logging to /home/fantj/download/spark-1.5.1-bin-hadoop2.4/sbin/../logs/spark-root-org.apache.spark.deploy.worker.Worker-1-s168.out localhost: starting org.apache.spark.deploy.worker.Worker, logging to /home/fantj/download/spark-1.5.1-bin-hadoop2.4/sbin/../logs/spark-root-org.apache.spark.deploy.worker.Worker-1-s169.out ``` -------------------------------- ### Verify Hadoop Installation Version Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS7-Hadoop安装.md This command verifies the installed Hadoop version and provides details about its compilation. It confirms that Hadoop is correctly installed and accessible via the system PATH. ```shell [root@localhost ~]# hadoop version Hadoop 2.7.0 Subversion Unknown -r Unknown Compiled by root on 2015-05-21T03:49Z Compiled with protoc 2.5.0 From source with checksum a9e90912c37a35c3195d23951fd18f This command was run using /home/fantj/download/hadoop-2.7.0/share/hadoop/common/hadoop-common-2.7.0.jar ``` -------------------------------- ### Install vsftpd and Create FTP User Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS-FTP服务搭建.md Commands to install the vsftpd server package, create a dedicated system user ("ftpuser") with a specified home directory ("/ftpfile") and no login shell, set ownership for the home directory, and assign a password to the new user. These steps establish the foundational environment for the FTP service. ```Shell yum -y install vsftpd useradd ftpuser -d /ftpfile -s /sbin/nologin chown -R ftpuser.ftpuser /ftpfile passwd ftpuser ``` -------------------------------- ### Run Hadoop WordCount Example Job Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Hadoop/3. Hadoop-单词统计.md This snippet demonstrates how to execute the built-in Hadoop WordCount example job. It navigates to the Hadoop MapReduce examples directory and then runs the 'hadoop-mapreduce-examples-2.7.0.jar' with the 'wordcount' command, specifying '/wordcount' as the input directory and '/print' as the output directory. ```Shell [root@s166 fantj]# cd /home/fantj/hadoop/share/hadoop/ [root@s166 hadoop]# ls common hdfs httpfs kms mapreduce tools yarn [root@s166 hadoop]# cd mapreduce/ [root@s166 mapreduce]# ls hadoop-mapreduce-client-app-2.7.0.jar hadoop-mapreduce-client-hs-plugins-2.7.0.jar hadoop-mapreduce-examples-2.7.0.jar hadoop-mapreduce-client-common-2.7.0.jar hadoop-mapreduce-client-jobclient-2.7.0.jar lib hadoop-mapreduce-client-core-2.7.0.jar hadoop-mapreduce-client-jobclient-2.7.0-tests.jar lib-examples hadoop-mapreduce-client-hs-2.7.0.jar hadoop-mapreduce-client-shuffle-2.7.0.jar sources [root@s166 mapreduce]# hadoop jar hadoop-mapreduce-examples-2.7.0.jar wordcount /wordcount /print ``` -------------------------------- ### Verify Java Installation Version Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS7-Hadoop安装.md This command checks the installed Java Development Kit (JDK) version. It outputs the Java runtime environment and virtual machine build details, confirming a successful Java setup. ```shell [root@localhost ~]# java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode) ``` -------------------------------- ### Create Test File for Flume Spooling Directory Source Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Example content of a `test.txt` file to be placed in the monitored directory (`/home/fantj/log/`) to trigger Flume's spooling directory source. Once processed, Flume will append `.COMPLETED` to the filename. ```text test.txt this is a spoordir agent test ``` -------------------------------- ### Install Snap Application Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md This command installs a specified application from the Snap Store using superuser privileges. It downloads and sets up the application on the system. ```shell sudo snap install vlc ``` -------------------------------- ### Start Flume Agent with NetCat Logger Configuration Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Command to start the Flume agent using the `netcat-logger.conf` file. It specifies the configuration directory (`-c conf`), the configuration file (`-f conf/netcat-logger.conf`), the agent name (`-n a1`), and sets the root logger level to INFO for console output (`-Dflume.root.logger=INFO,console`). ```shell flume-ng agent -c conf -f conf/netcat-logger.conf -n a1 -Dflume.root.logger=INFO,console ``` -------------------------------- ### Manage Shadowsocks Service (Enable, Start, Status) Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Fedora-Shadowsocks客户端的配置.md Commands to enable Shadowsocks to start automatically on boot, immediately start the service, and check its current running status. ```bash systemctl enable shadowsocks.service systemctl start shadowsocks.service systemctl status shadowsocks.service ``` -------------------------------- ### Install Shadowsocks Client Dependencies and Package Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Fedora-Shadowsocks客户端的配置.md Commands to install the EPEL repository, Python pip, and then the Shadowsocks client using pip on a CentOS/RHEL-based system. ```bash yum -y install epel-release yum -y install python-pip pip install shadowsocks ``` -------------------------------- ### Flume NetCat Source Configuration Properties Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Documentation for configuring the NetCat Source in Flume, detailing properties like channels, type, bind, and port. ```APIDOC Property Name Default Description channels – type – The component type name, needs to be netcat bind – 日志需要发送到的主机名或者Ip地址,该主机运行着netcat类型的source在监听 port – 日志需要发送到的端口号,该端口号要有netcat类型的source在监听 ``` -------------------------------- ### Java WebSocket Server Main Class for Startup Source: https://github.com/fantj2016/java-reader/blob/master/3. 框架专题/3.1 实战篇/Netty/2. Netty聊天室的实战.md This Java code snippet demonstrates the main class responsible for starting the WebSocket server. It instantiates a `WebSocketServer` with a specified IP address and port, then calls its `start()` method to initiate the server and begin listening for connections. ```Java public class Main { public static void main(String[] args) { new WebSocketServer("192.168.1.33",9999).start(); } } ``` -------------------------------- ### Install NTFS-3G for NTFS File System Support Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/RedHat考级/文件系统管理:分区、挂载....md This section provides steps to install NTFS-3G, a third-party driver, to enable read and write support for NTFS file systems on Linux. It includes downloading, compiling, and installing the software, followed by an example of mounting an NTFS partition. ```bash wget https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz tar ntfs-3g_ntfsprogs-2017.3.23.tgz cd ntfs-3g_ntfsprogs-2017.3.23 ./configure make make install mount -t ntfs-3g 分区设备文件名 挂载点 eg:mount -t ntfs-3g /dev/sda1 /mnt/windows ``` -------------------------------- ### Java Main Class for WebSocket Server Startup Source: https://github.com/fantj2016/java-reader/blob/master/1. 算法基础/1.3 leetcode/Netty网络聊天(一) 聊天室的实战(最易懂).md This Java `Main` class serves as the application's entry point, demonstrating how to initialize and start the `WebSocketServer`. It creates a new `WebSocketServer` instance, specifying the server's IP address and port, and then invokes the `start()` method to begin listening for incoming WebSocket connections. ```Java public class Main { public static void main(String[] args) { new WebSocketServer("192.168.1.33",9999).start(); } } ``` -------------------------------- ### Test FTP Server Connection and Login Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS-FTP服务搭建.md A command-line session demonstrating how to connect to the vsftpd server using the "ftp" client, log in with the "ftpuser" credentials, list directories to verify access, and then exit the FTP session. This confirms the server's operational status and successful user authentication. ```Shell [root@FantJ vsftpd]# ftp 127.0.0.1 Connected to 127.0.0.1 (127.0.0.1). 220 Welcome to FTP Server Name (127.0.0.1:root): ftpuser 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (127,0,0,1,239,251). 150 Here comes the directory listing. drwxrwxrwx 2 1002 1002 4096 Apr 27 20:47 image 226 Directory send OK. ftp> exit 221 Goodbye. ``` -------------------------------- ### Verify Java Development Kit (JDK) Installation Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS7-ElasticSearch安装.md This snippet verifies the successful installation of the Java Development Kit (JDK) by checking its version and displaying the JAVA_HOME environment variable, which points to the JDK installation directory. ```shell java -version echo $JAVA_HOME ``` -------------------------------- ### Configure Flume Environment Variables Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md This snippet demonstrates how to set FLUME_HOME and add Flume's bin directory to the system PATH for easy command execution. Remember to also configure JAVA_HOME in flume-env.sh. ```shell export FLUME_HOME=/xxx/flume export PATH=$PATH:$FLUME_HOME/bin ``` -------------------------------- ### Install Alien from Source Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md This sequence of commands describes the typical steps to install the 'alien' package conversion tool from its source code, commonly used on CentOS. It involves extracting the archive, configuring with Perl, compiling, and installing. ```shell tar xxxx perl Makefile.PL make make install ``` -------------------------------- ### Java: Example Usage and Unit Tests for Custom Client Source: https://github.com/fantj2016/java-reader/blob/master/3. 框架专题/3.4 手写实现篇/手写一个Jedis以及JedisPool.md This `Main` class contains JUnit tests demonstrating the usage of the custom `Jedis` client. It showcases `set`, `get`, and `append` operations, including `set` with expiration and NX options, and verifies the client's functionality. ```java /** * 测试我们自己写的客户端 */ public class Main { private Jedis client = new Jedis("www.xxx.top",6380); @Test public void set(){ client.set("fantj","fantj"); String result = client.get("fantj"); System.out.println(result); } @Test public void setNx(){ client.set("fantj","fantj","NX","EX",10000); String result = client.get("fantj"); System.out.println(result); } @Test public void append(){ // client.append("fantj","-2019"); String fantj = client.get("fantj"); System.out.println(fantj); } @Test public void testChar(){ System.out.println((char)42); System.out.println(((char)36)); } } ``` -------------------------------- ### Crossover: Installing via RPM Package Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md Command to install Crossover on Red Hat-based systems using an RPM package. This method directly installs the software from the downloaded package. ```Shell rpm -ivh crossoverxxxx.rpm ``` -------------------------------- ### List Installed Snap Applications Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md This command lists all Snap applications currently installed on the system, showing their name, version, revision, tracking channel, publisher, and notes. ```shell [fantj@localhost /]$ snap list ``` -------------------------------- ### Download and Extract Elasticsearch Archive Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS7-ElasticSearch安装.md This snippet downloads the specified version of Elasticsearch from the official Elastic artifacts repository using curl and then extracts the downloaded tar.gz archive, preparing it for installation. ```shell curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz tar -xvf elasticsearch-6.2.4.tar.gz ``` -------------------------------- ### Synchronize Spark and Scala Files to Slave Nodes using SCP Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Spark/2. Spark-安装和集群搭建.md This snippet provides `scp` commands to securely copy Spark and Scala installation directories, along with the updated `/etc/profile` file, to remote slave nodes. This ensures consistent environments across all cluster machines. ```Shell scp -r scala-2.11.7 spark-1.5.1-bin-hadoop2.4/ s168:/home/fantj/download/ scp -r scala-2.11.7 spark-1.5.1-bin-hadoop2.4/ s169:/home/fantj/download/ scp /etc/profile s167:/etc/profile scp /etc/profile s168:/etc/profile scp /etc/profile s169:/etc/profile ``` -------------------------------- ### Snapcraft: Installing Snapd on Fedora Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md Commands to install Snapd, the Snapcraft daemon, on Fedora distributions. This enables the use of Snap packages for application management. ```Shell sudo dnf install snapd sudo ln -s /var/lib/snapd/snap /snap ``` -------------------------------- ### Install RPM Package Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md This command installs an RPM package using the 'rpm' package manager. The '-i' flag indicates installation, '-v' provides verbose output, and '-h' displays a hash mark progress bar. ```shell rpm -ivh xxx ``` -------------------------------- ### Yum Commands Reference Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/常用命令/Linux命令参数详细解析-yum.md A list of common Yum commands for package management, including installation, updates, removal, and information retrieval. ```APIDOC check: Check RPM database issues check-update: Check for available package updates clean: Delete cached data deplist: List package dependencies distribution-synchronization: Synchronize packages to the latest available version downgrade: Downgrade packages erase: Remove one or more packages from the system fs: Creates filesystem snapshots, or lists/deletes current snapshots. fssnapshot: Creates filesystem snapshots, or lists/deletes current snapshots. groups: Display or use group information help: Display usage hints history: Display or use transaction history info: Display detailed information about packages or groups install: Install one or more packages into the system langavailable: Check available languages langinfo: List languages information langinstall: Install appropriate language packs for a language langlist: List installed languages langremove: Remove installed language packs for a language list: List one or a group of packages load-transaction: Load a saved transaction from a file makecache: Create metadata cache provides: Find packages that provide specified content reinstall: Reinstall packages repo-pkgs: Treat a repository as a package group, so we can install/remove all packages at once. repolist: Display configured repositories search: Search for a specified string in package details shell: Run an interactive yum shell swap: Simple way to swap packages, instead of using shell update: Update one or more packages in the system update-minimal: Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system updateinfo: Acts on repository update information upgrade: Update packages while considering package replacements version: Display machine and/or available repository versions. ``` -------------------------------- ### Test Flume NetCat Source with Netcat Command Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Command to test the Flume NetCat source by sending messages to the configured port (44444) using the `nc` (netcat) utility. This simulates a client sending data to Flume. If `nc` is not available, install it using `yum install nmap-ncat.x86_64` (for Redhat/CentOS). ```shell nc localhost 44444 ``` -------------------------------- ### Launch Spark-shell and Verify Startup Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Spark/2. Spark-安装和集群搭建.md This snippet shows the command to launch `spark-shell` and its extensive output, indicating a successful connection to the Spark cluster and the availability of the SQL context. It confirms the interactive shell is ready for use. ```Shell [root@s166 bin]# spark-shell 18/07/30 12:34:16 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 18/07/30 12:34:20 INFO spark.SecurityManager: Changing view acls to: root 18/07/30 12:34:20 INFO spark.SecurityManager: Changing modify acls to: root 18/07/30 12:34:20 INFO spark.SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(root); users with modify permissions: Set(root) 18/07/30 12:34:22 INFO spark.HttpServer: Starting HTTP Server 18/07/30 12:34:23 INFO server.Server: jetty-8.y.z-SNAPSHOT 18/07/30 12:34:23 INFO server.AbstractConnector: Started SocketConnector@0.0.0.0:35005 18/07/30 12:34:23 INFO util.Utils: Successfully started service 'HTTP class server' on port 35005. ... ... 18/07/30 12:38:39 INFO session.SessionState: Created local directory: /tmp/2c350bb0-1297-40d8-a9bd-47446b116bf3_resources 18/07/30 12:38:39 INFO session.SessionState: Created HDFS directory: /tmp/hive/root/2c350bb0-1297-40d8-a9bd-47446b116bf3 18/07/30 12:38:39 INFO session.SessionState: Created local directory: /tmp/root/2c350bb0-1297-40d8-a9bd-47446b116bf3 18/07/30 12:38:40 INFO session.SessionState: Created HDFS directory: /tmp/hive/root/2c350bb0-1297-40d8-a9bd-47446b116bf3/_tmp_space.db 18/07/30 12:38:40 INFO repl.SparkILoop: Created sql context (with Hive support).. SQL context available as sqlContext. scala> ``` -------------------------------- ### Start Flume Agent with Spooling Directory to HDFS Configuration Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Command to start the Flume agent using the `spoordir.conf` file. It specifies the configuration directory (`-c conf`), the configuration file (`-f ../conf/spoordir.conf`), the agent name (`-n agent1`), and sets the root logger level to INFO for console output (`-Dflume.root.logger=INFO,console`). ```shell flume-ng agent -c conf -f ../conf/spoordir.conf -n agent1 -Dflume.root.logger=INFO,console ``` -------------------------------- ### Start GitLab Docker Compose Service Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Docker-compose/docker-compose部署gitlab中文版.md This command starts the GitLab service defined in the `docker-compose.yml` file in detached mode. ```Bash sudo docker-compose up -d ``` -------------------------------- ### Create Shadowsocks Configuration Directory and File Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Fedora-Shadowsocks客户端的配置.md Commands to create the necessary directory for Shadowsocks configuration and open the `shadowsocks.json` file for editing using vi. ```bash mkdir /etc/shadowsocks vi /etc/shadowsocks/shadowsocks.json ``` -------------------------------- ### Initialize React Project Source: https://github.com/fantj2016/java-reader/blob/master/前端专题/React-js/React----脚手架.md Command to create a new React application using create-react-app. Replace 'xxx' with your desired project name. ```Shell create-react-app xxx ``` -------------------------------- ### Example: Performing GET Request with RestTemplate and ResponseEntity in Java Source: https://github.com/fantj2016/java-reader/blob/master/3. 框架专题/3.1 实战篇/SpringBoot/Springboot-RestTemplate详解.md Demonstrates how to use `RestTemplate.getForEntity()` to perform a GET request, retrieve the `ResponseEntity`, extract `HttpStatus` and body, and then use `ResponseEntity.BodyBuilder` to construct a new response. ```Java @Test public void rtGetEntity(){ RestTemplate restTemplate = new RestTemplate(); ResponseEntity entity = restTemplate.getForEntity("http://fantj.top/notice/list/1/5" , Notice.class); HttpStatus statusCode = entity.getStatusCode(); System.out.println("statusCode.is2xxSuccessful()"+statusCode.is2xxSuccessful()); Notice body = entity.getBody(); System.out.println("entity.getBody()"+body); ResponseEntity.BodyBuilder status = ResponseEntity.status(statusCode); status.contentLength(100); status.body("我在这里添加一句话"); ResponseEntity> body1 = status.body(Notice.class); Class body2 = body1.getBody(); System.out.println("body1.toString()"+body1.toString()); } ``` -------------------------------- ### Java NIO Server Main Method for Startup Source: https://github.com/fantj2016/java-reader/blob/master/2. Java基础/2.1 基础/Java-NIO/18. Java-NIO-实例.md The main method serves as the entry point for the NIOServer application. It instantiates NIOServer, initializes it on port 8000, and then starts the server's event listening loop. This method demonstrates how to run the server. ```Java /** * 启动服务端测试 * * @throws IOException */ public static void main(String[] args) throws IOException { NIOServer server = new NIOServer(); server.initServer(8000); server.listen(); } ``` -------------------------------- ### Flatpak CLI: Comprehensive Command Reference Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md Detailed documentation for the Flatpak command-line interface, outlining all available commands for managing applications, runtimes, file access, permissions, remote repositories, and building applications. This serves as a complete reference for Flatpak operations. ```APIDOC Usage: flatpak [OPTION…] COMMAND Builtin Commands: Manage installed apps and runtimes install Install an application or runtime update Update an installed application or runtime uninstall Uninstall an installed application or runtime list List installed apps and/or runtimes info Show info for installed app or runtime config Configure flatpak repair Repair flatpak installation create-usb Put apps and/or runtimes onto removable media Finding applications and runtimes search Search for remote apps/runtimes Running applications run Run an application override Override permissions for an application make-current Specify default version to run enter Enter the namespace of a running application ps Enumerate running applications Manage file access document-export Grant an application access to a specific file document-unexport Revoke access to a specific file document-info Show information about a specific file document-list List exported files Manage dynamic permissions permission-remove Remove item from permission store permission-list List permissions permission-show Show app permissions permission-reset Reset app permissions Manage remote repositories remotes List all configured remotes remote-add Add a new remote repository (by URL) remote-modify Modify properties of a configured remote remote-delete Delete a configured remote remote-ls List contents of a configured remote remote-info Show information about a remote app or runtime Build applications build-init Initialize a directory for building build Run a build command inside the build dir build-finish Finish a build dir for export build-export Export a build dir to a repository build-bundle Create a bundle file from a ref in a local repository build-import-bundle Import a bundle file build-sign Sign an application or runtime build-update-repo Update the summary file in a repository build-commit-from Create new commit based on existing ref repo Print information about a repo Help Options: -h, --help Show help options Application Options: --version Print version information and exit --default-arch Print default arch and exit --supported-arches Print supported arches and exit --gl-drivers Print active gl drivers and exit -v, --verbose Print debug information during command processing, -vv for more detail --ostree-verbose Print OSTree debug information during command processing ``` -------------------------------- ### View Snap Application Details Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md This command provides detailed information about a specific installed or available Snap application, including its summary, publisher, contact, full description, snap-id, available commands, and release channels. ```shell $ snap info vlc ``` -------------------------------- ### Create and Activate a Linux Swap Partition Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/RedHat考级/文件系统管理:分区、挂载....md Steps to initialize a disk partition as a swap area and then activate it. `mkswap` formats the partition, and `swapon` enables it. A final `swapon` command without arguments can verify the setup. ```Linux Shell mkswap /dev/sda3 格式化分区,注意此时sda3并没有成为swap分区 swapon /dev/sda3 将sda3设置成swap分区 swapon 查看设置结果 ``` -------------------------------- ### Flume Exec Source and HDFS Sink Types Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Brief mention of the component types used for collecting data from an executed command and sending them to HDFS. ```APIDOC sources.type: exec sink.type: hdfs ``` -------------------------------- ### Flume Spooling Directory Source and HDFS Sink Types Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Brief mention of the component types used for collecting files from a directory and sending them to HDFS. ```APIDOC sources.type: spooldir sinks.type: hdfs ``` -------------------------------- ### Create Local Text Files for Hadoop Input Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Hadoop/3. Hadoop-单词统计.md This snippet demonstrates how to create local text files (file1.txt, file2.txt, file3.txt) in a directory named 'input' using basic shell commands (mkdir, cd, echo, ls). These files will serve as input for a Hadoop job. ```Shell [root@s166 fantj]# mkdir input [root@s166 fantj]# cd input/ [root@s166 input]# echo "hello fantj" > file1.txt [root@s166 input]# echo "hello hadoop" > file2.txt [root@s166 input]# echo "hello mapreduce" > file3.txt [root@s166 input]# ls file1.txt file2.txt file3.txt ``` -------------------------------- ### Key Parameters in Postfix main.cf Configuration File Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/RedHat考级/邮件服务.md This section details important parameters within the `main.cf` configuration file, which controls core Postfix components and queue information. It explains `myhostname`, `mydomain`, `myorigin`, `inet_interfaces`, `inet_protocols`, `mydestination`, `local_transport`, and `relayhost`. ```APIDOC main.cf: myhostname: Default hostname, usually derived from the system's hostname. mydomain: Domain part derived from myhostname (e.g., everything after the first dot). myorigin: Specifies the domain name that appears on outgoing mail (the @ part). inet_interfaces: Defines the network interfaces Postfix listens on. 'all' means all IPs (0.0.0.0). inet_protocols: Specifies the IP protocols to use (ipv4, ipv6, or all). mydestination: Description: Specifies the list of domains that this machine considers local destinations. If the @ value (myorigin) is not found here, mail will not be sent. Value: $myhostname, localhost.$mydomain, localhost ,$mydomain local_transport: Description: How received mail is delivered and forwarded. Default is local:$myhostname. relayhost: Description: Sets the mail gateway. All mail will be forwarded to this IP for processing. Value: [ip.xx.xx.xx] ``` -------------------------------- ### Render Icon Font in React Component Source: https://github.com/fantj2016/java-reader/blob/master/前端专题/React-js/React----脚手架.md Example of how to conditionally apply an icon font class within a React component's JSX, based on component state or props. This snippet shows how to use the defined icon font classes. ```JavaScript ``` -------------------------------- ### Overview of Postfix master.cf Configuration File Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/RedHat考级/邮件服务.md This section introduces the `master.cf` configuration file, which defines the Postfix daemon processes and their command-line arguments. It controls how Postfix services are started and managed. ```APIDOC master.cf: Description: Defines the Postfix daemon processes and their command-line arguments. ``` -------------------------------- ### Flume Configuration for Exec Source to HDFS Sink (Partial) Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md Partial configuration file (`exec.conf`) for a Flume agent that uses an Exec source to collect data from a command and sends it to an HDFS sink. This snippet shows the initial component definitions. ```Flume Configuration agent1.sources = source1 agent1.sinks = sink1 agent1.channels = channel1 ``` -------------------------------- ### Shadowsocks Client Configuration JSON Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Fedora-Shadowsocks客户端的配置.md Example JSON configuration for the Shadowsocks client, specifying server details, local proxy settings, password, encryption method, and other options. ```json { "server":"xx.xx.xx.xx", "server_port":xxxx, "local_address": "127.0.0.1", "local_port":1080, "password":"password", "timeout":300, "method":"aes-256-cfb", "fast_open": false, "workers": 1 } ``` -------------------------------- ### Configure GitLab with Docker Compose Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Docker-compose/docker-compose部署gitlab中文版.md This Docker Compose configuration defines a GitLab CE service using a Chinese-localized image. It sets up hostname, timezone, external URL, and maps local volumes for configuration, data, and logs. It also includes commented-out examples for SMTP settings. ```YAML version: '3' services: gitlab: image: 'twang2218/gitlab-ce-zh:9.4' restart: unless-stopped hostname: 'fantj.gitlab.top' environment: TZ: 'Asia/Shanghai' GITLAB_OMNIBUS_CONFIG: | external_url 'http://fantj.gitlab.top:9999' gitlab_rails['time_zone'] = 'Asia/Shanghai' # 需要配置到 gitlab.rb 中的配置可以在这里配置,每个配置一行,注意缩进。 # 比如下面的电子邮件的配置: # gitlab_rails['smtp_enable'] = true # gitlab_rails['smtp_address'] = "smtp.exmail.qq.com" # gitlab_rails['smtp_port'] = 465 # gitlab_rails['smtp_user_name'] = "xxxx@xx.com" # gitlab_rails['smtp_password'] = "password" # gitlab_rails['smtp_authentication'] = "login" # gitlab_rails['smtp_enable_starttls_auto'] = true # gitlab_rails['smtp_tls'] = true # gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com' ports: - '9999:9999' #- '443:443' #- '22:22' volumes: - /home/fantj/app/docker/compose/gitlab/config:/etc/gitlab - /home/fantj/app/docker/compose/gitlab/data:/var/opt/gitlab - /home/fantj/app/docker/compose/gitlab/logs:/var/log/gitlab ``` -------------------------------- ### Interactive fdisk Partitioning Commands Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/RedHat考级/文件系统管理:分区、挂载....md This snippet demonstrates the interactive `fdisk` command, showing how to access the help menu (`m`), list partition types (`l`), add a new partition (`n`), print the partition table (`p`), quit without saving (`q`), and write changes to disk (`w`). It also shows the prompts for creating a new primary partition. ```bash fdisk /dev/sda 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 命令(输入 m 获取帮助):m 命令操作 d delete a partition 删除一个分区 l list known partition types 显示文件系统类型,82为swap分区,8 ``` -------------------------------- ### Install NTP Package Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/同步时间.md Installs the Network Time Protocol (NTP) package on a Linux system using the yum package manager. The '-y' flag automatically confirms all prompts during installation. ```Shell yum -y install ntp ``` -------------------------------- ### Ping Command Line Options Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.1 基础篇/常用命令/Linux命令参数详细解析-ping.md Detailed documentation for various command-line options of the `ping` utility, including their syntax, purpose, and behavior. ```APIDOC -a Description: Audible ping. ``` ```APIDOC -A Description: Adaptive ping, determines ping speed based on round-trip time. ``` ```APIDOC -b Description: Allows pinging a broadcast address. ``` ```APIDOC -B Description: Disallows ping from changing the source address in the packet header. ``` ```APIDOC -c count Description: Ping stops after sending the specified number of packets. ``` ```APIDOC -d Description: Uses the Socket's SO_DEBUG feature. ``` ```APIDOC -F flow_label Description: Assigns a 20-bit "flow label" for ping echo requests. If unset, the kernel assigns randomly. ``` ```APIDOC -f Description: Flood ping, rapidly and continuously pings a host at 100 times per second. ``` ```APIDOC -i interval Description: Sets the interval in seconds between sending ping packets. Default is one second. ``` ```APIDOC -I interface Description: Specifies the network interface or local address to send data packets from. Can be used to ping a local host through an interface with no route, provided -I is also used. ``` ```APIDOC -l preload Description: Sets the number of data packets to send before sending the request information. ``` ```APIDOC -L Description: Suppresses multicast packet loopback, only applicable when the ping target is a multicast address. ``` ```APIDOC -n Description: Do not convert IP addresses to hostnames. ``` ```APIDOC -p pattern Description: Specifies the hexadecimal content to fill ping data packets. Useful for diagnosing data-related network errors, e.g., "-p ff". ``` ```APIDOC -q Description: Does not display any transmission packet information, only the final result. ``` ```APIDOC -Q tos Description: Sets QoS (Quality of Service) for the ICMP datagram. Can be decimal or hexadecimal. See rfc1349 and rfc2474. ``` ```APIDOC -R Description: Records the ping's routing process (IPv4 only). Due to IP header limitations, a maximum of 9 routes can be recorded; others are ignored. Many hosts ignore or discard this option. ``` ```APIDOC -r Description: Ignores the normal routing table and sends the data packet directly to the remote host. Usually used to check if the local network interface has issues. Returns an error if the host is not on a directly-connected network. ``` ```APIDOC -S sndbuf Description: Sets the socket send buffer size (sndbuf). If not specified, it is selected to buffer not more than one packet. ``` ```APIDOC -s packetsize Description: Specifies the number of data bytes to send. Default is 56 bytes, resulting in 64 ICMP data bytes with the 8-byte ICMP header. Total packet size (header + content) cannot exceed 65535 bytes, max value is 65507 (Linux) / 65500 (Windows). ``` ```APIDOC -t ttl Description: Sets the IP Time to Live (TTL) to the specified value. This field indicates the maximum number of network segments an IP packet can pass through before being discarded by a router. ``` ```APIDOC -T timestamp_option Description: Sets IP timestamp options. Options include 'tsonly' (only timestamps), 'tsandaddr' (timestamps and addresses), or 'tsprespec host1 [host2 [host3]]' (timestamp prespecified hops). ``` ```APIDOC -M hint Description: Sets MTU (Maximum Transmission Unit) fragmentation policy. Options: 'do' (prohibit fragmentation, even if dropped); 'want' (fragment if too large); 'dont' (do not set DF flag). ``` ```APIDOC -m mark Description: Sets a mark on the outgoing packet, which can be used for policy routing or firewall rules. ``` ```APIDOC -U Description: Prints full user-to-user latency (old behavior). Normally, ping prints network round trip time, which can differ, e.g., due to DNS failures. ``` ```APIDOC -v Description: Enables verbose mode, printing all returned ICMP packets in addition to ECHO-RESPONSE packets. ``` ```APIDOC -V Description: Shows version and exits. ``` ```APIDOC -w deadline Description: Specifies a timeout in seconds before ping exits, regardless of packets sent/received. Ping waits for deadline, 'count' probes answered, or network error. ``` ```APIDOC -W timeout Description: Time to wait for a response, in seconds. This option only affects timeout in absence of responses; otherwise, ping waits for two RTTs. ``` -------------------------------- ### Configure Firewall Rules for vsftpd Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS-FTP服务搭建.md iptables rules to open specific TCP ports required for vsftpd operation. This includes ports 20 (FTP data), 21 (FTP control), and the passive mode port range (61001-62000) for both inbound and outbound traffic, ensuring proper connectivity to the FTP server. ```Shell -A INPUT -p TCP --dport 61001:62000 -j ACCEPT -A OUT -p TCP --dport 61001:62000 -j ACCEPT -A INPUT -p TCP --dport 20 -j ACCEPT -A OUT -p TCP --dport 20 -j ACCEPT -A INPUT -p TCP --dport 21 -j ACCEPT -A OUT -p TCP --dport 21 -j ACCEPT ``` -------------------------------- ### Flume Configuration for NetCat Source to Logger Sink Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Flume/Flume入门.md This configuration file (`netcat-logger.conf`) defines a Flume agent (a1) that listens on a network port (44444) using a NetCat source (r1), logs events to the console using a Logger sink (k1), and uses an in-memory channel (c1) to connect them. ```Flume Configuration # 定义这个agent中各组件的名字 a1.sources = r1 a1.sinks = k1 a1.channels = c1 # 描述和配置source组件:r1 a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 # 描述和配置sink组件:k1 a1.sinks.k1.type = logger # 描述和配置channel组件,此处使用是内存缓存的方式 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # 描述和配置source channel sink之间的连接关系 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1 ``` -------------------------------- ### Configure Spark and Java Environment Variables in /etc/profile Source: https://github.com/fantj2016/java-reader/blob/master/8. 大数据/8.2 实战篇/Spark/2. Spark-安装和集群搭建.md This snippet shows how to add Spark, Java, and Scala home directories to the system's PATH and CLASSPATH in the `/etc/profile` file, making them accessible system-wide for all users. ```Shell export SPARK_HOME=/home/fantj/spark export PATH=$PATH:$SPARK_HOME/bin export CLASSPAHT=.:$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib ``` -------------------------------- ### Flatpak: Listing Installed Applications Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/Fedora-Redhat所有系列-桌面级工具整合.md Displays a list of all Flatpak applications and runtimes currently installed on the system, along with their architecture and installation source. ```Shell flatpak list Ref Options com.tencent.wechat/i386/2.6 system,current com.deepin.wine.Platform/i386/2.18 system,runtime ``` -------------------------------- ### Render Static and Dynamic React TodoList Components Source: https://github.com/fantj2016/java-reader/blob/master/前端专题/React-js/React学习----实现todolist.md Compares rendering a simple static React component with hardcoded values to a dynamic component that utilizes component state (`this.state`) for data. The dynamic example demonstrates how to display data from `this.state` and iterate over lists using the `map` method for rendering, enabling data-driven UI updates. ```JavaScript import React, { Component } from 'react' class TodoList extends Component{ render(){ return(
  • 学英语
  • 学高数
) } } export default TodoList; ``` ```JavaScript import React, { Component } from 'react' class TodoList extends Component{ // Constructor constructor(props){ super(props); this.state = { inputValue: 'FantJ', list: ['hello','world'] } } render(){ return(
    { this.state.list.map((item,index)=>{ return
  • {item}
  • }) }
) } } export default TodoList; ``` -------------------------------- ### Creating Threads by Extending Java's Thread Class Source: https://github.com/fantj2016/java-reader/blob/master/2. Java基础/2.1 基础/Java基础总结(一).md This example demonstrates one of the primary ways to create a thread in Java: by extending the java.lang.Thread class. The thread's execution logic is defined by overriding the run() method. The main method shows how to instantiate and start multiple threads, and how to gracefully interrupt a running thread. ```Java public class CreatThreadDemo1 extends Thread{ /** * 构造方法: 继承父类方法的Thread(String name);方法 * @param name */ public CreatThreadDemo1(String name){ super(name); } @Override public void run() { while (!interrupted()){ System.out.println(getName()+"线程执行了..."); try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } } } public static void main(String[] args) { CreatThreadDemo1 d1 = new CreatThreadDemo1("first"); CreatThreadDemo1 d2 = new CreatThreadDemo1("second"); d1.start(); d2.start(); d1.interrupt(); //中断第一个线程 } } ``` -------------------------------- ### Flatpak: Common Application Management Commands Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md Essential commands for managing Flatpak applications, including installation, listing, running, and removal. These commands are executed in the terminal. ```Shell flatpak install xxxx.flatpak flatpak list flatpak run com.tencen.tim flatpak remove com.tencen.tim ``` -------------------------------- ### Spring Boot REST Controller: User CRUD Endpoints Source: https://github.com/fantj2016/java-reader/blob/master/3. 框架专题/3.1 实战篇/SpringBoot/Springboot2-整合-Mybatis.md This Java code defines a `UserController` as a Spring Boot REST controller. It exposes various HTTP endpoints for managing `User` resources, including `GET` for deletion and selection, and `POST` for insertion and update. It demonstrates the use of `@RestController`, `@RequestMapping`, `@Autowired`, `@PathVariable`, and `@RequestParam` for building RESTful APIs. ```Java @RestController @RequestMapping("/user") public class UserController { @Autowired private UserService userService; @RequestMapping(method = RequestMethod.GET,value = "/delete/{id}") public void delete(@PathVariable("id")int id){ userService.delete(id); } @RequestMapping(method = RequestMethod.POST,value = "/insert") public void insert(User user){ userService.insert(user); } @RequestMapping(method = RequestMethod.POST,value = "/update/{id}") public void update(@RequestParam User user){ userService.update(user); } @RequestMapping(method = RequestMethod.GET,value = "/{id}/select") public User select(@PathVariable("id")int id){ return userService.selectById(id); } @RequestMapping(method = RequestMethod.GET,value = "/selectAll/{pageNum}/{pageSize}") public List selectAll(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize){ return userService.selectAll(pageNum,pageSize); } } ``` -------------------------------- ### Configure vsftpd Directory Permissions Source: https://github.com/fantj2016/java-reader/blob/master/7. Linux专题/7.2 常用服务搭建/CentOS-FTP服务搭建.md Commands to set appropriate file system permissions for the vsftpd user's home directory ("/ftpfile") and a designated writable subdirectory ("/ftpfile/ftp"). This is crucial because newer vsftpd versions restrict write access to the user's root home directory, requiring a separate writable subdirectory. ```Shell #执行权限授予命令 chmod 755 -R /ftpfile chmod 777 -R /ftpfile/ftp #两个目录的所有者和权限 dr-x------ 3 ftpuser ftpuser 4096 Apr 27 20:47 ftpfile drwxrwxrwx 3 ftpuser ftpuser 4096 Apr 27 20:47 ftp ``` -------------------------------- ### Java Source Code for Object Creation Example Source: https://github.com/fantj2016/java-reader/blob/master/2. Java基础/2.1 基础/1. JVM/对象的创建过程.md This Java code defines a `Main` class with a `main` method that instantiates an `Entry` object, and an `Entry` class with a private `total` field and its getter/setter methods. It serves as the foundational source for demonstrating object creation and subsequent bytecode analysis. ```Java public class Main { public static void main(String[] args) { Entry entry = new Entry(); } } public class Entry { private int total = 10; public int getTotal() { return total; } public Entry setTotal(int total) { this.total = total; return this; } } ``` -------------------------------- ### Find Snap Applications Source: https://github.com/fantj2016/java-reader/blob/master/6. 高效开发/6.1 Git/Git-如何忽略IDEA配置文件夹.md This command searches for available applications in the Snap Store that match the specified keywords. It lists the application name, version, developer, and a brief summary. ```shell $ snap find "media player" ``` -------------------------------- ### Update React Component State with setState and Event Binding Source: https://github.com/fantj2016/java-reader/blob/master/前端专题/React-js/React学习----实现todolist.md Demonstrates how to modify component state in React using the `this.setState()` method in response to user interactions, such as a button click. It highlights the importance of binding `this` to event handlers (e.g., `onClick={this.handleButtonClick.bind(this)}`) to ensure the correct context when accessing `this.state` within the handler. The example shows how to append a new item to a list. ```JavaScript import React, { Component } from 'react' class TodoList extends Component{ // Constructor constructor(props){ super(props); this.state = { inputValue: 'FantJ', list: ['hello','world'] } } render(){ return(
    { this.state.list.map((item,index)=>{ return
  • {item}
  • }) }
) } handleButtonClick() { this.setState({ list: [...this.state.list,'FantJ'] }) } } export default TodoList; ```