centos7操作大全
不要走朋友,下面有很多安裝教程(注意查閱目錄)
基礎命令
#查看cnetos7版本 cat /etc/centos-release #更改密碼 passwd #(root指的是用戶名,也可以不指定,默認更改當前用戶) passwd root #刪除文件命令 rm -f example.txt #刪除文件夾命令 rm -rf example #解壓命令 tar zxvf example.gz #使profile文件生效 source /etc/profile #查看端口使用情況 netstat -an | grep 3306 #查看分區和磁盤 lsblk #查看分區 cfdisk /dev/sda #查看當前磁盤掛載 df -h免密及腳本
#1、添加hosts節點 vi /etc/hosts #追加如下 # IP 節點名稱 192.168.10.121 node1 192.168.10.122 node2 #創建ssh密鑰 分別在三個節點都執行 ssh-keygen #回車四次 #復制私鑰到其他節點 ssh-copy-id -i node1(或者ip) ssh-copy-id -i node2(或者ip) #驗證,例如復制文件 scp /root/1.txt node1:/root/tmux
#1、基礎配置、安裝、使用 #安裝 yum install tmux #更新 yum update #版本 tmux -V #創建新會話 tmux new -s [會話名] #刪除會話 tmux kill-session -t [會話名] #會話更改名稱 tmux rename -t [舊會話名] [新會話名] #查看會話 tmux ls #進入會話 tmux a -t [會話名] #退出會話 ctrl+b d #新建窗口 ctrl+b c #切換窗口 #切換到上一個window ctrl+b p #切換到下一個window ctrl+b n #切換到0號window,依次類推,可換成任意窗口序號 ctrl+b 0 #列出當前session所有window,通過上、下鍵切換窗口 ctrl+b w #相鄰的window切換 ctrl+b l #水平分屏 ctrl+b " #垂直分屏 ctrl+b % #切換窗格 #依次切換當前窗口下的各個pane ctrl+b o #根據按箭方向選擇切換到某個pane ctrl+b Up|Down|Left|Right #對當前窗口下的所有pane重新排列布局,每按一次,換一種樣式 ctrl+b Space (空格鍵) #最大化當前pane。再按一次后恢復 ctrl+b z #關閉窗格 ctrl+b xcrontab
#查看crontab文件 #root用戶可以用-u參數查看指定用戶的計劃任務,如果沒有-u參數,表示查看自己的計劃任務。普通用戶只查看自己的計劃任務,不允許使用-u參數。 crontab -l [-u 用戶名] #編輯crontab文件 -u 同上 crontab -e [-u 用戶名] #刪除crontab文件 -u 同上 crontab -r [-u 用戶名] #示例 #沒6分鐘執行 example.sh(腳本:必須寫全路徑) example.log(結果輸出位置) */6 * * * * /home/example.sh \> /home/example.log #根據上面簡單demo我們自行參考cron定時任務表達式。 https://cron.qqe2.com/上面例子細觀察,發現其表達式是在分鐘開始,所以crontab是5位。如果我們想每秒進行任務處理。
 編寫一份sh文件,內容如下。
JDK1.8.0_281
1、下載jdk
 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
 
