russellchang54 / PM

daily note
1 stars 0 forks source link

2017年3月 #6

Open russellchang54 opened 7 years ago

russellchang54 commented 7 years ago

先在域名解析系统,添加一个A记录的二级域名的映射,如demo.aek56.com;

在nginx 的配置文件中,增加Server记录,端口为80,servername 指向子域名,如demo.aek56.com.

这样,就支持同一个EP(IP:80), 可以跑多个域名不同的系统,利用了nginx 的域名劫持功能

russellchang54 commented 7 years ago

https://eacdy.gitbooks.io/spring-cloud-book/content/2%20Spring%20Cloud/2.5%20%E9%85%8D%E7%BD%AE%E4%B8%AD%E5%BF%83.html

https://www.gitbook.com/book/eacdy/spring-cloud-book/details

https://exampledriven.wordpress.com/2016/06/24/spring-boot-docker-example/

https://github.com/rohitghatol/spring-boot-microservices/tree/master/api-gateway

//安装docker-compose curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

russellchang54 commented 7 years ago

SSO(单点登录):基于oauth2协议。given 3 domains sso.ebey56.com (Authorization server), assets.ebey56.com(assets-Center), supervisor.ebey56.com( supervisor-Center).

1》两个系统都没有登陆之前,用户先向其中一个发起登录,比如assets.ebey56.com,请求到了assets,服务端发现没有session,便302跳转到sso;

2》用户输入用户名和密码,向sso发起登录请求,验证通过,生成ticket,再根据用户个人信息和ticket生成session; 对session 进行加密生成token;于是就有了sso/session。

3》客户端收到token后,解密后拆解后,得到用户个人信息和session,并将session 记入assets.ebey56.com和sso.ebey56.com这两个域名下;

4》客户端协此session 重新登录assets.ebey56.com,并向sso发起验证,sso拆解session,验证用户资料和ticket,两个都有效,验证通过,用户完成登录

5》客户端再访问supervisor资源,supervisor服务端发现客户端没有session,便302跳转至sso, 如同步骤 1

6》因为之前已经登录过sso,客户端拥有sso的session,通过拆解session,比对用户信息和ticket,验证通过后,客户端返回,并将生成的session再写入一份到supervisor域名下,接着跳转到supervisor

7》客户端协此session 重新访问supervisor.ebey56.com,supervisor向sso发起验证,sso拆解session,验证用户资料和ticket,两个都有效,验证通过,授权用户访问资源。如同步骤4;

用户退出: 8》客户端从任一服务退出如supervisor.ebey56.com,清除supervisor域名下的session, supervisor收到请求后,将请求转发给sso(301跳转?),客户端清除sso下的session,sso删除session,和ticket;

9》客户端再访问assets.ebey56.com资源,服务端收到请求301跳转到sso,验证session时候,sso发现没有有效session,认为用户没有登陆(已经登出),就跳转到sso的登录窗,要求用户重新登陆

russellchang54 commented 7 years ago

spring cloud 中的几个概念,搞清楚撒! 配置管理(configuration management),服务发现(service discovery),断路器(circuit breakers),智能路由( intelligent routing),微代理(micro-proxy),控制总线(control bus),一次性令牌( one-time tokens),全局锁(global locks),领导选举(leadership election)

russellchang54 commented 7 years ago

1> gradlew build 报错:java.lang.UnsupportedOperationException (no error message)

方法:修改 org.springframework.boot:spring-boot-gradle-plugin 版本到 1.4.0.RELEASE

2> 又gradlew build,再报错:Could not set unknown property 'mainClassName' for root project 。。。

方法: 增加 apply plugin: 'application'

3> ./gradlew clean,报错:Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

方法:重新生成wrapper文件. sudo gradle wrapper

4> 下载包慢 方法: 在build.gradle文件中,在repositories 中 将mavenCentral()和jcenter() 删除,替换成: maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}

russellchang54 commented 7 years ago

阿里云的docker镜像: sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://70cshhod.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker

russellchang54 commented 7 years ago

阿里云的maven私服: http://maven.aliyun.com/nexus/content/groups/public/

russellchang54 commented 7 years ago

列举当前目录下大于100k的文件 find . -size +100k -exec ls -l {} \;

删除当前目录下所有.o文件 find . -name '*.o' -exec rm {} \;

统计当前目录下.c文件的个数 find . -name '*.c'|wc -l

查找 名为svn的目录 find / -type d -name 'svn'

查找那些包含特征字符串admin_notice的php文件 find . -name "*.php" -exec grep -H 'admin_notice' {} \;

du统计当前目录下所有文件占用的磁盘空间,不包括*.o文件。

du -ch --exclude='*.o'

利用find 命令配合awk命令对符合条件即某一特定的文件作汇总统计

find . -mtime -1 -exec ls -l {} \; |awk 'BEGIN{count=0;size=0;} \

{count = count + 1; size = size + $5/1024/1024;} \

