首页 文章 精选 留言 我的

精选列表

搜索[学习],共10000篇文章
优秀的个人博客,低调大师

开始学习Docker啦--容器理论知识(一)

一、容器核心技术 一谈到容器,我们都会想到 Docker。 Docker 现在几乎是容器的代名词。确实,是 Docker 将容器技术发扬光大。同时,我们也需要知道围绕 Docker 还有一个生态系统。Docker 是这个生态系统的基石,但完善的生态系统才是保障 Docker 以及容器技术能够真正健康发展的决定因素。 1、容器规范 容器不光是 Docker,还有其他容器,比如 CoreOS 的 rkt。为了保证容器生态的健康发展,保证不同容器之间能够兼容,包含 Docker、CoreOS、Google在内的若干公司共同成立了一个叫 Open Container Initiative(OCI) 的组织,其目是制定开放的容器规范。 2、容器 runtime runtime 是容器真正运行的地方。runtime 需要跟操作系统 kernel 紧密协作,为容器提供运行环境。 lxc、runc 和 rkt 是目前主流的三种容器 runtime。 lxc 是 Linux 上老牌的容器 runtime。Docker 最初也是用 lxc 作为 runtime。 runc 是 Docker 自己开发的容器 runtime,符合 oci 规范,也是现在 Docker 的默认 runtime。 rkt 是 CoreOS 开发的容器 runtime,符合 oci 规范,因而能够运行 Docker 的容器。 3、容器管理工具 光有 runtime 还不够,用户得有工具来管理容器啊。容器管理工具对内与 runtime 交互,对外为用户提供 interface,比如 CLI。这就好比除了 JVM,还得提供 java 命令让用户能够启停应用不是。 lxd 是 lxc 对应的管理工具。 runc 的管理工具是 docker engine。docker engine 包含后台 deamon 和 cli 两个部分。我们通常提到 Docker,一般就是指的 docker engine。 rkt 的管理工具是 rkt cli。 4、容器定义工具 容器定义工具允许用户定义容器的内容和属性,这样容器就能够被保存,共享和重建。 docker image 是 docker 容器的模板,runtime 依据 docker image 创建容器。 dockerfile 是包含若干命令的文本文件,可以通过这些命令创建出 docker image。 ACI (App Container Image) 与 docker image 类似,只不过它是由 CoreOS 开发的 rkt 容器的 image 格式。 5、Registry 容器是通过 image 创建的,需要有一个仓库来统一存放 image,这个仓库就叫做 Registry。 Docker Hub(https://hub.docker.com) 是 Docker 为公众提供的托管 Registry,上面有很多现成的 image,为 Docker 用户提供了极大的便利。 Quay.io(https://quay.io/)是另一个公共托管Registry,提供与 Docker Hub 类似的服务。 6、容器 OS 由于有容器 runtime,几乎所有的 Linux、MAC OS 和 Windows 都可以运行容器。但这不并没有妨碍容器 OS 的问世。 容器 OS 是专门运行容器的操作系统。与常规 OS 相比,容器 OS 通常体积更小,启动更快。因为是为容器定制的 OS,通常它们运行容器的效率会更高。 目前已经存在不少容器 OS,CoreOS、atomic 和 ubuntu core 是其中的杰出代表。 二、说说容器 1、什么是容器 容器是一种轻量级、可移植、自包含的软件打包技术,使应用程序可以在几乎任何地方以相同的方式运行。开发人员在自己笔记本上创建并测试好的容器,无需任何修改就能够在生产系统的虚拟机、物理服务器或公有云主机上运行。 Containers vs. virtual machines 容器在 Host 操作系统的用户空间中运行,与操作系统的其他进程隔离。这一点显著区别于的虚拟机。 传统的虚拟化技术,比如 VMWare, KVM, Xen,目标是创建完整的虚拟机。为了运行应用,除了部署应用本身及其依赖(通常几十 MB),还得安装整个操作系统(几 GB)。 Virtual Machine diagramContainer diagram 由于所有的容器共享同一个 Host OS,这使得容器在体积上要比虚拟机小很多。另外,启动容器不需要启动整个操作系统,所以容器部署和启动速度更快,开销更小,也更容易迁移。 Containers and Virtual Machines Together 2、为什么使用容器 如今的系统在架构上较十年前已经变得非常复杂了。以前几乎所有的应用都采用三层架构(Presentation/Application/Data),系统部署到有限的几台物理服务器上(Web Server/Application Server/Database Server)。 而今天,开发人员通常使用多种服务(比如 MQ,Cache,DB)构建和组装应用,而且应用很可能会部署到不同的环境,比如虚拟服务器,私有云和公有云。 一方面应用包含多种服务,这些服务有自己所依赖的库和软件包;另一方面存在多种部署环境,服务在运行时可能需要动态迁移到不同的环境中。这就产生了一个问题: 如何让每种服务能够在所有的部署环境中顺利运行? 聪明的技术人员从传统的运输行业找到了答案。 几十年前,运输业面临着类似的问题。 每一次运输,货主与承运方都会担心因货物类型的不同而导致损失,比如几个铁桶错误地压在了一堆香蕉上。另一方面,运输过程中需要使用不同的交通工具也让整个过程痛苦不堪:货物先装上车运到码头,卸货,然后装上船,到岸后又卸下船,再装上火车,到达目的地,最后卸货。一半以上的时间花费在装、卸货上,而且搬上搬下还容易损坏货物。 幸运的是,集装箱的发明解决这个难题。 打一个比方,集装箱(容器)对于远洋运输(应用运行)来说十分重要。集装箱(容器)能保护货物(应用),让其不会相互碰撞(应用冲突)而损坏,也能保障当一些危险货物发生规模不大的爆炸(应用崩溃)时不会波及其它货物(应用)但是把货物(应用)装载在集装箱(容器)中并不是一件简单的事情。而出色的码头工人(Docker)的出现解决了这一问题。它(Docker)使得货物装载到集装箱(容器)这一过程变得轻而易举。对于远洋运输(应用运行)而言,用多艘小货轮(虚拟机)代替原来的大货轮(实体机)也能保证货物(应用)彼此之间的安全,但是和集装箱(容器)比,成本过高,但适合运输某些重要货物(应用)。 任何货物,无论钢琴还是保时捷,都被放到各自的集装箱中。集装箱在整个运输过程中都是密封的,只有到达最终目的地才被打开。标准集装箱可以被高效地装卸、重叠和长途运输。现代化的起重机可以自动在卡车、轮船和火车之间移动集装箱。集装箱被誉为运输业与世界贸易最重要的发明。 Docker 将集装箱思想运用到软件打包上,为代码提供了一个基于容器的标准化运输系统。Docker 可以将任何应用及其依赖打包成一个轻量级、可移植、自包含的容器。容器可以运行在几乎所有的操作系统上。 其实,“集装箱” 和 “容器” 对应的英文单词都是 “Container”。 “容器” 是国内约定俗成的叫法,可能是因为容器比集装箱更抽象,更适合软件领域的原故吧。 3、容器的优势 对于开发人员 容器意味着环境隔离和可重复性。开发人员只需为应用创建一次运行环境,然后打包成容器便可在其他机器上运行。另外,容器环境与所在的 Host 环境是隔离的,就像虚拟机一样,但更快更简单。 对于运维人员 只需要配置好标准的 runtime 环境,服务器就可以运行任何容器。这使得运维人员的工作变得更高效,一致和可重复。容器消除了开发、测试、生产环境的不一致性。 注:部分内容参照文章《每天五分钟玩转Docker容器技术》 本文转自 wzlinux 51CTO博客,原文链接:http://blog.51cto.com/wzlinux/2044331,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android学习笔记--Android开发时常用控件(三)

ProgressBar(进度条) ListView(很重要的显示控件) 例:<ProgressBarandroid:id="@+id/pBar" Style="?Android:attr/progressBarStyleHorizontal"--水平方向的进度条 Android:layout_width="200dp" Android:layout_height="wrap_content" Android:visibility="gone" Android:max=200 /> 代码:1.声明变量 2.根据ID取得控件对象findViewById 3.设置监听类 ClassButtonLinstenerimplementsOnClickListener{ PublicvoidonClick(Viewv){ If(i==0){ pBar.setVisibility(View.VISIBLE); } Elseif(i<pBar.getMax()){ pBar.setProgress(i);--设置主进度条的当前值 pBar.setSecondaryProgress(i+10);--设置第二进度条的当前值 } Else{ pBar.setVisbility(View.GONE); } I=i+10; } } 4.绑定事件 myButton.setOnClickListener(newButtonLinstener()); 例:main布局文件 <ListViewandroid:id="@id/android:list" Android:layout_width="fill_parent" Android:layout_height="wrap_content" Android:drawSelecrorOnTop="false" Android:scrollbars="vertical"/> User布局文件略(两个TextView) 代码:publicclassActivityextendsListActivity{ super.onCreate(savedInstanceState); setContentView(R.layout.main); //用一个集合对象装数据 ArrayList<HashMap<Stirng,String>>list=newArrayList<HashMap<Stirng,String>>(); HashMap<String,String>Map1=newHashMap<String,String>(); HashMap<String,String>Map2=newHashMap<String,String>(); HashMap<String,String>Map3=newHashMap<String,String>(); Map1.put("user_name","zhangsan"); Map1put("user_ip","192.168.0.1"); Map2.put("user_name","lisi"); Map2.put("user_ip","192.168.0.2"); Map3.put("user_name","wangwu"); Map3.put("user_ip","192.168.0.3"); List.add(Map1); List.add(Map2); List.add(Map3); //listActivity对象,map,第二个布局文件,对应hashMap的值对(可想象成列),控件显示的位置 SimpleAdapterlistAdapter=newSimpleAdapter(this,list,R.layout.user,newString[]{"user_name","user_ip"},newint[]{R.id.user_ip,R.id.user_name}); setListAdapter(listAdapter); } //重写 ProtectedvoidonListItemClick(ListViewlv,Viewv,intposition,longid){ super.onListItemClick(1,v,position,id); System.out.println("id--------"+id); System.out.println("position-------"+position) } 本文转自My_King1 51CTO博客,原文链接:http://blog.51cto.com/apprentice/1360573,如需转载请自行联系原作者

优秀的个人博客,低调大师

【iOS知识学习】_iOS动态改变TableView Cell高度

在做tableView的时候,我们有时候须要依据cell的高度动态来调整。近期在网上看到一段代码不错。跟大家Share一下。 在 -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{ 类中获取cell的高度: CGSize boundSize = CGSizeMake(216, CGFLOAT_MAX); cell.textLabel.text = @"12345678900123456789"; cell.userInteractionEnabled = NO; cell.textLabel.numberOfLines = 0; CGSize requiredSize = [cell.textLabel.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:boundSize lineBreakMode:UILineBreakModeWordWrap]; CGRect rect = cell.frame; rect.size.height = requiredSize.height+5; cell.frame = rect;这时候获取到了cell的高度,然后在 - (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath { 类中改变cell的高度: UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath]; NSLog(@"cell height %f",cell.frame.size.height); return cell.frame.size.height; 这样以来cell的高度就依据cell里label的内容自己主动改变啦。 其主要出发点就是我有一个label。然后我要把这个label展示出来。我依据字体的大小还有行数来获取一个高度,这样cell的高度就有啦。 本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5350356.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

openstack学习笔记六 多节点部署之keystone

keystone 对用户进行验证,每个组件必须得实用一个用户向keystone进行注册,只有成功了,那么这个组件才能正常工作。所以当我们在创建其他组件的时候,也包括keystone本身,都得为这个组件创建一个用户名和密码 keystone也必须知道这些组件到底在什么地方,比如在那台主机上。 User 住宾馆的人 Credentials 开启房间的钥匙 Authentication 宾馆为了拒绝不必要的人进出宾馆,专门设置的机制,只有拥有钥匙的人才能进出 Token 也是一种钥匙,有点特别 Tenant 宾馆 Service 宾馆可以提供的服务类别,比如,饮食类,娱乐类 Endpoint 具体的一种服务,比如吃烧烤,打羽毛球 Role VIP 等级,VIP越高,享有越高的权限 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [root@h1~] #sourcekeystonerc_admin [root@h1~(keystone_admin)] #keystoneendpoint-list +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ | id |region|publicurl|internalurl|adminurl|service_id| +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ |03bf88d48e2648149242a571684fbfce|RegionOne|http: //192 .168.1.201:9696|http: //192 .168.1.201:9696|http: //192 .168.1.201:9696|1100243c5a694bc5857218dd0543297b| |1b5ccdf306484fefadc63d1eeb20de5d|RegionOne|http: //127 .0.0.1:8774 /v3 |http: //127 .0.0.1:8774 /v3 |http: //127 .0.0.1:8774 /v3 |4bda82ded4db46f68428d4e00247c14c| |2408bc6cb5164053b86c0983fd39961a|RegionOne|http: //192 .168.1.201:8080 /v1/AUTH_ %(tenant_id)s|http: //192 .168.1.201:8080 /v1/AUTH_ %(tenant_id)s|http: //192 .168.1.201:8080|30c62c3c0797462a8bd4ff059a71296e| |432e655e85614a5eb69b7de5c5aacf34|RegionOne|http: //192 .168.1.201:8776 /v2/ %(tenant_id)s|http: //192 .168.1.201:8776 /v2/ %(tenant_id)s|http: //192 .168.1.201:8776 /v2/ %(tenant_id)s|5d60cb24769e403cb10bb70cb1077f2b| |4d5c1e505b30467c9966a5e5e93feef0|RegionOne|http: //192 .168.1.201:9292|http: //192 .168.1.201:9292|http: //192 .168.1.201:9292|87d30bb0dd8e44ccba00127f77831e9e| |8683d84884d74e7c8a73513260aec774|RegionOne|http: //192 .168.1.201:8080|http: //192 .168.1.201:8080|http: //192 .168.1.201:8080|e6ced100d94e4f3b86cccfc82e12b83a| |8fa0e177bac746f79e229f16954506fb|RegionOne|http: //192 .168.1.201:8776 /v1/ %(tenant_id)s|http: //192 .168.1.201:8776 /v1/ %(tenant_id)s|http: //192 .168.1.201:8776 /v1/ %(tenant_id)s|dc75a046272548db99e1cbbe93c2025c| |9006207b29a04700922ee55905a7f445|RegionOne|http: //192 .168.1.201:8774 /v2/ %(tenant_id)s|http: //192 .168.1.201:8774 /v2/ %(tenant_id)s|http: //192 .168.1.201:8774 /v2/ %(tenant_id)s|1c9e6e4d00824327bfe4e8e7175317e1| |a9ec253a705c4b3c9848b5bed32e9768|RegionOne|http: //192 .168.1.201:8773 /services/Cloud |http: //192 .168.1.201:8773 /services/Cloud |http: //192 .168.1.201:8773 /services/Admin |81bbcf83509a42e9a867914cde84e9d4| |bcab3bbc3281451494428315b24b0dba|RegionOne|http: //192 .168.1.201:8777|http: //192 .168.1.201:8777|http: //192 .168.1.201:8777|8f54fc4364de49efbeb72020bf2aa176| |e3d9a4fa64bd441ea3fe143b1d72b8a4|RegionOne|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:35357 /v2 .0|02ce8247c5924913a73422bcf5275c40| +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [root@h1~(keystone_admin)] #keystoneservice-list服务 +----------------------------------+------------+--------------+--------------------------------+ | id |name| type |description| +----------------------------------+------------+--------------+--------------------------------+ |8f54fc4364de49efbeb72020bf2aa176|ceilometer|metering|OpenstackMeteringService| |dc75a046272548db99e1cbbe93c2025c|cinder|volume|CinderService| |5d60cb24769e403cb10bb70cb1077f2b|cinderv2|volumev2|CinderServicev2| |87d30bb0dd8e44ccba00127f77831e9e|glance|image|OpenStackImageService| |02ce8247c5924913a73422bcf5275c40|keystone|identity|OpenStackIdentityService| |1100243c5a694bc5857218dd0543297b|neutron|network|NeutronNetworkingService| |1c9e6e4d00824327bfe4e8e7175317e1|nova|compute|OpenstackComputeService| |81bbcf83509a42e9a867914cde84e9d4|nova_ec2|ec2|EC2Service| |4bda82ded4db46f68428d4e00247c14c|novav3|computev3|OpenstackComputeServicev3| |30c62c3c0797462a8bd4ff059a71296e|swift|object-store|OpenstackObject-StoreService| |e6ced100d94e4f3b86cccfc82e12b83a|swift_s3|s3|OpenstackS3Service| +----------------------------------+------------+--------------+--------------------------------+ 1 2 3 4 5 6 7 8 9 [root@h1~(keystone_admin)] #keystonerole-list角色 +----------------------------------+---------------+ | id |name| +----------------------------------+---------------+ |7455105a501842e097e7825257eb5be4|ResellerAdmin| |5d2a5d2f80d442e09b9c3d514ded412e|SwiftOperator| |9fe2ff9ee4384b1894a90878d3e92bab|_member_| |794f590d02344bafb280f37ff29433ae|admin| +----------------------------------+---------------+ 1 2 3 4 5 6 7 8 [root@h1~(keystone_admin)] #keystonerole-create--nametest1 +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ | id |467d36315d9c4e529e9400c606f8d7a2| |name|test1| +----------+----------------------------------+ [root@h1~(keystone_admin)] #keystonerole-deletetest1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [root@h1~(keystone_admin)] #keystoneuser-list用户 +----------------------------------+------------+---------+----------------------+ | id |name|enabled|email| +----------------------------------+------------+---------+----------------------+ |1627cc3d61c04f9db9608e9703a01371|admin|True|root@localhost| |04247710cdf34914a7f5b315ab166731|ceilometer|True|ceilometer@localhost| |cb5e12e30a4a4c1dae57255c184b8b30|cinder|True|cinder@localhost| |632fb20205ea4c40988d7d65b2844ff6|glance|True|glance@localhost| |23c4fb48a5a247d68e50c6b74fb6f035|http|True|| |80069f5c8edc454b8038e7f116df4ff5|neutron|True|neutron@localhost| |adbcaaf58d09495988b57be8e82b4e6b|nova|True|nova@localhost| |4f488ff4859e4973afefea6e7872ed83|swift|True|swift@localhost| +----------------------------------+------------+---------+----------------------+ [root@h1~(keystone_admin)] #keystoneuser-create--namehequan--passhequan--emailhequan2011@sina.com +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ |email|hequan2011@sina.com| |enabled|True| | id |9d12907283b64b02a80f1e98074a9c84| |name|hequan| |username|hequan| +----------+----------------------------------+ 1 2 3 4 [root@h1~(keystone_admin)] #keystoneuser-gethequan##查看信息 [root@h1~(keystone_admin)] #keystoneuser-deletehequan [root@h1~(keystone_admin)] #keystoneuser-password-update--passhequan1hequan##密码更新 [root@h1~(keystone_admin)] #keystoneuser-role-add--userhequan--role_member_--tenant=http#划分角色和租户 1 2 3 4 5 6 7 8 [root@h1~(keystone_admin)] #keystonetenant-list租户 +----------------------------------+----------+---------+ | id |name|enabled| +----------------------------------+----------+---------+ |43986fb013804aa0a04ca277e4d0e69c|admin|True| |1af10fa8077e4b52b3427786bb15e968|http|True| |842da711a1b740ddbf006a9f0a7ee116|services|True| ##内置服务默认都属于services +----------------------------------+----------+---------+ 1 2 3 4 5 6 7 8 9 10 [root@h1~(keystone_admin)] #keystonetenant-create--name123###创建租户123 +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |description|| |enabled|True| | id |c2a2e3aadf614bb08b1fc943157b668e| |name|123| +-------------+----------------------------------+ [root@h1~(keystone_admin)] #keystonetenant-delete123 配置安装keystone 首先创建数据库 使用token登陆keystone 创建服务 endpoint 创建用户 关闭token登陆,使用admin登陆 基本环境 1 2 3 4 5 6 7 192.168.1.204h4.hequan.comh4 ##keystone systemctlstopNetworkManager systemctldisableNetworkManager [root@h4~] #yuminstallcentos-release-openstack-liberty 1 2 3 4 5 6 7 8 9 [root@h4~] #yuminstallopenstack-keystoneopenstack-utilsopenstack-selinux-y [root@h4~] #openstack-db--init--servicekeystone--rootpw123456--passwordkeystone keystonedefaultDBisnotmysql.Wouldyouliketoresettomysqlnow?(y /n ):y mysql-serverisnotinstalled.Wouldyouliketo install itnow?(y /n ):y mysqldisnotrunning.Wouldyouliketostartitnow?(y /n ):y VerifiedconnectivitytoMySQL. Creating 'keystone' database. Initializingthekeystonedatabase,pleasewait... Complete! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [root@h4~] #mysql-uroot-p123456 MariaDB[(none)]>showdatabases; [root@h4keystone] #opensslrand-hex10 73fa731f6fa567630fdd [root@h4keystone] #pwd /etc/keystone [root@h4keystone] #vimkeystone.conf admin_token=73fa731f6fa567630fdd rabbit_host=localhost rabbit_port=5672 rabbit_hosts=$rabbit_host:$rabbit_port rabbit_use_ssl= false rabbit_userid=guest rabbit_password=guest rabbit_login_method=AMQPLAIN rabbit_virtual_host=/ connection=mysql: //keystone :keystone@192.168.1.204 /keystone ###用到上面写的用户名和密码 启动服务 1 2 3 4 5 6 [root@h4keystone] #systemctllist-unit-files|grepkeyston openstack-keystone.servicedisabled [root@h4keystone] #systemctlstartopenstack-keystone.service [root@h4keystone] #systemctlenableopenstack-keystone.service 现在没有用户,只有token 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 cat keystone_token ##创建文件 export SERVICE_TOKEN=73fa731f6fa567630fdd export SERVICE_ENDPOINT=http: //192 .168.1.204:35357/v2.0 export PS1= '[\u@\h\W(keystone_token)]\$' source keystone_token ps aux| grep keystone keystone33431.51.632184468704?Ss20:100:05 /usr/bin/python2 /usr/bin/keystone-all netstat -lntup| grep 35357 tcp000.0.0.0:353570.0.0.0:*LISTEN3343 /python2 keystoneservice-list [root@h4~] #keystoneservice-create--namekeystone--typeidentity--description="keystone" +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |description|keystone| |enabled|True| | id |e0c6163cb7dd42098225f13a3fa4220e| |name|keystone| | type |identity| +-------------+----------------------------------+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [root@h4~] #keystoneendpoint-create--service-ide0c6163cb7dd42098225f13a3fa4220e--publicurl''--internalurl''--adminurl'' 可以找一个模板去抄 [root@h1~(keystone_admin)] #keystoneendpoint-list +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ | id |region|publicurl|internalurl|adminurl|service_id| +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ |e3d9a4fa64bd441ea3fe143b1d72b8a4|RegionOne|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:35357 /v2 .0|02ce8247c5924913a73422bcf5275c40| [root@h1~(keystone_admin)] #keystoneservice-list |02ce8247c5924913a73422bcf5275c40|keystone|identity|OpenStackIdentityService| [root@h4~] #keystoneendpoint-create--service-ide0c6163cb7dd42098225f13a3fa4220e--publicurl'http://192.168.1.201:5000/v2.0'--internalurl''--adminurl''--publicurl'http://192.168.1.204:5000/v2.0'--internalurl'http://192.168.1.204:5000/v2.0'--adminurl'http://192.168.1.204:35357/v2.0' +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |adminurl|http: //192 .168.1.204:35357 /v2 .0| | id |810e5faef22f44aebd17f55d1808e3c5| |internalurl|http: //192 .168.1.204:5000 /v2 .0| |publicurl|http: //192 .168.1.204:5000 /v2 .0| |region|regionOne| |service_id|e0c6163cb7dd42098225f13a3fa4220e| +-------------+----------------------------------+ 创建管理员 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root@h4~] #keystonetenant-create--nameadmin +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |description|| |enabled|True| | id |3a331dd90062458b8fcc259ce84be0e5| |name|admin| +-------------+----------------------------------+ [root@h4~] #keystonerole-create--nameadmin +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ | id |c63ed09a433144108a23a592632e2e08| |name|admin| +----------+----------------------------------+ [root@h4~] #keystoneuser-create--nameadmin--pass123456 +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ |email|| |enabled|True| | id |172b6a61991e4fbeafe9039688eb2afc| |name|admin| |username|admin| +----------+----------------------------------+ [root@h4~] #keystoneuser-role-add--useradmin--tenantadmin--roleadmin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [root@h4~] #cpkeystone_tokenkeystone_token_admin [root@h4~(keystone_admin)] #catkeystone_token_admin unset SERVICE_TOKEN unset SERVICE_ENDPOINT export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=123456 export OS_AUTH_URL=http: //192 .168.1.204:35357 /v2 .0 export PS1= '[\u@\h\W(keystone_admin)]\$' [root@h4~(keystone_admin)] #keystoneuser-list##可以看到就表示成功了 +----------------------------------+-------+---------+-------+ | id |name|enabled|email| +----------------------------------+-------+---------+-------+ |172b6a61991e4fbeafe9039688eb2afc|admin|True|| +----------------------------------+-------+---------+-------+ 关闭token验证 1 2 12 #admin_token=73fa731f6fa567630fdd 13 至此安装完成。 本文转自 295631788 51CTO博客,原文链接:http://blog.51cto.com/hequan/1796108,如需转载请自行联系原作者

优秀的个人博客,低调大师

Centos7.3 Docker安装部署学习记录1

一、Docker基础环境的安装 1. 环境说明 本机采用操作系统如下: CentOS-7.3-X86-64,内核3.10 x64位,docker 1.12.x版本。 建议采用CentOS7版本或ubuntu版本,本文采用CentOS7即CentOS-7-x86_64-DVD-1611.iso版本最小化安装。 Docker可以在虚拟机环境中运行进行使用测试。本文出自:http://koumm.blog.51cto.com/ 2. 主机网络 1)关闭firewalld防火墙和SELinux setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux systemctl disable firewalld systemctl stop firewalld docker是必须要防火墙功能模块的,个人目前用iptables systemctl disable iptables.service systemctl stop iptables.service 注意最小化需要补充安装的软件包: yum install vim net-tools iptables-config 2)配置hosts文件(主机名称) echo "192.168.1.90 docker1" >> /etc/hosts 3. 安装Docker软件包 1)可以直接安装包yum源 # yum install -y docker 2)配置docker开机自启动以及启动服务 # systemctl start docker.service # systemctl enable docker.service 3)查看docker服务器,表示docker已安装成功 查看版本:docker version 帮助信息:docker --help 概要信息:docker info 镜像查看:docker images 进程查看:docker ps -a 搜索镜像:docker search centos #搜索可用docker镜像 示例: 表示docker已安装成功。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 本文转自 koumm 51CTO博客,原文链接:http://blog.51cto.com/koumm/1936465 ,如需转载请自行联系原作者

优秀的个人博客,低调大师

CCNA学习笔记--路由器的基本配置

路由器简介 路由器能起到隔离广播域的作用,还能在不同网络间转发数据包。路由器实际上是一台特殊用途的计算机,和常见的PC 机一样,路由器有CPU、内存、BOOTROM。路由器没有键盘、硬盘、显示器;然而比起计算机,路由器多了NVRAM、FLASH 以及各种各样的接口。路由器各个部件的作用如下: (1) CPU:中央处理单元,和计算机一样,它是路由器的控制和运算部件。 (2) RAM/DRAM:内存,用于存储临时的运算结果,如:路由表、ARP 表、快速交换缓存、缓冲数据包、数据队列、当前配置。众所周知,RAM 中的数据在路由器断电后是会丢失的。 (3) FLASH:可擦除、可编程的ROM,用于存放路由器的IOS,FLASH 的可擦除特性允许我们更新、升级IOS 而不用更换路由器内部的芯片。路由器断电后,FLASH 的内容不会丢失。FLASH 容量较大时,就可以存放多个IOS 版本。 (4) NVRAM:非易失性RAM,用于存放路由器的配置文件,路由器断电后,NVRAM 中的内容仍然保持。 (5) ROM:只读存储器,存储了路由器的开机诊断程序、引导程序和特殊版本的IOS 软件 (用于诊断等有限用途),ROM 中软件升级时需要更换芯片。 (6) 接口(Interface):用于网络连接,路由器就是通过这些接口和不同的网络进行连接的 路由器的使用与IOS 基本命令 实验拓扑: 1:用户模式和特权模式的切换 Router> //“Router”是路由器的名字,而“>”代表是在用户模式 Router>enable //“enable”命令可以使路由器从用户模式进入到特权模式 Router# Router#disable //“disable”命令则相反,在特权模式下的提示符为“#” Router> 2、IOS 编辑命令与历史命令缓存大小 Router#show history //显示历史命令 Router#terminal editing //打开编辑功能,实际上这是默认的。用上下左右光标键试试移动光标, Router#terminal history size 50 //以上把缓存的历史命令数改为50,默认值为10 Router#terminal no editing //关闭terminal 的编辑功能 Router#terminal editing 3、基本IOS 命令 先连接到R1 路由器上: Router>enable Router#configure terminal Router(config)#hostname R1 //改变路由器的名称为“R1”,设置立即生效。 R1(config)#enable password cisco //改变了enable 的密码为“cisco”,这个密码是从用户模式进入到特权模式的密码。 R1(config)#interface g0/0 //进入到接口模式,这里是千兆以太网口(第0 个插槽的第0 个接口,编号从0 开始)。 R1(config-if)#ip address 10.1.1.1 255.255.255.0 //给以太接口配置一个IP 地址10.1.1.1,掩码为255.255.255.0 。 R1(config-if)#no shutdown //开启以太网口,因为默认时路由器的各个接口是关闭的。 R1(config-if)#exit //退回到上一级模式 R1(config)#interface s0/0/0 //进入到接口模式,这里是串行接口 R1(config-if)#ip address 10.12.12.1 255.255.255.0 //给串行接口配置一个IP 地址 R1(config-if)#no shutdown //开启接口 R1(config-if)#end(或【Ctrl+Z】) //结束配置直接回到特权模式下。 R1#copy running-config startup-config //把内存中的配置保存到NVRAM 中,路由器开机时会读取它。 Destination filename [startup-config]? Building configuration... [OK] 4、连接到R2 路由器上,进行以下操作: Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R2 R2(config)#enable password cisco R2(config)#interface g0/0 R2(config-if)#ip address 10.2.2.2 255.255.255.0 R2(config-if)#no shutdown R2(config-if)#exit R2(config)#interface s0/0/0 R2(config-if)#ip address 10.12.12.2 255.255.255.0 R2(config-if)#clock rate 128000 //R2 这一端是DCE,需要配置时钟 R2(config-if)#no shutdown R2(config-if)#end R2#copy running-config startup-config R2#ping 10.12.12.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.14.126, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms //从R2 ping R1 的串行接口,可以ping 通 本文转自1594cqb 51CTO博客,原文链接:http://blog.51cto.com/wolfchen/1088673,如需转载请自行联系原作者

优秀的个人博客,低调大师

android学习之-随机色的定义与获取

在学取色的时候代码写的想当然了,结果弄了半天颜色一直不变,仔细看后才发现问题,见代码 packagesucre.android; importandroid.app.Activity; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.Button; importandroid.widget.TextView; /** *通过定义一个color.xml,然后让字体随机变色,这里在取色的时候 *要注意一个问题,getResources().getColor(你定义的颜色)这样才 *能真正取到相应的颜色 *@authorqiaolei * */ publicclassEX03_13extendsActivity{ privateButtonbt; privateTextViewtv; privateint[]colors; privateintcolumn; /**Calledwhentheactivityisfirstcreated.*/ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); //定义一个颜色数组 colors=newint[]{R.color.red,R.color.blue,R.color.black,R.color.green, R.color.yellow,R.color.orange,R.color.brown}; column=0; bt=(Button)findViewById(R.id.mButton); tv=(TextView)findViewById(R.id.changColor); bt.setOnClickListener(newButton.OnClickListener(){ publicvoidonClick(Viewv){ if(column<colors.length){ System.out.println(colors[column]+":"+getResources().getColor(colors[column])); //tv.setTextColor(colors[column]); //tv.setTextColor(-65536); tv.setTextColor(getResources().getColor(colors[column])); column++; }else{ column=0; } } }); } } 注意到文中的 tv.setTextColor(colors[column]); 这行代码了吗?这样是取不到颜色的,为了验证通过 System.out.println(colors[column]+":"+getResources().getColor(colors[column])); 这行代码得到结果 看到了-65536才是真正的颜色的值,直接这样写 tv.setTextColor(-65536); 也是可以变色的,所以取色的时候要这样取 getResources().getColor(colors[column]) 本文转自sucre03 51CTO博客,原文链接:http://blog.51cto.com/sucre/743483,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android学习笔记--Android开发时常用控件(一)

MicrosoftInternetExplorer402DocumentNotSpecified7.8Normal0 TextView,Button,EditText,Menu 例,实现一个简单的计算器功能 实现过程一1.在第一个Activity中,声明4个控件(2个编辑框,1个文本域,1个按钮) 2.要为其中的两个空间设置显示的值(文本域和按钮) 3.创建一个监听器.监听按钮事件 4.将监听器对象绑定到按钮对象上 在布局的xml文件中添加控件例: <EditText Android:id="@+id/eText1" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> <TextView Android:id="@+id/tView" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> <EditText Android:id="@+id/eText2" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> <Button Android:id="@+id/bBtn" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> 在使用空间的Activity页面中取出控件 例:publicclassActivityextendsActivity{ PrivateEditTexteText1; PrivateEditTexteText2; PrivateTextViewtView; PriveteButtonbBtn; @override PublicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); //根据控件的ID来取得代表控件的对象 eText1=(EditText)findViewById(R.id.eText1); eText2=(EditText)findViewById(R.id.eText2); tView=(TextView)findViewById(R.id.tView); tView,setText("乘以"); bBtn=(Button)findViewById(R.id.bBtn); bBtn.setText("计算");//为button设置值 //或设置在res/strings.xml中设置 //例:<stringname="bBtnText">计算</string> //bBtn.setText(R.string.bBtnText); //将监听器对象绑定按钮对象上去 bBtn.setOnClickLinstrener(newCalculateListener()); } //内部类监听器 ClassCalculateListenerimplementsOnClickListener{ @Override PublicvoidonClick(Viewv){ //取得两个编辑框的值 StringeText1=eText1.getText().toString(); StringeText2=eText2.getText().toString(); //将两个值放入到Intent对象之中 Intentintent=newIntent(); //使用这个Intent对象启动下一个Activity intent.putExtra("one",eText1); intent.putExtra("two",eText2); intent.setClass(Activity.this,ResultActivity.class); Activity.this.startActivity(intent); } } } 实现过程第二步: 1.接受从Activity当中传递的值 2.计算两个值的积 3.将计算的结果显示在当前的Activity中 //在当前的Activity中的xml文件中添加一个文本域 <TextView Android:id="@+id/tViewResult" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> 在onCreate中执行语句(不再累赘) 关键代码://取到RestltView的对象 Intentintent=getIntent(); StringtText1=intnet.getStringExtra("one"); StringtText2=intnet.getStringExtra("two"); InttText1int=Integer.parseInt(tText1); InttText2int=Integer.parseInt(tText2); Intresult=tText1int*tText2int; RestltView.setText(result+""); Menu对象的实现 复写函数onCreateOptionMenu() PublicbooleanonCreateOptionMenu(Menumenu){ //第二个参数就是itemid Menu.add(0,1,1,R.string.exit); Menu.add(0,2,2,R.string.about); Returnsuper.onCreate } 继续实现menuitem的事件方法 //当用户点击菜单的某一选项时,会调用该方法 复写onOPtionsItemSelected(MenuItemitem); PublicbooleanonOPtionsItemSelected(MenuItemitem){ If(item.getItemId()==1){ Finish(); } Returnsuper.onOptionsItemSelected(MenuItemitem); } 本文转自My_King1 51CTO博客,原文链接:http://blog.51cto.com/apprentice/1360577,如需转载请自行联系原作者

优秀的个人博客,低调大师

【swift学习笔记】四.swift使用Alamofire和swiftyJson

Alamofire是AFNetworking的swift版本,功能灰常强大。 github:https://github.com/Alamofire/Alamofire SwiftyJSON是操作json的非常棒的开源库 github:https://github.com/SwiftyJSON/SwiftyJSON 接下来我做一个简单的入门小例子, 我使用cocoaPods来管理依赖,需要在Podfile里添加我们需要的两个库 source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! target 'AlamofireDemo' do pod 'Alamofire', '~> 3.4' pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git' end 在terminal里运行 cocoapods会为我们自动生成需要导入的第三方库的信息。 关闭工程打开cocoaPods为我们生成的工程文件,编辑通过后就能导入这两个库了 import Alamofire import SwiftyJSON 因为我们要访问网络,需要在info.plist里开放权限,加入下面的代码 <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> 接下来就可以用它Alamofire请求网络使用swiftyJson解析Json let currRequest = Alamofire.request(.POST, "http://www.yourweb.com", parameters: ["para1":"aaa", "para2":[0,1,2,3], "para3":NSNull()], encoding: .JSON, headers: ["Content-Type":"application/json"]) currRequest.responseJSON{(responseJson) -> Void in print(responseJson.response?.statusCode) print(responseJson.request) print(responseJson.response) print(responseJson.data) print(responseJson.result) switch responseJson.result { case .Success(let value): print("Value:\(value)") print("------") let swiftyJsonVar = JSON(value) print(swiftyJsonVar) case .Failure(let error): print(error) } } 好了这个简单的例子就写完了,还有一个更方便的方法就是用下边这个库,他是集成了上边说的两个库,有时间你可以玩一下 https://github.com/SwiftyJSON/Alamofire-SwiftyJSON 本文转自lpxxn博客园博客,原文链接:http://www.cnblogs.com/li-peng/p/5558551.html,如需转载请自行联系原作者

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码