欢迎来到 艾瑞可erik 的魔法世界 🧙‍♂️

给我一个需求,还你一个项目——别管它是什么。这就是全栈。

📚 292 篇文章 🏷️ 507 个标签 📂 90 个分类

🔥 最新文章

代理服务搭建

代理服务器(Proxy)主要是用户有因特网数据要求时,Proxy会帮用户去向目的地取得用户所需要的数据。

Proxy获取信息的工作流程
  • 当Proxy的缓存拥有用户所想要的数据时
    • Client端向Server端发送一个数据需求数据包。
    • Server端接收后,先比对这个数据包的来源与预计要前往的目标网站是否为可接受?如果来源与目标合法,或者说,来源与目标网站Proxy都能帮忙取得数据时,那么Server端会开始替Client取得数据。
    • Server首先会检查自己缓存数据,如果有Client所需的数据,那就将数据取出,而不经过向Internet要求数据的程序。
    • 最后将数据发送给Client端。

Setting Up a Proxy Server

A proxy server is mainly about this: when a user has a request for data on the Internet, the Proxy goes to the destination on the user’s behalf and fetches the data the user needs.

How the Proxy fetches information
  • When the Proxy’s cache already holds the data the user wants
    • The Client sends a data request packet to the Server.
    • After the Server receives it, it first compares the source of this packet and the target website it intends to reach to see whether they are acceptable. If the source and the target are legitimate, or in other words, if the Proxy can help fetch data for both the source and the target website, then the Server will start fetching data on behalf of the Client.
    • The Server first checks its own cached data. If it has the data the Client needs, it takes the data out without going through the process of requesting data from the Internet.
    • Finally it sends the data to the Client.

hadoop2.8和3.1版本配置变化

新版hadoop3.1相较于老版hadoop2.8在配置文件这块有了变化。

这个是我早些时候配置的

hadoop2.8安装教程

在hadoop2.8中配置java路径和项目路径统一在/path/etc/hadoop/yarn-env.sh中。而hadoop3.1中则是在hadoop-env.sh中开启配置

原来slaves的节点配置改成works文件。

昨晚一不留神掉坑里了。这里附上配置。

Configuration changes between hadoop2.8 and 3.1

Compared with the older hadoop2.8, the new hadoop3.1 has changes when it comes to configuration files.

This is what I configured earlier

hadoop2.8 installation tutorial

In hadoop2.8, configuring the java path and the project path was all done in /path/etc/hadoop/yarn-env.sh. In hadoop3.1, however, the configuration is enabled in hadoop-env.sh

The original slaves node configuration has been changed to the works file.

Last night I carelessly fell into a pit. The configuration is attached here.

Scraping Page Images to Local Storage and Generating SQL

With nothing better to do, I put together an image scraper.
After scraping the images from a certain website, save them to a specified local directory, and at the same time generate the SQL statements that write them into the database.

The approach is as follows:

  1. Get the URLs of the images on the page
  2. Download them locally based on the image URLs
  3. Store the downloaded images in the specified directory, and generate the SQL that writes them into the database

Hbase安装教程

hbase分布式数据库,很早就知道了,今天尝试在docker中搭建一下。
首先,安装配置hadoop环境。

hadoop安装教程

这教程是我之前在百度经验分享的,版本是2.8,现在看了看了最新版hadoop,教程还是可以用的。

安装好hadoop后别忘了配置ssh、java环境等。

顺便创建用户和组为hadoop(也可以自己定义,这块不会的去预习一下linux用户和组的创建)

HBase Installation Tutorial

I heard about the HBase distributed database a long time ago; today I’m going to try setting one up in Docker.
First, install and configure the Hadoop environment.

Hadoop installation tutorial

I shared that tutorial on Baidu Experience before; it’s for version 2.8, and now that I’ve looked at the latest Hadoop, the tutorial still works.

After installing Hadoop, don’t forget to configure SSH, the Java environment, and so on.

While you’re at it, create a user and group named hadoop (you can define your own too; if you don’t know how, go read up on creating Linux users and groups)

