首页 文章 精选 留言 我的

精选列表

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

openstack 调用API 实现云主机的IO 控制,CGroup 策略

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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 # vim: tabstop= 4 shiftwidth= 4 softtabstop= 4 # Copyright (c) 2011 X.commerce, a business unit of eBay Inc. # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License" ); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http: //www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # Single virtual machine io limit , reader 70 /MB , writer 50 /MB "" " curl -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "admin"}}}' -H "Content-type: application/json" http: //127.0.0.1:35357/v2.0/tokens | python -m json.tool curl -v -d '{"ioctlAction": {"instance_name":"instance-0000000c","limit_reader":"40MB","limit_writer":"60MB"}}' -i http: //127.0.0.1:8774/v2/ba5a6a86a8224a70ba0ffde747d8a724/servers/e6b9cae7-8732-405d-9aaf-575643b4bbef/action -X POST -H "X-Auth-Project-Id: ba5a6a86a8224a70ba0ffde747d8a724" -H "Accept: application/json" -H "X-Auth-Token: 6f0c37595f384fd4a18766825cf49013" -H "Content-Type: application/json" "" " import time,sys,os,libvirt, trace back,re,subprocess,json from nova import log as logging from nova import flags from nova.periodic.blkio import config from nova import utils from nova.periodic.blkio import utils as blkio_utils FLAGS = flags.FLAGS LOG = logging.getLogger(__name__) class ActionIoctl(object): def __init__(self,instance_name,limit_reader,limit_writer): self.conn = libvirt.open(None) self.limitReader = int (limit_reader[ 0 :- 2 ]) self.limitWriter = int (limit_writer[ 0 :- 2 ]) self.name = instance_name self.path = FLAGS.instances_path def diskDeviceNum(self,disk): "" " Func info: Returns the number of hard disk,other is 8:0 " "" if disk == '/dev/sda1' or disk == '/dev/hda1' or disk[:- 1 ] == '/dev/sda' or disk[:- 1 ] == '/dev/hda' : return '8:0' elif disk == '/dev/sdb1' or disk == '/dev/hdb1' or disk[:- 1 ] == '/dev/sdb' or disk[:- 1 ] == '/dev/hdb' : return '8:16' elif disk == '/dev/sdc1' or disk == '/dev/hdc1' or disk[:- 1 ] == '/dev/sdc' or disk[:- 1 ] == '/dev/hdc' : return '8:32' elif disk == '/dev/sdd1' or disk == '/dev/hdd1' or disk[:- 1 ] == '/dev/sdd' or disk[:- 1 ] == '/dev/hdd' : return '8:48' else : return '8:16' def vmsPIDall(self): "" " Getting all vm port, return to " "" pid = list() try : cmds = "" "ps -ef |grep uuid|grep -v grep |awk '{print $2}'" "" pid=os.popen(cmds).readlines() return pid except Exception,e: LOG.error(_( '[-william-] Error %s' %e)) return def cgroupPath(self): '' ' Func info : Return Cgroup path ,Because the system is not the same, the Cgroup path is different also. By default , have RedHat, Centos, Ubuntu linux ... osType : The current system version , And return to ... Cpath : Cgroup path '' ' osType = open( '/etc/issue' ).readlines() for i in osType: if re.match( 'Ubuntu' ,i): Cpath = '/sys/fs/cgroup/' return Cpath elif re.match( 'CentOS' ,i): Cpath = '/cgroup/' return Cpath elif re.match( 'Red Hat' ,i): Cpath = '/cgroup/' return Cpath else : return '/sys/fs/cgroup/' def exeCmd(self,cmds): '' ' Perform system command ' '' LOG.info(_( 'exeCmd %s' %cmds)) try : exec_process = subprocess.Popen(cmds, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) exec_process.wait() rest = exec_process.stdout.read() err = exec_process.stderr.read() if err == '' : return rest else : LOG.error(_( '[-william-] return values is null' )) except Exception,e: LOG.error(_( '[-william-] Error %s' ) %e) return '' ' Geting vmName name and pid ' '' def get_vm_pid(self,name): pid = self.conn.listDomainsID() try : pid = os.popen( "" "ps -ef |grep %s |grep -v grep |awk '{print $2}'" "" %name).readlines() return int (pid[ 0 ]) except: LOG.error(_( '[-william-] Error %s' \ % trace back.format_exc())) return def _vm_pids(self): try : return os.popen( 'pidof kvm' ).read().split() except: return def work(self): "" " Func info : working func ................ Cpath : is _Cpath function return values ... path : The current virtual machine IMG file path vm_count: All of the current node number of virtual machines size : Limit size mountInfo : mounting point "" " Cpath = self.cgroupPath() vm_pid = self.get_vm_pid(self.name) LOG.info(_( '[- william -] %s , %s' %(self.name,vm_pid))) r_size = self.limitReader * 1000 * 1000 w_size = self.limitWriter * 1000 * 1000 device = blkio_utils.instance_path(self.path) diskDeviceNum = self.diskDeviceNum(device) vmTaskPath = "%s/blkio/%s" %(Cpath,self.name) utils.execute( "mkdir" , "-p" ,vmTaskPath,run_as_root=True) utils.execute( "tee" , "%s/blkio.throttle.read_bps_device" %vmTaskPath,\ process_input = "%s %s" %(diskDeviceNum,r_size),\ run_as_root=True) utils.execute( "tee" , "%s/blkio.throttle.write_bps_device" %vmTaskPath, \ process_input = "%s %s" %(diskDeviceNum,w_size) ,\ run_as_root=True) LOG.info(_( "" " [-william-] echo '%s, %s, %s , %s , %s ' write oK " "" %(self.path , device, diskDeviceNum, w_size, r_size))) utils.execute( 'tee' , '%s/tasks' %vmTaskPath,\ process_input= str(vm_pid) ,\ run_as_root=True) LOG.info(_( '[- william-] append pid %s in task' %vm_pid)) if __name__ == "__main__" : sc = ActionIoctl( 'instance-0000000c' , '40MB' , '30MB' ) sc.work() 本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1412022

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

