因爲運維的項目都是在服務器上,有的是在客戶服務器上操作,所以我們必須熟練使用各種***和遠程連接工具;
比如open***、360connect,easy connect,微軟自帶的***和遠程,還有***堡壘機,teamware,向日葵等等;必須非常熟悉各種連接方式,當然不乏當初最艱苦的客戶拍照片,我給說命令的非常原始低效率的工作方式。總之,連上服務器,進行操作就是最終目的。
當我們跟項目經理要來各種各樣的連接方式並費勁九牛二虎之力連上的時候,Please show time;
首先第一個巨大的坑,網卡的誤操作,在上線環境中,網卡的操作一般是不允許的,因爲涉及到本地的映射,以及項目的延誤等等;
如果我們需要改配置文件添加DNS或者網關的時候,我們需要的是重啓命令;
service network restart | systemctl restart network
一定不要用 ifdown 命令,用完 ifdown 以後,你不會有機會用 ifup 命令的。你的遠程就會斷開,沒有辦法再次連上,只能讓機房管理人員去啓動網卡。
2.查看內存;
一開始一直以爲 free -[h|g|m] , free 下邊對應的就是剩餘內存數;後來才知道原來 available 下邊對應的纔是服務器剩餘內存;
Centos 7系列可以用 h 選項進行查看,Centos 6系列就只能用 g or m 選項纔可以,而且6系列查看內存也是很大的坑;
Centos 7:available 參數對應的即爲當前剩餘內存;
[root@cms ~]# free -h total used free shared buff/cache available Mem: 15G 6.4G 4.8G 109M 4.1G 8.2G Swap: 7.7G 1.2G 6.5G
Centos 6: -/+ buffers/cache: 參數後的第二個參數即爲當前剩餘內存;
[root@Web-A ~]# cat /etc/redhat-release CentOS release 6.5 (Final) [root@Web-A ~]# free -m total used free shared buffers cached Mem: 32051 31140 910 0 1919 26859 -/+ buffers/cache: 2361 29689 Swap: 8015 7 8008
3.服務器整個 Apache 部署替換爲 Nginx 部署;留下痛苦的淚水,熬了好多個夜。
首先是對配置文件進行復寫,這個需要進行統計域名,統計對應端口等,然後在進行復寫。這個不是最重要的,我寫一下最後的替換上線。
首先把配置文件寫入到 /conf.d/ 目錄下 ,然後進行書寫檢查,檢查通過在停 Apache,啓動nginx或者reload,讓開發和測試進行統一測試,查看各種各樣的問題。
這個步驟一定不能亂,事先寫好,讓領導檢查一遍,然後在進行急速的替換。這樣極大的減少的項目的下線時間。之所以寫這個是因爲當時我就直接把Apache停了,項目直接下線了,耽誤了大家很多時間。
4.Docker中的Nginx的https部署;我也寫一下步驟;
①.首先查看容器的映射目錄和端口。
查看端口是查看是否有 443 端口;
查看目錄是SSL證書的目錄是否在映射目錄下,沒在的話,需要複製到映射的 /home 目錄下;以供容器內的nginx使用;
[root@localhost ~]# docker port DOCEKR_NAME 82/tcp -> 0.0.0.0:82 83/tcp -> 0.0.0.0:83 888/tcp -> 0.0.0.0:62080 80/tcp -> 0.0.0.0:80 81/tcp -> 0.0.0.0:8 [root@localhost ~]# docker inspect DOCEKR_NAME "Binds": [ "/home:/storage" ],
②.因爲這個要求是對 聚視 https證書進行部署,所以需要我我們需要找到 jushi 的 nginx 配置文件;
在nginx主配置文件中有關於 443 的配置內容,需要複製下來,粘貼到 jushi的配置文件下邊,jushi的80配置文件內容也需要,粘貼到 443 的配置文件內容下,以供443端口進行解析配置;
我在掛載下邊新建了個目錄,把證書複製到映射目錄下。然後在配置文件中進行修改。
ssl_certificate "/storage/peopel-ssl-key/people.pem"; ssl_certificate_key "/storage/peopel-ssl-key/people.key";
sh-4.2# cat /etc/nginx/conf.d/jushi.conf server { listen 80; root /web/html; location / { ssi on; ssi_silent_errors on; ssi_types text/shtml; index index.shtml index.html index.htm index.php list.shtml; } location ~ \.php/?.*$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } } server { listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server; server_name _; root /web/html; ssl_certificate "/storage/peopel-ssl-key/people.pem"; ssl_certificate_key "/storage/peopel-ssl-key/people.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { ssi on; ssi_silent_errors on; ssi_types text/shtml; index index.shtml index.html index.htm index.php list.shtml; } location ~ \.php/?.*$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
③.修改完配置文件之後。進行書寫檢查;無報錯後 reload nginx;
nginx -t nginx -s reload
④.找出第一步的端口映射關係和目錄映射關係;然後 export 出來並 import 一個鏡像;stop 老鏡像,並重新啓動新鏡像。加入443端口;
export需要的是容器ID;
[root@localhost ~]# docker export c68bb01a7e90>docker_cms.tar [root@localhost ~]# docker import docker_cms.tar IMAGE_NAME [root@localhost ~]# docker container stop DOCEKR_NAME [root@localhost ~]# docker run -tdi --name DOCEKR_NAME2 --restart=always --privileged -p 80:80 -p 81:81 -p 82:82 -p 83:83 -p 888:62080 -p 443:443 -v /home:/storage IMAGE_NAME init
⑤.檢查端口關係,並進行測試。
netstat -tnlp