4-19
Saturday
标签
梦涛笔记

ROS通过aliyun域名解析实现DDNS脚本

ROS 发布时间:2025-03-29 13:51:38
#aliyun Access Key
:local id "key"
:local secret "secret"

#domain
:local domain "your.domain.com"


#PPPoE-out
:local pppoe "pppoe-out1"

#阿里云DDNS服务器:

:local ipaddr [/ip address get [/ip address find interface=$pppoe] address]
:set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)]
#:log info $ipaddr;
:local result [/tool fetch url="https://www.zhisg.com/route.php/ddns/ali/set\?id=$id&secret=$secret&domain=$domain&ip=$ipaddr" as-value output=user];
:log info $result;


#:global ddnspool "ipv6"
#:global ddnsinterface "bridge"
#:global ddnsinterface "6to4-henet"
#:global ddnsinterface "pppoe-out1"
#:global ddnsinterface "ether6"

# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }


# Define Local Variables
:local int

# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:if ([ :typeof $ddnsinterface ] != "str" ) do={
  :foreach int in=[ /ipv6 address find global ] do={
    :local testip [ /ipv6 address get $int address ]
    :if ($testip in "fe80::/10" || $testip in "fc00::/7") do={
    } else={
      :global ddnsip $testip
    }
  }
} else={
  :if ([ :typeof $ddnspool ] != "str" ) do={
    # Grab the current Global IP address on that interface.
    :foreach int in=[ /ipv6 address find interface=$ddnsinterface global ] do={
      :local testip [ /ipv6 address get $int address ]
      :if ($testip in "fe80::/10" || $testip in "fc00::/7") do={
      } else={
        :global ddnsip $testip
      }
    }
  } else={
    # Grab the current Global IP address on that interface from spec ip pool.
    :global ddnsip [ /ipv6 address get [ /ipv6 address find interface=$ddnsinterface  from-pool=$ddnspool ] address ]
  }
}

# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = nil ) do={
   :log info ("DynDNS: No ip address present on please check.")
} else={
  :log info ("DynDNS: check IPv6 UPDATE " . $ddnsip)
#  :if ($ddnsip != $ddnslastip) do={
:local result [/tool fetch url="https://www.zhisg.com/route.php/ddns/ali/set\?id=$id&secret=$secret&domain=$domain&ip=$ddnsip&type=AAAA" as-value output=user];
:log info $result;    
    :global ddnslastip $ddnsip
#  }
}


PHP OPcache 配置参数优化方案

PHP 发布时间:2025-03-19 18:45:14
vim /etc/php.d/10-opcache.ini
; Enable Zend OPcache extension module
zend_extension=opcache

; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1

; The OPcache shared memory storage size.
opcache.memory_consumption=512

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=16

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=300000

; The maximum percentage of "wasted" memory until a restart is scheduled.
;opcache.max_wasted_percentage=5

; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
;opcache.use_cwd=1

; When disabled, you must reset the OPcache manually or restart the
; webserver for changes to the filesystem to take effect.
opcache.validate_timestamps=1

; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
opcache.revalidate_freq=10

; Enables or disables file search in include_path optimization
;opcache.revalidate_path=0

; If disabled, all PHPDoc comments are dropped from the code to reduce the
; size of the optimized code.
;opcache.save_comments=1

; If enabled, compilation warnings (including notices and deprecations) will
; be recorded and replayed each time a file is included. Otherwise, compilation
; warnings will only be emitted when the file is first cached.
;opcache.record_warnings=0

; Allow file existence override (file_exists, etc.) performance feature.
;opcache.enable_file_override=0

; A bitmask, where each bit enables or disables the appropriate OPcache
; passes
;opcache.optimization_level=0x7FFFBFFF

; This hack should only be enabled to work around "Cannot redeclare class"
; errors.
;opcache.dups_fix=0

; The location of the OPcache blacklist file (wildcards allowed).
; Each OPcache blacklist file is a text file that holds the names of files
; that should not be accelerated.
opcache.blacklist_filename=/etc/php.d/opcache*.blacklist

; Allows exclusion of large files from being cached. By default all files
; are cached.
;opcache.max_file_size=0

