asp.net filter类库区别

MVC由System.Web.Mvc.ActionFilterAttribute 来做action请求的拦截。
webapi 由 System.Web.Http.Filters.ActionFilterAttribute 来处理。\

MVC 直接在System.Web.Mvc.GlobalFilterCollection 这个全局管道里面注册 ActionFilter ,位置在App_Start目录>FilterConfig 类>RegisterGlobalFilters 方法 使用参数filters , filters.Add(new YourMvcAttribute()) 添加你的mvc ActionFilterAttribute 。

WebAPI 在System.Web.Http.Filters 中注册, 在项目的App_Start 目录>WebApiConfig类中>Register 方法中加入使用 config参数, config.Filters.Add(new YourWebApiAttribute()); 添加你的 webapi ActionFilterAttribute

这样就可以注册你的 ActionFilterAttribute 成为全局的Filter,系统中请求经过Action 之前或之后 都会被你的ActionFilter 拦下来做处理然后在转交下去。

centos7.6中二进制安装安装mysql8.0.20安装

https://www.cnblogs.com/xuewenlong/p/12882047.html
1

1.删除之前安装的MySQL包

[root@localhost ~]# rpm -qa | grep mariadb

mariadb-libs-5.5.60-1.el7_5.x86_64

[root@localhost ~]# yum erase -y mariadb-libs-5.5.60-1.el7_5.x86_64

2.解压缩

tar -xf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz

3.重命名并移动到/usr/local/mysql

mv mysql-8.0.13-linux-glibc2.12-x86_64 /usr/local/mysql

4.创建mysql用户和组

groupadd mysql

useradd -r -g mysql -s /sbin/nologin mysql

5.创建数据目录,日志目录,配置文件目录,变更权限

mkdir /data/mysql

mkdir /usr/local/mysql/etc

mkdir /usr/local/mysql/log

chown -R mysql:mysql /data/mysql/

chown -R mysql:mysql /usr/local/mysql/

6.编辑mysql配置文件

vim /usr/local/mysql/etc/my.cnf

[mysql]
port = 3306
socket = /data/mysql/mysql.sock
[mysqld]
port = 3306
mysqlx_port = 33060
mysqlx_socket = /data/mysql/mysqlx.sock
basedir = /usr/local/mysql
datadir = /data/mysql
socket = /data/mysql/mysql.sock
pid-file = /data/mysql/mysqld.pid
log-error = /usr/local/mysql/log/error.log
#这个就是用之前的身份认证插件
default-authentication-plugin = mysql_native_password
#保证日志的时间正确
log_timestamps = SYSTEM

7.初始化数据库,并查看日志

cd /usr/local/mysql

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

tail -f /usr/local/mysql/log/error.log

2019-01-13T20:27:49.270330+08:00 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.13) initializing of server in progress as process 6990
2019-01-13T20:27:53.320375+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: SV!sgk7?k0i=
2019-01-13T20:27:54.805257+08:00 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.13) initializing of server has completed

记住这个临时密码,后边要用到

8.设置启动文件,设置环境变量

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld

/etc/init.d/mysqld start
Starting MySQL.. SUCCESS!

[root@localhost ~]# ps -ef | grep mysql
root       7072      1  0 20:30 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid
mysql      7287   7072  7 20:30 pts/0    00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/log/error.log --pid-file=/usr/local/mysql/data/mysqld.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306
root       7334   6821  0 20:30 pts/0    00:00:00 grep --color=auto mysql

配置环境变量
vim /etc/profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

source /etc/profile

9.登录并配置远程登录

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#这里就是重置临时密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456!';
Query OK, 0 rows affected (0.02 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host, user, authentication_string, plugin from user;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host      | user             | authentication_string                                                  | plugin                |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root             | *611725B3AA4055897CDB648E55E0A0EA856389E2                              | mysql_native_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
4 rows in set (0.00 sec)
#这里就可以看到root@localhost这里的密码已经是mysql_native_password方式了
#这就是创建一个远程用户登录
mysql>  create user 'root'@'%' identified by '123456!';
Query OK, 0 rows affected (0.05 sec)

mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.04 sec)

mysql> select host, user, authentication_string, plugin from user;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host      | user             | authentication_string                                                  | plugin                |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| %         | root             | *43CAAB27D90B4E33EC75DEEFA02577F7E2BACE93                              | mysql_native_password |
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root             | *611725B3AA4055897CDB648E55E0A0EA856389E2                              | mysql_native_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
5 rows in set (0.00 sec)

mysql> exit
Bye

win安装绿色mysql5.6

https://www.cnblogs.com/zhangkanghui/p/9613844.html
####(1)配置环境变量

变量名:MYSQL_HOME

变量值:E:\mysql-5.7.20-winx64

2)初始化

以管理员身份运行cmd

进入E:\python\mysql\mysql-8.0.12-winx64\bin>下

执行命令:mysqld –initialize-insecure –user=mysql

(3) 安装MySQL

继续执行命令:mysqld -install

4)启动服务

继续执行命令:net start MySQL

