Ubuntu 新服务器配置
# 修改主机名
hostnamectl set-hostname myHostName
# 如果想要直接使用主机名,还需要在 /etc/hosts 里添加相关记录
# nano /etc/hostname
# nano /etc/hosts
# 生成中文
locale-gen zh_CN.UTF-8
# 基本更新
apt-get update
apt-get upgrade
# 出现 The following packages have been kept back 可考虑 apt dist-upgrade 或 install
# 当 /etc/apt/sources.list* 有其他仓库时使用 dist-upgrade 相对没那么安全
# 修改密码
passwd
# 创建用于部署的用户
useradd deploy
mkdir /home/deploy
mkdir /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
# 将需要使用该用户的公钥添加进去
vim /home/deploy/.ssh/authorized_keys
chmod 400 /home/deploy/.ssh/authorized_keys
chown deploy:deploy /home/deploy -R
# 编辑 sudoers
visudo
# 将需要 sudo 的用户添加进去
# deploy ALL=(ALL) ALL
# 修改 sshd 权限
vim /etc/ssh/sshd_config
# PermitRootLogin no # 不允许直接 root 登陆
# PasswordAuthentication no # 不允许密码登陆
# AllowUsers deploy@(your-ip) deploy@(another-ip-if-any) # 只允许指定地址的人登陆
# service ssh restart
# 防火墙设置
# DNS 53
# mosh allow 60000:61000/udp 或 allow mosh
ufw allow 22
ufw allow 80
ufw allow 443
ufw default deny
ufw enable
Tips
当有多台主机需要部署的时候,建议使用 sshrc, tmuxrc, 这样能快速的将所有的配置都带给服务器,能够快速方便的对多台进行安装部署.
mosh-dev
由于 mosh 部分鼠标相关的功能需要最新版,所以建议直接安装 dev 版本
apt-get install -y software-properties-common
add-apt-repository ppa:keithw/mosh-dev
apt-get update
apt install -y mosh
fail2ban
apt-get install fail2ban
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# bantime = 3600 # ban 1 小时
# destemail = admin@admin # 发送警告的邮箱地址
# 将 ssh/ssh-ddos 等段落下的 enable 设置为 true 打开相应的 filter
env
apt-get install software-properties-common
# 添加 Oracle Java 仓库
add-apt-repository ppa:webupd8team/java#
apt-get update
# 安装 Oracle Java 8 JDK
apt-get install oracle-java8-installer
# 如果有多个 Java 环境可调整配置
update-alternatives --config java
ipv6
# https://jiandanxinli.github.io/2016-08-06.html
# /etc/sysctl.conf
# net.ipv6.conf.all.disable_ipv6=0
# net.ipv6.conf.default.disable_ipv6=0
# net.ipv6.conf.lo.disable_ipv6=0
sysctl -p
# https://www.tunnelbroker.net/
# 选择 linux route2, 然后执行脚本
# 检测 ipv6 是否可用
# http://ready.chair6.net/?url=wener.me
# 如果操作失败了则删除通道从来
ip tun del he-ipv6
分布式架构手记
这几天尝试了很多的 *aaS, 期望能找到在当前架构下适合公司后续发展的一个系统架构, 然而一路下来发现并没那么简单.
Go Redis module
Writing Redis Module in Golang.
Play Tap Titans using shell
Tap Titans on Play Store
Features
- Auto upgrade
- Auto spell skill
- Auto start challenge
- Auto close ad dialog
- Verify fast tap (0.03s/tap)
NOTE
- Only tested on Nexus 5, different devices may use different coordinates and event dev.
- Used to plat tiantis long time ago, may not works in current version.Different version may use different color and coordinates
Requirement
- ADB
- Image Magic
- Bash
Get started
- Start game
- Get source tap-titans-play.sh
chmod +x play.sh
# Connect through lan, so you don't have to use the usb
./play.sh use-tcp
# Push the pre-generated event file
adb push events /mnt/sdcard
# Start playing
./play.sh
How is works ?
Why fast ?
- Because I don't use
adb shell input tap
, instead use a generated file that represent a tap event, thencat tap > /dev/input/event1
. - Use generated shell run in android.
How to detect the screen event ?
Use screen capture, then use the image magic to check the color,kind of slowly, but works.
More
Check the source
BBVM - BeBasic Virtual Machine
The first VM in my live.
Guava 简介
转战 Hugo, 博客迁移之路
都快要把自己感动, 从最初(2011年)的 Wordpress, 到后来自己开发的 Tellets , 现在又到了 Hugo.
之所以抛弃 Wordpress 是因为它太笨重了,那些年是租的虚拟主机来挂博客,每年也还会有些投入,但是后来很少维护了,便不在想续费了.
后面想找一个轻便的能根据文件时生成的博客系统,所幸找到了 Droplet,但发现好多东西都不能满足要求,后来把 Droplet 完全重写成了 Tellts,自己添加的最喜欢的功能是直接配置 Github 的文章引用. Tellets 也是 PHP 的,而且必须要支持文件操作,但很多 PHP 应用服务器都不提供文件操作(例如: 新浪 SEA, 当初的京东云擎),后来主机停了便没有去管了. 再后来有点想用 Go 重写 Tellts, 但实在没时间,然后又过了很长一段时间.
在工作的情况下需要了解 Docker, 顺势也就利用 Docker 部署了 Hugo.
一致性Hash算法
该算法最开始是开发来替代memcached
键到服务器的映射算法的.
消息中间件简介 mom-intro
同步
分布式对象技术(Distributed Object Technologies - DOT), 远程过程调用 RPC: 同步操作 (调用被阻塞,直到被调用者返回).