mysql5.7.31
mysql5.7.31安裝
1、基礎準備、下載、解壓、安裝
#卸載CentOS7系統自帶mariadb rpm -qa|grep mariadb rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 #刪除etc目錄下的my.cnf(如果存在要刪除) rm /etc/my.cnf #下載mysql wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz #解壓 tar -zxvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz #更改文件夾名字 mv mysql-5.7.31-linux-glibc2.12-x86_64 mysql-5.7.31 #檢查該鏈接庫文件有沒有安裝使用 rpm -qa|grep libaio #未安裝則運行 yum install libaio-devel.x86_64 #進入mysql/bin/目錄,編譯安裝并初始化mysql,務必記住數據庫管理員臨時密碼 ./mysqld --initialize --user=root --datadir=/home/server/mysql-5.7.31/data --basedir=/home/server/mysql-5.7.31 #配置文件 vi /etc/my.cnf#配置內容如下
 [mysqld]
 user=root
 #數據位置
 datadir = /home/server/mysql-5.7.31/data
 #安裝位置
 basedir = /home/server/mysql-5.7.31
 #端口
 port = 3306
 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 #支持數據分區存儲
 symbolic-links = 0
 #最大連接數
 max_connections = 666
 #最大錯誤連接數
 max_connect_errors = 666
 #數據庫默認字符串
 character-set-server = utf8mb4
 #數據庫字符集對應一些排序等規則
 collation-server = utf8mb4_general_ci
 #client連接mysql時的字符集,防止亂碼
 init_connect=‘SET NAMES utf8mb4’
 #獨享表空間
 innodb_file_per_table=1
 #表名大小寫不明感,敏感為
 #lower_case_table_names=1
 #binlog日志文件保存的過期時間,過期后自動刪除
 expire_logs_days = 5
 #日志
 log_error = /home/server/mysql-5.7.31/log/error.log
 slow_query_log = 1
 slow_query_log_file = /home/server/mysql-5.7.31/log/slow.log
mysql備份
1、編寫備份腳本 backup.sh 存放至/backup/mysql/sh/
#!/bin/bash DATE=`date +%Y%m%d%H%M` #開始時間 DATABASE=springboot-admin #數據庫名 DB_USERNAME=root #賬號 DB_PASSWORD="mysql" #密碼 BACKUP_PATH=/backup/mysql/data/ #備份位置#備份及壓縮 /usr/bin/mysqldump -u$DB_USERNAME -p$DB_PASSWORD -h 127.0.0.1 -R --opt $DATABASE | gzip > ${BACKUP_PATH}\/${DATABASE}_${DATE}.sql.gz#保存5天的備份信息 find ${BACKUP_PATH} -mtime +5 -name "${DATABASE}_*.sql.gz" -exec rm -f {} \;2、編寫完腳本后以防萬一,更改腳本字符集。
vi /backup/mysql/sh/backup.sh :set ff=unix3、給腳本授權、備份位置授權
chmod +x /backup/mysql/sh/backup.sh chmod a+w /backup/mysql/data/4、編寫定時任務
crontab -e #在文件中編寫如下內容 #凌晨3點備份 00 3 * * * /backup/mysql/sh/backup.sh #需要重啟crond才能生效 service crond stop service crond start #查看狀態 service crond status #查看執行記錄日志 less /var/log/cron*注意事項
#出現如下警告。可以去my.cnf 里面設置[mysqldump] 并配置號賬號密碼(也可以忽略) mysqldump: [Warning] Using a password on the command line interface can be insecureoracle11g
oracle11g安裝(無圖形界面)
#查看磁盤空間:選擇較大的路徑用于建立用戶和數據庫的安裝 df -lh #創建安裝Oracle程序用戶組、DBA用戶組,創建用戶并授權 groupadd oinstall groupadd dba useradd -g oinstall -G dba oracle #修改用戶密碼 passwd oracle #查看新建的用戶 id oracle #創建Oracle的主目錄、配置目錄 mkdir -p /home/oracle/Oracle11G mkdir -p /home/oracle/Inventory11G #先把下載好的Oracle文件傳輸到oracle目錄下,切換到oracle目錄下解壓縮,自動生成database目錄 cd /home/oracle unzip 對應的壓縮文件名稱(2個) #新建的三個目錄授權 chown -R oracle:oinstall /home/oracle/Oracle11G chown -R oracle:oinstall /home/oracle/Inventory11G chown -R oracle:oinstall /home/oracle/database #輸入以下命令:如果有提示未安裝的軟件包,用命令# yum -y install compat-libstdc++-33-3.2.3(軟件包名稱)安裝對應的軟件包即可,完成安裝后的效果見下圖 rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel #查看firewalld防火墻狀態 systemctl status firewalld.service #關閉firewalld防火墻 systemctl stop firewalld.service #禁止開機使用firewalld防火墻 systemctl disable firewalld.service #修改文件 vi /etc/selinux/config修改如下配置
 SELINUX=disabled
