Sentris 64M/128M一键重装/备份恢复/SSR教程


Sentris出了几款便宜的Openvz VPS,6刀3年很便宜。一个月才0.17刀,买了第3个套餐(64M openvz pccw)最好加多1刀上128M,后台不支持重装系统,貌似发工单可以免费重装系统,64M内存很小,不建议装Centos、debian这些系统,建议重装成Alpine Linux。

Alpine Linux是一个社区开发的面向安全应用的轻量级Linux发行版操作系统,占用资源很少,初始状态基本只占用几M内存和几十M硬盘,而且还很稳定,适合很多小型服务器和设备使用。

购买地址:6刀三年

安装Alpine

你可以通过如下脚本将VPS上现有的linux系统一键转换为Alpine Linux
注:如下脚本只支持Openvz系统,并且VPS上原有数据会全部丢失,安装成功后ssh端口号会变为22密码不变

wget --no-check-certificate http://yangwenqing.com/files/Source/alpine.sh && bash alpine.sh

安装完成后ssh会断开,重新登录会变为Alpine Linux系统

Welcome to Alpine!

The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <http://wiki.alpinelinux.org/>.

You can setup the system with the command: setup-alpine

You may change this message by editing /etc/motd.

LXC_NAME:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/simfs                5.0G     21.8M      5.0G   0% /
tmpfs                     6.4M     72.0K      6.3M   1% /run
dev                      10.0M         0     10.0M   0% /dev
shm                      32.0M         0     32.0M   0% /dev/shm
LXC_NAME:~# free -m
             total       used       free     shared    buffers     cached
Mem:            64          6         57          0          0          3
-/+ buffers/cache:          3         60
Swap:            0          0          0
LXC_NAME:~#

磁盘和内存占用(内存占用6M,硬盘占用21M)

常用命令

apk update //更新最新镜像源列表
apk search //查找所以可用软件包
apk add //安装软件
apk del //删除软件
apk upgrade //升级软件

安装软件

apk add wget //安装wget
apk add bash //安装bash
apk add curl //安装curl

重新安装

如果想恢复初始状态(相当于重装),在Alpine下运行下面的命令

wget --no-check-certificate http://yangwenqing.com/files/Source/unalpine.sh && chmod 755 unalpine.sh &&./unalpine.sh &

备份恢复

备份恢复使用场景:在机器上,我们部署了很多程序,举个例子,安装了supervisord,并且配置了需要的监听程序,已经设置开机启动,那如果去其他机器上,还是得照样子写一次,显得非常麻烦,所以我们使用此脚本,即可自动对系统进行打包,去其他机器上执行恢复脚本即可。

备份系统:

cd /
tar czf backup.tar.gz * --exclude dev --exclude proc --exclude sys

备份后,会在根目录下出现backup.tar.gz文件,把此文件拷贝到其他机器即可,可以利用scp,resyn,winscp等工具。

还原系统:

wget --no-check-certificate http://yangwenqing.com/files/Source/restore_alpine.sh
chmod 755 restore_alpine.sh
#把backup.tar.gz文件上传到服务器,比如/root/all.tar.gz
./restore_alpine.sh /root/all.tar.gz

即可恢复成备份的系统。

搭建SSR

SSR 脚本

wget --no-check-certificate http://yangwenqing.com/files/Source/alpinessr.sh
sh alpinessr.sh

运行状态

netstat -ntlp

看到有8080端口就说明成功运行SSR了,如果需要修改端口和加密方式的话,请修改/root/config.json即可,修改后需要kill - 9 PID杀掉SSR的进程,再执行:

nohup python3 /usr/local/shadowsocks/server.py -c /root/config.json &

脚本预览

apk update
apk add py3-lxml
apk add python3
pip3 install pip==10.0.0
pip3 freeze
apk add --no-cache --virtual .build-deps tar
apk add --no-cache --virtual .build-deps wget
apk add --no-cache --virtual .build-deps openssl
apk add --no-cache --virtual .build-depslibsodium-dev
wget -O /tmp/shadowsocksr-3.2.2.tar.gz https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz
tar zxf /tmp/shadowsocksr-3.2.2.tar.gz -C /tmp
mv /tmp/shadowsocksr-3.2.2/shadowsocks /usr/local/
rm -rf /tmp/shadowsocksr-3.2.2
rm -rf /tmp/shadowsocksr-3.2.2.tar.gz
cd /root
echo '{
    "server":"0.0.0.0",
    "server_ipv6":"::",
    "server_port":8080,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"123123",
    "timeout":120,
    "method":"none",
    "protocol":"auth_chain_a",
    "protocol_param":"",
    "obfs":"plain",
    "obfs_param":"",
    "redirect":"",
    "dns_ipv6":false,
    "fast_open":true,
    "workers":1
}' >config.json
nohup python3 /usr/local/shadowsocks/server.py -c /root/config.json &
echo "nohup python3 /usr/local/shadowsocks/server.py -c /root/config.json & " >/etc/local.d/ssr.start
chmod +x /etc/local.d/ssr.start
rc-update add local

安装完成后重启,包含SSR和系统的内存占用如下:

LXC_NAME:~# free -m
         total       used       free     shared    buffers     cached
Mem:            64         26         37          0          0          9
-/+ buffers/cache:         17         46
Swap:            0          0          0
LXC_NAME:~# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:222             0.0.0.0:*               LISTEN      502/sshd
tcp        0      0 :::8080                 :::*                    LISTEN      525/python3
tcp        0      0 :::222                  :::*                    LISTEN      502/sshd
LXC_NAME:~#
Last modification:January 12th, 2021 at 10:04 am
If you think my article is useful to you, please feel free to appreciate