安装环境VMware
首先下载 IOS安装包
|
|
开始安装
|
|
![键盘
默认虚拟存储为sda,点OK继续:
测试使用,我就用DHCP了……
|
|
|
|
DevOps|Python|Linux
|
|
|
|
Perl 是一种弱类型语言,所以变量不需要指定类型,Perl 解释器会根据上下文自动选择匹配类型。
三个基本的数据类型:标量、数组、哈希
Perl 为每个变量类型设置了独立的命令空间,所以不同类型的变量可以使用相同的名称,如 $foo 和 @foo 是两个不同的变量。标量
在变量名前加$表示是标量
12345 #number$my_number=123;#string$my_str="123";
.可以用来链接两个标量
1 print ( "$my_number . $my_str\n");
分别表示当前执行脚本的文件名,行号,包名。
这些特殊字符是单独的标记,不能写在字符串中
123 print "FileName:" . "\t".__FILE__."\n";print "LineNumber:" . "\t".__LINE__."\n";print "PackageName:" . "\t".__PACKAGE__."\n";
|
|
数组变量以字符”@”开头,索引从0开始
也可以以 qw 开始定义数组
|
|
|
|
哈希是一个无序的 key/value 对集合。可以使用键作为下标获取值
类似Python的字典
123 %hash=('name'=>'LongLi','age'=>18);print (%hash{'name'}, "\n");print (%hash{'age'}, "\n");
|
|
配置简单、不依赖第三方软件;将容器和物理机放在同一网段
vim /etc/network/interfaces
|
|
Docker网络设置
vim /etc/default/docker
|
|
使用自定义网桥
在启动docker服务的时候,使用-b BEIDGE 或者–bridge=BEIDGE来指定使用的网桥
|
|
ip addr show bridge0
配置Docker服务
默认桥接到创建的网桥上
echo ‘DOCKER_OPTS=”-b=bridge0”‘ >> /etc/default/docker
service docker start
新建容器进行测试
高质量、多层虚拟交换机 使用GRE协议
12 GRE 通用路由协议封装隧道技术是一种通过使用互联网络的基础设施在网络之间传递数据的方式,使用隧道传送的数据可以是不同协议的数据帧或包,隧道协议将其它协议的数据帧或包重新封装然后通过隧道发送;新的帧头提供路由信息,以便通过互联网传递被封装的负载数据。
apt-get install openvswitch-switch
apt-get install bridge-utils配置
pc1=192.168.1.110
pc2=192.168.1.55
1234567 #建立网桥ovs-vsctl add-br obr0#添加GRE连接ovs-vsctl add-port obr0 gre0#配置Docker容器虚拟网桥set interface gre0 type=gre options:remote_ip=192.168.1.55root@tp-ubuntu:/etc/default# ovs-vsctl show
|
|
|
|
修改Docker配置文件
为虚拟网桥添加ovs接口
vim /etc/default/docker
1 BRIDGE=br0
原理:建立一个虚拟的网络,用于将运行在不同主机的Docker容器连接起来
安装
1 wget -O /usr/bin/weave https://raw.githubusercontent.com/zettio/weave/master/weave && chmod a+x /usr/bin/weaveweave操作
|
|
客户机1
192.168.1.110
1 weave luanch客户机2
|
|
虚拟机1
1 weave run 192.168.11.2/24 -it ubuntu:14.04 /bin/bash虚拟机2
|
|
查看weave路由状态
weave ps
12 容器重启问题如果使用weave,则就不能再使用docker自带的auto-restart feature(如docker run –restart=always redis),因为weave是在docker之外为容器配置的网络,容器重启的时候docker本身不会做这些事情。因而,还需额外的工具来管理容器的状态(比如systemd, upstart等),这些工具要调用weave命令(weave run/start/attach)来启动容器。
https://github.com/jpetazzo/pipework
思路
在同一宿主主机中创建两台容器,通过pipework创建网桥进行通讯
c1
docker run –name c1 -it ubuntu:14.04
docker run –name c2 -it ubuntu:14.04
创建网桥
git clone https://github.com/jpetazzo/pipework.git
|
|
效果图
Docker提供了一种标准化的DSL,你只需要编写一个Dockerfile,运行docker build指令,就可以构建自己的Image
Dockerfile指令
https://docs.docker.com/engine/reference/builder/
|
|
构建镜像
123456789101112 ➜ DockerfileDemo docker build -t="debian/nginx:2" .Sending build context to Docker daemon 2.048 kBStep 1 : FROM debian---> 1b01529cc499Step 2 : RUN echo "Hello docker!"---> Using cache---> 3791785c0268Step 3 : RUN apt-get update && apt-get install -y nginx---> Using cache---> 47fcc445f762****************************************Successfully built 26eee4e7b4e4查看构建成功后的镜像
123 ➜ DockerfileDemo docker images debian/nginx:2REPOSITORY TAG IMAGE ID CREATED SIZEdebian/nginx 2 26eee4e7b4e4 6 minutes ago 196.4 MB使用该 镜像创建容器
-d 告诉容器以分离的方式在后台运行
nginx -g “daemon off;” 以前台的方式启动Nginx,作为Web容器
1234 ➜ ~ docker run -itd -p 80 debian/nginx:2 nginx -g "daemon off;"b329360da168141902fc623b71f5cc79540bdffad26b1802e504988925ffec54➜ ~ docker port b329360da168141902fc623b71f5cc79540bdffad26b1802e504988925ffec5480/tcp -> 0.0.0.0:32769
以docker hub为例
|
|
|
|
|
|
或者这样查看所有docker映射的端口
先创建一个容器,并在容器里做出修改,最后commit修改
类似github的使用
1234 ➜ ~ docker run -i -t --name test-docker-commit debian /bin/bashroot@8b20759d9e60:/#root@8b20759d9e60:/# apt-get -yqq updateroot@8b20759d9e60:/# apt-get -yqq install ipythoncommit修改
|
|
查看新创建的镜像
|
|
可通过docker inspect查看镜像详细详细
|
|
docker commit 的一些参数
|
|
使用docker-registry进行私有仓库搭建
基于容器
docker pull registry
|
|
打开浏览器输入http://127.0.0.1:5000/v2
通过docker tag将该镜像标志为要推送到私有仓库
|
|
|
|
|
|
|
|
sudo vim /etc/supervisord.conf
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 ➜ /etc cat supervisord.conf; Sample supervisor config file.;; For more information on the config file, please see:; http://supervisord.org/configuration.html;; Notes:; - Shell expansion ("~" or "$HOME") is not supported. Environment; variables can be expanded using this syntax: "%(ENV_HOME)s".; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".[unix_http_server]file=/private/var/run/supervisor.sock ; (the path to the socket file);chmod=0700 ; socket file mode (default 0700);chown=nobody:nogroup ; socket file uid:gid owner;username=user ; (default is no username (open server));password=123 ; (default is no password (open server));[inet_http_server] ; inet (TCP) server disabled by default;port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface);username=user ; (default is no username (open server));password=123 ; (default is no password (open server))[supervisord]logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)logfile_backups=10 ; (num of main logfile rotation backups;default 10)loglevel=info ; (log level;default info; others: debug,warn,trace)pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)nodaemon=false ; (start in foreground if true;default false)minfds=1024 ; (min. avail startup file descriptors;default 1024)minprocs=200 ; (min. avail process descriptors;default 200);umask=022 ; (process file creation umask;default 022);user=chrism ; (default is current user, required if root);identifier=supervisor ; (supervisord identifier, default is 'supervisor');directory=/tmp ; (default is not to cd during start);nocleanup=true ; (don't clean up tempfiles at start;default false);childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP);environment=KEY="value" ; (key value pairs to add to environment);strip_ansi=false ; (strip ansi escape codes in logs; def. false); the below section must remain in the config file for RPC; (supervisorctl/web interface) to work, additional interfaces may be; added by defining them in separate rpcinterface: sections[rpcinterface:supervisor]supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface[supervisorctl]serverurl=unix:///private/var/run/supervisor.sock ; use a unix:// URL for a unix socket;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket;username=chris ; should be same as http_username if set;password=123 ; should be same as http_password if set;prompt=mysupervisor ; cmd line prompt (default "supervisor");history_file=~/.sc_history ; use readline history if available; The below sample program section shows all possible program subsection values,; create one or more 'real' program: sections to be able to control them under; supervisor.;[program:theprogramname];command=/bin/cat ; the program (relative uses PATH, can take args);process_name=%(program_name)s ; process_name expr (default %(program_name)s);numprocs=1 ; number of processes copies to start (def 1);directory=/tmp ; directory to cwd to before exec (def no cwd);umask=022 ; umask for process (default None);priority=999 ; the relative start priority (default 999);autostart=true ; start at supervisord start (default: true);startsecs=1 ; # of secs prog must stay up to be running (def. 1);startretries=3 ; max # of serial start failures when starting (default 3);autorestart=unexpected ; when to restart if exited after running (def: unexpected);exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2);stopsignal=QUIT ; signal used to kill process (default TERM);stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10);stopasgroup=false ; send stop signal to the UNIX process group (default false);killasgroup=false ; SIGKILL the UNIX process group (def false);user=chrism ; setuid to this UNIX account to run the program;redirect_stderr=true ; redirect proc stderr to stdout (default false);stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB);stdout_logfile_backups=10 ; # of stdout logfile backups (default 10);stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0);stdout_events_enabled=false ; emit events on stdout writes (default false);stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB);stderr_logfile_backups=10 ; # of stderr logfile backups (default 10);stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0);stderr_events_enabled=false ; emit events on stderr writes (default false);environment=A="1",B="2" ; process environment additions (def no adds);serverurl=AUTO ; override serverurl computation (childutils); The below sample eventlistener section shows all possible; eventlistener subsection values, create one or more 'real'; eventlistener: sections to be able to handle event notifications; sent by supervisor.;[eventlistener:theeventlistenername];command=/bin/eventlistener ; the program (relative uses PATH, can take args);process_name=%(program_name)s ; process_name expr (default %(program_name)s);numprocs=1 ; number of processes copies to start (def 1);events=EVENT ; event notif. types to subscribe to (req'd);buffer_size=10 ; event buffer queue size (default 10);directory=/tmp ; directory to cwd to before exec (def no cwd);umask=022 ; umask for process (default None);priority=-1 ; the relative start priority (default -1);autostart=true ; start at supervisord start (default: true);startsecs=1 ; # of secs prog must stay up to be running (def. 1);startretries=3 ; max # of serial start failures when starting (default 3);autorestart=unexpected ; autorestart if exited after running (def: unexpected);exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2);stopsignal=QUIT ; signal used to kill process (default TERM);stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10);stopasgroup=false ; send stop signal to the UNIX process group (default false);killasgroup=false ; SIGKILL the UNIX process group (def false);user=chrism ; setuid to this UNIX account to run the program;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB);stdout_logfile_backups=10 ; # of stdout logfile backups (default 10);stdout_events_enabled=false ; emit events on stdout writes (default false);stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB);stderr_logfile_backups=10 ; # of stderr logfile backups (default 10);stderr_events_enabled=false ; emit events on stderr writes (default false);environment=A="1",B="2" ; process environment additions;serverurl=AUTO ; override serverurl computation (childutils); The below sample group section shows all possible group values,; create one or more 'real' group: sections to create "heterogeneous"; process groups.;[group:thegroupname];programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions;priority=999 ; the relative start priority (default 999); The [include] section can just contain the "files" setting. This; setting can list multiple files (separated by whitespace or; newlines). It can also contain wildcards. The filenames are; interpreted as relative to this file. Included files *cannot*; include files themselves.[include]files = /etc/supervisord.d/*.ini
sudo su - root -c “mkdir -p /etc/supervisord.d”
以后supervisord.d 就存放进程的管理脚本
|
|
|
|
|
|
|
|
|
|
|
|
Docker官方脚本
1 curl -sSL https://get.docker.com/ | sh阿里云脚本
|
|
DaoCloud脚本
|
|
不是终止
|
|
|
|
以kali为例
1 docker search kali
|
|
before
|
|
改名
1 ➜ ~ docker tag daocloud.io/library/ubuntu:xenial-20160809 ubuntu:latest可以看到除了REPOSITORY和TAG 其他的都一样
12 daocloud.io/library/ubuntu xenial-20160809 f8d79ba03c00 13 days ago 126.4 MBubuntu latest f8d79ba03c00 13 days ago 126.4 MB然后删除之前的别名
|
|
如果没设置docker服务开机启动的话,先运行命令
chkconfig –add docker
1 在运行docker run的时候再加上命令 --restart=always
对于已经在运行的容器,可通过如下命令进入容器中进行配置
1 docker exec -it $container_id /bin/bash
|
|
tag:
缺失模块。
1、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
2、在根目录_config.yml里添加配置:
jsonContent: meta: false pages: false posts: title: true date: true path: true text: true raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true