在文件最后一行前,追加以下內容
 oracle soft nproc 2047
 oracle hard nproc 16384
 oracle soft nofile 1024
 oracle hard nofile 65536
將下列內容加入該文件,要使 /etc/sysctl.conf 更改立即生效,保存后執行:# sysctl -p
 fs.file-max = 6815744
 fs.aio-max-nr = 1048576
 kernel.shmall = 2097152
 kernel.shmmax = 2147483648
 kernel.shmmni = 4096
 kernel.sem = 250 32000 100 128
 net.ipv4.ip_local_port_range = 9000 65500
 net.core.rmem_default = 4194304
 net.core.rmem_max = 4194304
 net.core.wmem_default = 262144
 net.core.wmem_max = 1048576
添加以下內容(對應安裝目錄),保存后執行:# source /home/oracle/.bashrc
export PATH export ORACLE_BASE=/home/oracle/Oracle11G export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export ORACLE_SID=orcl export ORACLE_UNQNAME=orcl export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export LANG=C export NLS_LANG="SIMPLIFIED CHINESE_CHINA".ZHS16GBK #重啟 reboot #切換到oracle用戶,裝數據庫 su oracle #編輯數據庫安裝文件 vi /home/oracle/database/response/db_install.rsp #將下面配置參數根據安裝目錄修改安裝類型
 oracle.install.option=INSTALL_DB_SWONLY
 主機名稱
 ORACLE_HOSTNAME=oracle.server
 安裝組
 UNIX_GROUP_NAME=oinstall
 INVENTORY目錄
 INVENTORY_LOCATION=/home/oracle/Inventory11G
 選擇語言
 SELECTED_LANGUAGES=en,zh_CN
 oracle_home
 ORACLE_HOME=/home/oracle/Oracle11G/product/11.2.0/db_1
 oracle_base
 ORACLE_BASE=/home/oracle/Oracle11G
 oracle版本
 oracle.install.db.InstallEdition=EE
 dba用戶組
 oracle.install.db.DBA_GROUP=dba
 oper用戶組
 oracle.install.db.OPER_GROUP=oinstall
 數據庫類型
 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
 globalDBName
 oracle.install.db.config.starterdb.globalDBName=orcl
 SID
 oracle.install.db.config.starterdb.SID=orcl
 默認數據庫編碼
 oracle.install.db.config.starterdb.characterSet=AL32UTF8
 自動管理內存的最小內存(M)
 oracle.install.db.config.starterdb.memoryLimit=800
 設定所有數據庫用戶使用同一個密碼
 oracle.install.db.config.starterdb.password.ALL=oracle
 設置安全更新
 DECLINE_SECURITY_UPDATES=true
注意:安裝出現swap(交換空間)不足,如下示例。
 解決方案如下
將
 ORACLE_HOME_LISTNER=$1
 修改為
 ORACLE_HOME_LISTNER=/home/oracle/Oracle11G/product/11.2.0/db_1
將
 orcl:/home/oracle/Oracle11G/product/11.2.0:N
 修改為
 orcl:/home/oracle/Oracle11G/product/11.2.0:Y