(5)登录MySQL

登录mysql:(因为之前没设置密码,所以密码为空,不用输入密码,直接回车即可)

E:\python\mysql\mysql-8.0.12-winx64\bin>mysql -u root -p

6)查询用户密码

查询用户密码命令:mysql> select host,user,authentication_string from mysql.user;

7)设置(或修改)root用户密码

mysql> update mysql.user set password=password(“123456″) where user=”root”;
mysql> flush privileges;

8) 使用配置文件:

复制解压目录下的my-default.ini为my.ini,修改里面的文件

centos7.6中源码安装mysql8.0.20安装

1.官方下载带boost的mysql8的源码安装包

2.解压后进入目录,使用安装参数:

cmake3 参数说明boost路径使用自动下载时设置为1,不下载为0

 cmake3 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DWITH_DEBUG=OFF \
-DENABLED_PROFILING=ON \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=ON \
-DWITH_FEDERATED_STORAGE_ENGINE=ON \
-DWITH_ARCHIVE_STORAGE_ENGINE=ON \
-DWITH_EMBEDDED_SERVER=OFF \
-DWITH_BLACKHOLE_STORAGE_ENGINE=ON \
-DWITH_UNIT_TESTS=OFF \
-DENABLE_DTRACE=OFF \
-DFORCE_INSOURCE_BUILD=1 \
-DDOWNLOAD_BOOST=0 \
-DWITH_BOOST=/root/tools/mysql-8.0.20/boost/boost_1_70_0 \
-DMYSQL_DATADIR=/data/mysql

3.如果遇到问题请看下面的问题解决

4.问题解决后,运行cmake3 也无问题后,编译安装

make && make install 
还是太慢了,建议使用二进制安装
https://www.cnblogs.com/xuewenlong/p/12882047.html

————遇到的问题———–

1.cmake需使用cmake3,使用yum安装

yum -y install cmake3

2.gcc需要5.3以上,使用devtoolset直接安装7+

//1.devtoolset + scl (推荐用这种方式) 
yum install centos-release-scl -y
yum install devtoolset-7 -y
scl enable devtoolset-7 bash
gcc --version

scl enable devtoolset-7 bash #这样是创建了一个类似子shell的,在脚本里面不介意这样用,会有问题,如果在终端安装可以

#export CC=/opt/rh/devtoolset-7/root/usr/bin/gcc #脚本里可以这样定义GCC 的环境变量
#export CPP=/opt/rh/devtoolset-7/root/usr/bin/cpp  
#export CXX=/opt/rh/devtoolset-7/root/usr/bin/c++
#source /opt/rh/devtoolset-7/enable or source scl_source enable devtoolset-7

3.c++找不到路径:缺少软链接,添加软链接

ln -s /opt/rh/devtoolset-7/root/usr/bin/c++ /usr/bin/c++

4.建议不使用源码安装,cmake3后面加上编译参数

 "-DFORCE_INSOURCE_BUILD=1"

读ASP.NET Core与RESTfull API开发实战第八章

1.Http认证的常用两个状态码:

401未授权,说明登录信息无效。
403拒绝访问,登录信息正确,但权限不足拒绝访问

2.消息格式:

在消息头中Authorization:

3.认证常用三种格式:凭证不同,认证过程不同

a)Basic ,凭证中是用户名密码,一定要用https这种方式传输

b)Digest,凭证中包含信息和md5(类似支付中常用的md5验签)

c)Bearer,常用于Oauth2.0中,也常见于基于Token的认证中,常用的方式类似于Basic,所以一定要用https这种方式传输

4.Bearer认证

a)认证流程,从流程中可以看到解耦客户端与应用程序。

b)常见的两种Token类型:引用类型,自包含

引用类型:在服务端根据自己定义规则生成的字符串,通常存储在数据库中与用户信息关联
自包含:Token自身包含用户信息,服务端就不再需要访问数据库,JWT是最常见的自包含类型Token.

c)JWT组成

5.asp.net core中实现

单表数据量大的情况下,如果改表结构

问题:当单表数据量很大时,修改表结构,会有表锁让此表无法使用,也可能会操作超时,改表不成功。

1.加字段锁表时间非常短,选对运维时间加字段

2.删除/修改表字段表锁很久

3.离线改表,让业务说明维护时间:

a)方案,在范围时间内直接简单sql,时间要提前预演
b)方案,创建临时表,自写sql,迁表进新表完成后,rename 表名

4.在线改表,

a)使用工具pt,gh-ost
b)创建临时表,自写sql,迁表进新表完成后,rename 表名,迁完第一批后需要再次迁移这段时间内的增量数据。

netcore的Dockerfile

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base    
WORKDIR /app
EXPOSE 80                                   #显示暴露的端口,只是显示说明

WORKDIR /app                                #进入现在所在的容器工作目录
COPY  zyhand.webapi .                       #使用当前宿主的相对路径复制
ENTRYPOINT ["dotnet", "ZYHand.WebAPI.dll"]  #如果没有指定,默认监听端口是80