ansible環境安裝及數據恢復

来源:https://www.cnblogs.com/The-day-of-the-wind/archive/2022/06/27/16416327.html
-Advertisement-
Play Games

配置免密登錄伺服器及下載備份文件#!/bin/bash BACKUP=192.168.30.233 #一行寫一個IP BACKUP_PASSWD="lxzl_root*#2021" #root密碼 MYSQLBACKUP=192.168.30.232 #一行寫一個IP MYSQLBACKUP_PAS ...


配置免密登錄伺服器及下載備份文件
#!/bin/bash BACKUP=192.168.30.233 #一行寫一個IP BACKUP_PASSWD="lxzl_root*#2021" #root密碼 MYSQLBACKUP=192.168.30.232 #一行寫一個IP MYSQLBACKUP_PASSWD="lxzl_root*#2021" #root密碼 #檢查是否安裝expect function init { rpm -qa | grep expect if [[ $? == 0 ]]; then echo "expect已安裝" else yum -y install expect fi #抓取伺服器IP及寫入hosts文件 sed -n "/^\[$1/,/^$/p" /etc/ansible/init_server/hosts | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' > /etc/ansible/init_server/ip.list && sed -n "/^\[$1/,/^$/p" /etc/ansible/init_server/hosts >> /etc/ansible/hosts } #function ssh_hosts { #sed -n '/^\[$1/,/^$/p' /etc/ansible/init_server/hosts | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' > /etc/ansible/init_server/ip.list && sed -n '/^\[$1/,/^$/p' /etc/ansible/init_server/hosts >> /etc/ansible/hosts # SERVERS=`cat /etc/ansible/init_server/ip.list` #一行寫一個IP # PASSWD="123456" #root密碼 # for server in $Server # do # sshcopyid # done #} #BACKUP=192.168.30.233 #一行寫一個IP #BACKUP_PASSWD="lxzl_root*#2021" #root密碼 #輸入免密伺服器密碼函數 function sshcopyid { expect -c " set timeout -1; spawn ssh-copy-id $1; expect { \"yes/no\" { send \"yes\r\" ;exp_continue; } \"password:\" { send \"$PASSWD\r\";exp_continue; } }; interact " } #免密登錄備份伺服器拉去備份文件 function backup_sshcopyid { expect -c " set timeout -1; spawn ssh-copy-id $1; expect { \"yes/no\" { send \"yes\r\" ;exp_continue; } \"password:\" { send \"$BACKUP_PASSWD\r\";exp_continue; } }; interact " } #免密登錄MYSQL備份伺服器拉去備份文件 function mysqlbackup_sshcopyid { expect -c " set timeout -1; spawn ssh-copy-id $1; expect { \"yes/no\" { send \"yes\r\" ;exp_continue; } \"password:\" { send \"$MYSQLBACKUP_PASSWD\r\";exp_continue; } }; interact " } #ansible配置免密登錄部署伺服器 function ssh_server { SERVERS=`cat /etc/ansible/init_server/ip.list` #一行寫一個IP PASSWD="LXZLProSvr4ROOT*#2021" #root密碼 #PASSWD="123456" #root密碼 for server in $SERVERS do sshcopyid $server done } #下載代理備份文件 function proxy { ansible_nginx=/etc/ansible/init_server/roles/nginx/files/ if [ $1 == "NGINX" ];then scp $BACKUP:/lxserver/backup/Nginx/192.168.0.10/`date +%F`/*.tar.gz $ansible_nginx #/etc/ansible/init_server/roles/nginx/files/ rm -rf nginx && tar xzf nginx_10.tar.gz ssh_server elif [ $1 == "JENKINS" ];then scp $BACKUP:/lxserver/backup/Nginx/192.168.0.120/`date +%F`/*.tar.gz $ansible_nginx #/etc/ansible/init_server/roles/nginx/files/ rm -rf nginx && tar xzf nginx_120.tar.gz ssh_server elif [ $1 == "SLB" ];then scp $BACKUP:/lxserver/backup/Nginx/192.168.0.200/`date +%F`/*.tar.gz $ansible_nginx #/etc/ansible/init_server/roles/nginx/files/ rm -rf nginx && tar xzf nginx_200.tar.gz ssh_server else exit fi } #下載NoSql備份文件 function Nosql { scp $BACKUP:/lxserver/backup/MongoDB/192.168.0.71/`date +%F -d "1 days ago"`/*.tar.gz /etc/ansible/init_server/roles/mongodb/files/ } #下載MYSQL備份文件 function mysql { ansible_mysql=/etc/ansible/init_server/roles/mysql/files/ if [ $1 == "ERPMYSQL" ];then rm -f $ansible_mysql/*.sql.gz scp $MYSQLBACKUP:/lxserver/backup/MySQL/192.168.0.82/`date +%F -d "1 days ago"`/*.sql.gz $ansible_mysql #rm -rf nginx && tar xzf nginx_10.tar.gz ssh_server elif [ $1 == "AMSMYSQL" ];then rm -f $ansible_mysql/*.sql.gz scp $MYSQLBACKUP:/lxserver/backup/MySQL/192.168.0.84/`date +%F -d "1 days ago"`/*.sql.gz $ansible_mysql #/etc/ansible/init_server/roles/nginx/files/ #rm -rf nginx && tar xzf nginx_120.tar.gz ssh_server elif [ $1 == "HSCSMYSQL" ];then rm -f $ansible_mysql/*.sql.gz scp $MYSQLBACKUP:/lxserver/backup/MySQL/192.168.0.162/`date +%F -d "1 days ago"`/*.sql.gz $ansible_mysql #/etc/ansible/init_server/roles/nginx/files/ #rm -rf nginx && tar xzf nginx_200.tar.gz ssh_server elif [ $1 == "WMSMYSQL" ];then rm -f $ansible_mysql/*.sql.gz scp $MYSQLBACKUP:/lxserver/backup/MySQL/192.168.0.164/`date +%F -d "1 days ago"`/*.sql.gz $ansible_mysql #/etc/ansible/init_server/roles/nginx/files/ #rm -rf nginx && tar xzf nginx_200.tar.gz ssh_server elif [ $1 == "ALMMYSQL" ];then rm -f $ansible_mysql/*.sql.gz scp $MYSQLBACKUP:/lxserver/backup/MySQL/192.168.0.166/`date +%F -d "1 days ago"`/*.sql.gz $ansible_mysql #/etc/ansible/init_server/roles/nginx/files/ #rm -rf nginx && tar xzf nginx_200.tar.gz ssh_server else exit fi } #main函數 function main { if [ $1 == "NGINX" -o $1 == "SLB" -o $1 == "JENKINS" ];then init #備份伺服器 backup_sshcopyid $BACKUP proxy $1 elif [ $1 == "NoSql" ];then init backup_sshcopyid $BACKUP Nosql $1 ssh_server elif [ $1 == "HSCS-NoSql" -o $1 == "APP" -o $1 == "KAFKA" -o $1 == "FASTDFS" -o $1 == "SERVER" ];then init ssh_server elif [ $1 == "ERPMYSQL" -o $1 == "HSCSMYSQL" -o $1 == "AMSMYSQL" -o $1 == "WMSMYSQL" -o $1 == "ALMMYSQL" -o $1 == "MYSQL" ];then init ssh_server mysqlbackup_sshcopyid $MYSQLBACKUP mysql $1 #ssh_server else echo "輸入參數錯誤,請輸入:APP | NGINX | SLB | JENKINS | NoSql | HSCS-NOSQL | KAFKA | FASTDFS | SERVER | ERPMYSQL | AMSMYSQL | HSCSMYSQL | WMSMYSQL | ALMMYSQL" exit fi } #程式入口 main $1
安裝配置redis
cat
HSCS-Init_Nosql.yml - name: init server #gather_facts: False remote_user: root hosts: Hscs-NoSql roles: - init - hscs-redis

