$stream_opts = [
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
];
$response = file_get_contents($url, false, stream_context_create($stream_opts));
dd if=/dev/zero of=swapfile bs=1024 count=500000
500000+0 records in
500000+0 records out
512000000 bytes (512 MB) copied, 0.847481 s, 604 MB/s
ll
total 500000
-rw-r--r-- 1 root root 512000000 Sep 11 16:24 swapfile
[root@dics-no iflytek]# mkswap swapfile
Setting up swapspace version 1, size = 499996 KiB
no label, UUID=bf7c48ab-d829-4291-a477-f75cdd33f72a
[root@dics-no iflytek]#
[root@dics-no iflytek]# swapon swapfile
swapon: swapfile: insecure permissions 0644, 0600 suggested.
[root@dics-no iflytek]#
[root@dics-no iflytek]# free -h
total used free shared buffers cached
Mem: 31G 918M 30G 8.3M 704K 589M
-/+ buffers/cache: 328M 30G
Swap: 488M 0B 488M
[root@dics-no iflytek]#
删除swapfile[root@i-5608690E /]# swapoff swapfile
然后再执行删除文件操作[root@i-5608690E /]# rm swapfile
注:如果没有执行swapoff操作,就执行执行删除文件的操作,系统会报错,不给删除。swapoff相当于是卸载swap分区。ls -l | grep "^-"
我们可以用wc命令进行统计:ls -l ./|grep "^-"|wc -l
3.统计文件夹中目录个数ls -l ./|grep "^d"|wc -l
4.统计文件夹下文件个数,包括子文件ls -lR | grep "^-"| wc -l
5.统计文件夹下目录个数,包括子目录ls -lR | grep "^d"| wc -l
./yii migrate/create test_user
执行后,就会在/console/migrations/下面生成m160511_080937_test_user.php。[root@services datacenter_1000]# ./yii migrate/create test_user
Yii Migration Tool (based on Yii v2.0.7)
Create new migration '/www/web/datacenter/datacenter_1000/console/migrations/m160511_080937_test_user.php'? (yes|no) [no]:yes
New migration created successfully.
./yii migrate --migrationPath=@yii/log/migrations/
同样 down() , 采用 safeDown()方法。yii\db\Migration::execute(): 执行一条 SQL 语句
yii\db\Migration::insert(): 插入单行数据
yii\db\Migration::batchInsert(): 插入多行数据
yii\db\Migration::update(): 更新数据
yii\db\Migration::delete(): 删除数据
yii\db\Migration::createTable(): 创建表
yii\db\Migration::renameTable(): 重命名表名
yii\db\Migration::dropTable(): 删除一张表
yii\db\Migration::truncateTable(): 清空表中的所有数据
yii\db\Migration::addColumn(): 加一个字段
yii\db\Migration::renameColumn(): 重命名字段名称
yii\db\Migration::dropColumn(): 删除一个字段
yii\db\Migration::alterColumn(): 修改字段
yii\db\Migration::addPrimaryKey(): 添加一个主键
yii\db\Migration::dropPrimaryKey(): 删除一个主键
yii\db\Migration::addForeignKey(): 添加一个外键
yii\db\Migration::dropForeignKey(): 删除一个外键
yii\db\Migration::createIndex(): 创建一个索引
yii\db\Migration::dropIndex(): 删除一个索引
yii migrate 3
你也可以指定一个特定的迁移,按照如下格式使用 migrate/to 命令来指定数据库应该提交哪一个迁移:yii migrate/to 150101_185401 # using timestamp to specify the migration 使用时间戳来指定迁移
yii migrate/to "2015-01-01 18:54:01" # using a string that can be parsed by strtotime() 使用一个可以被 strtotime() 解析的字符串
yii migrate/to m150101_185401_create_news_table # using full name 使用全名
yii migrate/to 1392853618 # using UNIX timestamp 使用 UNIX 时间戳
yii migrate/down # revert the most recently applied migration 还原最近一次提交的迁移
yii migrate/down 3 # revert the most 3 recently applied migrations 还原最近三次提交的迁移
yii migrate/redo # redo the last applied migration 重做最近一次提交的迁移
yii migrate/redo 3 # redo the last 3 applied migrations 重做最近三次提交的迁移
yii migrate/history # 显示最近10次提交的迁移
yii migrate/history 5 # 显示最近5次提交的迁移
yii migrate/history all # 显示所有已经提交过的迁移
yii migrate/new # 显示前10个还未提交的迁移
yii migrate/new 5 # 显示前5个还未提交的迁移
yii migrate/new all # 显示所有还未提交的迁移
yii migrate/mark 150101_185401 # 使用时间戳来指定迁移
yii migrate/mark "2015-01-01 18:54:01" # 使用一个可以被 strtotime() 解析的字符串
yii migrate/mark m150101_185401_create_news_table # 使用全名
yii migrate/mark 1392853618 # 使用 UNIX 时间戳
lsblk
选择自己要挂载的硬盘,不要选错了sudo parted /dev/sdb #使用parted来对GPT磁盘操作,进入交互式模式
(parted) mklabel gpt # 将MBR磁盘格式化为GPT
(parted) mkpart primary ext4 0% 100% 将所有容量分为一个主分区
(parted) p #打印当前分区
(parted) q #退出
sudo mkfs.ext4 /dev/sdb1
四、挂载sudo mkdir /disk1
sudo mount /dev/sdb1 /disk1 #挂载在disk1上
sudo blkid
六、修改/etc/fstabUUID=cf116c95-b7f0-4ce4-b0da-7f2856784c43 /disk1 ext4 defaults 0 2
var index = layer.open();
var index = layer.alert();
var index = layer.load();
var index = layer.tips();
正如你看到的,每一种弹层调用方式,都会返回一个indexlayer.close(index); //此时你只需要把获得的index,轻轻地赋予layer.close即可
如果你想关闭最新弹出的层,直接获取layer.index即可layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
当你在iframe页面关闭自身时var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
nginx -V | grep with-stream # 如果有启用 Stream 模块,则会显示相关内容,这里的 Nginx 版本为 1.20.X
nginx version: nginx/1.20.1
built by gcc 10.2.1 20201203 (Alpine 10.2.1_pre1)
built with OpenSSL 1.1.1i 8 Dec 2020 (running with OpenSSL 1.1.1k 25 Mar 2021)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fomit-frame-pointer -g' --with-ld-opt=-Wl,--as-needed
2. 修改 nginx.conf,添加 Stream 配置user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
# 启用流转发
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /var/log/nginx/tcp-access.log proxy ;
open_log_file_cache off;
include /etc/nginx/tcp.d/*.conf;
}
3. 新建一个 tcp.d 目录,用于存放 TCP 转发配置mkdir tcp.d && cd tcp.d
4. MySQL 转发示例配置vi mysql.conf
upstream tcp {
server {目标机器 IP}:3306;
}
server {
listen 3306;
proxy_connect_timeout 8s;
proxy_timeout 24h;
proxy_pass tcp;
}
5. Redis 转发示例配置vi redis.conf
upstream tcp {
server {目标机器 IP}:6379;
}
server {
listen 6379;
proxy_connect_timeout 8s;
proxy_timeout 24h;
proxy_pass tcp;
}
6. 启动指令 - docker 方式docker run --name tcp-nginx -d -p 3306:3306 -p 6379:6379 -v $PWD/nginx.conf:/etc/nginx/nginx.conf -v $PWD/tcp.d:/etc/nginx/tcp.d nginx:1.20-alpine
[statement_1] if [expression] else [statement_2]
如果表达式的计算结果为True,则选择statement_1。否则,如果表达式的计算结果为False,则选择statement_2。a, b = 2, 5
# 得到a,b的最大值
max = a if a > b else b
print(max) # 5;运行程序,由于 a> b 返回 False,因此选择了 b。
a, b = 2, 5
# 三元运算符
print('a') if a > b else print('b') # b
a, b, c = 15, 93, 22
# 嵌套三元运算符
max = a if a > b and a>c else b if b>c else c
print(max) # 93