同一台 linux主机同时安装 lamp 和 lnmp

同一台 linux Server同时安装 lamp 和 lnmp: 共同点: 可以同时安装共存运行。 1. mysql公用,安装一次即可。 2. lnmp的php编译的时候,新建一个php-fpm目录(lamp已安装好的基础上),比如叫 /usr/local/php-fpm 3. 如果apache已经监听80,那么nginx就要监听8080 4.安装顺序:mysql→apache/ngnix→php 不同点: 1.lamp中php目录名:/usr/local/php 2.lnmp中php目录名:/usr/local/php-fpm 3.编译的参数不同 4.php.ini 是php的全局配置文件,比如我要配置时区,配置禁止函数。 php-fpm.conf 是php-fpm 专属的配置文件,比如配置运行服务的用户,配置启动参数等; php-fpm 就是一个启动二进制文件。 5.apache和nginx和php结合的模式不同,这两个架构中,php在编译的时候以一个模块的形式和apache成为了一个整体,php脚本的处理是通过apache来处理,实际上是apache的php 模块处理的,可以把php目录删除的,因为lamp中的php是作为apache的一个动态模块libphp5.so来调用的,唯一有影响的是如果指定了php的配置文件php.ini在php的目录下,如果删除后则配置文件失效; lnmp中的php启动了一个服务php-fpm,这种模式相当于nginx处理php脚本时,直接把请求转发给了php-fpm服务来处理,说白了就是一个代理。这个php的安装目录是不可以删除的。 这两种模式其实是可以共存的,编译配置的时候,把prefix=后面的目录改一下即可,不让它覆盖。 本文转自 boy461205160 51CTO博客,原文链接:http://blog.51cto.com/461205160/1734556

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

阿里云ECS云主机Ubuntu 16.04图形化过程