; Check the cache checksum each N requests.
; The default value of "0" means that the checks are disabled.
;opcache.consistency_checks=0

; How long to wait (in seconds) for a scheduled restart to begin if the cache
; is not being accessed.
;opcache.force_restart_timeout=180

; OPcache error_log file name. Empty string assumes "stderr".
;opcache.error_log=

; All OPcache errors go to the Web server log.
; By default, only fatal errors (level 0) or errors (level 1) are logged.
; You can also enable warnings (level 2), info messages (level 3) or
; debug messages (level 4).
;opcache.log_verbosity_level=1

; Preferred Shared Memory back-end. Leave empty and let the system decide.
;opcache.preferred_memory_model=

; Protect the shared memory from unexpected writing during script execution.
; Useful for internal debugging only.
;opcache.protect_memory=0

; Allows calling OPcache API functions only from PHP scripts which path is
; started from specified string. The default "" means no restriction
;opcache.restrict_api=

; Enables and sets the second level cache directory.
; It should improve performance when SHM memory is full, at server restart or
; SHM reset. The default "" disables file based caching.
; RPM note : file cache directory must be owned by process owner
;   for mod_php, see /etc/httpd/conf.d/php.conf
;   for php-fpm, see /etc/php-fpm.d/*conf
opcache.file_cache=/tmp

; Enables or disables opcode caching in shared memory.
;opcache.file_cache_only=0

; Enables or disables checksum validation when script loaded from file cache.
;opcache.file_cache_consistency_checks=1

; Implies opcache.file_cache_only=1 for a certain process that failed to
; reattach to the shared memory (for Windows only). Explicitly enabled file
; cache is required.
;opcache.file_cache_fallback=1

; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
; Under certain circumstances (if only a single global PHP process is
; started from which all others fork), this can increase performance
; by a tiny amount because TLB misses are reduced.  On the other hand, this
; delays PHP startup, increases memory usage and degrades performance
; under memory pressure - use with care.
; Requires appropriate OS configuration.
opcache.huge_code_pages=1

; Validate cached file permissions.
; Leads OPcache to check file readability on each access to cached file.
; This directive should be enabled in shared hosting environment, when few
; users (PHP-FPM pools) reuse the common OPcache shared memory.
;opcache.validate_permission=0

; Prevent name collisions in chroot'ed environment.
; This directive prevents file name collisions in different "chroot"
; environments. It should be enabled for sites that may serve requests in
; different "chroot" environments.
;opcache.validate_root=0

; If specified, it produces opcode dumps for debugging different stages of
; optimizations.
;opcache.opt_debug_level=0

; Specifies a PHP script that is going to be compiled and executed at server
; start-up.
; https://php.net/opcache.preload
;opcache.preload=

; Preloading code as root is not allowed for security reasons. This directive
; facilitates to let the preloading to be run as another user.
; https://php.net/opcache.preload_user
;opcache.preload_user=

; Prevents caching files that are less than this number of seconds old. It
; protects from caching of incompletely updated files. In case all file updates
; on your site are atomic, you may increase performance by setting it to "0".
;opcache.file_update_protection=2

; Absolute path used to store shared lockfiles (for *nix only).
;opcache.lockfile_path=/tmp
;
;JIT
opcache.jit=tracing
opcache.jit_buffer_size=256M


MySQL配置优化参数

MySQL 发布时间:2025-03-19 18:31:54
vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
event_scheduler=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER
max_connections=1000

skip_name_resolve

innodb_buffer_pool_size = 32000M
innodb_log_file_size = 2048M

query_cache_type=0
query_cache_size=0
query_cache_limit=1M

server-id = 112031
master-info-repository = table
relay-log-info-repository = table
relay-log-recovery=1

log-bin = mysql-bin
expire_logs_days = 7
binlog_format = mixed
#binlog-ignore-db = mysql
binlog-ignore-db = sys
binlog-ignore-db = phpmyadmin
binlog-ignore-db = information_schema
binlog-ignore-db = performance_schema

log-slave-updates
#replicate-ignore-db = mysql
#
slave-skip-errors=all

slow_query_log = 1
long_query_time = 2
#log_output = table


网线接线方法

发布时间:2025-03-18 10:29:31

五类线的标识是“CAT5”,超五类线的标识是“CAT5E”,六类线的标识是“ CAT6”。

超五类双绞线裸铜线径为0.51mm(线规为24AWG),绝缘线径为0.92mm,UTP电缆直径为5mm;

六类非屏蔽双绞线裸铜线径为0.57mm(线规为23AWG),绝缘线径为1.02mm,UTP电缆直径为6.53mm。

T568B:橙白、橙、绿白、蓝、蓝白、绿、棕白、棕    

T568A:绿白、绿、橙白、蓝、蓝白、橙、棕白、棕

T568Q:绿白、绿、橙白、棕白、棕、橙、蓝、蓝白

Linux 测机命令

Linux 发布时间:2025-03-18 10:18:51

测试写速度:

time dd if=/dev/zero of=/tmp/test bs=8k count=1000000

测试读速度:

time dd if=/tmp/test of=/dev/null bs=8k

测试读写速度:

time dd if=/tmp/test of=/tmp/test1 bs=64k

一行命令让CPU占用率达到100%

for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do dd if=/dev/zero of=/dev/null & done

如何在mysql存储过程中处理select语句返回的多行结果(用游标)

MySQL 发布时间:2025-03-18 10:10:47
CREATE PROCEDURE curdemo()
BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE a CHAR(16);
  DECLARE b,c INT;
  DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1;
  DECLARE cur2 CURSOR FOR SELECT i FROM test.t2;
  DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
  
  OPEN cur1;
  OPEN cur2;
  
  REPEAT
    FETCH cur1 INTO a, b;
    FETCH cur2 INTO c;
    IF NOT done THEN
       IF b < c THEN
          INSERT INTO test.t3 VALUES (a,b);
       ELSE
          INSERT INTO test.t3 VALUES (a,c);
       END IF;
    END IF;
  UNTIL done END REPEAT;
  
  CLOSE cur1;
  CLOSE cur2;
END


ESXI升级补丁命令

虚拟化 发布时间:2025-03-14 17:19:30
vmware -vl
esxcli software vib list

esxcli software vib install -d "/vmfs/volumes/datestroe02/os/ESXi670-202207001.zip"


esxcli software sources profile list -d /vmfs/volumes/iso/VMware-ESXi-8.0-20513097-depot.zip
esxcli software profile update -d /vmfs/volumes/iso/VMware-ESXi-8.0-20513097-depot.zip -p ESXi-8.0.0-20513097-standard

ESXI 硬盘直通

虚拟化 发布时间:2025-03-14 17:16:23
vmkfstools -z /vmfs/devices/disks/naa.50000396a1b811a9  /vmfs/volumes/5eefaf52-4d40184a-07a6-4cd98f75a46c/nas1-1T.vmdk

CentOS Certbot SSL

HTML CentOS Apache 发布时间:2025-03-14 17:14:06

安装命令

yum install certbot

获取证书命令

certbot certonly --manual -m jason@zhisg.com -d *.zhisg.com
certbot certonly --webroot -w /var/www/html/zhisg/ -d www.zhisg.com
certbot renew   #继订全部证书
certbot renew --cert-name domain.com  #指定证书


certonly 表示安装模式,Certbot 有安装模式和验证模式两种类型的插件。
–manual 表示手动安装插件,Certbot 有很多插件,不同的插件都可以申请证书,用户可以根据需要自行选择
-d 为那些主机申请证书,如果是通配符,输入 *.domain.com (替换为你自己的域名)
–preferred-challenges dns,使用 DNS 方式校验域名所有权
–server,Let’s Encrypt ACME v2 版本使用的服务器不同于 v1 版本,需要显示指定。

Apache配置 mpm_event_module

Apache 发布时间:2025-03-14 17:00:04

编辑配置文件:/etc/httpd/conf.modules.d/00-mpm.conf

LoadModule mpm_event_module modules/mod_mpm_event.so

<IfModule mpm_event_module>
    StartServers             4
    MinSpareThreads         16
    MaxSpareThreads        512
    ThreadsPerChild         64
    ServerLimit             64
    MaxRequestWorkers     4096
    MaxConnectionsPerChild 15000
</IfModule>