#### Nginx的特點
* 擅長處理靜態小文件(1M)
* 支持高并發(支持epoll模型)
* 占用資源少
* 2W并發連接,10個進程,200M內存
* 配置簡單、靈活、輕量
* 功能豐富(Web、Proxy、Cache)
* 工作在IOS第七層(支持限速、連接數限制等)
#### Nginx基本功能
* 靜態服務(圖片、視頻、css、js、html)
* 基于域名/IP/端口的虛擬主機
* Http/Https、SMTP、POP3反向代理
* TCP/UDP反向代理
* FastCGI、uWSGI反向代理
* 負載均衡
* 頁面緩存(CDN)
* 支持gzip、expirse
* URL Rewrite
* 路徑識別
* 基于IP、用戶的訪問控制
* 支持訪問速率、并發限制
* 反向代理(適用2000WPV、并發連接1W/秒)
#### Nginx原理
##### master process
1. 與外界通訊和工作進程管理
2. 讀取nginx配置文件并驗證有效性
3. 建立、綁定和關閉Socket
4. 按照配置文件生成、管理和結束工作進程
5. nginx重啟、停止、重載配置文件、平滑升級、管理日志文件
##### worker process
1. 接收客戶端請求,講請求交給各個功能模塊處理
2. 系統IO調用,獲取相應的數據,發送相應給客戶端
3. 數據緩存管理
4. 接收主進程指令,比如重啟、關閉
##### 緩存索引重建及管理進程
cache模塊主要由緩存索引重建和緩存索引管理兩個進程完成,緩存索引重建進程是在nginx服務啟動一段時間后(默認1分鐘),由主進程生成,對本地磁盤的索引文件在內存中建立元數據,包括掃描、過期更新等操作,完成后退出
* 模塊只有使用時才加載
#### Nginx常用模塊
核心模塊
* Core functionality
標準模塊
* ngx\_http\_core\_module
* ngx\_http\_access\_module
* ngx\_http\_fastcgi\_module
* ngx\_http\_gzip\_module
* ngx\_http\_rewrite\_module
* ngx\_http\_upstream\_module
* ngx\_http\_proxy\_module
* ngx\_http\_limit\_conn\_module
* ngx\_http\_limit\_req\_module
* ngx\_http\_auth\_basic\_module
* ngx\_http\_log\_module
* ngx\_http\_ssl\_module
* ngx\_http\_status\_module
* ngx\_http\_realip\_module
#### Nginx(Proxy)支持的算法
rr 輪詢wrr 權重輪詢iphash hash算法(解決session命中)urlhash hash算法fair 動態算法(響應時間最短)
### Nginx部署(1.8.1)
#### 安裝依賴
~~~
yum install openssl-devel pcre-devel pcre gcc zlib -y
~~~
* pcre 正則處理需要
* gcc 編譯需要
* zlib 壓縮需要
* openssl 安全鏈接需要
~~~
#### 基本操作
~~~
#啟動
/app/nginx/sbin/nginx
#停止
/app/nginx/sbin/nginx -s stop
# 檢查語法
/app/nginx/sbin/nginx -t
#重啟
/app/nginx/sbin/nginx -s
#重啟原理:生成基于新配置的線程,新請求轉發到新線程,舊線程處理完成后停止。
~~~
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
~~~
- 文章翻譯
- Large-scale cluster management at Google with Borg
- Borg Omega and kubernetes
- scaling kubernetes to 7500 nodes
- bpf 的過去,未來與現在
- Demystifying Istio Circuit Breaking
- 知識圖譜
- skill level up graph
- 一、運維常用技能
- 1.0 Vim (編輯器)
- 1.1 Nginx & Tengine(Web服務)
- 基礎
- 1.2 zabbix
- 定義
- 登錄和配置用戶
- 1.3 RabbitMQ(消息隊列)
- 原理
- RabbitMQ(安裝)
- 1.4虛擬化技術
- KVM
- 1.5 Tomcat(Web中間件)
- 1.6Jenkins
- pipline
- 1.7 Docker
- network
- 1.8 Keepalived(負載均衡高可用)
- 1.9 Memcache(分布式緩存)
- 1.10 Zookeeper(分布式協調系統)
- 1.11 GitLab(版本控制)
- 1.12 Jenkins(運維自動化)
- 1.13 WAF(Web防火墻)
- 1.14 HAproxy負載均衡
- 1.15 NFS(文件傳輸)
- 1.16 Vim(編輯器)
- 1.17 Cobbler(自動化部署)
- 二、常用數據庫
- 2.1 MySQL(關系型數據庫)
- mysql主從復制
- 2.2 Mongodb(數據分析)
- 2.3 Redis(非關系數據庫)
- 三、自動化運維工具
- 3.1 Cobbler(系統自動化部署)
- 3.2 Ansible(自動化部署)
- 3.3 Puppet(自動化部署)
- 3.4 SaltStack(自動化運維)
- 四、存儲
- 4.1 GFS(文件型存儲)
- 4.2 Ceph(后端存儲)
- 五、運維監控工具
- 5.1 云鏡
- 5.2 ELK
- 六、運維云平臺
- 6.1 Kubernetes
- 6.2 OpenStack
- 介紹
- 安裝
- 七、Devops運維
- 7.1 理念
- 7.2 Devops運維實戰
- 八、編程語言
- 8.1 Shell
- 書籍《Wicked Cool Shell Scripts》
- 8.2 Python
- 8.3 C
- 8.4 Java
- leecode算法與數據結構
- 九、雜記
- 高優先級技能
- 知識點
- JD搜集
- 明顯的短板
- 1.0 Python
- 1.1 Kubernetes
- 1.18.2 《kubernetes in action》
- 遺漏知識點
- 1.18.3 GCP、azure、aliyun
- Azure文檔
- 1.18.5 《program with kubernetes》
- Istio
- HELM
- 《Kubernetes best practice》
- Kubernetes源碼學習
- Scheduler源碼
- 調度器入口
- 調度器框架
- Node篩選算法
- Node優先級算法
- pod搶占調度
- 入口
- 主要代碼結構
- new
- 文章翻譯
- Flannel
- 從二進制集群搭建
- 信息收集
- docker優化
- 1.2 shell
- 面試題
- grep awk sed 常見用法
- shell實踐
- 1.3 Data structure(數據結構)
- Calico
- Aliyun文檔以及重點模塊
- git
- 大數據組件
- 前端,后端,web框架
- cgroup,namespace
- 內核
- Linux搜集
- crontab
- centos7常用優化配置
- centos Mariadb
- eBPF
- ebpf的前世今生
- Linux性能問題排查與分析
- 性能分析搜集
- 性能分析常用10條
- 網絡性能優化
- 文本處理命令
- sql
- Iptables
- python面試題
- iptables
- iptables詳細
- zabbix面試題,proj
- prometheus
- web中間件
- nginx
- Haproxy
- grep sed awk
- Linux常用命令
- 云平臺
- 書籍Linux應用技巧
- kafka
- kafka面試題
- ETCD
- Jenkins
- 3天補充的點
- K8s源碼
- K8s
- k8s實操
- etcd
- test
- BPF
- PSFTP使用
- StackOverflow問答精選
- 問題
- 我對于學習思考
- 修改ssh超時時間
- 課程目錄
- 運維與運維開發
- The Person
- 個人雜談
- mysql主從復制
- 對于工作的認識與思考