西维蜀黍

【VPN】Terminal 运行 Cisco AnyConnect VPN

$ vim VpnCrendentials
1

here_goes_your_username
here_goes_your_passwordy
$ alias vpn="/opt/cisco/anyconnect/bin/vpn connect your.cisco.vpn.hostname/vpn_name -s < ~/VpnCrendentials"
$ alias svpn="/opt/cisco/anyconnect/bin/vpn disconnect your.cisco.vpn.hostname/vpn_name"
  ...


【Microservices】微服务 - 服务注册(Service Registry)和服务发现(Service Discovery)

Service Discovery

Let’s imagine that you are writing some code that invokes a service that has a REST API or Thrift API. In order to make a request, your code needs to know the network location (IP address and port) of a service instance. In a traditional application running on physical hardware, the network locations of service instances are relatively static. For example, your code can read the network locations from a configuration file that is occasionally updated.

In a modern, cloud‑based microservices application, however, this is a much more difficult problem to solve as shown in the following diagram.

  ...


【ZooKeeper】Basic

ZooKeeper

Apache ZooKeeper is an open-source server for highly reliable distributed coordination of cloud applications. It is a project of the Apache Software Foundation.

ZooKeeper is essentially a service for distributed systems offering a hierarchical key-value store, which is used to provide a distributed configuration service, synchronization service, and naming registry for large distributed systems (see Use cases). ZooKeeper was a sub-project of Hadoop but is now a top-level Apache project in its own right.

Zookeeper 一个最常用的使用场景就是用于担任服务生产者和服务消费者的注册中心。 服务生产者将自己提供的服务注册到Zookeeper中心,服务的消费者在进行服务调用的时候先到Zookeeper中查找服务,获取到服务生产者的详细信息之后,再去调用服务生产者的内容与数据。

如下图所示,在 Dubbo架构中 Zookeeper 就担任了注册中心这一角色。

当然,在Dubbo中,我们利用ZooKeeper 中的瞬时节点(ephemeral node)了,即当服务的消费者 subscribe 了自己依赖的一个服务生产者的信息后,当服务生产者在Zookeeper中心更新了自己的节点信息时,服务的消费者可以实时的收到通知。

这意味着我们可以实现“优雅的服务注册与服务下线”,即服务消费者可以(通过被push的形式)实时的感知到服务生产者的节点变化。

  ...


【ZooKeeper】安装

Install on OS

Prerequisition

安装 ZooKeeper 之前需要先安装 JDK, 关于 JDK 的安装这里不再赘述。

  ...


【Java】安装

Ubuntu

Execute the following command to install the default Java Runtime Environment (JRE), which will install the JRE from OpenJDK 11:

$ apt install default-jre

The JRE will allow you to run almost all Java software.

Verify the installation with:

$ java -version

You’ll see the following output:

Outputopenjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing)

You may need the Java Development Kit (JDK) in addition to the JRE in order to compile and run some specific Java-based software. To install the JDK, execute the following command, which will also install the JRE:

$ sudo apt install default-jdk
  ...