分类 教程 下的文章

virtualenv is a tool to create isolated Python environments. Since Python 3.3, a subset of it has been integrated into the standard library under the venv module.

virtualenv是一个用于创建隔离Python环境的工具。从3.3版本开始, 标准库实现了virtualenv的一个功能子集,社区应该是考虑在标准库中集成virtualenv, 不过到目前为止,也近仅仅是个功能子集,完整的功能使用还是需要使用 pip 安装 virtualenv 包才行。

virtualenv主要是解决依赖冲突问题,如果操作系统版本的某个lib库版本较高, 和应用的低版本lib不兼容,那这时候在不影响系统python lib库的同时还能完美的支持应用的调试和使用,将非常方便python开发。也用于模拟不同的python版本环境, 比如Python 2X/3X, 这种大版本的不兼容问题隔离验证。

- 阅读剩余部分 -

维基百科 Filesystem Hierarchy Standard 有一段介绍 /run 和 /var/run 目录的说明

Modern Linux distributions include a /run directory as a temporary filesystem (tmpfs) which stores volatile runtime data, following the FHS version 3.0. According to the FHS version 2.3, such data were stored in /var/run but this was a problem in some cases because this directory is not always available at early boot. As a result, these programs have had to resort to trickery, such as using /dev/.udev, /dev/.mdadm, /dev/.systemd or /dev/.mount directories, even though the device directory isn't intended for such data.[23] Among other advantages, this makes the system easier to use normally with the root filesystem mounted read-only. For example, below are the changes Debian made in its 2013 Wheezy release:[24]

/run 目录是一个临时文件系统, 存储是启动以来的信息.当系统重启时,这个目录下的文件应该被删掉或清除.如果你的系统上有/var/run目录,应该让它指向run.

- 阅读剩余部分 -

CentOS yum工具如果开启了fastmirror插件,会自动查找最近的源以供使用,有时候有更好的源供选择,希望指向固定的epel源.

禁用fastmirror插件

编辑

/etc/yum/pluginconf.d/fastestmirror.conf 

将内容修改为:

# 1 - 开启
# 0 - 关闭
enabled = 0

修改 Base 仓库源

国内目前镜像源比较丰富了,各个云厂商大都提供公共的镜像源对外使用.比如腾讯/网易/阿里等等,根据自己的网络条件和喜欢选择即可, 个人一般倾向使用清华的源, 开源镜像仓库比较丰富.
在清华的镜像站点上对各个源的使用皆有帮助信息, 参考网址:https://mirrors.tuna.tsinghua.edu.cn

- 阅读剩余部分 -

由于安全限制, 我们需要访问远端大量的服务地址和不同端口,因此需要端口转发.但为每个端口分别创建本地端口又异常麻烦, 所以希望尽量简化这个过程.动态端口转发绑定了一个本地端口,而目标地址:目标端口则是不固定的.

ssh该功能是由 DynamicForward 在控制,可以通过命令行直接指定, 也可以通过 ~/.ssh/ssh_config 来配置.

命令行直接配置:

ssh -D localhost:5963 root@192.168.56.10

- 阅读剩余部分 -

rdesktop是一个开源软件,使您可以使用RDP远程桌面协议从Linux计算机连接和管理远程Windows桌面.要使rdesktop能够连接到Windows计算机,需要开启相关Windows配置.

  • 防火墙打开 RDP 服务端口 3389
  • 开启Windows的远程桌面
  • 用户启用密码登陆

在Linux上安装 rdesktop:

  • Centos
yum -y install rdesktop
  • Debian/Ubuntu
apt -y install rdesktop
  • Gentoo
emerge -a net-misc/rdesktop

- 阅读剩余部分 -

HAProxy是一个免费的负载均衡软件,可以运行于大部分主流的Linux操作系统上。HAProxy提供了L4(TCP)和L7(HTTP)两种负载均衡能力,具备完善的扩展能力, 性能和稳定性都非常好。

HAProxy常用功能:

  • 负载均衡:L4和L7两种模式,支持RR/静态RR/LC/IP Hash/URI Hash/URL_PARAM Hash/HTTP_HEADER Hash等丰富的负载均衡算法
  • 健康检查:支持TCP和HTTP两种健康检查模式
  • 会话保持:对于未实现会话共享的应用集群,可通过Insert Cookie/Rewrite Cookie/Prefix Cookie,以及上述的多种Hash方式实现会话保持
  • SSL:HAProxy可以解析HTTPS协议,并能够将请求解密为HTTP后向后端传输
  • HTTP请求重写与重定向
  • 监控与统计:HAProxy提供了基于Web的统计信息页面,展现健康状态和流量数据。

- 阅读剩余部分 -

openssh 从7.2版本开始,添加了对PorxyJump的支持,PorxyJump选项主要用于多级跳板机的支持

Changes since OpenSSH 7.2
=========================

New Features
------------

 * ssh(1): Add a ProxyJump option and corresponding -J command-line
   flag to allow simplified indirection through a one or more SSH
   bastions or "jump hosts".

跳板机主要是因为安全管控性要求以及安全审计的需求,以便将网络环境隔离同时将所有到机房的操作行为记录下来.

- 阅读剩余部分 -

安装 RabbitMQ

CentOS

CentOS 机器上需要先安装 epel-release 包, 我们的 rabbitmq-server 包就再这个仓库中。

yum -y install epel-release

安装号epel-release仓库后, 我们就可以直接使用yum命令安装了 rabbitmq-server 了。

yum -y install rabbitmq-server

- 阅读剩余部分 -

通过前面13篇文章,我们已经完全准备好了PXE的装机环境, 按PXE系列文章(9)- 优化 PXE 装机流程系统架构,我们需要实现带外管理的Driver以及带内执行逻辑的Agent.

  • Driver 负责带外功能的实现,功能包括 开机关机重启PXE启动Disk启动Ping ILO Host等等功能、主要是基于 ipmitool 命令来实现, 也提供了可插拔的机制来实现其他带外管理的能力,比如 iDRAC、Redfish、SNMP等,目前我们使用 ipmitool 能满足使用需求, 所以从实现上来讲仅实现 ipmitool 的支持就足够了。

- 阅读剩余部分 -

我们前面几节已经详细介绍了基于 UbuntuCentOS 构建内存镜像的方案,其中 ~/work/initramfs/init 脚本内容大致如下:

#!/bin/busybox sh

# Dump to sh if something fails
error() {
    echo "Jumping into the shell..."
    setsid cttyhack sh
}

# Populate /bin with binaries from busybox
/bin/busybox --install /bin

mkdir -p /proc
mount -t proc proc /proc

mkdir -p /sys
mount -t sysfs sysfs /sys

mkdir -p /sys/dev
mkdir -p /var/run
mkdir -p /dev

mkdir -p /dev/pts
mount -t devpts devpts /dev/pts

# Populate /dev
echo /bin/mdev > /proc/sys/kernel/hotplug
mdev -s

echo "mount rootfs... "
mkdir -p /newroot
mount -t tmpfs -o size=80% tmpfs /newroot || error

xz -d -c -f rootfs.tar.xz | tar -x -f - -C /newroot || error

mount --move /sys /newroot/sys
mount --move /proc /newroot/proc
mount --move /dev /newroot/dev

exec switch_root /newroot /sbin/init || error

- 阅读剩余部分 -