Elastic Cloud on Kubernetes 快速入门
在 Kubernetes 集群中部署 ECK(Elastic Cloud Kubernetes)
安装自定义资源定义(Custom Resource Definition, CRD)
在 Kubernetes 集群中部署 ECK(Elastic Cloud Kubernetes)
安装自定义资源定义(Custom Resource Definition, CRD)
查找文件
-name 或 -iname(大小写不敏感)
find . -name "*.pyc"
-m(最近多长时间修改)
min, 分钟
time, 哪天 0(24小时) 1(24-48小时) 2(48-72小时)
$ find /var/log -mmin -10
/var/log/messages
$ find /var/log -mtime 0 -ls
33575669 4 drwxr-xr-x 15 root root 4096 7月 29 06:33 /var/log
34131780 164 -rw------- 1 root root 166061 7月 29 10:20 /var/log/messages
find /var/log -mtime -1
find /var/log -mtime 1
find /var/log -mtime +1
-size(文件大小) 显示当前目录下超过 40M的文件 $ find .
搜索文件内容
grep 'text' hello.txt
grep -i 'text' hello.txt
grep 'text' hello.txt hi.txt
grep 'text' *
grep -R 'text' *
匹配搜索
grep "index-url" ~/.config -RnH
/home/lnsoft/.config/pip/pip.conf:2:index-url = https://mirrors.aliyun.com/pypi/simple/
find ~ -name pip* | xargs -i grep "index-url" {} --color -nH
/home/lnsoft/.config/pip/pip.conf:2:index-url = https://mirrors.aliyun.com/pypi/simple/
find . | grep -F .run
查看图像信息
$ file test.jpg
test.jpg: JPEG image data, JFIF standard 1.02, resolution (DPI), density 96x96, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=7, orientation=upper-left, xresolution=98, yresolution=106, resolutionunit=2, software=Adobe Photoshop CS Windows, datetime=2013:03:18 11:45:34], baseline, precision 8, 750x499, frames 3
ImageMagick是一个用于查看、编辑位图文件以及进行图像格式转换的开放源代码软件套装。它可以读取、编辑超过100种图像格式。
安装
sudo apt-get install imagemagick
brew install imagemagick
格式转换
convert test.jpg test.png
灰度
convert -colorspace gray input_file output_file
字符串
分隔符号可以自由更换
$ echo "Hi, John." | sed 's/Hi/HI/g'
HI, John.
$ echo "Hi, John." | sed 's#Hi#HI#g'
HI, John.
$ echo "Hi, John." | sed 's-Hi-HI-g'
HI, John.
单引号' $ echo "'s', 'm', 'l', 'x'" | sed 's/'"'"'s'"'"', '"'"'m'"'"', '"'"'l'"'"', '"'"'x'"'"'/'"'"'s'"'"', '"'
下载多个文件
wget https://upload.wikimedia.org/wikipedia/commons/1/13/Intel_CPU_Core_i7_6700K_Skylake_perspective.jpg https://images-na.ssl-images-amazon.com/images/I/51iVSqLIBWL._AC_.jpg
wget -i urls.txt
后台下载(-b)
wget -i urls.txt -b
指定输出目录
wget -i urls.txt -P output
断点续传(-c --continue)
wget -c https://github.com/goharbor/harbor/releases/download/v2.1.3/harbor-offline-installer-v2.1.3.tgz
可读的方式显示文件大小
# -h, --human-readable with -l and/or -s, print human readable sizes (e.g., 1K 234M 2G)
ls -lh
ll -h
显示目录的所有子目录的内容
# -R, --recursive list subdirectories recursively
ls -lR
ll -R
按时间进行排序
按时间降序显示当前目录
# -l use a long listing format; -t sort by modification time, newest first
ls -lt
ll -t
按时间升序显示当前目录
# -r --reverse reverse order while sorting
ls -lrt
ll -rt
按大小进行排序
按大小降序显示当前目录
# -S sort by file size, largest first
ls -lS
ll -S
按大小升序显示当前目录
ls -lrS
ll -rS
统计目录下文件数量
统计当前目录下的文件数量
ls -l | grep "^-" | wc -l
统计当前目录下的目录数量
ls -l | grep "^d" | wc -l
统计当前目录下(包含子目录)的文件数量 ls -lR | grep
导入包
>>> import os
>>> import shutil
文件
拷贝文件
目录路径可以是目录名
>>> shutil.copy('/home/python/main.py', '/home/python/main.py.bak')
>>> shutil.copy('/home/python/main.py', '/home/python/bak/')
创建文件
open(filename, 'w').close()
def touch(path):
with open(path, 'a'):
os.utime(path, None)
OS X需要root特权
os.mknod(filename)
修改文件名
>>> os.rename('filename', 'new_filename')
删除文件
>>> os.remove('/home/python/main.py')
目录
拷贝目录树 >>> shutil.
拉取镜像 Detectron
sudo docker pull gouchicao/detectron:latest
创建工程(COCO格式)
└── helmet 工程目录
├── images 样本图片目录
├── helmet_train.json 训练的样本标注信息
├── helmet_val.json 验证的样本标注信息
├── test 测试图片目录
├── predict 预测图片目录
├── model 模型目录
└── e2e_mask_rcnn_R-101-FPN_2x.yaml 网络配置文件
运行容器 Detectron,挂载工程目录。
sudo docker run -it --runtime=nvidia --name detectron-helmet \
-v /helmet-project-realpath:/detectron/project \
gouchicao/detectron:latest
修复BBOX_XFORM_CLIP错误
nano /detectron/detectron/utils/env.py
yaml_load = lambda x: yaml.load(x, Loader=yaml.Loader)
工程设置 配置数据集 nano /detectron/detectron/datasets/dataset_catalog.
本地安装
云端环境
Binder
Google Colab
多用户版本
部署
使用Docker在Kubernetes上部署JupyterHub,允许它为大量用户进行有效扩展和维护。
专为小型部署而设计的最新版本,是一种在单个虚拟机上安装JupyterHub的轻量级方法。适用于单个服务器上的(0-100)个少量用户。
编译darknet
git clone https://github.com/pjreddie/darknet
cd darknet/
make
创建工程 工程目录结构 ├── darknet53.conv.74 基于imagenet的预训练模型 └── open-close 工程目录 ├── backup 存储模型训练时权重值 ├── cfg 配置目录 │ ├── train.txt 存储用于训练的图像路径 │ ├── valid.txt 存储用于验证的图像路径 │ ├── voc.data 配置文件 │ ├── voc.names 标签名 │ └── yolov3.cfg YOLOv3神经网络文件 ├── data │ └── labels 预测时用于显示标签名字 │ ├── 100_0.png │ ├── 100_1.png │ ├── ...... │ └── make_labels.py ├── images 图像样本集 │ ├── IMG_9255.JPG │ ├── IMG_9263.JPG │ ├── IMG_9266.JPG │ └── IMG_9280.JPG ├── labels PASCAL VOC格式的标注 │ ├── IMG_9255.xml │ ├── IMG_9263.xml │ ├── IMG_9266.xml │ └── IMG_9280.
安装五笔输入法
yum remove ibus
yum install ibus ibus-table
yum install ibus ibus-table-wubi
apt purge ibus
apt install ibus ibus-table
apt install ibus ibus-table-wubi
Ubuntu
修改IP
$ sudo nano /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
eno1:
addresses:
- 172.16.33.1/24
gateway4: 172.16.33.254
nameservers: {}
version: 2
应用配置
$ sudo netplan apply
# 推荐使用 debug 参数
$ sudo netplan --debug apply
或者
sudo netplan generate
验证
ip a | grep eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 172.16.33.1/24 brd 172.16.33.255 scope global eno1
参考资料 How to setup a static IP on Ubuntu Server 18.04 How to configure Network Settings in Ubuntu 18.
JDK-MCR(MATLAB Compiler Runtime)
FROM openjdk:latest
LABEL maintainer="wang-junjian@qq.com"
MAINTAINER Wang Junjian
RUN apt-get update && apt-get install -y curl wget unzip xorg
#Install MATLAB runtime
RUN mkdir /mcr-install && cd /mcr-install && \
wget -nv http://ssd.mathworks.com/supportfiles/downloads/R2018b/deployment_files/R2018b/installers/glnxa64/MCR_R2018b_glnxa64_installer.zip && \
unzip MCR_R2018b_glnxa64_installer.zip && \
./install -mode silent -agreeToLicense yes && \
rm -Rf /mcr-install
ENV LD_LIBRARY_PATH /usr/local/MATLAB/MATLAB_Runtime/v95/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v95/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v95/extern/bin/glnxa64
CMD /bin/sh
Registry
配置hosts
sudo nano /etc/hosts
10.10.10.10 HOSTNAME
运行registry
docker pull registry:2
sudo docker run -d \
-p 5000:5000 \
-v /home/ailab/docker-registry:/var/lib/registry \
--restart=always \
--name docker-registry \
registry:2
修改Docker配置
sudo nano /etc/docker/daemon.json
{
"live-restore": true,
"group": "dockerroot",
"insecure-registries": ["HOSTNAME:5000"]
}
重启Docker Engine
sudo systemctl restart docker
推送镜像
sudo docker tag hello-world:latest HOSTNAME:5000/hello-world:latest
sudo docker push HOSTNAME:5000/hello-world:latest
Registry UI
安装VNC服务
sudo apt-get install x11vnc
配置VNC
x11vnc -storepasswd
启动VNC服务
x11vnc -forever -shared -rfbauth ~/.vnc/passwd
连接VNC服务
打开splotlight,搜索[屏幕共享],运行。输入IP:5900
参考资料
Ubuntu
sudo apt-get install openssh-server
sudo apt-get remove openssh-server
sudo service ssh start
sudo service ssh stop
sudo service ssh restart
service ssh status
sudo vi /etc/ssh/sshd_config
ssh username@ip -p 22
sudo update-rc.d ssh defaults
sudo update-rc.d ssh remove
ls /etc/rc*
......
......
ls -l /etc/rc2.d/S02ssh
lrwxrwxrwx 1 root root 13 12月 25 16:33 /etc/rc2.d/S02ssh -> ../init.d/ssh
参考资料