安裝配置mongodb及數據恢復
cat
roles/mongodb/tasks/main.yml - name: copy install package copy: src: "{{ item }}" dest: /root with_items: - mongodb-org-4.0.1-1.el7.x86_64.rpm - mongodb-org-server-4.0.1-1.el7.x86_64.rpm - mongodb-org-mongos-4.0.1-1.el7.x86_64.rpm - mongodb-org-shell-4.0.1-1.el7.x86_64.rpm - mongodb-org-tools-4.0.1-1.el7.x86_64.rpm - name: install mongod shell: yum localinstall -y /root/mongodb-* && rm -f /root/mongodb-* /etc/mongo* && rm -f /usr/lib/systemd/system/mongo* - name: copy mongo service && conf copy: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" with_items: - { src: 'mongod19000.conf', dest: '/etc/', mode: '0644' } - { src: 'mongod19001.conf', dest: '/etc/', mode: '0644' } - { src: 'mongod19000.service', dest: '/usr/lib/systemd/system', mode: '0644' } - { src: 'mongod19001.service', dest: '/usr/lib/systemd/system', mode: '0644' } - name: mkdir dir file: path: "{{ item }}" state: directory with_items: - /var/run/mongodb19000 - /var/lib/mongo19000 - /var/log/mongodb19000 - /var/run/mongodb19001 - /var/lib/mongo19001 - /var/log/mongodb19001 - name: Unarchive a file that is already on the remote machine unarchive: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" with_items: - { src: 'mongodb_71_19000_all.tar.gz', dest: '/var/lib/mongo19000', mode: '0755' } - { src: 'mongodb_71_19001_all.tar.gz', dest: '/var/lib/mongo19001', mode: '0755' } - name: daemon-reload shell: systemctl daemon-reload - name: systemctl start service: name: "{{ item }}" state: started enabled: yes with_items: - mongod19000 - mongod19001 - name: 19000 restore data shell: mongorestore -h 127.0.0.1:19000 -d "{{ item.name }}" "{{ item.path }}" with_items: - { name: 'workflow', path: '/var/lib/mongo19000/mongodb_71_19000_all/workflow' } - { name: 'risk_system', path: '/var/lib/mongo19000/mongodb_71_19000_all/risk_system' } - { name: 'admin', path: '/var/lib/mongo19000/mongodb_71_19000_all/admin' } - name: 19001 restore data shell: mongorestore -h 127.0.0.1:19001 -d "{{ item.name }}" "{{ item.path }}" with_items: - { name: 'tencent_qm_status', path: '/var/lib/mongo19001/mongodb_71_19001_all/tencent_qm_status' } - { name: 'lxzl_message', path: '/var/lib/mongo19001/mongodb_71_19001_all/lxzl_message' } - { name: 'admin', path: '/var/lib/mongo19001/mongodb_71_19001_all/admin' } - name: 19000 restore data shell: mongorestore -h 127.0.0.1:19000 -u '{{ item.user}}' -p '{{ item.password}}' -d "{{ item.name }}" "{{ item.path }}" with_items: - { user: 'workflow', password: 'workflow', name: 'workflow', path: '/var/lib/mongo19000/mongodb_71_19000_all/workflow' } - { user: 'risk_system', password: 'risk_system', name: 'risk_system', path: '/var/lib/mongo19000/mongodb_71_19000_all/risk_system' } - { user: 'root', password: 'lx_root*#2020', name: 'admin', path: '/var/lib/mongo19000/mongodb_71_19000_all/admin' } - name: 19001 restore data shell: mongorestore -h 127.0.0.1:19001 -u '{{ item.user}}' -p '{{ item.password}}' -d "{{ item.name }}" "{{ item.path }}" with_items: - { user: 'tencent_qm_status', password: 'tencent_qm_status', name: 'tencent_qm_status', path: '/var/lib/mongo19001/mongodb_71_19001_all/tencent_qm_status' } - { user: 'lxzl_message', password: 'lxzl_message', name: 'lxzl_message', path: '/var/lib/mongo19001/mongodb_71_19001_all/lxzl_message' } - { user: 'root', password: 'lx_root*#2020', name: 'admin', path: '/var/lib/mongo19001/mongodb_71_19001_all/admin' } shell: systemctl daemon-reload - name: systemctl start service: name: "{{ item }}" state: started enabled: yes with_items: - mongod19000 - mongod19001 - name: reboot shell: reboot
cat Init_Mysql.yml
- name: init server
  gather_facts: False
  remote_user: root
  hosts: Mysql
  vars:
    - key: 164  #主機變數,指定後續恢復那台mysql數據
  roles:
    - init
    - mysql