oracle客戶端鏈接
#修改安裝目錄下的 listener.ora vi /安裝目錄(目錄不一,自行查找)/listener.ora #參考配置 LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.104)(PORT = 1521))))SID_LIST_LISTENER = (SID_LIST =(SID_DESC =# (GLOBAL_DBNAME = ORCL)(ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)(SID_NAME = orcl)) ) ADR_BASE_LISTENER = /home/oracle/appredis6.2.1
1、基礎準備、下載、解壓、安裝
#下載 wget http://download.redis.io/releases/redis-6.2.1.tar.gz #解壓 tar -zxvf /home/server/redis-6.2.1.tar.gz #安裝依賴包 #安裝gcc(期間可能由于你的centos7版本導致還是不能編輯,自行升級且切換gcc使用) yum install gcc #redis目錄中進行編譯 make install#redis.conf 配置內容介紹如下
 #訪問IP
 bind 0.0.0.0
 #端口
 port 6379
 #守護進程
 daemonize yes
 #進程文件地址(redis.pid 自行新建)
 pidfile /home/server/redis-6.2.1/run/redis-6379.pid
 #當客戶端閑置多長時間后關閉連接,如果指定為0,表示關閉該功能
 timeout 0
 #設置數據庫的數量
 databases 6
 #數據庫文件名
 dbfilename dump.rdb
 #數據庫文件地址
 dir /home/server/redis-6.2.1/data/
 #連接密碼
 requirepass pssword
svn
1、基礎配置、下載、安裝
#安裝 yum -y install subversion #項目倉庫 mkdir -p /home/server/svn/project #版本庫 svnadmin create /home/server/svn/project #切換至版本庫配置配置詳解
 
 #conf目錄下
 authz:負責賬號權限的管理,控制賬號是否讀寫權限
 passwd:負責賬號和密碼的用戶名單管理
 svnserve.conf:svn服務器配置文件
 編輯 authz 文件(注意:[/]也是必須的)
 [/] 表示根目錄,即 /var/svnrepos
 luo = rw 表示用戶luo對根目錄具有讀寫權限。
 
 編輯 passwd 文件
 用戶名為:luo,認證密碼為:luo123456
 
 編輯 svnserve.conf 文件(注意:配置的前面不能有空格,一定要頂格寫)
 anon-access = none:表示禁止匿名用戶訪問。
 auth-access = write:表示授權用戶擁有讀寫權限。
 password-db = passswd:指定用戶名口令文件,即 passwd 文件。
 authz-db = authz:指定權限配置文件,即 authz 文件。
 realm = /home/server/svn/project:指定認證域,即 /var/svnrepos 目錄。
 
輸入賬號密碼后,提示 svn: Authorization failed解決辦法
 把authz 文件 [/] 改為 [] 試試
nginx 1.18.0
nginx 1.18.0安裝
1、基礎配置、下載、安裝
#安裝依賴環境 #安裝gcc環境 yum install -y gcc #安裝PCRE庫,用于解析正則表達式 yum install -y pcre pcre-devel #安裝zlib壓縮和解壓縮依賴 yum install -y zlib zlib-devel #安裝openssl,SSL安全加密的套接字協議層,用于HTTP安全傳輸,也就是https yum install -y openssl openssl-devel #下載nignx包 wget http://nginx.org/download/nginx-1.18.0.tar.gz #解壓上傳上來的Nginx壓縮包 tar -zxvf nginx-1.18.0.tar.gz #切換到nginx目錄安裝 #編譯配置項 運行./configure進行默認配置的設置,當然你也可以使用自定義方式進行配置 ./configure #編譯 make #安裝 make install #開機自啟 vi /etc/init.d/nginx #!/bin/bash # # nginx - this script starts and stops the nginx daemon # # chkconfig: 2345 85 15 # description: NGINX is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pidnginx=/usr/local/nginx/sbin/nginx prog=$(basename $nginx) NGINX_CONF_FILE=/usr/local/nginx/conf/nginx.confstart() {$nginx -c $NGINX_CONF_FILE }stop() {$nginx -s stop }restart() {teststopsleep 1start }reload() {test$nginx -s stop }test() {$nginx -t -c $NGINX_CONF_FILE }status() {echo `ps -A | grep nginx` }V() {$nginx -V }case "$1" instart)$1;;stop)$1;;restart|test)$1;;reload)$1;;status)$1;;V)$1;;*)echo $"Usage: $0 {start|stop|status|restart|reload|test|V}"exit 2 esac #啟動nginx /usr/local/nginx/sbin/./nginx #賦值一份pid cp /usr/local/nginx/logs/nginx.pid /run #更改nginx.conf pid /run/nginx.pid #賦予可執行權限 chmod +x /etc/init.d/nginx #添加服務 chkconfig --add nginx #顯示服務列表 chkconfig --list #開機啟動 chkconfig nginx on #啟動服務 /etc/init.d/nginx startnginx 注意事項
虛擬目錄 alias、root
1、root與alias主要區別在于nginx如何解釋location后面的uri,這會使兩者分別以不同的方式將請求映射到服務器文件上。
 2、root的處理結果是:root路徑+location路徑。
 3、alias的處理結果是:alias路徑替換location路徑。
 4、還有一個重要的點是alias后面必須要用"/"結束。