ca证书生成

想要从商业 CA 获取数字证书需要向其支付一定的金钱,不过我们不用那么破费,可以自己成为 root CA,为自己发布证书。

在本实验中,我们将成为 root CA,并为该 CA 生成证书。不像其他 CA 需要被另外的 CA 认证, root CA 的证书是自己为自己认证的,一般 Root CA 的证书都已事先加载在大多数操作系统,浏览器或者依赖 PKI 的软件之中了。Root CA 的证书是被无条件信任的。

Generating a CA Certificate

Getting a digital certificate from a commercial CA costs money, but we don’t have to go to that expense — we can become a root CA ourselves and issue certificates for ourselves.

In this lab we will become a root CA and generate a certificate for that CA. Unlike other CAs, which need to be certified by another CA, a root CA’s certificate is certified by itself. Root CA certificates are generally already loaded in most operating systems, browsers, or software that depends on PKI. A root CA’s certificate is trusted unconditionally.

php配置zookeeper3.5.5扩展

这两天想用用zookeeper,顺便做个提升。查了下官方给出的3.5.5和3.4.14。而php手册也有介绍配置方法,不过扩展好久没更新,就是试试用了。

下载php-zookeeper扩展,放到本地编译、安装。在执行make命令的时候总是报错缺少lzookeeper_mt.so库。
官方搜索教程都是老版本的,说是在文件根目录src/c下生成库。可是我用的是3.5.5版本的,目录下根本没有。
根据官方文档可知,新版本分为bin和源码版,也就是说bin是编译好的,下载后配置一下cfg文件就可以用了。

Configuring the PHP ZooKeeper 3.5.5 Extension

I’ve been wanting to try zookeeper for the past couple of days, and figured I’d level up a bit along the way. I looked up the official releases, 3.5.5 and 3.4.14. The PHP manual also explains how to configure it, though the extension hasn’t been updated in ages — I just gave it a try anyway.

I downloaded the php-zookeeper extension, dropped it locally, compiled and installed it. Every time I ran make it errored out about a missing lzookeeper_mt.so library.
The tutorials I found through official channels were all for old versions, saying the library is generated under src/c in the root directory of the project. But I’m using version 3.5.5, and there’s no such directory there at all.
According to the official docs, new versions come in a bin build and a source build, meaning the bin one is already compiled — you download it and just configure a cfg file to use it.

关于任意金额分配10元、5元、2元的算法

今天去一家做电商的公司面试,笔试题有个算法,如下:

输入任意金额,计算分配出10元、5元、2元是否可以分配,如果可以分别分配几张。

根据需求可知优先分配最高金额,根据最高金额计算出分配值,然后取整数。

An algorithm for splitting any amount into 10 yuan, 5 yuan and 2 yuan

Today I went to interview at an e-commerce company, and there was an algorithm question on the written test, as follows:

Input any amount, calculate whether it can be split into 10 yuan, 5 yuan and 2 yuan, and if so how many notes of each.

From the requirement we know we should allocate the highest denomination first, calculate the allocation value from the highest denomination, then take the integer.

http1.1和http2.0的知识点

Http1.1

  • 缓存处理

    引入了更多的缓存控制策略例如Entity tag,If-Unmodified-Since, If-Match, If-None-Match等更多可供选择的缓存头来控制缓存策略。

  • 带宽优化及网络连接的使用

    在请求头引入了range头域,它允许只请求资源的某个部分,即返回码是206(Partial Content),这样就方便了开发者自由的选择以便于充分利用带宽和连接。

Knowledge points about HTTP 1.1 and HTTP 2.0

Http1.1

  • Cache handling

    It introduces more cache control strategies, such as Entity tag, If-Unmodified-Since, If-Match, If-None-Match and other cache headers you can choose from to control caching policy.

  • Bandwidth optimization and network connection usage

    A range header field was introduced into requests, allowing you to request only a certain part of a resource, i.e. returning status code 206 (Partial Content), which makes it convenient for developers to choose freely and make full use of bandwidth and connections.