安裝配置mysql及數據恢復
cat
roles/mysql/tasks/main.yml - name: copy mysql copy: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" with_items: - { src: 'mysql-community-common-5.7.11-1.el7.x86_64.rpm', dest: '/opt', mode: '0644' } - { src: 'mysql-community-libs-5.7.11-1.el7.x86_64.rpm', dest: '/opt', mode: '0644' } - { src: 'mysql-community-libs-compat-5.7.11-1.el7.x86_64.rpm', dest: '/opt', mode: '0644' } - { src: 'mysql-community-client-5.7.11-1.el7.x86_64.rpm', dest: '/opt', mode: '0644' } - { src: 'mysql-community-server-5.7.11-1.el7.x86_64.rpm', dest: '/opt', mode: '0644' } #- name: stop mariadb # service: # name: mariadb # state: stopped - name: remove mariadb yum: name: mariadb state: absent - name: install mysql yum: name: "{{ packages }}" vars: packages: - /opt/mysql-community-common-5.7.11-1.el7.x86_64.rpm - /opt/mysql-community-libs-5.7.11-1.el7.x86_64.rpm - /opt/mysql-community-libs-compat-5.7.11-1.el7.x86_64.rpm - /opt/mysql-community-client-5.7.11-1.el7.x86_64.rpm - /opt/mysql-community-server-5.7.11-1.el7.x86_64.rpm - name: copy mysql config file copy: src='my.cnf' dest='/etc/' mode='0644' - name: start mysqld service: name: mysqld state: started enabled: yes - name: copy change password copy: src: "mysql.sh" dest: "/root" - name: chang root password shell: sh /root/mysql.sh - name: copy AMS file that is already on the remote machine copy: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" with_items: - { src: 'mysql_84_db_lxzl_ams_admin.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_84_db_lxzl_ams.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_84_db_lxzl_ams_workflow.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_84_db_lxzl_nacos.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_84_db_lxzl_openapi.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_84_db_lxzl_rules_engine.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_84_mysql.sql.gz', dest: '/root', mode: '0644' } when: key == 84 - name: gzip backup file shell: cd /root && gzip -d {{ item }} with_items: - mysql_84_db_lxzl_ams_admin.sql.gz - mysql_84_db_lxzl_ams.sql.gz - mysql_84_db_lxzl_ams_workflow.sql.gz - mysql_84_db_lxzl_nacos.sql.gz - mysql_84_db_lxzl_openapi.sql.gz - mysql_84_db_lxzl_rules_engine.sql.gz - mysql_84_mysql.sql.gz when: key == 84 - name: copy ERP file that is already on the remote machine copy: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" with_items: - { src: 'mysql_82_db_lxzl_app.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_bank_enterprise.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_bill.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_contract.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_coupon.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_datacenter.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_dingding.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_erp.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_file_gateway.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_message_gateway.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_oauth.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_payment_gateway.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_product.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_risk_system.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_sap_assets_modification.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_sms.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_worker.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_workflow.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_db_lxzl_zl_jd.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_82_mysql.sql.gz', dest: '/root', mode: '0644' } when: key == 82 - name: gzip backup file shell: cd /root && gzip -d {{ item }} with_items: - mysql_82_db_lxzl_app.sql.gz - mysql_82_db_lxzl_bank_enterprise.sql.gz - mysql_82_db_lxzl_bill.sql.gz - mysql_82_db_lxzl_contract.sql.gz - mysql_82_db_lxzl_coupon.sql.gz - mysql_82_db_lxzl_datacenter.sql.gz - mysql_82_db_lxzl_dingding.sql.gz - mysql_82_db_lxzl_erp.sql.gz - mysql_82_db_lxzl_file_gateway.sql.gz - mysql_82_db_lxzl_message_gateway.sql.gz - mysql_82_db_lxzl_oauth.sql.gz - mysql_82_db_lxzl_payment_gateway.sql.gz - mysql_82_db_lxzl_product.sql.gz - mysql_82_db_lxzl_risk_system.sql.gz - mysql_82_db_lxzl_sap_assets_modification.sql.gz - mysql_82_db_lxzl_sms.sql.gz - mysql_82_db_lxzl_worker.sql.gz - mysql_82_db_lxzl_workflow.sql.gz - mysql_82_db_lxzl_zl_jd.sql.gz - mysql_82_mysql.sql.gz when: key == 82 - name: copy HSCSMYSQL file that is already on the remote machine copy: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" with_items: - { src: 'mysql_162_db_lxzl_hscs.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_162_mysql.sql.gz', dest: '/root', mode: '0644' } when: key == 162 - name: shell: cd root && gzip -d {{ item }} with_items: - mysql_162_db_lxzl_hscs.sql.gz - mysql_162_mysql.sql.gz when: key == 162 - name: copy WMSMYSQL file that is already on the remote machine copy: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" with_items: - { src: 'mysql_164_db_lxzl_purchase.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_164_db_lxzl_sap.sql.gz', dest: '/root', mode: '0644' } - { src: 'mysql_164_db_lxzl_wms.sql.gz', dest: '/root', mode: '0644' }
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 迎面走來了你的面試官,身穿格子衫,挺著啤酒肚,髮際線嚴重後移的中年男子。 手拿泡著枸杞的保溫杯,胳膊夾著MacBook,MacBook上還貼著公司標語:“我愛加班”。 面試開始,直入正題。 面試官: 看你簡歷上面寫著精通MySQL,我先問你事務的特性是什麼? 老生常談,這個還有誰不會背的嗎? 我: ...
  • 「簡單有價值的事情長期堅持做」 這是成功最簡單,但也最難學的秘訣。不經過訓練,人很難意識到時間複利的威力。 仙劍奇俠傳的「十里坡劍神」和金庸群俠傳的「十級野球拳」,就是簡單的事情持之以恆反覆做,最後就有巨大的威力 唐家三少成為網文收入第一,最重要的一步是十四年從未斷日更 這樣的案例很多,一開始可能成 ...
  • 目錄 一.簡介 二.效果演示 三.源碼下載 四.猜你喜歡 零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 基礎 零基礎 OpenGL (ES) 學習路線推薦 : OpenGL (ES) 學習目錄 >> OpenGL ES 轉場 零基礎 O ...
  • 前言 本文將以 C# 語言來實現一個簡單的布隆過濾器,為簡化說明,設計得很簡單,僅供學習使用。 感謝@時總百忙之中的指導。 布隆過濾器簡介 布隆過濾器(Bloom filter)是一種特殊的 Hash Table,能夠以較小的存儲空間較快地判斷出數據是否存在。常用於允許一定誤判率的數據過濾及防止緩存 ...
  • (註:此筆記預設操作系統為centOS7) 文件許可權 超級管理員用戶(root)可以修改任何文件,普通用戶才有許可權這個概念。 文件許可權就是文件的訪問許可權,即哪些用戶和群組可以訪問文件以及執行怎麼樣的操作。 Linux/Unix系統是典型的多用戶系統,不同的用戶處於不同的地位,對文件和目錄有不同的訪問 ...
  • 一、前期準備 測試環境:VMware Workstation / centos8 1)增加一塊磁碟 2)查看新增磁碟(lsblk),發現沒找到新增的磁碟 3)解決查不到新增磁碟問題 重新掃描SCSI匯流排添加設備, $ echo "- - -" > /sys/class/scsi_host/host0 ...
  • 前提:關閉selinux和防火牆 SElinux: setenforce 0 vim /etc/selinux/config-->disabled 防火牆: firewall-cmd --set-default-zone=trusted iptables -F 1.下載安裝包: 使用yum info ...
  • Windows 10 啟動谷歌瀏覽器Chrome失敗(應用程式無法啟動,因為應用程式的並行配置不正確)解決方法 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...