nginx 基礎配置
#配置用戶或者組,默認為nobody nobody user administrator administrators; #允許生成的進程數,默認為1 worker_processes 2; #指定nginx進程運行文件存放地址 pid /nginx/nginx.pid; #制定日志路徑,級別。這個設置可以放入全局塊,http塊,server塊,級別以此為:debug|info|notice|warn|error|crit|alert|emerg error_log log/error.log debug;events {#設置網路連接序列化,防止驚群現象發生,默認為onaccept_mutex on;#設置一個進程是否同時接受多個網絡連接,默認為offmulti_accept on;#事件驅動模型,select|poll|kqueue|epoll|resig|/dev/poll|eventportuse epoll;#最大連接數,默認為512worker_connections 1024; }http {#文件擴展名與文件類型映射表include mime.types;#默認文件類型,默認為text/plaindefault_type application/octet-stream;#取消服務日志access_log off;#自定義格式log_format myFormat '$remote_addr–$remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for';#combined為日志格式的默認值access_log log/access.log myFormat;#允許sendfile方式傳輸文件,默認為off,可以在http塊,server塊,location塊。sendfile on;#每個進程每次調用傳輸數量不能大于設定的值,默認為0,即不設上限。sendfile_max_chunk 100k;#連接超時時間,默認為75s,可以在http,server,location塊。keepalive_timeout 65;#允許最大上傳client_max_body_size 5M;upstream mysvr { server 127.0.0.1:8081;#熱備server 192.168.1.110:8081 backup;}#錯誤頁error_page 404 https://www.error.com;server {#監聽端口listen 80;#監聽地址server_name 127.0.0.1;#單連接請求上限次數。keepalive_requests 120;#請求的url過濾,正則匹配,~為區分大小寫,~*為不區分大小寫。location ~*^.+$ {#將代理服務器收到的用戶的信息傳到真實服務器上proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #根目錄#root path;#設置默認頁#index vv.txt;#請求轉向mysvr 定義的服務器列表proxy_pass http://mysvr;#拒絕的ipdeny 127.0.0.1;#允許的ipallow 172.18.5.54;} }#HTTP可用于訪問RTMP統計數據server {listen 8080;#此URL提供XML格式的RTMP統計信息location /stat {rtmp_stat all;#使用此樣式表可以將XML作為網頁查看,在瀏覽器中rtmp_stat_stylesheet stat.xsl;}location /stat.xsl {#查看RTMP統計數據的XML樣式表。將stat.xsl復制到任何需要的地方然后把完整的目錄路徑放在這里root /path/to/stat.xsl/;}location /hls {#提供HLS碎片types {application/vnd.apple.mpegurl m3u8;video/mp2t ts;}root /tmp;add_header Cache-Control no-cache;}location /dash {#提供DASH碎片root /tmp;add_header Cache-Control no-cache;}} }#模塊通過自動流推送到 nginx 工作人員來支持多工作人員直播。此選項由 rtmp_auto_push 指令切換。 rtmp {server {listen 1935;chunk_size 4000;#電視模式:一個出版商,多個訂戶application mytv {#啟用實時流媒體live on;#記錄流的前1Krecord all;record_path /tmp/av;record_max_size 1K;#將當前時間戳附加到每個flvrecord_unique on;#僅從本地主機發布(不配置就是所有)allow publish 127.0.0.1;deny publish all;}#轉碼(需要ffmpeg)application big {live on;#在每個pusblished流上運行此命令(ffmpeg)#使用替換:$app/${app},$name/${name}作為應用程序和流名稱。#此ffmpeg調用接收來自此應用程序的流,將分辨率降低到32x32。#該流是發布到的同名的“小型”應用程序#ffmpeg可以對流做任何事情,比如視頻/音頻轉碼、調整大小、更改容器/編解碼器參數等#可以指定多個exec行。exec ffmpeg -re -i rtmp://localhost:1935/$app/$name -vcodec flv -acodec copy -s 32x32 -f flv rtmp://localhost:1935/small/${name}; }#分辨率降低的視頻來自ffmpeg(上面的配置)application small {live on;}application webcam {live on;#來自本地網絡攝像頭的流exec_static ffmpeg -f video4linux2 -i /dev/video0 -c:v libx264 -an -f flv rtmp://localhost:1935/webcam/mystream; }application mypush {live on;#這里發布的每一條流自動推送到這兩臺機器push rtmp1.example.com;push rtmp2.example.com:1934;}application mypull {live on;#從遠程計算機中提取所有流在本地玩pull rtmp://rtmp3.example.com pageUrl=www.example.com/index.html;}application mystaticpull {live on;#在nginx啟動時啟動靜態拉動pull rtmp://rtmp4.example.com pageUrl=www.example.com/index.html name=mystream static;}#視頻點播application vod {play /var/flvs;}application vod2 {play /var/mp4s;}#很多出版商,很多訂戶,沒有支票,沒有錄音application videochat {live on;#以下通知接收所有會話變量以及HTTP POST中的特定調用參數請求,發出HTTP請求并使用HTTP代碼決定是否允許發布,是否從這個連接on_publish http://localhost:8080/publish;#播放一樣on_play http://localhost:8080/play;#發布/播放結束(斷開連接時重復)on_done http://localhost:8080/done;#上述所有通知均收到標準connect()參數以及播放/發布。如果發送了任何參數使用GET style語法進行播放和發布.這些也包括在內。#示例URL:rtmp://localhost/myapp/mystream?a=b&c=d#每2分鐘錄制10個視頻關鍵幀(無音頻)record keyframes;record_path /tmp/vc;record_max_frames 10;record_interval 2m;#異步通知已記錄的flvon_record_done http://localhost:8080/record_done;}#HLS#要使HLS正常工作,請在tmpfs中創建一個目錄(/tmp/HLS here)尋找碎片。目錄內容通過HTTP提供(請參閱)http{}節(在配置中)傳入流必須為H264/AAC格式。對于iPhone,使用基線H264配置文件(參見ffmpeg示例)。此示例從準備用于HLS的電影創建RTMP流:#ffmpeg-loglevelverbose-re-i電影。avi-vcodec libx264#-vprofile基線-acodec libmp3lame-ar 44100-ac 1#-f flvrtmp://localhost:1935/hls/movie#如果您需要對實時流進行轉碼,請使用“exec”功能。application hls {live on;hls on;hls_path /tmp/hls;}#MPEG-DASH類似于HLSapplication dash {live on;dash on;dash_path /tmp/dash;}} }nginx https
#關閉nginx進程 /etc/init.d/nginx stop #切換到nginx解壓目錄 cd /home/server/nginx-1.18.0/ #執行如下命令(可自行更改對應改裝目錄) ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module #接著執行 make #nginx解壓目錄下的objs目錄中的nginx程序,拷貝到nginx的安裝目錄/usr/local/nginx/sbin目錄下.替換時注意回復 y . cp /home/server/nginx-1.18.0/objs/nginx /usr/local/nginx/sbin/nginx #檢查模塊是否安裝 /etc/init.d/nginx Vnginx rtmp
參考地址:https://github.com/arut/nginx-rtmp-module
 下載 nginx-rtmp-module 模塊
