1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

vps add some

This commit is contained in:
shylinux 2018-09-11 11:11:32 +08:00
parent 6d2d7c2f81
commit c69887664a
7 changed files with 456 additions and 17 deletions

View File

@ -130,9 +130,9 @@ function menu() {
var m = document.getElementsByTagName("pre");
for (var i = 0; i < m.length; i++) {
var line = (m[i].clientHeight-10)/15
// if (line < 3) {
// continue
// }
if (line < 3) {
continue
}
console.log(m[i].clientHeight)
var nu = m[i].parentElement.insertBefore(document.createElement("div"), m[i]);
nu.className = "number1"

View File

@ -147,15 +147,17 @@
padding-left:10px;
}
.number1 {
padding:5px;
line-height:15px;
padding:10px;
float:left;
margin-left:0px;
font-size:13px;
background-color:#f8f8f8;
border: solid 1px green;
border:solid 1px green;
}
.number1 div {
color:#999;
text-align:right;
margin:0;
padding:0;

59
usr/wiki/docker.md Normal file
View File

@ -0,0 +1,59 @@
## 简介
docker为应用软件提供一个完整的独立的运行环境比物理机与虚拟机更加轻量。
- 官网: <https://www.docker.com/>
- 文档: <https://docs.docker.com/>
- 源码: <https://github.com/docker/docker-ce>
- 入门: <https://yeasy.gitbooks.io/docker_practice>
配置镜像加速器
MAC->Preferences->Daemon->Register Mirrors->"https://registry.docker-cn.com"
### 基本命令
下载镜像,启动容器。
```
$ docker pull busybox:latest
$ docker run -it busybox
#
```
挂载目录,启动容器。
```
$ docker run -it -v ~/share:/home/share busybox
```
### 镜像管理 docker image
- 查看: docker image ls
- 删除: docker image rm
- 清理: docker image prune
### 容器管理 docker container
- 查看: docker container ls
- 查看: docker container ls -a
- 清理: docker container prune
### 启动容器 docker run
- 交互式启动: docker run -it busybox
- 守护式启动: docker run -dt busybox
- 交互式连接: docker exec -it *container* sh
- 一次性执行: docker exec *container* ls
- 停止容器: docker stop *container*
### 制作镜像
- 交互式: docker commit *container* *repos:tag*
- 脚本式: docker build *deploy_path*
```
$ mkdir image && cd image
$ vi Dockerfile
FROM debian
RUN apt-get update\
&& apt-get install python \
&& apt-get install git
$ docker build .
```

7
usr/wiki/mysql.md Normal file
View File

@ -0,0 +1,7 @@
## 简介
MySQL 是一个开源的关系数据库管理系统。
- 官网: <https://www.mysql.com>
- MAC客户端: <https://sequelpro.com/download#auto-start>
变量的定义与引用: <https://www.cnblogs.com/EasonJim/p/7966918.html>

45
usr/wiki/nginx.md Normal file
View File

@ -0,0 +1,45 @@
## 简介
Nginx 是一个异步框架的Web服务器也可以用作反向代理负载均衡和HTTP缓存。
- 维基百科: [https://zh.wikipedia.org/wiki/Nginx](https://zh.wikipedia.org/wiki/Nginx)
- 官网: [https://www.nginx.org/](https://www.nginx.org/)
## 源码安装
```
$ wget http://nginx.org/download/nginx-1.15.2.tar.gz
$ tar xzf nginx-1.15.2.tar.gz
$ cd nginx-1.15.2
$ ./configure
$ make
$ sudo make install
$ sudo nginx
$ curl localhost
...
```
## 基本配置
```
http {
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /proxy {
proxy_pass http://localhost:9094;
}
}
}
```
### http 系统配置
### server 服务配置
#### listen 网络连接
#### server_name 服务名称
### location 路由配置
#### root 文件目录
#### index 索引文件
#### proxy_pass 反向代理

320
usr/wiki/redis.md Normal file
View File

@ -0,0 +1,320 @@
## 简介
Redis是一个使用ANSI C编写的开源、支持网络、基于内存、可持久性的键值对存储数据库。
Redis是最流行的键值对存储数据库。
- 维基百科: <https://zh.wikipedia.org/wiki/Redis>
- 官网: <https://redis.io](https://redis.io>
- 源码: <https://shylinux.com/wiki/redis-4.0.11>
- github: <https://github.com/antirez/redis>
## 源码安装
```
$ wget http://download.redis.io/releases/redis-4.0.11.tar.gz
$ tar xzf redis-4.0.11.tar.gz
$ cd redis-4.0.11
$ make
```
#### 启动服务端
```
$ src/redis-servce
...
```
#### 启动客户端
```
$ src/redis-cli
127.0.0.1:6379>
```
#### 基本命令
```
$ src/redis-cli
127.0.0.1:6379> set employee_name shy
OK
127.0.0.1:6379> get employee_name
"shy"
```
## 源码解析
### 目录解析
- COPYING 版权文件
- README.md 说明文档
- Makefile make文件
- deps/ 依赖库
- src/ 源码目录
- tests/ 测试脚本
- utils/ 工具脚本
- redis.conf 配置文件
- sentinel.conf 配置文件
BUGS
INSTALL
MANIFESTO
CONTRIBUTING
00-RELEASENOTES
dump.rdb
runtest
runtest-cluster
runtest-sentinel
### 代码解析
```
server.h //服务端
redisObject:struct //数据结构
type:unsigned
encoding:unsigned
lru:unsigned
refcount:int
ptr:void*
server.c //服务端
server: redisServer //服务端上下文
pid: pid_t
configfile: char*
executable: char*
exec_argv: char*
commands: dict* //命令哈希表
db: redisDb* //数据库
dict: dict*
expires: dict*
blocking_keys: dict*
ready_keys: dict*
watched_keys: dict*
id: int
avg_ttl: long long
clients: list/client //客户端连接
id: uint64
fd: int
db: redisDb*
name: robj*
querybuf: sds
pending_querybuf: sds
argc: int
argv: robj**
cmd: redisCommand*
reply: list*
redisCommandTable: redisCommand //命令列表
"get": getCommand
"set": setCommand
setGenericCommand(c)
setKey(c->db,k,v)
lookupKeyWrite(db,k)
lookupKey(db,k)
dictFind(db->dict,k->ptr)
dbAdd(db,k,v)
dictAdd(db->dict,k->ptr,v)
dbOverwrite(db,k,v)
dictReplace(db->dict,k->ptr,v)
addReply(c, o)
prepareClientToWrite(c)
listAddNodeHead(server.clients_pending_write, c)
_addReplyToBuffer(c, o)
c->buf
c->bufpos
_addReplyObjecToList(c, o)
listAddNodeTail(c->reply, sdsdup(o->ptr))
serverLog() //输出日志
server.verbosity
serverLogRaw()
server.logfile
ustime()
mstime()
main() //程序入口
initServerConfig() //初始化server
populateCommandTable() //加载命令列表
server.commands = redisCommandTable
loadServerConfig() //加载配置文件
initServer() //
aeCreateFileEvent()
loadDataFromDisk()
aeMain():ae.c //事件循环
el->beforesleep()
handleClientsWithPendingWrites() //返回命令执行结果
writeToClient(c)
write(c->buf)
aeProcessEvents(el):ae.c
aeApiPoll()
el->aftersleep()
fe->rfileProc()/acceptTcpHandler() //添加网络监听事件
anetTcpAccept()
acceptCommonHandler()
createClient()
aeCreateFileEvent()/readQueryFromClient(el) //添加读取数据事件
read(c->querybuf)
processInputBuffer(c)
processInlineBuffer() //解析客户端命令
c->argv[i]=createObject()
processCommand(c) //执行客户端命令
c->cmd=lookupCommand()
dictFetchValue(server.commands)
call(c)
c->cmd->proc(c)/setCommand(c)
fe->wfileProc()
fe->rfileProc()
processTimeEvnts()
db.c
setKey()
t_string.c
setGenericCommand()
setCommand()
t_hash.c
t_list.c
t_set.c
t_zset.c
networking.c //
createClient()
adlist.h //双链表
aslist.c
ae.h //事件循环
ae.c
ae_epoll.c
ae_evport.c
ae_kqueue.c
ae_select.c
anet.h //网络接口
anet.c
aof.c
asciilogo.h
atomicvar.h
bio.h
bio.c
bitops.c
blocked.c
childinfo.c
cluster.h
cluster.c
config.h
config.c
crc16.c
crc64.c
crc64.h
debug.c
debugmacro.h
defrag.c
dict.h
dict.c
edianconv.c
edianconv.h
evict.c
expire.c
fmacros.h
geo.c
geo.h
geohash.h
geohash.c
geohash_helper.h
geohash_helper.c
help.h
hyperloglog.c
intset.h
intset.c
latency.h
latency.c
lazyfree.c
lzf.h
lzf_c.h
lzf_d.h
lzfP.h
memtest.c
module.c
multi.c
networking.c
notify.c
object.c
pqsort.c
pqsort.h
pubsub.c
quicklist.c
quicklist.h
rand.c
rand.h
rax.c
rax.h
rax.malloc.h
rdb.c
rdb.h
redis-benchmark.c
redis-cli.c
redisassert.h
redismodule.h
release.c
release.h
replication.c
rio.h
rio.c
scripting.c
sds.h
sds.c
sdsalloc.h
sentinel.c
setproctitle.c
sha1.h
sha1.c
siphash.h
siphash.c
sort.c
sparkline.h
sparkline.c
syncio.c
testhelp.c
util.c
util.h
version.h
ziplist.h
ziplist.c
zipmap.c
zipmap.h
zmalloc.c
zmalloc.h
dict.c //
dict:struct
type:dictType
privdata:void*
ht:dictht[2]
table:dictEntry**
key:void*
v:union
next:void*
size:long
sizemask:long
used:long
rehashidx:long
iterators:long
zmalloc.c //内存管理
zmalloc()
zcalloc()
zrealloc()
zmalloc_size()
zfree()
zstrdup()
```
### server.h
#### struct redisServer
#### struct client
#### struct redisObject
### networking.c
### db.c
### object.c
### t_hash.c
### t_list.c
### t_set.c
### t_string.c
### t_zset.c
### ae.c 事件循环

View File

@ -1,4 +1,4 @@
## 简介
## 0. 简介
zsh 和bash一样是一种终端的shell但提供了更丰富的功能更快捷的补全。
@ -8,7 +8,11 @@ vim 是一款强大的编辑器,通过模式化快捷键提升编辑速度,
使用zsh+tmux+vim的工具链根据自己的使用习惯进行个性化配置可以极大的提升编程开发速度。
### zsh安装
相关链接
- Mac包管理器: <https://brew.sh/>
### 0.1 zsh安装
Mac上自带zsh不用安装但Ubuntu上需要自己安装一下。
```
$ sudo apt-get install zsh
@ -21,7 +25,7 @@ $ chsh -s /usr/bin/zsh
```
$ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
```
### tmux安装
### 0.2 tmux安装
Ubuntu上安装
```
$ sudo apt-get install tmux
@ -30,7 +34,7 @@ Mac上安装
```
$ brew install tmux
```
如果Mac上没有brew可以安装一下 [Mac 包管理器 brew](https://brew.sh/)
如果Mac上没有brew可以安装一下.
```
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```
@ -38,7 +42,7 @@ $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/maste
```
$ tmux
```
### vim安装
### 0.3 vim安装
Mac上自带vim不需要安装但Ubuntu需要自己安装一下。
```
$ sudo apt-get install vim
@ -47,12 +51,12 @@ vim有很丰富的插件可以下载一个插件管理器。
```
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
```
## 基本快捷键
### zsh使用
### tmux使用
### vim使用
## 个性化配置
## 源码解析
## 1. 基本快捷键
### 1.1 zsh使用
### 1.2 tmux使用
### 1.3 vim使用
## 2. 个性化配置
## 3. 源码解析
Mac上安装pip
```
$ sudo easy_install pip
@ -65,5 +69,7 @@ $ sudo apt-get update
$ sudo apt-get install asciinema
$ sudo apt-get install python3-pip
$ sudo pip install TermRecord
```
[终端录制](https://asciinema.org/)
<video id="video" poster="/static/public/player/playerbg.png" width="100%" height="auto" preload="metadata" controls="" src="blob:http://99vbkc.com/5aa889fc-0af4-4fdc-ac25-46d456b70028"></video>
- 终端录制: <https://asciinema.org/>