步骤一 首先参考:https://help.aliyun.com/knowledge_detail/41530.html (ubuntu的教程在下边) 按上面教程一路操作,直到这一步: 到这一步之后,下面的步骤可能就不适合了。 一下是我的方法 步骤二:修改配置文件 1.备份文件 cp~/.vnc/xstartup~/.vnc/xstartup.bak 2.修改修改vnc启动文件xstartup,文件位置:vi~/.vnc/xstartup 对与下载了FileZilla的同学,可以使用FileZilla操作 对与没有的同学,可以通过命令行完成。 具体修改步骤: 打开文件后,点击insert按钮,这时就可以输入了,在 “x-window-manager &” 前加 “#”,然后回车输入 “gnome-session &”,然后点击 “Esc ” 退出编辑模式,输入 “:wq!”保存修改即可) 把配置文件修改成下面: #!/bin/sh # Uncomment the following two lines for normal desktop: export XKL_XMODMAP_DISABLE=1 unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc unset DBUS_SESSION_BUS_ADDRESS gnome-panel & gnmoe-settings-daemon & metacity & nautilus & gnome-terminal & ps.建议把原来的代码注释掉(前面加"#"就是注释),然后把上面的代码粘贴上去 下面是我的配置文件,我使用Visual Studo Code来编辑 ps.window自带文本编辑器不太舒服. 步骤三:安装软件 $sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal 我并不知道这是什么软件,但是不安装的话vnc连接上就是灰屏 之前就是没安装这个,所以一直灰屏。 安装完后, vncserver -kill :1 杀死原来的vncserver vncserver :1 开启新的vncserver 最后连接,输入密码。 到此图形化完成。 欢迎留言,我会尽量回复。

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

如何远程连接阿里云主机服务器(Linux系统)

注意,请先到阿里云官网 领取幸运券,除了价格上有很多优惠外,还可以参与抽奖。详见:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=2a7uv47d&utm_source=2a7uv47d 安装SSH 此过程没有什么技术含量,默认安装就可以了。 成功安装后,桌面会出现这两个图标,“SSH Secure Shell Client”是“SSH安全Shell客户端”;“SSH Secure File Transfer Client”是“SSH的安全文件传输的客户端”。 SSH相关工具介绍: “SSH Secure Shell Client”是“SSH安全Shell客户端”,连接服务器后出现的是字符命令操作界面;“SSH Secure File Transfer Client”是“SSH的安全文件传输的客户端”,连接服务器后出现的是文件管理界面,如图示: 使用SSH连接服务器: 双击打开SSH,以“SSH Secure File Transfer Client”为例,其实两个界面的连接方式都是一样的,相当于CentOS6.5中的命令字符界面和可视化界面。 点击界面左上角的电脑标志,然后在弹出的对话框中输入服务器的IP地址(公网IP),和账号——然后点击右边的“connect”按钮——输入密码,点击OK,成功连接服务器。 服务器系统环境配置: 刚开始开通的服务器,都是需要配置服务器环境,安装一些必要的程序,那么久可以在“SSH Secure Shell Client”界面中通过字符命令来操作。例如,查看系统中是否已经安装Mysql数据库。 具体的环境配置跟在服务器本机操作是一样的。 服务器文件管理: 如果需要上传下载文件,可以使用“SSH Secure File Transfer Client”来操作,连接之后打开的界面跟ftp的差不多,操作方法也类似。 断开服务器连接: 点击界面左上角带有红色斜杠的电脑标志,在弹出的对话框中点击OK就可以断开服务器连接了。 步骤阅读

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

在宿主机查看docker使用cpu、内存、网络、io情况

使用命令 docker stats [OPTIONS] [CONTAINER...] docker stats命令返回一个用于运行容器的实时数据流。要将数据限制到一个或多个特定的容器,可以指定一个由空格分隔的容器名称或ID的列表。您也可以指定一个已停止的容器,但是停止的容器不返回任何数据 显示多个容器的运行信息 docker stats dockername1 dockername2 #容器名之间用空格隔开 扩展参数 OPTIONS 默认 说明 –all, -a false 显示所有容器(默认显示刚刚运行) –format 使用Go模板打印图像 –no-stream false 禁用流统计信息,仅拉取第一个结果 查看所有容器的运行状态 docker stats -a 我的官网 我的官网http://guan2ye.com 我的CSDN地址http://blog.csdn.net/chenjianandiyi 我的简书地址http://www.jianshu.com/u/9b5d1921ce34 我的githubhttps://github.com/javanan 我的码云地址https://gitee.com/jamen/ 阿里云优惠券https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=vf2b5zld&utm_source=vf2b5zld 阿里云教程系列网站http://aliyun.guan2ye.com 我的开源项目spring boot 搭建的一个企业级快速开发脚手架

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

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

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