nginx 負載均衡
#負載示例,在http{}配置與server{}同級 upstream example{ip_hash;server 192.168.0.1:8080;server 192.168.0.2:8080 weight=100 down;server 192.168.0.3:8080 weight=100;server 192.168.0.4:8080 weight=100 backup;server 192.168.0.5:8080 weight=100 max_fails=3 fail_timeout=30s; } #配置講解 #down:表示當前的server暫時不參與負載 #weight:默認為1.weight越大,負載的權重就越大。 #backup: 其它所有的非backup機器down或者忙的時候,請求backup機器。所以這臺機器壓力會最輕。 #上例中 192.168.0.5 設置最大失敗次數為 3,也就是最多進行 3 次嘗試,且超時時間為 30秒。max_fails 的默認值為 1,fail_timeout 的默認值是 10s。 #注意,當upstream中只有一個 server 時,max_fails 和 fail_timeout 參數可能不會起作用。weight\backup 不能和 ip_hash 關鍵字一起使用。 #使用 server {/example {proxy_pass http://example(對應upstream的名字)/} }node、pm2
node安裝
#確認服務器有nodejs編譯及依賴相關軟件,如果沒有可通過運行以下命令安裝 yum -y install gcc gcc-c++ openssl-devel #進入要存放下載資源的目錄(本演示目錄) wget http://nodejs.org/dist/v14.16.1/node-v14.16.1-linux-x64.tar.gz #解壓 tar -zxvf node-v14.16.1-linux-x64.tar.gz #解壓完成后重命名文件夾,將文件夾重命名為node mv node-v14.16.1-linux-x64 node-v14.16.1 #進入 node 目錄下的bin目錄,執行 ls命令(會看到node和npm) node -v 檢查版本 cd node-v14.16.1/bin && ls #設置全局變量 vi /etc/profile #加入以下內容 export NODE_HOME=/home/server/node-v14.16.1 export PATH=$PATH:$NODE_HOME/bin export NODE_PATH=$NODE_HOME/lib/node_modules #保存修改,然后使用如下命令使配置生效 source /etc/profile #在任意位置執行node -v命令 node -v #為npm添加淘寶鏡像 npm config set registry https://registry.npm.taobao.org npm config get registry #使用淘寶npm鏡像的cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org #安裝yarn(自己選擇) npm install -g yarn 或者 cnpm install -g yarn將服務項目,放到服務器內。進入項目目錄。
 進行相應的環境編譯與windows無誤。
 例如 cnpm install 、yarn install 、npm install
