裸金属服务器kvm虚拟化安装win10

受够了小鸡的各种卡顿以及各种套路,就想要一只”大鸡”,趁着双十一的余热购入达州创梦网络江苏宿迁高防裸金属服务器(一种集合了虚拟机和物理机优点的产物),本人没有使用或配置过独立服务器,不过多评价。但和普通的 VPS 相比,裸金属服务器属于物理服务器,我的数据和其他用户数据做到了物理隔离,同时服务器本身是支持二次虚拟化的。

裸金属服务器的购入主要为满足自己下列几点需求:

  • 较高性能低延迟的 Windows 桌面工作台
  • 高防大容量的 Linux 网站服务器

当服务器交付完成,第一步就是对它进行虚拟化!这一台主机有下列硬件资源:

  • CPU model : Intel(R) Xeon(R) CPU L5630 @ 2.13GHz
  • Number of cores : 16
  • Thread(s) per core: 2
  • Core(s) per socket: 4
  • Socket(s): 2
  • CPU frequency : 1600.000 MHz
  • Total size of Disk : 932.0 GB (7.1 GB Used)
  • OS : CentOS 7.5.1804
  • Arch : x86_64 (64 Bit)
  • Kernel : 3.10.0-862.el7.x86_64

目前计划在宿主机上虚拟化一台 win10 和一台 Debian,其中为 win10 分配 6C/8G/100GB的硬件资源。下面就记录一下在 CentOS 7.5环境下使用 KVM架构虚拟化安装 Win10 Pro的过程。

环境准备

以下为摘录的部分关于 KVM 的描述,运行描述后的命令以完成 KVM 的环境准备。

KVM架构:

KVM 是基于虚拟化扩展(Intel VT 或者 AMD-V)的 X86 硬件的开源的 Linux 原生的全虚拟化解决方案。KVM 中,虚拟机被实现为常规的 Linux 进程,由标准 Linux 调度程序进行调度; 虚机的每个虚拟 CPU 被实现为一个常规的 Linux 进程。这使得 KMV 能够使用 Linux 内核的已有功能。 但是,KVM 本身不执行任何硬件模拟,需要客户空间程序通过 /dev/kvm 接口设置一个客户机虚拟服务器的地址空间,向它提供模拟的 I/O,并将它的视频显示映射回宿主的显示屏。 目前这个应用程序是 QEMU。

KVM 工具集合

  • libvirt:操作和管理KVM虚机的虚拟化 API,使用 C 语言编写,可以由 Python,Ruby, Perl, PHP, Java 等语言调用。可以操作包括 KVM,vmware,XEN,Hyper-v, LXC 等 Hypervisor。
  • Virsh:基于 libvirt 的 命令行工具 (CLI)
  • Virt-Manager:基于 libvirt 的 GUI 工具
  • virt-v2v:虚机格式迁移工具
  • virt-* 工具:包括 Virt-install (创建KVM虚机的命令行工具), Virt-viewer (连接到虚机屏幕的工具),Virt-clone(虚机克隆工具),virt-top 等
  • sVirt:安全工具

(⚠️注:”$” 后代表一条命令,没有该符号的行代表运行结果,”\”结尾代表多行命令,请注意)

$ yum -y install vim lrzsz
$ cat /etc/centos-release
  CentOS Linux release 7.4.1708 (Core) 
$ uname -a
  Linux bogon 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ yum -y install qemu-kvm virt-manager python-virtinst qemu-kvm-tools libvirt virt-install libvirt-python           # 其中第2-4个是KVM的管理工具
$ lsmod |grep kvm         # 确定是否正确加载kvm模块
$ reboot                    # 重启后下面的命令才管用,否则会出错
$ systemctl enable libvirtd       # 将libvitd服务加入开机自启
$ systemctl start libvirtd          # 启动libvitd服务
$ systemctl status libvirtd         # 查看libvitd服务的状态

$ virsh -c qemu:///system list (或者virsh  list)      # 如出现下面的信息则表明kvm成功安装

Id 名称             状态
----------------------------------------------------

准备资源

经过一番搜索和实践,创建一台虚拟机需要的资源清单如下:

  • 桥接网卡(br0)
  • 虚拟磁盘文件(WASU_AF.qcow2)
  • virtio驱动(virtio-win-0.1.126_amd64.vfd)
  • windows 10镜像(Win10_1903_V2_Chinese_Simplified_x64.iso)

需下载的资源

在进行下面的操作前先说需要下载的资源,可以在进行下列操作前先将这些资源下载好并整理好,创建虚拟机需要指定以上资源的路径,因此建议根据需求将需要的文件归类。

下面先来说说 virtio驱动, kvm 的虚拟硬盘的模式是virtio,virtio的性能和稳定性上佳, 但是windows安装盘是找不到virtio模式的虚拟硬盘的, 因此必须要加载virtio的磁盘驱动。驱动可以在安装前加载或是直接使用包含了驱动的镜像(第三方),此外还可以在安装时加载,本次安装就是在安装时加载驱动,将驱动作为磁盘进行加载,因此首先需要下载驱动,创建虚拟机时这个驱动将会和镜像一起加载。

Virtio驱动官方渠道: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/

根据需要选择,在这里我选择 virtio-win-0.1.173_amd64.vfd wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.173-2/virtio-win-0.1.173_amd64.vfd

windows10镜像不必多说,网上途径很多,在这里我选择通过官方渠道下载:

下载 Windows 10 光盘映像(ISO 文件) : https://www.microsoft.com/zh-cn/software-download/windows10ISO

准备好以上资源,接下来进行下面的步骤。

网卡配置

KVM 客户机网络连接有三种方式:

  • host-only:虚拟机使用的是当前计算机中的虚拟网卡,如VMWare Network Adaptor(这是VMWare的),仅主机模式,意思就是将所有的虚拟机组成一个局域网,不能和外界通信,不能访问Internet,其他主机也不能访问虚拟主机,安全性高,只能与本台真实机通信。
  • NAT方式(网络地址转换模式):让虚拟机访问主机、互联网或本地网络上的资源的简单方法,但是不能从网络或其他的客户机访问客户机,性能上也需要大的调整。
  • Bridge方式「虚拟网桥(Virtual Bridge)」:这网络模式下客户机与宿主机处于同一网络环境,类似于一台真实的宿主机,直接访问网络资源,设置好后客户机与互联网,客户机与主机之间的通信都很容易。

2019.11.22更新

实际配置发现网桥可以使虚拟机和物理机处于同一级别,但是我并不知道我的服务器在当前局域网中的配置,此外我仅有一个ip,因此使用网桥并不合适(不知道理解的对不对,这是我目前的理解,后续有误再更)。因此这里修改为采用 Nat 方式配置网络。

开启 IPV4转发:

vim /etc/sysctl.conf

net.ipv4.ip_forward = 1 值原来是 , 改成 1

执行命令 sysctl -p 使配置生效.

KVM虚拟机Nat方式上网:

virsh net-list

查看当前活跃的网络,可以看到一个default网络,这个就是安装 KVM 后自带的一个默认的Nat网络了。后面我们直接使用这个网络进行配置。


注:如果还没有进行bridge配置,继续下面的操作(磁盘配置)就好,如果已经使用 bridge 安装了虚拟机,可以按照以下的步骤修改/etc/libvirt/qemu/下的同名xml文件。

配置 bridge 的虚拟机XML配置文件中的网络配置部分形如:

<interface type='bridge'>
  <mac address='52:54:00:84:e9:e1'/>
  <source bridge='br0'/>
  <model type='rtl8139'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

只需将其中的 bridge 修改为 network 并修改网卡为 default即可,最后重启libvirt服务使之生效,systemctl restart libvirtd ,再启动虚拟机即可。


再次更新:如果需要使用外网访问 虚拟机,就需要使用 nat端口转发,在配置端口转发前需要先配置网桥,此时的网桥不是给虚拟机使用,而是为了端口转发。

配置过程中的物理机默认网卡信息可以在 /etc/sysconfig/network-scripts/ifcfg-eth0文件中看到(vim /etc/sysconfig/network-scripts/ifcfg-eth0),从上述文件中获取到物理机的 IPADDR, NETMASK, GATEWAY,之后在/etc/sysconfig/network-scripts/目录下新建ifcfg-br0文件(vim /etc/sysconfig/network-scripts/ifcfg-br0),写入以下信息(⚠️ 实际操作时请自动删除注释部分):

BOOTPROTO=static DEVICE=br0 TYPE=Bridge NM_CONTROLLED=no IPADDR=112.3.24.154 //设置为物理机所占有的ip地址 NETMASK=255.255.255.0 GATEWAY=112.3.24.1

配置好桥接网卡后还需要到默认网卡中添加这个桥接网卡,修改默认网卡(vim /etc/sysconfig/network-scripts/ifcfg-eth0),既在最后加入一行BRIDGE=br0 ,修改后的默认网卡文件文本如下: DEVICE=eth0 ONBOOT=yes TYPE=Ethernet BOOTPROTO=static PEERDNS=no NM_CONTROLLED=no IPADDR=112.3.24.154 NETMASK=255.255.255.0 GATEWAY=112.3.24.1 MACADDR=00:26:6c:f5:01:18 BRIDGE=br0

关闭 NetworkManager


$ systemctl stop NetworkManager

$ systemctl disable NetworkManager

重启网络服务

service network restart

通过brctl命令查看网桥状态

                                          vnet0 virbr0          8000.5254009b1724       yevirbr0-nic ```

### 虚拟磁盘配置

使用如下命令在需要的位置创建虚拟磁盘,根据需要调整名称和大小.

$ qemu-img create -f qcow2 win10.qcow2 100G


## 安装虚拟机

准备好所需资料,就差临门一脚,运行如下命令就可以完成虚拟机的创建,请根据自己的实际情况对每一行的内容进行修改,在此有一些备注:

1. 虚拟机名称 `name` 必须唯一
2. 分配给虚拟机的vCPU个数由sockets、cores、threads三个参数的乘积来控制,sockets指代CPU插槽数目,cores指代每个插槽芯片的核心数,threads指代那个核心的超线程,如下所示创建的虚拟机共有6个逻辑cpu (cpu 情况可以使用这个命令: `lscpu`)。
3. listen指代的是虚拟机的VNC监听接口,默认是localhost,0:0:0:0指带所有的IPv4接口,::指代所有接口,包括IPv4和IPv6。

```bash
louie@ubuntu:~$ virt-install \
--name Frytea-Win10 \
--memory 8192 \
--vcpus sockets=1,cores=3,threads=2 \
--cdrom=/srv/kvm/win10/Win10_1909_Chinese_Simplified_x64.iso \
--os-type=windows \
--os-variant=auto \
--disk /srv/kvm/win10/Win10.qcow2,bus=virtio,size=100 \
--disk /srv/kvm/win10/virtio-win-0.1.173_amd64.vfd,device=floppy \
--network bridge=default,model=virtio \
--graphics vnc,password=kvmwin10,listen=::,port=5910 \
--hvm \
--autostart \
--virt-type kvm

WARNING  Unable to connect to graphical console: virt-viewer not installed. Please install the 'virt-viewer' package.
WARNING  No console to launch for the guest, defaulting to --wait -1

Starting install...
Allocating 'win10.qcow | 100 GB  00:00     ERROR    Cannot get interface MTU on 'default': No such device
Removing disk 'win10.q |    0 B  00:00     Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start Frytea-Win10
otherwise, please restart your installation.

操作:

# 查看虚拟机运行状态
$ virsh list
 Id    Name                           State
----------------------------------------------------
 3     Frytea-Win10               running

# 查看所有
$ virsh list -l

# 关机
$ sudo virsh shutdown Frytea-Win10

# 开机
$ sudo virsh start Frytea-Win10

# 重启
$ sudo virsh reboot Frytea-Win10

# 暂停(挂起)
$ sudo virsh suspend Frytea-Win10

# 删除(强行关机)
$ sudo virsh destroy DELL_STORAGE
# 要想彻底删除一个虚拟机需要将其xml文件一并删除,即删除/etc/libvirt/qemu/下的同名xml文件.

# 移除虚拟机,虚拟机处于关闭状态后还可以启动,但是被该指令删除后不能启动。在虚拟机处于Running状态时,调用该指令,该指令暂时不生效,但是当虚拟机被关闭后,该指令生效移除该虚拟机,也可以在该指令生效之前调用define+TestKVM.xml取消该指令
$ virsh undefine DomainName

# 重启libvirt服务
$ systemctl restart libvirtd

安装 Win10

执行到这个阶段如果一切顺利就可以进入 win10 安装了,使用 VNC客户端连接到虚拟机,其中地址为宿主机 ip端口为命令中配置的5910,密码为kvmwin10

VNC(Virtual Network Computing),为一种使用RFB协议的屏幕画面分享及远程操作软件。此软件借由网络,可发送键盘与鼠标的动作及即时的屏幕画面。 VNC与操作系统无关,因此可跨平台使用,例如可用Windows连线到某Linux的电脑,反之亦同。甚至在没有安装客户端程序的电脑中,只要有支持JAVA的浏览器,也可使用。

VNC 是独立于操作系统而存在的,因此当 ssh/RDP 找不到服务器时,就可以进入 VNC 进行维护。网上有一些人会将 VNC和RDP放在一起做对比,个人认为这是没有什么可比性的,因为 RDP 是需要 windows 服务启动后才会随之启动,而 VNC 与操作系统无关,比如本次安装就可以看出 VNC 是可以看到 Windows 的整个安装过程的,如果没有这个想要为服务器远程安装系统就是一抹黑了。

安装win10需要提供激活码,在这里贴上几个来自互联网分享的激活码,截止到2019年6月:

六月最新win10永久激活key密钥攻略(大集合):

Operating system edition(操作系统版本):KMS Client Setup Key(KMS客户端安装序列号)

Windows 10 Professional(专业版):W269N-WFGWX-YVC9B-4J6C9-T83GX

Windows 10 Professional N(专业版N):MH37W-N47XK-V7XM9-C7227-GCQG9

Windows 10 Enterprise(企业版):NPPR9-FWDCX-D2C8J-H872K-2YT43

Windows 10 Enterprise N(企业版N):DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4

Windows 10 Education(教育版):NW6C2-QMPVW-D7KKK-3GKT6-VCFB2

Windows 10 Education N(教育版N):2WH4N-8QGBV-H22JP-CT43Q-MDWWJ 

全球主机论坛gyld大佬分享了一个 win10 pro 的激活码,本人 2019.11.22 日亲测直接激活。激活码: 9HTXD-BWVFH-PP4JD-2V43X-JCPJP

本文内容为多方探索后实践验证,最终整理的产物,在最后列出参考文献,本文若有描述不清楚的地方可以到参考文献中试试。

Nat 端口转发


[root@localhost ~]# ifconfig
...

virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:a0:ea:03  txqueuelen 1000  (Ethernet)
        RX packets 544450  bytes 27198927 (25.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 593033  bytes 1680545079 (1.5 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

...

通过上图,我们可以看出网卡virbr0就是NAT方式连接网络时,所使用到的网卡。

除此之外我们还可以通过配置文件,来查看NAT方式的DHCP地址池。该配置文件为:/etc/libvirt/qemu/networks/default.xml。如下:


<network>

<name>default</name>

<uuid>1ea78a7d-4776-4e7e-99f1-aab6b9cba8b2</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:a0:ea:03'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>

<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>

我们可以看出,目前NAT使用的IP地址池是192.168.122.2-192.168.122.254,网关为192.168.122.1,子网掩码为255.255.255.0

下面开始配置 nat 端口转发 , 宿主机的公网 ip112.3.24.154 VM的IP为192.168.122.2,现在我要求通过访问KVM的 3389 端口访问VM的 3389 端口。

开启KVM服务器的IP转发功能。编辑/etc/stsctl.conf文件,把其中的net.ipv4.ip_forward = 0修为net.ipv4.ip_forward = 1,如下:

开启KVM服务器的IPtables的转发功能,使用如下命令:

iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE

注意该命令中的网卡时br0,而不是eth0。转发许可:

iptables -I FORWARD -o virbr0 -d 192.168.122.2 -j ACCEPT

需要注意的是 , 这里的 192.168.122.111 是你虚拟机的 IP, 如果你需要端口转发 , 建议在虚拟机里面设置成固定 IP, 而不是 dhcp 获取 . 否则你虚拟机 ip 变了就又连不上了 .

下面是一个代码段 , 有要开放的端口都可以依次设置 . 比如要开放 3389, 那么 iptables 命令就是 : 192.168.122.111 是虚拟机的 ip


$ iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
$ iptables -t nat -A PREROUTING -p tcp -m tcp -i br0 --dport 3389 -j DNAT --to-destination 192.168.122.2:3389

$ service iptables save
$ service iptables restart

执行这个命令的时候有时候可能会报错:The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

这是因为没有安装iptables服务,直接使用yum安装iptables服务再执行未执行完的命令即可.

yum install iptables-services

执行如下命令(老版本命令为:service iptables on),设置iptables开机自启

systemctl enable iptables.service

需关闭firewalld防火墙

$ systemctl stop firewalld.service

$ systemctl disable firewalld.service

补充,为宿主机安装桌面系统

Linux系统在服务器上一般都直接最小化安装,是不安装图形界面的,但是有时候,有一些特殊情况,需要使用图形界面,下面是安装 GNOME 桌面的步骤。

$ yum grouplist
# 列出的组列表里有GNOME Desktop。安装之
$ yum groupinstall -y "GNOME Desktop"
# 安装完成后,修改默认启动方式为图形化界面
$ systemctl set-default graphical.target  //设置成图形模式

# 如果要换回来
$ systemctl set-default multi-user.target  //设置成命令模式

# 然后重启即可,或者startx开启图形界面。第一次启动可能时间会长一点,耐心等待即可。

KVM 调整内存

ps:调小内存可以动态实现,不用关机

1、产看当前配置:

$ virsh dominfo vm | grep memory    

Max memory: 8388608 KiB
Used memory: 4194304 KiB

2、设置虚拟机内存: 512M

$ virsh setmem vm 524288

KVM 调整cpu

1、关闭虚机

$ virsh shutdown vm    | virsh destroy vm

2、编辑虚拟机配置文件,调整

#virsh edit vm

<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>4</vcpu>

3、从配置文件启动虚机

$ virsh create /etc/libvirt/qemu/vim.xml

4、查看当前内存大小

$ virsh dominfo vm | grep memory        

Max memory: 8388608 KiB
Used memory: 8388608 KiB

5、验证:

$ virsh dominfo vm

参考文献

【持续集成】Android使用Github Action自动打包并发布Fir.im内测

B8A09718-BB0F-4896-82E9-332323220F15.jpeg

!!!

Photo by Mesut Kaya on Unsplash

!!!

为什么封面图是一张旅游的照片?因为使用 CI/CD 等工具高效的完成工作,就可以出去玩了!

前言

GitHub ActionsGitHub 官方提供并免费提供给开源仓库使用的持续集成服务,在进入本文主题之前,先讲讲什么是持续集成 (CI/CD) 。

持续集成(CI/CD)

根据 WIkiPedia 引用自What is CI/CD – all you need to know 的说法:

In software engineering, CI/CD or CICD generally refers to the combined practices of continuous integration and continuous delivery (aka continuous deployment).

简单来说就是指”持续集成和持续交付”,更生动的表述可以引用自红帽官网《什么是 CI/CD?》一文中的描述:

CI/CD 是一种通过在应用开发阶段引入自动化来频繁向客户交付应用的方法。CI/CD 的核心概念是持续集成、持续交付和持续部署。作为一个面向开发和运营团队的解决方案,CI/CD 主要针对在集成新代码时所引发的问题(亦称:“集成地狱”)。

具体而言,CI/CD 在整个应用生命周期内(从集成和测试阶段,到交付和部署)引入了持续自动化和持续监控。这些关联的事务通常被统称为“CI/CD 管道”,由开发和运维团队以敏捷方式协同支持。

通俗来说,持续集成是面对开发团队不同人员针对同一软件开发产品不同部分代码的集成、持续交付、部署问题的一套解决方案。举个例子,在没有持续集成系统之前,团队合作进行软件开发,就需要有人专门负责代码的整合、编译、部署,而有了持续部署系统之后,团队成员只需将自己的代码提交至公共代码仓库,系统接收到代码推送请求后就会自动的执行一系列实现约定好的工作流程,不再需要有人专门负责这一工作,代码提交者也可以实时的看到自己的代码在整个系统中的运行状况,极大的提高了开发效率。

目前提供CI/CD服务的有很多家:

其中 Teavis-CI 和 CircleCI 对开源产品比较友好,在 GitHub Action 之前,它们几乎是开源产品必备的 CI/CD 的工具,开源代码仓库常见的这个绿色的 “passing” 就是 Travis-CI 很经典的一个部署状态徽标,这一抹绿不知道带给多少人多少快乐(编译不通过的苦懂得人自然会懂)。

Build Status

而 Jenkins 和 GitLab 是开源可自主部署的, Jenkins 使用 Java,可以部署在私有的服务器上,至于 GitLab 虽天然带有 CI/CD ,但一些操作必须依赖 Jenkins 才能完成。本人对于 Bamboo 的了解不多,偶然进入官网发现也是一个 CI/CD 工具,遂记录。

CI/CD 工具可以做很多事情,大概的操作逻辑就是:

  1. 触发条件
  2. 编译及前后工作
  3. 结束

给一个触发自动化部署的条件,比如提交代码后由代码参考使用 WebHook 向服务发送一个请求从而触发构建;触发后就是开发者的天下啦,CI/CD 是一个忠实的小精灵,它对于您给它的指令绝对服从,因此从这里就可以指定需要自动执行的操作了,比如:环境配置、编译、响应函数、发送状态邮件等等。

GitHub Action 虽为后起之秀,但它的出现还是让此前的 CI/CD 服务提供者捏了一把汗。因为 GitHub 本身就是全球最大代码托管仓库,而上文提到的 Travis-CI 等多是要针对 GitHub 仓库内的代码提供服务,而现在 GitHub 自身提供了别家依赖它实现的功能。

GitHub Action

GitHub Action 提供的 CI/CD 持续部署环境很是吸引我,根据官网描述:

Each virtual machine has the same hardware resources available.

  • 2-core CPU
  • 7 GB of RAM memory
  • 14 GB of SSD disk space

Virtual environment

  • Windows Server 2019
  • Ubuntu 18.04
  • Ubuntu 16.04
  • macOS X Catalina 10.15 macos-latest

这样一个配置的 CI/CD 环境对现在的我来说已经是豪华阵容了,试想使用 GitHub Action 就意味着有一台 2C 7G 的电脑专门为我的代码完成编译工作,此外这台电脑还是同时支持 Windows, Linux, Mac OS 系统的,也就是说我可以在这台电脑上完成现在针对所有主流平台代码的编译工作,是不是挺爽的?更详细的环境支持说明在 GitHub 官网 中的这篇文章可以看到 Software installed on GitHub-hosted runners.

更多关于 GitHUb Action 的说明可以在其官网找到详细描述,在此不再赘述,至于地址在文章一开始就有给出。下面就来记录一个使用 Github Action 的具体操作:代码提交后触发 => 编译并打包生成 APK 安装包 => 提交到 Fir.im 应用内测分发平台

Package Andrpid apk

先来分析一下需求,根据 CI/CD 的思想,将需要完成的工作流程化,建立一条流水线。我需要完成的工组有:

  1. 将 Android 程序源代码编译打包为 apk 安装包并签名
  2. 将编译通过并签过名的 apk 安装包上传至 fir.im 内测应用分发平台

明确需求下面就可以开工了。GitHub Action 的使用非常简单,在代码仓库中选择 Action 选项卡进入,或直接在根目录下建立文件夹 .github/workflows 并在其中新建一个 *.yml的文件即可,此文件就是指定你需要 Action 帮你完成的工作。GitHub MarkPlace 中提供了上千种社区开发者贡献的模版可以根据需求拿来使用。

AD787804-4BFB-44F6-B3EB-31E5DD316695.png

Package

GitHub 为 Android Apk 打包提供了一个模版,打开之后文件内容大概是这样子:

name: Android CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Build with Gradle
      run: ./gradlew build

模版创建会自动化在仓库 .github/workflows文件夹下新建一个 android.yml 文件,这个文件制定的工作流就已经可以完成 Android Apk 的打包工作j,但是我不光要完成打包,还要上传 fir.im ,下面就开始基于这个模版进行修改。

执行到文件结束就完成了打包工作,下面将打包的成果提交到 fir.im。

install fir-cli

fir.im」是国内首家为移动开发者提供 App 免费托管分发服务的平台,为移动开发者提供极速测试发布、崩溃收集分析、用户反馈收集等一系列开发测试效率工具服务,能够让开发者更专注于产品开发与优化。而 fir-cli是 fir.im 提供的一个可以通过指令查看, 上传, iOS/Android 应用的工具,想要在 CI/CD 环境中将应用提交到 fir.im 就需要安装这个工具。 fir-cli 使用 Ruby 构建, 无需编译, 只要安装相应 gem 即可.

$ ruby -v # > 2.6.1
$ gem install fir-cli

因此我们需要准备一个 Ruby 环境,在 .yml 文件末尾添加下列内容:

- uses: actions/cache@preview
      id: cache
      with:
        path: ~/local/rubies
        key: ruby-2.6.5    
    - uses: clupprich/ruby-build-action@master
      id: ruby
      with:
        ruby-version: 2.6.5
        files: app/build/outputs/apk/release/app-release.apk

参考模版在这里: GitHUb/Marketplace Actions Setup Ruby environment with ruby-build

Upload to fir.im

执行到这里就完成了 fir.im 运行环境的准备,下面就开始上传:

- name: install fir.im
      run: gem install fir-cli
- name: Upload to Fir.im
      run: fir login ${{ secrets.FIRTOKEN }}
- run: fir publish app/build/outputs/apk/release/app-release.apk

其中 FIRTOKEN 需要在代码仓库中设置,即 fir.im 账户中提供的 token。

C490731D-1496-453F-B9FB-A25F84320D2A.jpeg

接下来提交,触发构建,GitHub Action 就会完成指定的工作。

0B5D9692-D80D-492B-90CF-40DE21B28687.png

GitHub Action现在也提供了类似于上文提到的构建状态徽标,MarkDown 使用格式如下二选一:

https://github.com/
<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_NAME>/badge.svg

https://github.com/
<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_FILE_PATH>/badge.svg

例如我想要调用 songtianlunPlan Assistant 代码仓库中的 Android CI 工作流构建状态就可以通过 https://github.com/songtianlun/PlanAssistant/workflows/Android%20CI/badge.svg看到下图所示效果:

最后只需要下面这个网址,就可以下载到我的 Android 程序 PlanAssistant 最新内测版本了。而这一切的工作只需我进行一次代码提交,其他的 GitHub Action 就可以帮我完成,个人以为挺神奇的。

https://fir.im/xm19

End

终于完成本文,对 CI/CD 一直很感兴趣,目前在加拿大一台私有服务器部署自己的 Jenkins 并使用了几个月了(要问为什么是加拿大,还不是因为便宜,无奈忍受高延迟享受好计算力),现在GitHub 提供了这么好的平台对于目前毫无收入的我简直犹如久旱甘霖(下个月终于不用再承受不贵但还有点贵的续费费用)。而现在终于抽空研究通了使用 GitHub Action 替代 Jenkins 的方法。Jenkins 可私有部署,因而对于私密性要求较高的构建很友好,开源产品还提供了很方便美观的客户端,这就是开源的好处。而 GitHub 被 Microsoft 收购以后貌似其计算力提高了一大截,虽然现在主要服务还是部署在 Awazon Cloud Services ,国内访问需要忍受 AWS 国际版的高延迟,但其存在意义不言而喻。如果需要私有部署的代码仓库替代品有 GitLab、Gites等开源产品可私有部署,还有国内的 Gitea、Coding、DevCloud 等代码仓库服务,总是可以满足需求。而 CI/CD 在当前这个互联网节奏越来越快的时代一定会成为软件产品的必需品,总的来说折腾起来还是挺有意思的。

没想到写了这么久,更多详细的信息还可以在相关文献中阅读,GitHub Action 的使用实测在 Google 使用 English 检索可以找到更有意义的答案,对于我来说这也是一个难得的提高英语的途径了。

相关文献

[摘录] 哈利 · 波特 与混血王子(2005)

  1. The Prime Minister did not know what to say to this, but a persistent habit of wishing to appear well-informed on any subject that came up made him cast around for any details he could remember of their previous conversations. >>
  2. 首相听了这话,竟一时不知道该说什么好,但他有一个根深蒂固的习惯,不管谈论什么话题,他都要显示自己无所不知,因此他在记忆中苦苦搜寻他们前几次谈话的内容。 >>
  3. To his great surprise, the Prime Minister felt a fleeting stab of pity for Fudge at this point. It was, however, eclipsed almost immediately by a glow of smugness at the thought that, deficient though he himself might be in the area of materializing out of fireplaces, there had never been a murder in any of the government departments under his charge. … Not yet, anyway … >>
  4. 听到这里,首相突然间对福吉产生了恻隐之心,这使他自己也大为吃惊。不过,他的同情转瞬即逝,立刻就被一种自我得意的心情所取代。他想到,他虽说不具备从壁炉里显形的本领,但是在他所管辖的政府部门里,还从来没出过命案呢……至少现在还没有…… >>
  5. “So I suppose you’re going to tell me he caused the hurricane in the West Country too?” said the Prime Minister, his temper rising with every pace he took. It was infuriating to discover the reason for all these terrible disasters and not to be able to tell the public, almost worse than it being the government’s fault after all. >>
  6. “我想,你接着还会告诉我,西部的那场飓风也是他造成的吧?”首相问。他每走一步,心里的怒火就增长一分。他发现了所有那些可怕灾难的原因,却又不能告诉公众,这简直太令人生气了,如果真是政府的过失反倒还好一些。 >>
  7. “But,” said the Prime Minister, with a sense of dawning horror, “didn’t you tell me they’re the creatures that drain hope and happiness out of people?” >>
  8. “可是,”首相说,他心里渐渐产生了一种恐惧,“你不是告诉过我,它们这种生物是专门吸走人们的希望和快乐的吗?” >>
  9. “My dear Prime Minister, you can’t honestly think I’m still Minister of Magic after all this? I was sacked three days ago! The whole Wizarding community has been screaming for my resignation for a fortnight. I’ve never known them so united in my whole term of office!” said Fudge, with a brave attempt at a smile. >>
  10. 我亲爱的首相啊,发生这么多事情之后,你真的认为我还能当魔法部部长吗?我三天前就下台了!整个巫师界两个星期来一直叫嚷着要我辞职。我在任这么多年,还从没见过他们这么团结一致!”福吉说着勉强地笑了一下。 >>
  11. Dear Harry, If it is convenient to you, I shall call at number four, Privet Drive this coming Friday at eleven p.m. to escort you to the Burrow, where you have been invited to spend the remainder of your school holidays. If you are agreeable, I should also be glad of your assistance in a matter to which I hope to attend on the way to the Burrow. I shall explain this more fully when I see you. Kindly send your answer by return of this owl. Hoping to see you this Friday, I am, yours most sincerely, Albus Dumbledore >>
  12. 亲爱的哈利: 如果你方便的话,我将在本星期五夜里十一点到女贞路四号来接你去陋居,他们邀请你在那里度过暑假剩余的日子。 另外,我在去陋居的路上要办一件事,若能得到你的协助我将非常高兴。详情见面时谈。 请将回信托这只猫头鹰捎回。星期五见。 你最忠实的阿不思·邓布利多 >>
  13. But Harry had not packed. It just seemed too good to be true that he was going to be rescued from the Dursleys after a mere fortnight of their company. He could not shrug off the feeling that something was going to go wrong — his reply to Dumbledore’s letter might have gone astray; Dumbledore could be prevented from collecting him; the letter might turn out not to be from Dumbledore at all, but a trick or joke or trap. Harry had not been able to face packing and then being let down and having to unpack again. The only gesture he had made to the possibility of a journey was to shut his snowy owl, Hedwig, safely in her cage. >>
  14. 可是哈利没有收拾行李。刚在德思礼家住了两个星期就要被解救出去,这件事太美妙了,不像是真的。他怎么也摆脱不了心头的疑虑,总觉得会有什么地方出差错——他给邓布利多的回信送到别处去了,邓布利多被耽搁了、不能来接他了,或者那封信根本不是邓布利多写来的, 而是一个玩笑、恶作剧或陷阱。如果高高兴兴地收拾好行李,到头来大失所望,还要把东西一件件地从箱子里再拿出来,哈利肯定会受不了的。对于可能到来的旅行,他惟一的举动就是把他那只雪白的猫头鹰海德薇牢牢地关在笼子里。 >>
  15. Harry ran down the stairs two at a time, coming to an abrupt halt several steps from the bottom, as long experience had taught him to remain out of arm’s reach of his uncle whenever possible. >>
  16. 哈利一步两级地冲下楼梯,在离楼底还有几级时猛地刹住脚步,长期以来的经验告诉他,任何时候都要尽量与姨父保持距离,别让姨父的手臂够着他。 >>
  17. It might have been the blatant wizardishness of his appearance, but it might, too, have been that even Uncle Vernon could sense that here was a man whom it would be very difficult to bully. >>
  18. 也许是邓布利多所显露出的惹人注目的巫师气质,也许只是因为就连弗农姨父也能感觉到,他很难在这个男人面前耀武扬威。 >>
  19. These words seemed to rouse Uncle Vernon. It was clear that as far as he was concerned, any man who could look at Harry and say “excellent” was a man with whom he could never see eye to eye. >>
  20. 这句话似乎唤醒了弗农姨父。显然对他来说,任何一个能够看着哈利说“太好了”的人,他都永远不可能跟那人达成共识。 >>
  21. “I don’t mean to be rude —” he began, in a tone that threatened rudeness in every syllable. >>
  22. “我不是故意失礼——”他说,话里的每一个音节都透着无礼。 >>
  23. Dudley scrambled out of the way as Dumbledore passed him. Harry, still clutching the telescope and trainers, jumped the last few stairs and followed Dumbledore, who had settled himself in the armchair nearest the fire and was taking in the surroundings with an expression of benign interest. He looked quite extraordinarily out of place. >>
  24. 邓布利多经过达力身边时,达力慌忙闪到一边。哈利跳下最后几级楼梯,跟着邓布利多进了客厅,手里仍然抓着望远镜和运动鞋。邓布利多在最靠近壁炉的扶手椅上坐了下来,带着善意的兴趣打量着房间里的一切。他看上去与周围的环境完全不协调。 >>
  25. He drew his wand so rapidly that Harry barely saw it; with a casual flick, the sofa zoomed forward and knocked the knees out from under all three of the Dursleys so that they collapsed upon it in a heap. Another flick of the wand and the sofa zoomed back to its original position. >>
  26. 他忽地拔出魔杖,快得哈利都没看清。魔杖轻轻一挥,沙发嗖地冲了过去,撞在德思礼家三个人的膝盖上。他们一下子没有站住脚,全都栽倒在沙发上,滚作一团。魔杖又是轻轻一挥,沙发又嗖地回到了原处。 >>
  27. As he replaced his wand in his pocket, Harry saw that his hand was blackened and shriveled; it looked as though his flesh had been burned away. >>
  28. 他把魔杖重新放回了口袋,这时哈利看见他的那只手既干枯又焦黑,好像上面的肉都被烧干了。 >>
  29. “I would assume that you were going to offer me refreshment,”Dumbledore said to Uncle Vernon, “but the evidence so far suggests that that would be optimistic to the point of foolishness.” >>
  30. “我本来以为你们会让我喝点儿什么,”邓布利多对弗农姨父说,“现在看来,这种期望是乐观到了可笑的程度。” >>
  31. He thought he would be haunted forever by the memory of Sirius prowling its dark musty rooms alone, imprisoned within the place he had wanted so desperately to leave. >>
  32. 他觉得自己一辈子都忘不了小天狼星曾经在那些昏暗发霉的房间里独自徘徊,被囚禁在那个他日夜渴望离开的地方。 >>
  33. Nobody was talking. Dumbledore was humming quietly, apparently quite at his ease, but the atmosphere was thicker than cold custard >>
  34. 没有一个人说话。邓布利多轻声哼着小曲儿,一副自得其乐的样子,但是屋里的空气比冰冻的牛奶蛋糊还要凝重。 >>
  35. Dumbledore paused, and although his voice remained light and calm, and he gave no obvious sign of anger, Harry felt a kind of chill emanating from him and noticed that the Dursleys drew very slightly closer together. >>
  36. 邓布利多停住了,尽管他的声音还是那么轻松、平静,脸上也没有表现出丝毫的怒容,但哈利感觉到他身上散发出一股寒意。他注意到德思礼一家互相挤缩得更紧了。 >>
  37. “You did not do as I asked. You have never treated Harry as a son. He has known nothing but neglect and often cruelty at your hands. The best that can be said is that he has at least escaped the appalling damage you have inflicted upon the unfortunate boy sitting between you.” >>
  38. “你们没有按我说的去做。你们从来不把哈利当成自己的儿子。他在你们手里,得到的只是忽视和经常性的虐待。不幸中的万幸,他至少逃脱了你们对坐在你们中间的那个倒霉男孩造成的那种可怕伤害。” >>
  39. None of the Dursleys said anything. Dudley was frowning slightly, as though he was still trying to work out when he had ever been mistreated. Uncle Vernon looked as though he had something stuck in his throat; Aunt Petunia, however, was oddly flushed. >>
  40. 德思礼一家谁也没有吭声。达力微微皱着眉头,似乎还在琢磨他到底受到了什么虐待。弗农姨父看上去像是喉咙里卡了什么东西。佩妮姨妈呢,却莫名其妙地涨红了脸。 >>
  41. “And now, Harry, let us step out into the night and pursue that flighty temptress, adventure.” >>
  42. “好了,哈利,让我们走进黑夜里,去追逐那个轻浮而诱人的妖妇——冒险吧。” >>
  43. Courtesy dictates that we offer fellow wizards the opportunity of denying us entry. >>
  44. 礼貌要求我们向别的巫师提供拒绝我们的机会。 >>
  45. “No, I thought not. You have not asked me, for instance, what is my favorite flavor of jam, to check that I am indeed Professor Dumbledore and not an impostor.” >>
  46. “是啊,我也认为没用。比如,你并没有问我最喜欢哪一种果酱, 以此来检验我是否确实是邓布利多教授,而不是一个冒牌货。” >>
  47. He seemed remarkably unabashed for a man who had just been discovered pretending to be an armchair. >>
  48. 看来他的脸皮厚得惊人,要知道他刚刚可是装成了一把扶手椅被人识破的。 >>
  49. He pushed past Harry, his face turned resolutely away with the air of a man trying to resist temptation. >>
  50. 他推开哈利走了过去,并且坚决地把脸转向一边,像在抵御什么诱惑似的。 >>
  51. Slughorn eyed Dumbledore balefully for a moment, then muttered, “I haven’t given them the chance. I’ve been on the move for a year. Never stay in one place more than a week. Move from Muggle house to Muggle house — the owners of this place are on holiday in the Canary Islands — it’s been very pleasant, I’ll be sorry to leave. It’s quite easy once you know how, one simple Freezing Charm on these absurd burglar alarms they use instead of Sneakoscopes and make sure the neighbors don’t spot you bringing in the piano.” >>
  52. 斯拉格霍恩恶狠狠地瞪了邓布利多片刻,然后低声说道:“我没有给他们机会。一年来,我一直行踪不定。待在一个地方从来不超过一个星期。从一处麻瓜住宅搬到另一处麻瓜住宅——这幢房子的主人正在加那利群岛 度假呢。我在这儿住得很舒服,真舍不得离开。一旦找到窍门就很容易啦,他们不用窥镜,而用那些可笑的防盗警报器,你只要在上面施一个冰冻魔咒,还有,搬钢琴进来时别让邻居们看见就行了。” >>
  53. “Professor Umbridge ran afoul of our centaur herd,” said Dumbledore. “I think you, Horace, would have known better than to stride into the forest and call a horde of angry centaurs ‘filthy half-breeds.’ ” >>
  54. “乌姆里奇教授跟我们的那些马人发生了冲突。”邓布利多说道,“我想,霍拉斯,你肯定不会大摇大摆地走进禁林,管一群愤怒的马人叫‘肮脏的杂种’吧。” >>
  55. “Hmpf. Yes, well. You shouldn’t have favorites as a teacher, of course, but she was one of mine. Your mother,” Slughorn added, in answer to Harry’s questioning look. “Lily Evans. One of the brightest I ever taught. Vivacious, you know. Charming girl. I used to tell her she ought to have been in my House. Very cheeky answers I used to get back too.” >>
  56. “哼,是啊。当然啦,作为一名教师,是不应该偏爱学生的,但我就是偏爱她。你的母亲,”斯拉格霍恩看到哈利疑问的目光,补充道,“莉莉·伊万丝,是我教过的最聪明的学生之一。活泼可爱。一个迷人的姑娘。我经常对她说,她应该在我的学院才是。我经常得到她很不客气的回答。” >>
  57. Slughorn seemed agitated. He twiddled his fat thumbs and fidgeted as he watched Dumbledore fasten his traveling cloak, and Harry zip up his jacket. >>
  58. 斯拉格霍恩显得很不安。他摆弄着两根胖胖的大拇指,焦虑地看着邓布利多裹紧了旅行斗篷,哈利拉上了他的夹克衫拉链。 >>
  59. “Yes, yes,” said Slughorn impatiently. “I must be mad, but yes.” >>
  60. “是啊,是啊,”斯拉格霍恩不耐烦地说,“我肯定是疯了,但是没错,我愿意。” >>
  61. Harry had a sudden and vivid mental image of a great swollen spider, spinning a web around it, twitching a thread here and there to bring its large and juicy flies a little closer. >>
  62. 哈利脑海里立刻出现了一只胖鼓鼓的大蜘蛛,它这里吐一根丝,那里吐一根丝,在身体周围结了一张网,把美味多汁的大苍蝇引到自己身边来。 >>
  63. “I hope you will forgive me for mentioning it, Harry, but I am pleased and a little proud at how well you seem to be coping after everything that happened at the Ministry. Permit me to say that I think Sirius would have been proud of you.” >>
  64. “哈利,希望你能原谅我提起这个话题,但是在部里发生了那些事情之后,你似乎一直对付得不错,对此我很高兴,还有点儿自豪。请允许我说一句,我认为小天狼星也会为你感到自豪的。” >>
  65. “It’s just hard,” Harry said finally, in a low voice, “to realize he won’t write to me again.” >>
  66. “很难相信,”哈利终于低声说道,“他再也不会给我写信了。” >>
  67. “Sirius represented much to you that you had never known before,” said Dumbledore gently. “Naturally, the loss is devastating. …” >>
  68. “对你来说,小天狼星代表着许多你以前从不知道的东西。”邓布利多温和地说,“失去他肯定令你感到无比痛苦……” >>
  69. “But while I was at the Dursleys’ …” interrupted Harry, his voice growing stronger, “I realized I can’t shut myself away or — or crack up. Sirius wouldn’t have wanted that, would he? And anyway, life’s too short. …Look at Madam Bones, look at Emmeline Vance. … It could be me next, couldn’t it? But if it is,” he said fiercely, now looking straight into Dumbledore’s blue eyes gleaming in the wandlight, “I’ll make sure I take as many Death Eaters with me as I can, and Voldemort too if I can manage it.” >>
  70. “可是我在德思礼家的时候,”哈利打断了他的话,声音变得有力了,“我知道我不能把自己封闭起来,也不能——不能自暴自弃。小天狼星肯定不愿意这样,是吗?而且生命太短暂了……看看博恩斯夫人, 看看爱米琳·万斯……下一个可能就是我,对吗?如果真的轮到我,”他直视着邓布利多那双在魔杖的亮光下闪烁的蓝眼睛,激动地说道,“我一定要尽量多消灭几个食死徒,如果可能的话,就跟伏地魔同归于尽。” >>
  71. “Spoken both like your mother and father’s son and Sirius’s true godson!” said Dumbledore, with an approving pat on Harry’s back. “I take my hat off to you — or I would, if I were not afraid of showering you in spiders. >>
  72. “说得好,不愧是你父母的儿子、小天狼星的教子!”邓布利多说着赞许地拍了拍哈利的后背,“我要脱帽向你表示敬意——我很想这么做,但我担心会弄得你满身都是蜘蛛。 >>
  73. “A wise decision, on the whole,” said Dumbledore. “Although I think you ought to relax it in favor of your friends, Mr. Ronald Weasley and Miss Hermione Granger. Yes,” he continued, when Harry looked startled, “I think they ought to know. You do them a disservice by not confiding something this important to them.” >>
  74. “总的来说,这么做是明智的,”邓布利多说,“不过我认为你不妨在你的朋友罗恩·韦斯莱先生和赫敏·格兰杰小姐面前松松口。是啊,”看到哈利惊愕的神色,他又说道,“我认为可以让他们知道。你把这么重要的事情瞒着他们,会伤害他们的感情的。” >>
  75. “— to worry or frighten them?” said Dumbledore, surveying Harry over the top of his half-moon spectacles. “Or perhaps, to confess that you yourself are worried and frightened? You need your friends, Harry. As you so rightly said, Sirius would not have wanted you to shut yourself away.” >>
  76. “——让他们担惊受怕?”邓布利多从他的半月形眼镜片上方打量着哈利,说道,“或者,不想坦白你自己的担心和恐惧?哈利,你需要朋友。你刚才说得对,小天狼星肯定不愿意你把自己封闭起来。” >>
  77. “I think the word ‘fiasco’ would be a good one here,” said Dumbledore, nodding. Harry laughed. >>
  78. “我认为‘彻底失败’这个词用在这里很合适。”邓布利多点点头说。 哈利笑了起来。 >>
  79. “And lastly, while you stay here, the Burrow has been given the highest security the Ministry of Magic can provide. These measures have caused a certain amount of inconvenience to Arthur and Molly — all their post, for instance, is being searched at the Ministry before being sent on. They do not mind in the slightest, for their only concern is your safety. However, it would be poor repayment if you risked your neck while staying with them.” >>
  80. “最后,你住在这里时,陋居得到了魔法部所能提供的最严密的安全保护。这些措施给亚瑟和莫丽带来了一定程度的不便——比如,他们所有的邮件都要经部里审查后才能送达。但他们丝毫不介意,一心只牵挂着你的安全。可是,如果你跟他们住在一起时冒险胡来,可就太对不起他们了。” >>
  81. Let us not deprive Molly any longer of the chance to deplore how thin you are. >>
  82. 我们就让莫丽赶紧有机会哀叹你有多么瘦吧。 >>
  83. Hedwig hooted happily at Harry from her perch on top of a large wardrobe, then took off through the window; Harry knew she had been waiting to see him before going hunting. >>
  84. 海德薇在一个大衣柜顶上朝哈利高兴地叫了几声,然后便振翅飞出了窗外,哈利知道它一直在等着见他一面之后才去觅食。 >>
  85. It was the same last time he was powerful, people eloping left, right, and center —”“Including you and Dad,” said Ginny slyly. >>
  86. 上次神秘人得势的时候就是这样,到处都有人私奔——”“包括你和爸爸。”金妮调皮地说。 >>
  87. “Dumbledore says people find it far easier to forgive others for being wrong than being right,” said Hermione. >>
  88. “邓布利多说,人们容易原谅别人的错误,却很难原谅别人的正确。”赫敏说 >>
  89. Harry did not really listen. A warmth was spreading through him that had nothing to do with the sunlight; a tight obstruction in his chest seemed to be dissolving. He knew that Ron and Hermione were more shocked than they were letting on, but the mere fact that they were still there on either side of him, speaking bracing words of comfort, not shrinking from him as though he were contaminated or dangerous, was worth more than he could ever tell them. >>
  90. 哈利并没有认真地听。他感到全身暖融融的,而且这暖意跟阳光毫无关系,堵在他胸口的那块东西似乎正在渐渐融化。他知道罗恩和赫敏并没有把内心的恐惧都显露出来,但看到他们仍然和他站在一起,说着安慰和鼓励的话,而没有把他当成异类或危险分子,远远地躲开,他觉得这价值是他无法用语言向他们表达的。 >>
  91. Mrs. Weasley squeezed past them and opened the kitchen window. One, two, three, the owls soared through it and landed on the table in a neat line. All three of them lifted their right legs. >>
  92. 韦斯莱夫人挤过他们身边,打开了厨房的窗户。一只、两只、三只猫头鹰从窗口飞了进来,落在桌子上,整整齐齐地站成一排,步调一致地抬起了右腿。 >>
  93. ORDINARY WIZARDING LEVEL RESULTS Pass Grades Fail Grades Outstanding (O) Poor (P) Exceeds Expectations (E) Dreadful (D) Acceptable (A) Troll (T) >>
  94. “Well, we’re N.E.W.T. students now!” grinned Ron. “Mum, are there any more sausages?” >>
  95. “太好了,我们现在是N.E.W.Ts的学生了!”罗恩笑着说,“妈妈,还有香肠吗?” >>
  96. It was odd, really, seeing that it had been a Death Eater in disguise who had first told Harry he would make a good Auror, but somehow the idea had taken hold of him, and he couldn’t really think of anything else he would like to be. Moreover, it had seemed the right destiny for him since he had heard the prophecy a few weeks ago. … Neither can live while the other survives. … Wouldn’t he be living up to the prophecy, and giving himself the best chance of survival, if he joined those highly trained wizards whose job it was to find and kill Voldemort? >>
  97. 说来也奇怪,最初告诉哈利他会成为一名出色的傲罗的,是一个伪装的食死徒,但不知怎的,这个想法在哈利心里生了根,他想象不出除此之外他还愿意做什么。而且,自从一个月前听了那个预言之后,这似乎已是他注定的命运……两个人不能都活着……如果他加入那支足智多谋、以追捕和消灭伏地魔为己任的巫师队伍,他岂不是就能实施那个预言,给自己一个最大的生存机会吗? >>
  98. “That’s right. … Well, we thought Shield Hats were a bit of a laugh, you know, challenge your mate to jinx you while wearing it and watch his face when the jinx just bounces off. But the Ministry bought five hundred for all its support staff! And we’re still getting massive orders!” >>
  99. “没错……嘿,我们本来以为防咒帽只是一种搞笑的玩意儿。你知道的,就是你戴着这种帽子叫你的同伴给你施恶咒,然后你盯着他的脸,恶咒就会反弹出去。没想到魔法部给他们所有的工作人员买了五百顶!现在我们还不断接到大额订单呢!” >>
  100. “Our feet’ll be seen!” said Hermione anxiously, as the cloak flapped a little around their ankles; it was much more difficult hiding all three of them under the cloak nowadays. >>
  101. “我们的脚会被人看见的!”赫敏担心地说,因为隐形衣的下摆在他们脚脖子周围掀动着。如今,他们三个人藏在它下面比以前困难多了。 >>
  102. “People expect you to have cooler friends than us,” said Luna, once again displaying her knack for embarrassing honesty. >>
  103. “人们认为你应该有比我们更带劲的朋友。”卢娜说,又一次显示了她哪壶不开提哪壶的本领。 >>
  104. You should hear my gran talk about you. ‘That Harry Potter’s got more backbone than the whole Ministry of Magic put together!’ >>
  105. 你真该听听我奶奶是怎么说你的。‘那个哈利·波特比整个魔法部的人加在一起还有骨气!’ >>
  106. “A Wrackspurt … They’re invisible. They float in through your ears and make your brain go fuzzy,” she said. “I thought I felt one zooming around in here.” >>
  107. “骚扰虻……它们是隐形的,会飘到你耳朵里,把你的脑子搞乱。”她说,“我刚才好像觉得有一只在这里嗡嗡地飞。” >>
  108. He contemplated Harry for a moment as though he was a particularly large and succulent piece of pheasant >>
  109. 他沉思地端详着哈利,似乎哈利是一只肥墩墩的、美味多汁的鹌鹑 >>
  110. The fury and hatred bubbling inside Harry seemed to blaze white-hot, but he would rather have been immobilized all the way back to London than tell Snape why he was late. >>
  111. 哈利内心的愤怒和仇恨简直白热化了,他宁愿全身僵硬地返回伦敦,也不愿告诉斯内普他迟到的原因。 >>
  112. Still Harry remained silent, though he thought his chest might explode. He knew that Snape had come to fetch him for this, for the few minutes when he could needle and torment Harry without anyone else listening. >>
  113. 哈利仍然保持着沉默,尽管他觉得肺都要气炸了。他知道斯内普来接他就是为了这个,他可以有几分钟时间激怒和折磨哈利,而不会被任何人听见。 >>
  114. “It looks as if it’s died,” said Hermione, with a nauseated expression. “But there are some injuries you can’t cure … old curses … and there are poisons without antidotes. …” >>
  115. “那只手看上去像是死了。”赫敏脸上带着难受的表情说,“有些伤永远治不好……古老的咒语……还有一些魔药是没有解药的……” >>
  116. Harry told him. It was a mark of the strength of their friendship that Ron did not laugh. >>
  117. 哈利把事情告诉了他。罗恩没有笑,这显示了他们的友谊是多么牢固。 >>
  118. In fact, his ability to speak to serpents did not make me nearly as uneasy as his obvious instincts for cruelty, secrecy, and domination. >>
  119. 事实上,他与蛇对话的能力并没有使我感到很不安,令我担心的是他明显表现出来的那种残酷、诡秘和霸道的天性。 >>
  120. I trust that you also noticed that Tom Riddle was already highly self- sufficient, secretive, and, apparently, friendless? >>
  121. 我相信你同样也注意到了,汤姆·里德尔当时已经极为自信,讳莫如深,而且显然没有一个朋友。 >>
  122. “Very astute, Harry, but the mouth organ was only ever a mouth organ.” >>
  123. “眼光很敏锐,哈利,但口琴只是一把口琴而已。” >>
  124. It was as though something large and scaly erupted into life in Harry’s stomach, clawing at his insides: Hot blood seemed to flood his brain, so that all thought was extinguished, replaced by a savage urge to jinx Dean into a jelly. Wrestling with this sudden madness, he heard Ron’s voice as though from a great distance away. >>
  125. 似乎有个全身长鳞的大家伙在哈利心头突然活了起来,并用爪子抓挠着他的五脏六腑,热血一下子冲上了他的脑袋,所有的理性都被压制住了,取而代之的是一股强烈的冲动,只想用恶咒把迪安变成一堆果子冻。他与这种突如其来的疯狂念头搏斗着,听见罗恩的声音像是从很远的地方传来。 >>
  126. Hermione slid off the desk. The little flock of golden birds continued to twitter in circles around her head so that she looked like a strange, feathery model of the solar system. >>
  127. 赫敏从讲台上滑了下来。那群金黄色的小鸟继续围着她的脑袋叽叽喳喳地飞着,这使她看上去像一个奇怪的、长着羽毛的太阳系模型。 >>
  128. “I’m not talking about your stupid so-called Prince,” said Hermione, giving his book a nasty look as though it had been rude to her. “I’m talking about earlier. I went into the girls’ bathroom just before I came in here and there were about a dozen girls in there, including that Romilda Vane, trying to decide how to slip you a love potion. They’re all hoping they’re going to get you to take them to Slughorn’s party, and they all seem to have bought Fred and George’s love potions, which I’m afraid to say probably work —” >>
  129. “我不是说你那个愚蠢的所谓王子,”赫敏凶巴巴地瞪了他的书一眼,好像它招惹了她似的,“我是说刚才,到这儿来之前,我去盥洗室,那儿有一打女孩子,包括罗米达·万尼,都在讨论着怎么能让你喝下迷情剂。她们都希望能被你带去参加斯拉格霍恩的晚会,而且好像都买了弗雷德和乔治的迷情剂——” >>
  130. Parvati positively beamed. Harry could tell that she was feeling guilty for having laughed at Hermione in Transfiguration. He looked around and saw that Hermione was beaming back, if possible even more brightly. Girls were very strange sometimes. >>
  131. 帕瓦蒂满脸带笑,哈利看得出她在为变形课上笑了赫敏感到内疚。 他扭头一看,见赫敏也是一副笑容,如果可能的话,甚至可以说是灿烂的笑容。女孩子有时真是很奇怪。 >>
  132. She left. At once Lavender and Parvati put their heads together to discuss this new development, with everything they had ever heard about McLaggen, and all they had ever guessed about Hermione. Ron looked strangely blank and said nothing. Harry was left to ponder in silence the depths to which girls would sink to get revenge. >>
  133. 她走了。拉文德和帕瓦蒂马上把脑袋凑在一起议论着这个新情况, 包括她们对麦克拉根的一切耳闻,以及她们对赫敏的一切猜测。罗恩表情异常麻木,一言不发。哈利留在那儿,思考着女孩子为了报复可以陷得有多深。 >>
  134. Fred, George, Harry, and Ron were the only ones who knew that the angel on top of the tree was actually a garden gnome that had bitten Fred on the ankle as he pulled up carrots for Christmas dinner. Stupefied, painted gold, stuffed into a miniature tutu and with small wings glued to its back, it glowered down at them all, the ugliest angel Harry had ever seen, with a large bald head like a potato and rather hairy feet. >>
  135. 只有弗雷德、乔治、哈利和罗恩知道圣诞树顶上的小天使其实是一个花园小地精。弗雷德在拔圣诞晚餐用的胡萝卜时被这个小地精咬了脚踝,于是它被施了昏迷咒,涂成金色,塞进了一件小芭蕾舞裙,背上粘了对小翅膀,在树顶上对他们怒目而视。这是哈利见过的最丑的天使,长着土豆似的大秃脑袋,脚上还有毛。 >>
  136. And the rest of the evening passed amicably with both of them abusing the Minister of Magic, for Hermione, like Ron, thought that after all the Ministry had put Harry through the previous year, they had a great deal of nerve asking him for help now. >>
  137. 晚上剩下的时间是在友好的气氛中度过的,两人共同批判了魔法部长。赫敏跟罗恩一样认为,魔法部去年让哈利吃了那么多苦头,现在又来找他帮忙,脸皮真够厚的。 >>
  138. Lost in visions of this happy prospect, he flicked his wand a little too enthusiastically, so that instead of producing the fountain of pure water that was the object of today’s Charms lesson, he let out a hoselike jet that ricocheted off the ceiling and knocked Professor Flitwick flat on his face. >>
  139. 他沉浸在憧憬中,魔杖挥得劲太足了点儿,把那天魔咒课作业要变的一股清泉变成了一道水龙,射到天花板上反弹下来,正打在弗立维教授的脸上。 >>
  140. “Ah, Harry, how often this happens, even between the best of friends! Each of us believes that what he has to say is much more important than anything the other might have to contribute!” >>
  141. “啊,哈利,这是多么常见的事情,即使在最好的朋友之间!我们都相信自己要说的比对方的重要得多!” >>
  142. I believe that it was then that he dropped the name forever, assumed the identity of Lord Voldemort, and began his investigations into his previously despised mother’s family — the woman whom, you will remember, he had thought could not be a witch if she had succumbed to the shameful human weakness of death. >>
  143. 我相信就是在那时他抛弃了这个名字,改称伏地魔的,并开始调查以前被他轻视的他母亲的家史——你应该记得,他认为那个女人既然屈从于死亡这一人类的可耻弱点,就不可能是巫师。 >>
  144. Harry could not help but feel a resentful admiration for Voldemort’s complete lack of fear. >>
  145. 哈利不禁对伏地魔的毫无畏惧感到一种恼火的钦佩。 >>
  146. “You are quite right — they can detect magic, but not the perpetrator: You will remember that you were blamed by the Ministry for the Hover Charm that was, in fact, cast by —” >>
  147. “你说得很对——他们能测出魔法,但测不出施魔法者:你还记得魔法部指控你施了悬停魔咒,而实际上是——” >>
  148. “The important things to remember when Apparating are the three D’s!”said Twycross. “Destination, Determination, Deliberation! >>
  149. “幻影显形时最重要的是要记住三个D!”泰克罗斯说,“即目标,决心,从容 !” >>
  150. “Half our family does seem to owe you their lives, now I stop and think about it,” Mr. Weasley said in a constricted voice. “Well, all I can say is that it was a lucky day for the Weasleys when Ron decided to sit in your compartment on the Hogwarts Express, Harry.” >>
  151. “还真是,现在想起来,我们家好像有一半人的命都是你救的。”韦斯莱先生说,他的嗓子眼有些发紧,“我只能说,罗恩在霍格沃茨特快列车上决定坐在你的车厢里,那真是幸运的一天,哈利。” >>
  152. “Ginny came in to visit while you were unconscious,” he said, after a long pause, and Harry’s imagination zoomed into overdrive, rapidly constructing a scene in which Ginny, weeping over his lifeless form, confessed her feelings of deep attraction to him while Ron gave them his blessing. … >>
  153. “你昏迷的时候金妮来过。”停了好长时间,他说。哈利的想象立刻超速运转起来,飞快构思出一幕画面——金妮对着他没有知觉的身体抽泣,表白着她对他深深的爱恋,罗恩为他们俩祝福…… >>
  154. “I see,” said Dumbledore eventually, peering at Harry over the top of his half-moon spectacles and giving Harry the usual sensation that he was being X-rayed. “And you feel that you have exerted your very best efforts in this matter, do you? That you have exercised all of your considerable ingenuity? That you have left no depth of cunning unplumbed in your quest to retrieve the memory?” >>
  155. “噢,”邓布利多从半月形的眼镜片上方盯着哈利,哈利又有一种被X光照射的感觉,“你觉得已经尽了最大努力,是吗?已经充分发挥了你的聪明才智?想尽了一切点子?” >>
  156. A hot, prickly feeling of shame spread from the top of Harry’s head all the way down his body. Dumbledore had not raised his voice, he did not even sound angry, but Harry would have preferred him to yell; this cold disappointment was worse than anything. >>
  157. 一阵火辣辣的、针扎一般的羞耻感从哈利的头顶传遍全身。邓布利多没有提高嗓门,甚至话语中也没带怒气,但哈利宁愿他大吼大叫,这种冰冷的失望比什么都令人难受。 >>
  158. Silence fell between them again, the most uncomfortable silence Harry had ever experienced with Dumbledore; it seemed to go on and on, punctuated only by the little grunting snores of the portrait of Armando Dippet over Dumbledore’s head. Harry felt strangely diminished, as though he had shrunk a little since he had entered the room. >>
  159. 两人又沉默了,这是哈利在邓布利多身边经历过的最难堪的沉默, 它似乎无休无止,只是时而被邓布利多头顶上阿芒多·迪佩特哼哼哧哧的鼾声打断。哈利有一种奇怪的渺小感,好像自己进屋后缩小了。 >>
  160. “I believe he had several reasons, though he confided none of them to Professor Dippet,” said Dumbledore. “Firstly, and very importantly, Voldemort was, I believe, more attached to this school than he has ever been to a person. Hogwarts was where he had been happiest; the first and only place he had felt at home.” >>
  161. “我相信他有好几条理由,尽管他一条也没有告诉迪佩特教授。”邓布利多说,“首先,很重要的一条是,伏地魔对这所学校比他对任何个人更有感情。霍格沃茨是他最开心的地方,是他感到像家的第一个也是惟一的地方。” >>
  162. “So Voldemort went off to Borgin and Burkes, and all the staff who had admired him said what a waste it was, a brilliant young wizard like that, working in a shop. However, Voldemort was no mere assistant. Polite and handsome and clever, he was soon given particular jobs of the type that only exist in a place like Borgin and Burkes, which specializes, as you know, Harry, in objects with unusual and powerful properties. Voldemort was sent to persuade people to part with their treasures for sale by the partners, and he was, by all accounts, unusually gifted at doing this.” >>
  163. “伏地魔去了博金-博克,所有欣赏他的教员都说可惜,那样一个才华出众的年轻巫师去当了店员。但伏地魔不只是店员。他因为彬彬有礼,英俊聪明,很快就得到了只有博金-博克这种地方才有的特殊工作。你知道,哈利,这家店专销有特异性能的物品。伏地魔被派去说服别人将宝物交给店里出售,据说,他对此事特别擅长。” >>
  164. “So, Tom … to what do I owe the pleasure?” >>
  165. “那么,汤姆……是什么风把你吹来的?” >>
  166. He raised his glass as though toasting Voldemort, whose face remained expressionless. Nevertheless, Harry felt the atmosphere in the room change subtly: Dumbledore’s refusal to use Voldemort’s chosen name was a refusal to allow Voldemort to dictate the terms of the meeting, and Harry could tell that Voldemort took it as such. >>
  167. 他举起杯子,像要跟伏地魔干杯。伏地魔还是面无表情。但哈利感到屋里的气氛发生了微妙的变化:邓布利多拒绝用伏地魔选定的称呼, 是拒绝让伏地魔支配谈话。哈利看得出伏地魔也感觉到了。 >>
  168. Voldemort’s expression remained impassive as he said, “Greatness inspires envy, envy engenders spite, spite spawns lies. You must know this, Dumbledore.”“You call it ‘greatness,’ what you have been doing, do you?” asked Dumbledore delicately. >>
  169. 伏地魔依然面无表情,说道:“伟大引起嫉妒,嫉妒导致怨毒,怨毒滋生谎言。这你一定了解,邓布利多。”“你把你的所作所为称为‘伟大’,是吗?”邓布利多优雅地问。 >>
  170. For the first time, Voldemort smiled. It was a taut leer, an evil thing, more threatening than a look of rage. >>
  171. 伏地魔第一次笑了,那是一种睥睨的讥笑,邪恶的表情,比暴怒更加可怕。 >>
  172. “The old argument,” he said softly. “But nothing I have seen in the world has supported your famous pronouncements that love is more powerful than my kind of magic, Dumbledore.” >>
  173. “老论调,”他轻声说,“可是,邓布利多,我在世上所见没有一样能证明你那著名的观点:爱比我那种魔法更加强大。” >>
  174. Dumbledore set down his empty glass and drew himself up in his seat, the tips of his fingers together in a very characteristic gesture. >>
  175. 邓布利多放下空杯子,坐直身子,双手指尖碰在一起,这是他惯有的姿势。 >>
  176. “No, nothing,” said Dumbledore, and a great sadness filled his face. “The time is long gone when I could frighten you with a burning wardrobe and force you to make repayment for your crimes. But I wish I could, Tom. … I wish I could. …” >>
  177. “没有了。”邓布利多说,脸上露出深深的悲哀,“我能用燃烧的衣柜吓住你,迫使你赎罪的时间早已过去。可我希望能,汤姆……我希望能……” >>
  178. Harry did not answer for a moment. Then, slowly but surely, an exhilarating sense of infinite opportunity stole through him; he felt as though he could have done anything, anything at all … and getting the memory from Slughorn seemed suddenly not only possible, but positively easy. … >>
  179. 哈利一时没有回答,接着,慢慢地但是确确实实地,一种无比振奋的感觉流向全身,仿佛有无限的机会。他感到自己能做任何事,一切事……从斯拉格霍恩那里搞到记忆突然好像不仅可能,而且简直是轻而易举…… >>
  180. Slughorn raised a pudgy hand and pressed his shaking fingers to his mouth; he looked for a moment like an enormously overgrown baby. >>
  181. 斯拉格霍恩举起胖手,把颤抖的手指按到嘴上,他一时看上去像个庞大的婴儿。 >>
  182. It was very well done, thought Harry, the hesitancy, the casual tone, the careful flattery, none of it overdone. He, Harry, had had too much experience of trying to wheedle information out of reluctant people not to recognize a master at work. He could tell that Riddle wanted the information very, very much; perhaps had been working toward this moment for weeks. >>
  183. 恰到好处,哈利想,那种犹豫、不经意的语气,巧妙的恭维,一点儿都没有过火。哈利自己有过太多从不情愿的人嘴里套取信息的经历, 不会认不出一个行家。他看得出里德尔非常非常想要这个信息,也许为这一刻已经筹划了好几个星期。 >>
  184. “Well, you split your soul, you see,” said Slughorn, “and hide part of it in an object outside the body. Then, even if one’s body is attacked or destroyed, one cannot die, for part of the soul remains earthbound and undamaged. But of course, existence in such a form …” >>
  185. “就是说,你把你的灵魂分裂开,”斯拉格霍恩说,“将一部分藏在身体外的某个物体中。这样,即使你的身体遭到袭击或摧毁,你也死不了,因为还有一部分灵魂留在世间,未受损害。但是,当然,以这种形式存在……” >>
  186. “By an act of evil — the supreme act of evil. By committing murder. Killing rips the soul apart. The wizard intent upon creating a Horcrux would use the damage to his advantage: He would encase the torn portion —” >>
  187. “通过邪恶的行为——最邪恶的行为,通过谋杀。杀人会使灵魂分裂,想要制造魂器的巫师则利用这种破坏,把分裂出的灵魂碎片封存——” >>
  188. Yet it fitted: Lord Voldemort has seemed to grow less human with the passing years, and the transformation he has undergone seemed to me to be only explicable if his soul was mutilated beyond the realms of what we might call ‘usual evil’ >>
  189. 种种迹象都很吻合——这些年来伏地魔似乎变得越来越不像人,我想那种变形只能解释为,他的灵魂受到的破坏超出了我们所说的一般邪恶的范围…… >>
  190. “So,” said Harry, “the diary’s gone, the ring’s gone. The cup, the locket, and the snake are still intact, and you think there might be a Horcrux that was once Ravenclaw’s or Gryffindor’s?” >>
  191. “那,日记毁了,戒指毁了,杯子、挂坠盒和蛇还在,你认为还有一个魂器可能是拉文克劳或格兰芬多的遗物?” >>
  192. “I know!” said Harry impatiently. “I can love!” It was only with difficulty that he stopped himself adding, “Big deal!”“Yes, Harry, you can love,” said Dumbledore, who looked as though he knew perfectly well what Harry had just refrained from saying. “Which, given everything that has happened to you, is a great and remarkable thing. You are still too young to understand how unusual you are, Harry.” >>
  193. “我知道!”哈利不耐烦地说,“我有爱!”他好容易才没有加上:“有什么了不起!”“是的,哈利,你有爱,”邓布利多好像十分了解哈利舌头底下压着的话,“想想你经历的一切,这是非常了不起的。你还太年轻,不知道你是多么特殊,哈利。” >>
  194. “Yes — just love,” said Dumbledore. “But Harry, never forget that what the prophecy says is only significant because Voldemort made it so. I told you this at the end of last year. Voldemort singled you out as the person who would be most dangerous to him — and in doing so, he made you the person who would be most dangerous to him!” >>
  195. “对——就是爱。”邓布利多说,“但是哈利,永远不要忘记,预言的意义只是伏地魔造成的。我去年年底跟你讲过这一点。伏地魔把你当成对他最危险的人——而这样一来,他就使你变成了对他最危险的人!” >>
  196. “Harry, Harry, only because Voldemort made a grave error, and acted on Professor Trelawney’s words! If Voldemort had never murdered your father, would he have imparted in you a furious desire for revenge? Of course not! If he had not forced your mother to die for you, would he have given you a magical protection he could not penetrate? Of course not, Harry! Don’t you see? Voldemort himself created his worst enemy, just as tyrants everywhere do! Have you any idea how much tyrants fear the people they oppress? All of them realize that, one day, amongst their many victims, there is sure to be one who rises against them and strikes back! Voldemort is no different! Always he was on the lookout for the one who would challenge him. He heard the prophecy and he leapt into action, with the result that he not only handpicked the man most likely to finish him, he handed him uniquely deadly weapons!” >>
  197. “哈利呀,哈利,那只是因为伏地魔犯了个大错误,他按特里劳妮教授的预言采取了行动!如果伏地魔没有杀死你父亲,会让你产生强烈的复仇欲望吗?当然不会!如果他没有逼你母亲为你而死,会让你得到他无法穿透的魔法保护吗?当然不会!哈利。你看不到吗?伏地魔自己制造了他最可怕的敌人,就像普天下的暴君一样!你知道暴君多么害怕被压迫的人民吗?他们都知道总有一天,在众多受害者中会有一个起来奋起反击!伏地魔也一样。他总是在寻找那个会向他挑战的人,听到预言后就马上行动,结果他不仅亲手选出了那个最有可能除掉他的人,而且给了他一件特别致命的武器!” >>
  198. “It is essential that you understand this!” said Dumbledore, standing up and striding about the room, his glittering robes swooshing in his wake; Harry had never seen him so agitated. “By attempting to kill you, Voldemort himself singled out the remarkable person who sits here in front of me, and gave him the tools for the job! It is Voldemort’s fault that you were able to see into his thoughts, his ambitions, that you even understand the snakelike language in which he gives orders, and yet, Harry, despite your privileged insight into Voldemort’s world (which, incidentally, is a gift any Death Eater would kill to have), you have never been seduced by the Dark Arts, never, even for a second, shown the slightest desire to become one of Voldemort’s followers!” >>
  199. “你必须明白这一点!”邓布利多站了起来,在屋子里大步地走来走去,闪亮的袍子在身后呼呼飘动。哈利还从没见他这么激动过,“在企图杀你的时候,伏地魔就亲自选出了坐在我面前的这个卓越的人,并为他提供了工具!你能看到伏地魔的思想、野心,甚至能听懂他发令时那蛇说话般的语言,这都只能怪他自己。可是,哈利,尽管你能洞察伏地魔的世界——要知道,这是任何食死徒不惜用杀人来换取的能力,但你却从未接受黑魔法的诱惑,从未显露过丝毫想要追随伏地魔的欲望,一秒钟都没有!” >>
  200. “You are protected, in short, by your ability to love!” said Dumbledore loudly. “The only protection that can possibly work against the lure of power like Voldemort’s! In spite of all the temptation you have endured, all the suffering, you remain pure of heart, just as pure as you were at the age of eleven, when you stared into a mirror that reflected your heart’s desire, and it showed you only the way to thwart Lord Voldemort, and not immortality or riches. Harry, have you any idea how few wizards could have seen what you saw in that mirror? Voldemort should have known then what he was dealing with, but he did not! “But he knows it now. You have flitted into Lord Voldemort’s mind without damage to yourself, but he cannot possess you without enduring mortal agony, as he discovered in the Ministry. I do not think he understands why, Harry, but then, he was in such a hurry to mutilate his own soul, he never paused to understand the incomparable power of a soul that is untarnished and whole.” >>
  201. “简而言之,是你的爱保护了你!”邓布利多大声说,“惟有这种保护,才有可能抵御伏地魔那样的权力的诱惑!虽然经历了那么多诱惑, 那么多痛苦,你依然心地纯洁,还像你十一岁时那样。当时你向那面能照出你内心愿望的镜子中望去,看到的只有怎样挫败伏地魔,而没有永生和财富。哈利,你知不知道,世上没有几个巫师能看到你在镜中看到的东西?伏地魔那时就该知道他要对付的是什么,可惜他没有! “但他现在知道了。你侵入了伏地魔的思想而不受损害,他想附在你身上时却不能不忍受剧烈的痛苦,他在部里已经发现了这一点。但我想他不了解这是为什么,哈利。他那样忙于破坏自己的灵魂,从来无暇去了解一个纯洁健全的灵魂拥有何等无与伦比的力量。” >>
  202. Harry watched Dumbledore striding up and down in front of him, and thought. He thought of his mother, his father, and Sirius. He thought of Cedric Diggory. He thought of all the terrible deeds he knew Lord Voldemort had done. A flame seemed to leap inside his chest, searing his throat. >>
  203. 看着面前踱来踱去的邓布利多,哈利沉思起来。他想到了他的母亲、他的父亲和小天狼星,想到了塞德里克,想到了伏地魔的种种罪行。他的胸中腾起一股烈焰,直烧到喉咙口。 >>
  204. “Of course you would!” cried Dumbledore. “You see, the prophecy does not mean you have to do anything! But the prophecy caused Lord Voldemort to mark you as his equal. … In other words, you are free to choose your way, quite free to turn your back on the prophecy! But Voldemort continues to set store by the prophecy. He will continue to hunt you … which makes it certain, really, that —” >>
  205. “你当然会!”邓布利多叫道,“你看,预言并没表示你必须做什么!但预言使伏地魔认定你是他的对手……换句话说,你有权选择自己的道路,有权不理睬那个预言!但伏地魔还是会对它念念不忘,他会继续追杀你……所以确实是必然——” >>
  206. But he understood at last what Dumbledore had been trying to tell him. It was, he thought, the difference between being dragged into the arena to face a battle to the death and walking into the arena with your head held high. Some people, perhaps, would say that there was little to choose between the two ways, but Dumbledore knew — and so do I, thought Harry, with a rush of fierce pride, and so did my parents — that there was all the difference in the world. >>
  207. 他终于明白了邓布利多要告诉他的意思,那就是:被拽进角斗场去面对一场殊死搏斗和自己昂首走进去是不同的。也许有人会说这二者之间并无多少不同,但邓布利多知道——我也知道,哈利带着一阵强烈的自豪感想道,我父母也知道——这是世界上全部的不同。 >>
  208. “Coward,” said Hermione, though she looked amused. “Well, it was a bad night for romance all around. Ginny and Dean split up too, Harry.” >>
  209. “懦夫,”赫敏说道,不过看上去挺愉快的,“哎,昨晚好像罗曼司普遍不利,金妮和迪安也分手了,哈利。” >>
  210. . And to complicate matters, he had the nagging worry that if he didn’t do it, somebody else was sure to ask Ginny out soon: He and Ron were at least agreed on the fact that she was too popular for her own good. >>
  211. 更麻烦的是,他焦虑地想到如果自己不采取行动,肯定很快就会有别人约会金妮了。他和罗恩至少在这一点上看法是一致的:金妮太招人喜欢了,这对她本人没好处。 >>
  212. Harry and Ron stared: Hermione and Ginny, who had always got on together very well, were now sitting with their arms folded, glaring in opposite directions. Ron looked nervously at Harry, then snatched up a book at random and hid behind it. Harry, however, little though he knew he deserved it, felt unbelievably cheerful all of a sudden, even though none of them spoke again for the rest of the evening. >>
  213. 哈利和罗恩目瞪口呆——向来关系很好的赫敏和金妮现在都抱着胳膊坐在那里,眼睛瞪着相反的方向。罗恩不安地看看哈利,然后随手抓起一本书,躲到书后面去了。哈利虽然知道自己不配,却还是突然感到难以置信的快乐,尽管他们一晚上都没有再说话。 >>
  214. Harry looked around; there was Ginny running toward him; she had a hard, blazing look in her face as she threw her arms around him. And without thinking, without planning it, without worrying about the fact that fifty people were watching, Harry kissed her. >>
  215. 哈利看看周围,金妮向他奔来,她张开双臂抱住了他,脸上是一种炽烈的表情。于是,没有想,没有准备,没有担心有五十个人在看着, 哈利吻了她。 >>
  216. After several long moments — or it might have been half an hour — or possibly several sunlit days — they broke apart. The room had gone very quiet. Then several people wolf-whistled and there was an outbreak of nervous giggling. Harry looked over the top of Ginny’s head to see Dean Thomas holding a shattered glass in his hand, and Romilda Vane looking as though she might throw something. Hermione was beaming, but Harry’s eyes sought Ron. At last he found him, still clutching the Cup and wearing an expression appropriate to having been clubbed over the head. For a fraction of a second they looked at each other, then Ron gave a tiny jerk of the head that Harry understood to mean, Well — if you must. >>
  217. 过了长长的几分钟——也可能有半个小时——或阳光灿烂的几天——他们才分开了。屋里变得非常安静。然后有几个人吹起了口哨,有人不自然地吃吃笑了起来。哈利越过金妮的头顶,看到迪安手里举着一个破杯子,罗米达·万尼好像要摔东西,赫敏在笑,但哈利的眼睛在寻找罗恩,终于找到了,他还攥着奖杯,看上去像当头挨了一棍似的。两人对视了片刻,罗恩的脑袋微微动了一下,哈利知道那意思是:“好吧——如果你一定要。” >>
  218. “Enough,” said Dumbledore. He said it quite calmly, and yet Harry fell silent at once; he knew that he had finally crossed some invisible line. “Do you think that I have once left the school unprotected during my absences this year? I have not. Tonight, when I leave, there will again be additional protection in place. Please do not suggest that I do not take the safety of my students seriously, Harry.” >>
  219. “够了。”邓布利多说。虽然他说得极其平静,但是哈利马上沉默下来,因为他知道自己最终越过了一道看不见的底线,“你以为今年我有哪次是毫无保护措施就离开学校的吗?我还没有过。今晚,当我离开时,各处将会有额外的防御措施。请不要认为我没有认真对待我的学生们的安全,哈利。” >>
  220. Harry could smell salt and hear rushing waves; a light, chilly breeze ruffled his hair as he looked out at moonlit sea and star-strewn sky. He was standing upon a high outcrop of dark rock, water foaming and churning below him. He glanced over his shoulder. A towering cliff stood behind them, a sheer drop, black and faceless. A few large chunks of rock, such as the one upon which Harry and Dumbledore were standing, looked as though they had broken away from the cliff face at some point in the past. It was a bleak, harsh view, the sea and the rock unrelieved by any tree or sweep of grass or sand. >>
  221. 哈利可以闻到大海的气味,听见波涛汹涌的声音。他望着远处月光下的大海和繁星点点的夜空,一阵寒冷的微风吹拂着他的头发。他站在一块露出海面的高高的黑色岩石上,海浪在他脚下翻滚,泛起泡沫。他扭头朝后望去。身后耸立着一座悬崖,陡峭的岩壁直落而下,黑糊糊的看不清面目。几块很大的岩石,如哈利和邓布利多站着的这块,似乎是过去某个时候从悬崖的正面脱落下来的。四下里光秃秃的,满目荒凉, 除了苍茫的大海和岩石,看不见一棵树,也没有草地和沙滩。 >>
  222. “Lumos,” said Dumbledore, as he reached the boulder closest to the cliff face. A thousand flecks of golden light sparkled upon the dark surface of the water a few feet below where he crouched; the black wall of rock beside him was illuminated too. >>
  223. “荧光闪烁!”邓布利多下到最靠近悬崖正面的那块巨型卵石上,蹲下身念了句咒语。星星点点的金光在他身下几英尺处的黝黑海面上闪烁着。他身边那道漆黑的岩壁也被照亮了。 >>
  224. Harry did not ask how Dumbledore knew. He had never seen a wizard work things out like this, simply by looking and touching; but Harry had long since learned that bangs and smoke were more often the marks of ineptitude than expertise. >>
  225. 哈利没有问邓布利多是怎么知道的。他从没见过哪个巫师这样解决难题:只用眼睛看,用手摸。不过哈利早就知道,弄得乒乒乓乓、烟雾大作的,通常是水平较低的人的特点,而不是高手的做派。 >>
  226. Once again, Lord Voldemort fails to grasp that there are much more terrible things than physical injury. >>
  227. 伏地魔又一次没能理解,有许多东西比肉体的伤害更可怕得多。 >>
  228. “I am not worried, Harry,” said Dumbledore, his voice a little stronger despite the freezing water. “I am with you.” >>
  229. “我不担心,哈利,”邓布利多说,尽管海水寒冷刺骨,他的声音却多了一点儿气力,“我和你在一起呢。” >>
  230. “Yes, I do,” said Dumbledore, and Harry saw his feet slide a little on the floor as he struggled to remain upright. “But as for being about to kill me, Draco, you have had several long minutes now, we are quite alone, I am more defenseless than you can have dreamed of finding me, and still you have not acted. …” >>
  231. “是的,我很在意。”邓布利多说,这时哈利看见他双脚在地面上打了一个滑,使劲撑着不让自己瘫倒,“至于你要取我性命的事,德拉科,已经过去好几分钟了。周围没有别人,我现在手无寸铁,你做梦也不会想到有这样的好机会,可你还是没有动手……” >>
  232. The sound frightened Harry beyond anything he had experienced all evening. For the first time, Dumbledore was pleading. >>
  233. 这声音比哈利整晚经历的任何事情都叫他害怕。邓布利多在哀求, 这可是破天荒的第一次。 >>
  234. A jet of green light shot from the end of Snape’s wand and hit Dumbledore squarely in the chest. Harry’s scream of horror never left him; silent and unmoving, he was forced to watch as Dumbledore was blasted into the air. For a split second, he seemed to hang suspended beneath the shining skull, and then he fell slowly backward, like a great rag doll, over the battlements and out of sight. >>
  235. 斯内普的魔杖尖上射出一道绿光,不偏不倚地击中了邓布利多的胸膛。哈利惊恐的尖叫声被憋在了喉咙里,他发不出声音,也动弹不得, 只能眼睁睁地望着邓布利多被击到空中。邓布利多似乎在那闪亮的骷髅下停留了一秒钟,然后像一个破烂的大玩偶似的,慢慢地仰面倒下去, 从围墙的垛口上栽下去不见了。 >>
  236. And he slashed at the air: Harry felt a white-hot, whiplike something hit him across the face and was slammed backward into the ground. Spots of light burst in front of his eyes and for a moment all the breath seemed to have gone from his body, then he heard a rush of wings above him and something enormous obscured the stars. Buckbeak had flown at Snape, who staggered backward as the razor-sharp claws slashed at him. As Harry raised himself into a sitting position, his head still swimming from its last contact with the ground, he saw Snape running as hard as he could, the enormous beast flapping behind him and screeching as Harry had never heard him screech — >>
  237. 斯内普猛烈地抽打着空气。哈利感到有种白热的、像鞭子一样的东西打在脸上。他被重重地抽倒在地上,满眼冒着金星,有一阵子好像停止了呼吸。就在这时,他听见一阵翅膀的扑棱声,巨大的影子遮住了天空中的星星。巴克比克已经飞到了斯内普的头上,刀一样锋利的爪子抓得斯内普连连后退。哈利坐了起来,刚才撞到地上的脑袋还眩晕着,只见斯内普拼命奔跑着,巨大的巴克比克拍着翅膀在后面紧追不放,发出一种哈利从未听过的尖厉吼叫—— >>
  238. Harry felt a searing pain in his stomach at the sound of the name. In the silence and the stillness, horror rose inside him. >>
  239. 一听到邓布利多的名字,哈利的胃里一阵剧烈的灼痛。沉默和寂静中,恐惧感在体内增长。 >>
  240. Harry did not attempt to argue or explain. He was still shaking uncontrollably. Hagrid would find out soon enough, too soon. … As they directed their steps back toward the castle, Harry saw that many of its windows were lit now. He could imagine, clearly, the scenes inside as people moved from room to room, telling each other that Death Eaters had got in, that the Mark was shining over Hogwarts, that somebody must have been killed. … >>
  241. 哈利也不再试图争辩或解释了。他仍然不由自主地瑟瑟发抖。海格很快就会知道的……当他们朝城堡走去时,哈利见到许多窗子里的灯都亮了。他可以清楚地想象里面的情景,大家奔走相告,描述食死徒刚刚进来的情景,黑魔标记闪耀在霍格沃茨魔法学校的上空,一定有人被杀了…… >>
  242. Harry heard Hagrid’s moan of pain and shock, but he did not stop; he walked slowly forward until he reached the place where Dumbledore lay and crouched down beside him. He had known there was no hope from the moment that the full Body-Bind Curse Dumbledore had placed upon him lifted, known that it could have happened only because its caster was dead, but there was still no preparation for seeing him here, spread-eagled, broken: the greatest wizard Harry had ever, or would ever, meet. >>
  243. 哈利听见了海格痛苦和震惊的呻吟声,但他没有停住脚步,继续慢慢地向前移动,直到他走到邓布利多躺着的地方,蹲在他的身旁。 当邓布利多施在他身上的全身束缚咒解开后,哈利就知道没有希望了,如果施魔咒的人不死,魔咒是不会自然解开的。但是哈利仍没有心理准备见到眼前这一幕:他今生今世遇到的、也许以后再也遇不到的最好的巫师,四肢摊开,手脚折断,横躺在眼前。 >>
  244. Dumbledore’s eyes were closed; but for the strange angle of his arms and legs, he might have been sleeping. Harry reached out, straightened the half- moon spectacles upon the crooked nose, and wiped a trickle of blood from the mouth with his own sleeve. Then he gazed down at the wise old face and tried to absorb the enormous and incomprehensible truth: that never again would Dumbledore speak to him, never again could he help. … >>
  245. 邓布利多双眼紧闭,从他四肢摊开的角度看起来像是在熟睡。哈利伸手扶正那鹰钩鼻上的半月形眼镜,用自己的袖子擦了一下他嘴角的血痕,然后低头凝视着那张充满智慧的苍老的脸庞,努力地去面对这个难以接受的事实:邓布利多再也不会对他说什么了,再也不可能帮他什么了…… >>
  246. A much smaller and warmer hand had enclosed his and was pulling him upward. He obeyed its pressure without really thinking about it. Only as he walked blindly back through the crowd did he realize, from a trace of flowery scent on the air, that it was Ginny who was leading him back into the castle. Incomprehensible voices battered him, sobs and shouts and wails stabbed the night, but Harry and Ginny walked on, back up the steps into the entrance hall. Faces swam on the edges of Harry’s vision, people were peering at him, whispering, wondering, and Gryffindor rubies glistened on the floor like drops of blood as they made their way toward the marble staircase. >>
  247. 一只小了许多的、更加温暖的手握住了哈利的手,把他向上拉着。 哈利糊里糊涂地顺势站了起来,直到他茫然地穿过人群,从空气中飘来了一丝花香,这才意识到是金妮一直在拉着他往城堡里走。听不清楚的话语从四面传来,抽泣、叫喊和哀号划破了夜空,但哈利和金妮继续向前,走上台阶,进入门厅。一张张面孔在哈利视线边缘晃动,人们盯着他,窃窃私语,惊愕迷茫。他们向大理石楼梯走去,格兰芬多的红宝石散落在地上,闪耀着血滴一样的红光。 >>
  248. Gulping, Madam Pomfrey pressed her fingers to her mouth, her eyes wide. Somewhere out in the darkness, a phoenix was singing in a way Harry had never heard before: a stricken lament of terrible beauty. And Harry felt, as he had felt about phoenix song before, that the music was inside him, not without: It was his own grief turned magically to song that echoed across the grounds and through the castle windows. >>
  249. 庞弗雷夫人用手捂住嘴,咽着泪水,眼睛睁得大大的。在外面黑暗中的某个地方,凤凰正在用哈利从未听过的方式唱着令人动容的凄婉挽歌。像以前听凤凰的歌声一样,哈利感觉到这首挽歌的曲子是在他的脑海里,而不是在现实中,仿佛是他自己的悲伤化作了挽歌,在校园里和城堡的窗户间回荡。 >>
  250. “You thought I would not weesh to marry him? Or per’aps, you hoped?”said Fleur, her nostrils flaring. “What do I care how he looks? I am good- looking enough for both of us, I theenk! All these scars show is zat my husband is brave! And I shall do zat!” she added fiercely, pushing Mrs. Weasley aside and snatching the ointment from her. >>
  251. “你认为我会不想和他结婚?或者你希望我不想和他结婚?”芙蓉说,鼻翼翕动,“我只是在乎他的长相吗?我认为我一个人的美貌对我们俩来说已经足够了!所有这些伤疤说明我的丈夫是勇敢的!我来!”她气势汹汹地加了一句,一边推开韦斯莱太太,从她手中抢过药膏。 >>
  252. And then, Harry did not quite see how it happened, both women were crying and hugging each other. Completely bewildered, wondering whether the world had gone mad, he turned around: Ron looked as stunned as he felt and Ginny and Hermione were exchanging startled looks. >>
  253. 突然,哈利还没有反应过来是怎么回事——两个女人抱头痛哭。哈利被彻底搞糊涂了,转过身去,怀疑这个世界是不是疯了。罗恩看起来和哈利一样惊讶。金妮和赫敏也在交换着惊讶的眼神。 >>
  254. “Dumbledore would have been happier than anybody to think that there was a little more love in the world,” said Professor McGonagall curtly, just as the hospital doors opened again and Hagrid walked in. >>
  255. “如果这个世界拥有更多的爱,邓布利多会比任何人都更高兴。”麦格教授简短地说,这时门又开了,海格走了进来。 >>
  256. And he knew, without knowing how he knew it, that the phoenix had gone, had left Hogwarts for good, just as Dumbledore had left the school, had left the world … had left Harry. >>
  257. 他知道——虽然搞不清为什么会知道——凤凰已经走了,永远地离开了霍格沃茨,像邓布利多一样永远地离开了学校,离开了这个世界……离开了哈利。 >>
  258. An extraordinary assortment of people had already settled into half of the chairs; shabby and smart, old and young. Most Harry did not recognize, but a few he did, including members of the Order of the Phoenix: Kingsley Shacklebolt; Mad-Eye Moody; Tonks, her hair miraculously returned to vividest pink; Remus Lupin, with whom she seemed to be holding hands; Mr. and Mrs. Weasley; Bill supported by Fleur and followed by Fred and George, who were wearing jackets of black dragon skin. Then there was Madame Maxime, who took up two and a half chairs on her own; Tom, the landlord of the Leaky Cauldron in London; Arabella Figg, Harry’s Squib neighbor; the hairy bass player from the Wizarding group the Weird Sisters; Ernie Prang, driver of the Knight Bus; Madam Malkin, of the robe shop in Diagon Alley; and some people whom Harry merely knew by sight, such as the barman of the Hog’s Head and the witch who pushed the trolley on the Hogwarts Express. The castle ghosts were there too, barely visible in the bright sunlight, discernible only when they moved, shimmering insubstantially on the gleaming air. >>
  259. 一半椅子上已经坐了人,这些人各式各样,鱼龙混杂:有衣衫褴褛的,也有整洁体面的;有老年人,也有年轻人。大多数人哈利都不认识,但有一些他是知道的,其中包括凤凰社的成员:金斯莱·沙克尔, 疯眼汉穆迪,唐克斯——她的头发又奇迹般地变成了耀眼的粉红色,莱姆斯·卢平——唐克斯跟他手拉着手,韦斯莱夫妇,还有芙蓉搀扶着比尔,后面跟着穿黑色火龙皮夹克衫的弗雷德和乔治。此外还有马克西姆夫人——她一个人就占了两把半椅子,破釜酒吧的老板汤姆,哈利的哑炮邻居阿拉贝拉·费格,古怪姐妹演唱组里那位毛发粗重的低音提琴手,骑士公共汽车驾驶员厄恩·普兰,对角巷长袍专卖店的摩金夫人, 还有几个人哈利只是看着面熟,如猪头酒吧的那个服务员,霍格沃茨特快列车上推小车的女巫。城堡里的幽灵也来了,在阳光下几乎看不见他们,只有走动时才能辨认出来,在明亮的空气中闪烁着虚幻的光芒。 >>
  260. She met Harry’s gaze with the same hard, blazing look that he had seen when she had hugged him after winning the Quidditch Cup in his absence, and he knew that at that moment they understood each other perfectly, and that when he told her what he was going to do now, she would not say, “Be careful,” or “Don’t do it,” but accept his decision, because she would not have expected anything less of him. And so he steeled himself to say what he had known he must say ever since Dumbledore had died. >>
  261. 但金妮已经不哭了,她迎着哈利的目光,神情刚毅而热烈,就像哈利缺席的那天球队赢得魁地奇杯后她拥抱哈利的时候那样。在那一刻,哈利知道他们彼此心心相印,知道当他把他要做的事情告诉她时,她不会说“你要小心”或“你别去做”, 而是会欣然接受他的决定,因为她从心底里知道他就是那样一个人。于是,他咬咬牙,说出了自从邓布利多死后他就知道非说不可的话。 >>
  262. Harry looked at him, startled; the idea that anything as normal as a wedding could still exist seemed incredible and yet wonderful. >>
  263. 哈利不胜惊讶地望着他。世界上仍然存在婚礼这样平凡的事情,真是令人不可思议,同时也令人感到美妙无比。 >>
  264. His hand closed automatically around the fake Horcrux, but in spite of everything, in spite of the dark and twisting path he saw stretching ahead for himself, in spite of the final meeting with Voldemort he knew must come, whether in a month, in a year, or in ten, he felt his heart lift at the thought that there was still one last golden day of peace left to enjoy with Ron and Hermione. >>
  265. 他的手不由自主地握紧了那个假魂器,尽管种种的一切,尽管等待他的是一条漆黑而曲折的道路,尽管他知道最后——不管是一个月、一年、或是十年之后——他肯定要跟伏地魔面对面地较量,可是想到他仍然可以和罗恩、赫敏一起享受最后一个黄金般的平静日子,他就感到心情无比的愉快。 >>

[摘录] 哈利 · 波特 与密室(1998)

  1. I think I’d better do the actual stealing >>
  2. 我们需要声东击西 >>
  3. Fascinating creatures, phoenixes. They can carry immensely heavy loads, their tears have healing powers, and they make highly faithful pets.” >>
  4. 凤凰真是十分奇特迷人的生命。它们能携带极为沉重的东西,它们的眼泪具有疗伤的作用,而且它们还是特别忠诚的宠物。” >>
  5. “Not the way Lockhart teaches it,” said Ron. “I haven’t learned anything from him except not to set pixies loose.” >>
  6. “像洛哈特那种教法,我看未必。”罗恩说,“除了不要把小精灵放出来,我没有从他那里学到任何东西。” >>
  7. “Because that’s what Hermione does,” said Ron, shrugging. “When in doubt, go to the library.” >>
  8. 因为这就是赫敏的作风,”罗恩说着,耸了耸肩膀,“一有疑问,就上图书馆。” >>
  9. you will find that I will only truly have left this school when none here are loyal to me. You will also find that help will always be given at Hogwarts to those who ask for it.” >>
  10. 只有当这里的人都背叛我的时候,我才算真正离开了这所学校。你们还会发现,在霍格沃茨,那些请求帮助的人总是能得到帮助的。” >>
  11. Of the many fearsome beasts and monsters that roam our land, there is none more curious or more deadly than the Basilisk, known also as the King of Serpents. This snake, which may reach gigantic size and live many hundreds of years, is born from a chicken’s egg, hatched beneath a toad. Its methods of killing are most wondrous, for aside from its deadly and venomous fangs, the Basilisk has a murderous stare, and all who are fixed with the beam of its eye shall suffer instant death. Spiders flee before the Basilisk, for it is their mortal enemy, and the Basilisk flees only from the crowing of the rooster, which is fatal to it. >>
  12. 在我们国家,游荡着许多可怕的野兽和怪物,其中最离奇、最具有杀伤力的莫过于蛇怪,又被称为蛇王。这种蛇的体积可以变得十分巨大,通常能活好几百年,它是从一只公鸡蛋里、由一只癞蛤蟆孵出的。它杀人的方式十分惊人,除了它致命的毒牙外,蛇怪的瞪视也能致人死亡,任何人只要被它的目光盯住,就会立刻丧命。蜘蛛看到蛇怪就会逃跑,因为蛇怪是蜘蛛的死敌,而蛇怪只有听见公鸡的叫声才会仓皇逃命,因为公鸡的叫声对它来说也是致命的。 >>
  13. Harry could see the sun sinking, blood-red, below the skyline. This was the worst he had ever felt. If only there was something they could do. Anything. >>
  14. 哈利可以看见太阳红得像血一样,渐渐沉落到地平线以下。他心里从来没有像现在这样难过。哪怕他们能够做点什么也好啊,不管是什么。 >>
  15. — I fashioned myself a new name, a name I knew wizards everywhere would one day fear to speak, when I had become the greatest sorcerer in the world!” >>
  16. 我给自己想出了一个新的名字,我知道有朝一日,当我成为世界上最伟大的魔法师时,各地的巫师都不敢轻易说出这个名字!” >>
  17. For a split second, both Harry and Riddle, wand still raised, stared at it. Then, without thinking, without considering, as though he had meant to do it all along, Harry seized the basilisk fang on the floor next to him and plunged it straight into the heart of the book. >>
  18. 在那生死关头的一刹那,哈利,以及仍然举着魔杖的里德尔,眼睛都盯住了它。然后,哈利没有思考,也没有半点犹豫,好像他一直就打定主意要这么做似的,他一把抓起身边地上的蛇怪毒牙,径直把它插进了日记本的中心。 >>
  19. Never trust anything that can think for itself if you can’t see where it keeps its brain. >>
  20. 永远不要相信任何能够独立思考的东西,除非你看清了它把头脑藏在什么地方。 >>
  21. Which goes to show that the best of us must sometimes eat our words >>
  22. “这就说明,即使是我们中间最优秀的人,有时候也只能说话不算话了。” >>
  23. It only put me in Gryffindor,” said Harry in a defeated voice, “because I asked not to go in Slytherin. …” >>
  24. It is our choices, Harry, that show what we truly are, far more than our abilities.” >>
  25. 哈利,表现我们真正的自我,是我们自己的选择,这比我们所具有的能力更重要。 >>
  26. “Proud?” said Harry. “Are you crazy? All those times I could’ve died, and I didn’t manage it? They’ll be furious. …” >>
  27. “骄傲?”哈利说道,“难道你糊涂了吗?他们如果听说我好多次都差点死掉,却居然都死里逃生了,他们肯定会气坏的……” >>

5 步打造自己的资讯阅读平台

80FD1A99-BECC-43D7-A791-3B8BBC4BF6B0.jpeg

!!!

Photo by Roman Kraft on Unsplash

!!!

今天偶然看到一个GitHub仓库,创建者计划制做一个工具,用来连接中文独立博客博主,打造一个面向独立博客的推荐、曝光、资讯互通及阅读平台,为此使用这个仓库收集中文独立博客,并通过 js 处理搜集到的数据显示在 README 中,数据在之后会整合到他打造的平台中,实现上述目标。

仓库地址: https://github.com/timqian/chinese-independent-blogs

看到这个计划,不由得一阵兴奋,果断 rq 了自己的博客,在这个过程中,偶然发现了一款很好用的 RSS 工具 Feedly,解决了本人一直在寻找工具试图实现的目标:打造自己的资讯阅读平台。

先说说起因吧,现在这个时代,新闻资讯市场上充斥着各种各样的新闻客户端,获取资讯的渠道也是异彩纷呈,但是在资讯资源极其丰富的同时,也带来了一些不方便。我需要安装不计其数的客户端、收藏无穷无尽的网页,并定期进入访问,才能够实时获取到我想要的资讯。所以我就在想,能不能有这样一个平台,我将自己感兴趣的内容在这里订阅,之后只需进入这个平台就可以第一时间看到我感兴趣的新闻资讯!找了很久,但受限于个人水平和见识,一直都没有找到很理想的解决方案。

后来有一天我知道了 RSS ,根据维基百科的描述:RSS(简易信息聚合)是一种消息来源格式规范,用以聚合经常发布更新数据的网站,例如博客文章、新闻、音频或视频的网摘。RSS文件(或称做摘要、网络摘要、或频更新,提供到频道)包含全文或是节录的文字,再加上发布者所订阅之网摘数据和授权的元数据。

这真是很棒的消息,心中大致有了想法,但是还是没有解决这个问题,有了技术,还需要比较舒适的实现方式,因此我总结了自己的需求:

  • 跨平台,可以在不同设备间同步我订阅的内容
  • 简单易用,没有冗余的功能
  • 界面简洁大方

确定了需求,下面就是实现了,经过漫长的寻找,终于找到了对的那个!下面进入本文的重点!

8E8D80A6-1381-4F86-9141-09E2CAEF8B4B.png

Feedly 简介

根据维基百科的介绍:說明Feedly是一个RSS聚合器应用程序,支持各种网页浏览器和运行iOS或Android的移动设备,也是一个基于云端的服务。其从各种在线资源聚合用户自定的新闻订阅源,并可与他人分享。Feedly由DevHD于2008年推出。

官网的自述:Keep up with all the topics that matter to you. All in one place.

官网传送门: https://feedly.com/

简单来说, Feedly 将我感兴趣的内容聚集在一处,并实现跨平台阅读。我可以随时随地在各种设备(Android,ios,Web Breowe)浏览我订阅的内容。这就完美的解决了我的需求,从此不用再为了其中一小部分自己感兴趣的内容安装一大堆客户端,收藏一大堆网页啦。

Feedly 简单使用

Feedly 的使用真的很简单,下面就来介绍一下,如何五步开始使用Feedly:

Install or Open the Website ➡️ Sign up ➡️ Log in ➡️ Subscribe ➡️ Enjoy it!

怎么样,是不是很容易?对于上述操作中的一些步骤在这里进行一下补充说明,关于进入 Feedly 的世界,可以进入它的官网或着直接在应用商店搜索安装它的客户端即可,至于订阅部分,您只需找到您感兴趣博客、媒体、论坛等等网址,在FeedlyDiscover 界面键入网址,或者直接搜索关键词检索需要的内容媒体,比如在订阅我的博客,只需要键入 “https://blog.frytea.com” 就可以找到我的博客,点击添加,选择相应的 Feeds 即可。如果要订阅人民网的内容,只需要键入人民网的地址“http://www.people.com.cn/”此后的步骤同上

26C6791D-1EB3-47AD-95C5-96FFEC81E6D9.png

说了这么多,归根结底还是要实用才是王道,所以如果感兴趣,就赶快去实践一下吧,实践出真知。Feedly 使用的说到底还是RSS的技术,使用 RSS 获取到的资讯内容,您看不到其他无关的信息,不用忍受各种网站花里胡哨的外观及广告,可有助于您将注意力最好的集中在内容本身上。这一点是我很喜欢的,当然一些站长可能不是那么喜欢 RSS ,因为这可能会减少他们的访问量,不过我觉得,自己网站的内容只要是传送出去了,有更多的人看到了,这不就是网站或者说互联网存在的价值之一吗。

最后总结一下我订阅的部分的 RSS

祝您生活愉快!

宋天伦 2019.10.29

GTD高效工具之 WorkFlowy 推荐

ED5AC20B-E893-412A-AFCA-5F5FB9E30F05.jpeg

!!!

[tag outline] Photo by Andrew Neel on Unsplash [/tag]

!!!

GTD(Getting Things Done / 尽管去做),是一种行为管理的方法,也是戴维·艾伦(英语:David Allen (author))写的一本书的书名。

GTD的主要原则在于一个人需要通过记录的方式把头脑中的各种任务移出来。通过这样的方式,头脑可以不用塞满各种需要完成的事情,而集中精力在正在完成的事情。(WikiPedia)

简单来说,GTD 的理论帮助人们高效的完成需要做的事情,并提出将事情进行分级:

  • Horizon 5: Life
  • Horizon 4: Long-term visions
  • Horizon 3: 1-2 year goals
  • Horizon 2: Areas of focus and accountability
  • Horizon 1: Current projects

理论需联系实际,实践才是检验真理的唯一标准。在我个人对于高效工作的理解中,我需要的高效辅助工具应该具有如下特征:

  • 简单
  • 易用
  • 可扩展

经过一段时间的搜集和实践,最终确定两款工具 WorkFlowyNotion 比较符合我的要求。其中Workflowy 极其简单易用,软件打开就是记录界面,可以用于记录清单,非常的快捷,没有多余的功能,并且是 corss-platform 的,支持ios/android/web工欲善其事,必先利其器,为了更好的利用 GTD 的理念帮助自身高效的完成工作,今天就来聊聊 Workflowy ,聊一聊我是如何利用它来帮助我提高生活效率的。

WorkFlowy 官网: https://workflowy.com/

简单

在学习生活过程中,我将自己需要处理的事情分为如下几种:

  • 突发、紧急的事情
  • 短期计划
  • 长期规划

其中第一种突发、紧急的事情出现在没有任何预兆的情况下,比如突然收到一条信息说什么时间要做什么事情,这样的事情灵活多变,且极易忘记,因此我在遇到这样的事情时,就会第一时间打开软件,将事情快速的记录下,完成后打个✅。

针对第二种事情,即短期规划,常常是我想要做一件事情,这件事情不能一下子完成,需要简单分解,即出现简单短期规划,这时我就可以打开软件进行简单的规划,设置一个高级别的条目,之后缩进一级放置更多的关于这个计划的分解计划,完成一个打一个✅,直到done!

对于第三个长期规划,可能是一件我一直在做的事情,活着需要很长时间的规划去完成的事情,也会在此规划,比如规划自己本科的最后一年,再比如我规划自己的小项目 PlanAssistant 也会在这里记录下来,随时记录下小灵感。其实一直在做的事情就是这样子,灵感真是一个小机灵鬼,不知道什么时候就会光临我的大脑,如果我不赶快记录下来,它就会很快消失,当我真的需要的时候,只能干着急。

综上所述,软件具有简单的特性,打开直接就是一个记录界面,可以根据自己的需求进行各种定制,使用起来很方便!

下图为 web 端界面。

9C4118E3-F83E-4D56-97BC-3089CDB50D03.png

易用

为了实现高效、灵活的done,辅助工具一定要够简单、够好用,还要在需要的时候具有一定拓展性WorkFlowy 几乎完美的符合这点要求,软件打开后就是一个输入界面,不分常规笔记本常见的分类、归档等功能,只有一个页面!就是这样子的纯净、单一,显得这样一款工具弥足珍贵!

下图为 Android client 界面。

Screenshot_20191026-183529_WorkFlowy.jpg

总结

简单、易用、可扩展、纯净,是个人对这款工具的总结,打开直接使用的设计让它在当前这个“百花齐放”的软件市场中显得独树一帜,却令人感觉到它的不可替代。它的价值不在于不可替代,而是太容易被人模仿,却都不如它纯净。这就是我想要推荐的GTD 高效辅助工具,在当今这个科技飞速发展的世界,有很多很多的新技术新工具可以辅助我们更好的过好每一天。科学技术是第一生产力,因此发掘一下电子产品中的好软件、好产品说不定会有意外的收获!作为未来互联网行业的一员,我认为软件产品应该更好的为人服务,能够让一个完全不懂计算机的人很流畅的操作计算机,才算得上是一款成功的产品!(这个观点貌似和乔布斯神似)

  • 注1:WorkFlowy 软件请自行在应用商店下载,软件全英,有助于锻炼英文哟!
  • 注2:WorkFlowy 的block有每月250条的限制,日常使用足够了,请注意!

最后打一个小广告,本人致力于让自己的生活更高效,致力于做些什么让人们的生活更美好,甚至创造一些美好,为此一直在开发一款辅助个人记录生活轨迹并实现高效工作生活、提升生活幸福感的(Android)手机软件。当我想到一些什么可以让我更高效或是提升幸福感,却找不到想要的或是比较满意产品时,我就会将它用本人能力范围内的技能实现在软件上,欢迎测试吐槽!

PlanAssistant 官网:https://dev.frytea.com/PlanAssistant/

PlanAssistant 内测:https://fir.im/xm19

本人致力于过好每一天,希望能够创造美好,并一直在为此付诸努力。明天又是美好的一天,祝晚安!

宋天伦 2019.10.26

【趣味操作】Terminals显示带有酷炫linux标志的基本硬件信息

77DEA736-675A-4501-9002-2F81E22731B3.jpeg

!!!

[tag outline] Photo by Sai Kiran Anagani on Unsplash [/tag]

!!!

你是否还对 Linux 系统看上去“可怕”的命令行望而却步呢?其实在它看似“简陋”的背后,拥有着无限强大的功能性、拓展性甚至趣味性。今天就来介绍一款有意思的命令,使用它你就可以看到字符串背后的美好!

下面介绍两款可用于显示Linux标志及基础硬件信息的命令,分别是ScreenFetchLinux_Logo/linuxlogo,二者都可以实现上述需求,这篇文章将会从安装、使用和截图三个方面介绍,使用方面在此仅介绍最简单的使用,更多高级操作欢迎去到其所属的GitHub仓库探索,此外还可以从引用文献中发现更多有有意思的东西。

ScreenFetch

screenFetch 是一个能够在截屏中显示系统/主题信息的命令行脚本。它可以在 Linux,OS X,FreeBSD 以及其它的许多类Unix系统上使用。

[tip type=”info”] 这个方便的 Bash 脚本可以用来生成那些漂亮的终端主题信息和用 ASCII 构成的发行版标志,就像如今你在别人的截屏里看到的那样。它会自动检测你的发行版并显示 ASCII 版的发行版标志,并且在右边显示一些有价值的信息。 — 来自 man 手册的说明 [/tip]

GitHub传送门: https://github.com/KittyKatt/screenFetch

install

# Debian/Ubuntu/Mint
$ sudo apt-get install screenfetch

# Mac OS X
$ brew install screenfetch

# FreeBSD
$ sudo pkg install sysutils/screenfetch

# Fedora
$ sudo dnf install screenfetch

# universal
$ wget https://github.com/KittyKatt/screenFetch/archive/master.zip
$ unzip master.zip
$ sudo mv screenFetch-master/screenfetch-dev /usr/bin/screenfetch

use

# Simple use
$ screenfetch

screenshot

83FEFE13-3611-4C4F-8277-105AEF59EB41.jpeg

B311A013-B4B7-43FF-A8EF-C197774C9FDD.jpeg

Linux_Logo

linuxlogo or linux_logo is a Linux command line utility that generates a color ANSI picture of Distribution logo with a few system information.

GitHub传送门: https://github.com/deater/linux_logo

Install

# Debian/Ubuntu/Mint
$ apt-get install linuxlogo

# Centos/RHEL/旧版 Fedora
$ yum install linux_logo

# Fedora Linux v22+ 或更新版本
$ dnf install linux_logo

Use

$ linux_logo

Screenshot

5282D417-8A13-4092-A927-076CD70AE44D.jpeg

CA4BB70B-8210-4B1A-8257-614D530ACE0E.jpeg

Quote

注1: 如果您手边没有可用于操作的 Linux 系统,欢迎来到本站提供的 instantbox 中体验 Linux 的魅力。在 instantbox 中,您可以快速开启一个全新的 Linux 系统环境(如 Ubuntu/Centos/Arch Linux/Debian/Fedora/Alpine),并通过浏览器直接使用它,环境最长保留24小时,过期自动销毁,仅用于体验功能,切勿滥用! 传送门:https://shell.frytea.com/

注2: 更多Linux使用技巧欢迎来到我的知识库检索,我会在日常使用过程中不断完善,如有错误欢迎指正!

Frytea’s Wiki 传送门:https://wiki.frytea.com/

泛谈云计算

EB0C1FAB-78FF-451F-843B-764E13FB3A18.jpeg

!!!

[tag outline] Photo by Avi Richards on Unsplash [/tag]

!!!

“大数据与云计算”可谓是当今很火热的两个词,许多相关的竞赛、项目不断捧热这些新型的词汇。但是究竟什么才是云计算,它究竟可以带给我们什么变革?本文按照作者个人认识行文,试图以最简单的方式传达作者对于云计算的思考。

什么是云计算

某些课程讲过云计算,课上我说我用过云计算,结果被反问“你用云计算计算什么了?”我觉得很可笑。

  • 云计算就是为了计算?
  • 用过云计算,云计算的实现这么多种,我一定要用某一个?
  • 用过云计算这个命题本身有价值么?

马克思主义哲学贯彻“实事求是”的原则,毛主席也说“没有调查就没有发言权”。作为当今世界的新兴产业,云计算可以是一个很宽泛的定义了,教科书上说云计算是Google提出的,但其实第一个提供弹性计算服务的是亚马逊,Google 晚于亚马逊,于2007年10月开始推广自家的云计算服务,阿里云则要到2009年9月才创立。

云计算究竟是做什么的呢?根据维基百科的说法:

  • 云计算(英语:cloud computing),是一种基于互联网的计算方式,通过这种方式,共享的软硬件资源和信息可以按需求提供给计算机各种终端和其他设备,使用服务商提供的计算机基建作计算和资源。(Wikipedia)

云计算不是服务器

云计算是服务器,但不仅仅是服务器。传统的服务器提供商主要提供独立服务器、虚拟主机以及介于独立服务器和虚拟主机之间的VPS。而实际的开发过程中,有的时候并不需要一整台服务器,而一整台服务器的负载总是会造成很多的资源浪费,而更加灵活的弹性服务器就解决了这个问题。弹性服务器源于宿主服务器,却更加灵活,随时启动,用完销毁。而云计算提供商可以按照分钟甚至秒为单位进行计费。这样的方式可以最大程度的保证花费的每一分钱都用在了使用,杜绝了不必要的资源浪费。

因此我说,云计算是服务器,但不仅仅是服务器。它源于服务器,但它更加灵活,更加便捷,更加高效。

使用感受

本人对于云计算很感兴趣,自接触之日就利用业余时间研究各种云计算提供商,在此记录简单的使用感受。

Google cloud Platform (GCP) / Microsoft Azure

谷歌云按秒计费,网络质量较高,机器灵活,很实用。微软云桌面体验较好,提供windows10镜像,依旧在桌面端体验较好。

Ali Cloud

又称“套路云”,个人理解商业驱动大于技术驱动。虽然阿里云的技术同样是全国领先。但不得不说作为学生,阿里云的各种营销手段真的是令人摸不着头脑,使用起来倒是很方便,甚至有的时候需要用更多的时间研究活动规则,而非技术规则。因此对于阿里云,我持有又爱又恨的态度。

HuaWei Cloud / Tencent Cloud / Baidu Cloud

华为云和腾讯云个人认为较为良心,至少套路不多。百度云学生机对学生并不友好。

不想说了,不知道有没有人感兴趣,有兴趣再发文吧。本文就像说一件事情云计算不仅仅是服务器那么简单,云计算也不仅仅是计算