END{print "Total count " count; \

print "Total Size " size/1024 " GB" ; \

print "Avg Size " size / count "MB"; \

print "—"}'

统计当前目录下所有cpp文件的个数及大小: find . -name '*.cpp' -exec ls -l {} \;|awk 'BEGIN{count=0;size=0;} {count = count + 1; size = size + $5/1024/1024;} END{print "total count: " count; print "total size: " size "(MB)"; print "----"}'

统计当前目录下c文件的行数 find . -name '*.c' -exec wc -l {} \;|awk 'BEGIN {line=0;} {line = line + $1;} END{print "total line: " line}'

russellchang54 commented 7 years ago

配置服务器通过mini环境(git仓库:spring.cloud.config.server.git.uri)枚举属性源,并将它们通过JSON endpoint 发不出去,其形式如下: /{application}/{profile}[/{label}] /{application}-{profile}.yml /{label}/{application}-{profile}.yml /{application}-{profile}.properties /{label}/{application}-{profile}.properties

"application“是SpringApplication通过 spring.application.name注入的应用名称 "label" is an optional git label (defaults to "master".),分支名称 profile:yml文件中分号分割的属性列表名称

russellchang54 commented 7 years ago

http://blog.javachen.com/2016/02/19/spring-boot-auto-configuration.html

russellchang54 commented 7 years ago

bootstrap.yml,应用启动之前,读取配置文件的方式,如通过本地读取配置文件,配置所在路径;通过git读取配置文件,配置文件的仓库地址等

application.yml,应用具体的配置项

还有就是在bootstrap.yml里定义profiles,在application.yml里声明使用那个/些profile:spring.profiles.active=dev,hsqldb

russellchang54 commented 7 years ago

端口映射配置 /usr/local/rinetd/rinetd.conf

russellchang54 commented 7 years ago

OAuth2 的几个grant_type: authorization_code password client_credentials refresh_token

russellchang54 commented 7 years ago

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.showBanner

把spring-cloud更新到 1.2.3.RELEASE 版本

艹,搞了一天了这个问题,换了5个spring-boot的版本,却一直没有意识到是cloud的版本问题!

russellchang54 commented 7 years ago

是centos 镜像后台运行 docker run --name centos -d centos /bin/sh -c "while true; do sleep 10000; done"

russellchang54 commented 7 years ago

https://www.ibm.com/developerworks/cn/webservices/ws-multitenantpart4/ http://cmshelpcenter.saas.hp.com/CMS/10.30/ucmdb-docs/docs/eng/doc_lib/Content/admin/MultiTenUCMDB_c_User_permis_res.htm

https://developer.kaltura.com/api-docs/Overview

russellchang54 commented 7 years ago

认证、授权、访问控制 基于角色的访问控制,角色对应组织内的职责,每一个角色拥有1个或多个权限,使得拥有相应角色的人,具有对应的资源访问(处理业务)权限,权限与API一一对应;一个用户(用户组)可以同时拥有多个不同的角色。访问控制的管理在数据范围层(scope level)。每一个scope 继承parent scope的角色、权限和业务规则。系统会提供一系列默认的(预设)角色、权限供所有租户使用,租户自己也可以基于预设的角色自定义自己的角色:如基于预设的设备科工程师角色(复制预设角色),增加/减少权限等。

可配置 1》界面、logo 2》工作流&业务逻辑 3》数据模型可扩展 租户可以自行扩展默认的数据模型,来满足及的实际需要。三种方法: 专有(Dedicated )租户数据库:一个租户一个数据库。metadata服务需要跟踪租户与数据的对应关系。 共享(Share)数据库:租户表提供一个json类型的字段(customData),存储key-value键值对。 自定义字段,系统内置类型检查和数据验证功能

4》每个租户可以自行管理自己的资源的访问控制

数据安全、隔离

基于namespace的API,每一个租户对应一个namespace.

数据模型的架构

针对来自内部和外部的威胁:进行深度防御,使用多级防御体系、相辅相成,在各种情况下,提供多种方式的数据保护。三种基本的模式:

过滤:在租户和数据之间增加一个中间过滤层。 如租户视图过滤,每个租户对应一个自己的view: CREATE VIEW TenantEmployees AS SELECT FROM Employees WHERE TenantID = 在应用层和数据层分别定义一个租户id。租户管理员创建视图,视图名称 v. grant read privileges on view on .v_

权限:基于角色的权限的控制

加密:每个租户生成3个密钥,公钥/私钥,对称密钥。使用公钥加密对称密钥,私钥解密对称密钥。再用 对称密钥解密租户数据。

盈利模式

Operational support services (OSS)—Handle operational issues such as account activation, provisioning, service assurance, usage, and metering. Business support services (BSS)—Support billing (including invoicing, rating, taxation, and collections) and customer management (which includes order entry, customer self services, customer care, trouble ticketing, and customer relationship management).

搭建监控系统:可用性监控、性能监控