pm2安裝
#PM2是node進程管理工具,可以利用它來簡化很多node應用管理的繁瑣任務,如性能監控、自動重啟、負載均衡等 npm install -g pm2 #運行服務(run start 指運行命令,也可以腳本啟動,自行百度。) pm2 start yarn --name "名字標識" -- run start #設置pm2開機自啟動 pm2 startup #移除pm2開機自啟動 pm2 unstartup #保存當前進程開機自啟動 pm2 save #<進程啟動命令> [--name <進程名>] 啟動應用程序 pm2 start #顯示所有進程狀態 pm2 list #監控進程 pm2 monit #[進程id或名字] 顯示進程日志 pm2 logs #停止[所有]進程 pm2 stop [all] #重啟[所有]進程 pm2 restart [all] #刪除指定[所有]進程 pm2 delete [<進程名或者id>,all] #查看應用程序信息 pm2 info [進程id或名字]文件上傳下載
#使用lrzsz 安裝如下 yum -y install lrzsz #僅操作文件 非 文件夾 #下載 sz #上傳 rzfrp內網穿透
服務端安裝
下載對應安裝包:https://github.com/fatedier/frp/releases
 本人資源里面也有
 
后臺啟動服務
 cd /home/server/frp_0.40.0_linux_amd64/
 nohup ./frps -c ./frps.ini > /dev/null &
訪問 外網IP + 7500 出現如下后臺管理頁面 輸入上面配置的賬號密碼
 
至此我們服務端搭建完成
客戶端安裝
#windows 客戶端啟動 #解壓安裝包 frp_0.40.0_windows_amd64解壓內容如下
 
啟動服務(用命令啟動)
 切換到對應的盤符啟動命令
 frpc.exe -c frpc.ini
 
 測試:外網IP + 映射端口(8090)+ 對應路徑 ---------> 直達 127.0.0.1:8082 + 對應路徑
漏洞處理
CVE-2020-12321
RHSA-2021:0339: linux-firmware 安全更新
#解決方案 yum update iwl100-firmware yum update iwl1000-firmware yum update iwl105-firmware yum update iwl135-firmware yum update iwl2000-firmware yum update iwl2030-firmware yum update iwl3160-firmware yum update iwl3945-firmware yum update iwl4965-firmware yum update iwl5000-firmware yum update iwl5150-firmware yum update iwl6000-firmware yum update iwl6000g2a-firmware yum update iwl6000g2b-firmware yum update iwl6050-firmware yum update iwl7260-firmware yum update linux-firmware #重啟驗證 rebootCVE-2020-25648
RHSA-2021:1384: nss 安全和BUG修復更新
#解決方案 yum update nss #重啟驗證 rebootCVE-2021-20305
RHSA-2021:1145: nettle 安全更新
#解決方案 yum update nettle #重啟驗證 rebootCVE-2021-27803
RHSA-2021:0808: wpa_supplicant 安全更新
#解決方案 yum update wpa_supplicant #重啟驗證 rebootCVE-2020-8625
RHSA-2021:0671: bind 安全更新
#解決方案 yum update bind-export-libs yum update bind-libs-lite #重啟驗證 rebootCVE-2021-27219
RHSA-2021:2147: glib2 安全更新
#解決方案 yum update glib2 #重啟驗證 rebootCVE-2019-25013\CVE-2020-10029\CVE-2020-29573
RHSA-2021:0348: glibc 安全和BUG修復更新
#解決方案 yum update glibc #重啟驗證 rebootCVE-2021-25215
RHSA-2021:1469: bind 安全更新
#解決方案 yum update bind-export-libs yum update bind-libs-lite #重啟驗證 rebootCVE-2020-10543\CVE-2020-10878\CVE-2020-12723
RHSA-2021:0343: perl 安全更新
#解決方案 yum update perl-Pod-Escapes yum update perl-macros yum update perl #重啟驗證 rebootCVE-2020-25692
RHSA-2021:1389: openldap 安全更新
#解決方案 yum update openldap #重啟驗證 rebootCVE-2021-25217
RHSA-2021:2357: dhcp 安全更新
#解決方案 yum update dhclient #重啟驗證 rebootCVE-2020-0543、CVE-2020-0548、CVE-2020-0549、CVE-2020-24489
RHSA-2021:3028: microcode_ctl security,bug fix和修復更新
#解決方案 yum update microcode_ctl #重啟驗證 rebootCVE-2020-24489、CVE-2020-24511、CVE-2020-24512、CVE-2020-24513
RHSA-2021:2305: microcode_ctl security,bug fix和修復更新
#解決方案 yum update microcode_ctl #重啟驗證 rebootOpenSSH CVE-2018-15919
一般情況更新7.8以上版本就可以了
 官方地址:http://www.openssh.com/portable.html
 選擇http下面的china
 進入阿里下載地址 https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/
 選擇較高版本
有幫助,感謝!
 
總結
以上是生活随笔為你收集整理的centos7操作大全的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 5 模式识别-动态聚类算法(K均值算法
- 下一篇: iOS 播放系统声音系统声音大全
