
暂无个人介绍
samba 文件共享(共享文件夹) 完成了windows和linux的文件共享 配置SMB共享 Samba软件项目 用途:为客户机提供共享使用的文件夹 协议:SMB(TCP 139),CIFS(TCP 445) 所需软件包:samba 系统服务:smb 在RHCE7 中有这样一道题: 搭建基本的samba服务 通过 Samba 发布共享目录 在 system1 通过 SMB 共享/common 目录: 您的 SMB 服务器必须是 STAFF 工作组的一个成员 共享名必须为 common 只有 example.com 域内的客户端可以访问 common 共享 common 必须是可以浏览的 用户 harry 必须能够读取共享中的内容,如果需要的话,验证的密码是 migwhisk 1.安装samba软件包 [root@system1 ~]# yum -y install samba 2.创建samba的共享帐号 与系统用户名相同 但有独立密码 使用pdbedit管理工具 添加用户:pdbedit -a 用户名 查询用户:pdbedit -L [用户名] 删除用户:pdbedit -x 用户名 [root@system1 ~]# useradd -s /sbin/nologin harry#防止用户直接登陆操作系统 [root@system1 ~]# grep 'harry' /etc/passwd harry:x:1003:1004::/home/harry:/sbin/nologin [root@system1 ~]# pdbedit -a harry#添加Samba用户 [root@system1 ~]# pdbedit -L#查询所以Samba用户 harry:1003: 3.修改配置文件及参数 文件路径:/etc/samba/smb.conf [root@system1 ~]# vim /etc/samba/smb.conf ... workgroup = STAFF#89行 选改工作组 现在都不用了 ... [common]#321行 共享名 path = /common# 共享的实际路径 ... [root@system1 ~]# mkdir /common [root@system1 ~]# echo 'test' > /common/tset.txt 4.重启服务,并设置开机自启 [root@system1 ~]# systemctl restart smb [root@system1 ~]# systemctl enable smb.service 5.测试并访问 使用smbclient测试(一般直接挂载 不用装包) 所需软件包:samba-client 列出共享资源 smbclient -L 服务器地址 连接到共享文件夹 smbclient -U 用户名 //服务器地址/共享名 [root@system2 ~]# yum -y install samba-client.x86_64 [root@system2 ~]# smbclient -L //172.25.0.11 Enter root's password: Anonymous login successful Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1] Sharename Type Comment --------- ---- ------- common #共享名 Disk #共享类型 IPC$ IPC IPC Service (Samba Server Version 4.1.1) Anonymous login successful Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1] Server Comment --------- ------- Workgroup Master --------- ------- [root@system2 ~]# smbclient -U harry //172.25.0.11/common Enter harry's password: #这里输入密码 Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1] smb: \> ls NT_STATUS_ACCESS_DENIED listing \*#不能访问 6.SELinux: 布尔值(功能的开关) 具体关于SELinux的功能介绍 请看 : http://blog.51cto.com/13558754/2058355 getsebool 查看SELinux开关 setsebool 控制SELinux开关 需要加 -P 选项才能实现永久设置 (内存太小会死机) [root@system1 ~]# getsebool -a | grep samba 查看 samba_create_home_dirs --> off samba_domain_controller --> off samba_enable_home_dirs --> off samba_export_all_ro --> off #只读 samba_export_all_rw --> off# samba_portmapper --> off samba_run_unconfined --> off samba_share_fusefs --> off samba_share_nfs --> off sanlock_use_samba --> off use_samba_home_dirs --> off virt_sandbox_use_samba --> off virt_use_samba --> off [root@system1 ~]# setsebool -P samba_export_all_ro=on [root@system1 ~]# getsebool -a | grep samba_export_all_ro samba_export_all_ro --> on [root@system2 ~]# smbclient -U harry //172.25.0.11/common Enter harry's password: Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1] smb: \> ls#可以成功显示配置文件 . D 0 Mon Nov 6 10:43:17 2017 .. D 0 Mon Nov 6 10:42:56 2017 tset.txt N 5 Mon Nov 6 10:43:17 2017 40913 blocks of size 262144. 28492 blocks available 7.客户端访问点 安装软件包cifs-utils [root@system2 ~]# yum -y install cifs-utils.x86_64 修改/etc/fstab [root@system2 ~]# mkdir /mnt/samba/ [root@system2 ~]# vim /etc/fstab //172.25.0.11/common /mnt/samba cifs username=harry,password=123,_netdev 0 0 #_netdev 先启动网络 在完成挂载 验证 [root@system2 ~]# mount -a [root@system2 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/vda1 10G 3.1G 7.0G 31% / devtmpfs 906M 0 906M 0% /dev tmpfs 921M 80K 921M 1% /dev/shm tmpfs 921M 17M 904M 2% /run tmpfs 921M 0 921M 0% /sys/fs/cgroup //172.25.0.11/common 10G 3.1G 7.0G 31% /mnt/samba 在RHCE7中还有这样的一道题 配置多用户Samba挂载 在 system1 通过 SMB 共享目录/devops,并满足以下要求: 共享名为 devops 共享目录 devops 只能被 example.com 域中的客户端使用 共享目录 devops 必须可以被浏览 用户 kenji 必须能以读的方式访问此共享,该问密码是 atenorth 用户 chihiro 必须能以读写的方式访问此共享,访问密码是 atenorth 此共享永久挂载在 system2.example.com 上的/mnt/dev 目录,并使用用户 kenji 作为认证。任何用户可以通过用户 chihiro 来临时获取写的权限 为了方便理解 将这到题目分成两部分进行实验 1) chihiro 读写的方式访问此共享 1.创建samba的共享帐号 [root@system1 ~]# useradd -s /sbin/nologin kenji [root@system1 ~]# useradd -s /sbin/nologin chihiro [root@system1 ~]# pdbedit -a kenji [root@system1 ~]# pdbedit -a chihiro [root@system1 ~]# pdbedit -L#查询所以Samba用户 harry:1003: chihiro:1005: kenji:1004: 2.修改配置文件 [root@system1 ~]# vim /etc/samba/smb.conf ... [devops] path = /devops write list = chihiro ... [root@system1 ~]# mkdir /devops [root@system1 ~]# echo dasfasd > /devops/123.txt 3.重启smb服务 [root@system1 ~]# systemctl restart smb.service 4.客户端验证 [root@system2 ~]# smbclient -L //172.25.0.11 Enter root's password: Anonymous login successful Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1] Sharename Type Comment --------- ---- ------- common Disk devops Disk IPC$ IPC IPC Service (Samba Server Version 4.1.1) Anonymous login successful Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1] Server Comment --------- ------- Workgroup Master --------- ------- 5.客户端挂载 [root@system2 ~]# vim /etc/fstab ... //172.25.0.11/devops /mnt/dev cifs username=chihiro,password=atenorth,_netdev 0 0 ... [root@system2 ~]# mkdir /mnt/dev [root@system2 ~]# mount -a [root@system2 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/vda1 10G 3.1G 7.0G 31% / devtmpfs 906M 0 906M 0% /dev tmpfs 921M 80K 921M 1% /dev/shm tmpfs 921M 17M 904M 2% /run tmpfs 921M 0 921M 0% /sys/fs/cgroup //172.25.0.11/common 10G 3.1G 7.0G 31% /mnt/samba //172.25.0.11/devops 10G 3.1G 7.0G 31% /mnt/dev 实现读写操作 [root@system1 ~]# setfacl -m u:chihiro:rwx /devops/#开启目录本地权限 [root@system1 ~]# getfacl /devops/ getfacl: Removing leading '/' from absolute path names # file: devops/ # owner: root # group: root user::rwx user:chihiro:rwx group::r-x mask::rwx other::r-x [root@system1 ~]# setsebool samba_export_all_rw=on#开启SELinux samba 读写功能 [root@system1 ~]# getsebool -a | grep 'samba_export_all_rw' samba_export_all_rw --> on [root@system1 ~]# systemctl restart smb.service 2) multiuser 多用户访问 管理员只需要作一次挂载 客户端在访问挂载点时,若需要不同权限,可以临时切换为新的共享用户 multiuser ,提供对客户端多个用户身份的区分支持 sec=ntlmssp ,提供NT局域网管理安区支持 [root@system2 ~]# vim /etc/fstab //172.25.0.11/devops /mnt/dev cifs username=kenji,password=123,_netdev,multiuser,sec=ntlmssp 0 0 [root@system2 ~]# umount /mnt/dev/ [root@system2 ~]# mount -a [root@system2 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/vda1 10G 3.1G 7.0G 31% / devtmpfs 906M 0 906M 0% /dev tmpfs 921M 80K 921M 1% /dev/shm tmpfs 921M 17M 904M 2% /run tmpfs 921M 0 921M 0% /sys/fs/cgroup //172.25.0.11/common 10G 3.1G 7.0G 31% /mnt/samba //172.25.0.11/devops 10G 3.1G 7.0G 31% /mnt/dev [student@system2 /]$ cifscreds add -u chihiro 172.25.0.11 [student@system2 /]$ cd /mnt/dev/ [student@system2 dev]$ touch abc.txt [student@system2 dev]$ ls 123.txt abc.txt 扩展 在windows操作系统中如果想要使用samba 关闭防火墙 运行----> 输入\\172.25.0.11 ----->输入上面建立的用户名和密码-----> 进入 从而实现windows 和Linux 文件共享 本文转自 Xuenqlve 51CTO博客,原文链接:http://blog.51cto.com/13558754/2058701,如需转载请自行联系原作者
一、代码: [python] view plaincopy #!/usr/bin/env python # -*- coding: utf-8 -*- import cairo import pycha.pie import pycha.bar import pycha.scatter import pycha.stackedbar import pycha.line #设置画布 def set_charvalue(): width,height=600,600 surface=cairo.ImageSurface(cairo.FORMAT_ARGB32,width,height) return surface #画饼图 def draw_pie(surface, options, dataSet): chart=pycha.pie.PieChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\Pie.png') #垂直直方图 def draw_vertical_bar(surface, options, dataSet): chart=pycha.bar.VerticalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\vertical_bar.png') #垂直水平直方图 def draw_horizontal_bar(surface, options, dataSet): chart = pycha.bar.HorizontalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\horizontal_bar.png') #线图 def draw_line(surface, options, dataSet): chart = pycha.line.LineChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\line.png') #点图 def draw_scatterplot(surface, options, dataSet): chart = pycha.scatter.ScatterplotChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\scatterplotChart.png') #垂直块图 def draw_stackedverticalbarChar(surface, options, dataSet): chart = pycha.stackedbar.StackedVerticalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\stackedVerticalBarChart.png') #水平块图 def draw_stackedhorizontalbarChart(surface, options, dataSet): chart = pycha.stackedbar.StackedHorizontalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\stackedhorizontalbarChart.png') if __name__ == '__main__': ''''' Function:使用pycha画各种图表 Input:NONE Output: NONE author: socrates blog:http://blog.csdn.net/dyx1024 date:2012-02-28 ''' #数据来源 dataSet=( ('iphone',((0,1),(1,3),(2,2.5))), ('htc',((0,2),(1,4),(2,3))), ('hw',((0,5),(1,1,),(2,0.5))), ('zte',((0,3),(1,2,),(2,1.5))), ) #图像属性定义 options={ 'legend':{'hide':False}, 'title':'手机销售量分布图(by dyx1024)', 'titleColor':'#0000ff', 'titleFont':'字体', 'background':{'chartColor': '#ffffff'}, 'axis':{'labelColor':'#ff0000'}, } surface = set_charvalue() #根据需要调用不同函数画不同形状的图 #draw_pie(surface, options, dataSet) #draw_vertical_bar(surface, options, dataSet) #draw_horizontal_bar(surface, options, dataSet) #draw_scatterplot(surface, options, dataSet) #draw_stackedverticalbarChar(surface, options, dataSet) #draw_stackedhorizontalbarChart(surface, options, dataSet) draw_line(surface, options, dataSet) [python] view plaincopy #!/usr/bin/env python # -*- coding: utf-8 -*- import cairo import pycha.pie import pycha.bar import pycha.scatter import pycha.stackedbar import pycha.line #设置画布 def set_charvalue(): width,height=600,600 surface=cairo.ImageSurface(cairo.FORMAT_ARGB32,width,height) return surface #画饼图 def draw_pie(surface, options, dataSet): chart=pycha.pie.PieChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\Pie.png') #垂直直方图 def draw_vertical_bar(surface, options, dataSet): chart=pycha.bar.VerticalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\vertical_bar.png') #垂直水平直方图 def draw_horizontal_bar(surface, options, dataSet): chart = pycha.bar.HorizontalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\horizontal_bar.png') #线图 def draw_line(surface, options, dataSet): chart = pycha.line.LineChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\line.png') #点图 def draw_scatterplot(surface, options, dataSet): chart = pycha.scatter.ScatterplotChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\scatterplotChart.png') #垂直块图 def draw_stackedverticalbarChar(surface, options, dataSet): chart = pycha.stackedbar.StackedVerticalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\stackedVerticalBarChart.png') #水平块图 def draw_stackedhorizontalbarChart(surface, options, dataSet): chart = pycha.stackedbar.StackedHorizontalBarChart(surface,options) chart.addDataset(dataSet) chart.render() surface.write_to_png('d:\\stackedhorizontalbarChart.png') if __name__ == '__main__': ''''' Function:使用pycha画各种图表 Input:NONE Output: NONE author: socrates blog:http://blog.csdn.net/dyx1024 date:2012-02-28 ''' #数据来源 dataSet=( ('iphone',((0,1),(1,3),(2,2.5))), ('htc',((0,2),(1,4),(2,3))), ('hw',((0,5),(1,1,),(2,0.5))), ('zte',((0,3),(1,2,),(2,1.5))), ) #图像属性定义 options={ 'legend':{'hide':False}, 'title':'手机销售量分布图(by dyx1024)', 'titleColor':'#0000ff', 'titleFont':'字体', 'background':{'chartColor': '#ffffff'}, 'axis':{'labelColor':'#ff0000'}, } surface = set_charvalue() #根据需要调用不同函数画不同形状的图 #draw_pie(surface, options, dataSet) #draw_vertical_bar(surface, options, dataSet) #draw_horizontal_bar(surface, options, dataSet) #draw_scatterplot(surface, options, dataSet) #draw_stackedverticalbarChar(surface, options, dataSet) #draw_stackedhorizontalbarChart(surface, options, dataSet) draw_line(surface, options, dataSet) 二、测试: 1、函数draw_pie(surface, options, dataSet): 2、函数draw_vertical_bar(surface, options, dataSet): 3、函数draw_horizontal_bar(surface, options, dataSet): 4、函数draw_line(surface, options, dataSet): 5、函数draw_scatterplot(surface, options, dataSet): 6、函数draw_stackedverticalbarChar(surface, options, dataSet): 7、函数draw_stackedhorizontalbarChart(surface, options, dataSet): 本文转自 chengxuyonghu 51CTO博客,原文链接:http://blog.51cto.com/6226001001/1576046,如需转载请自行联系原作者
曾几何时软件定义的概念一时无两,超融合架构、无共享存储(Share Nothing Storage)的概念也是层出不穷;梦想总是要照进现实才有实际参考意义,这里拨开纷繁的软件定义存储选项,为大家揭示在即将到来的Windows Server 2016中软件定义存储的一个子集:借助存储空间直连技术可以让企业或者服务提供商借助工业标准的商业化服务器和本地存储构建高可靠,高可扩展性软件定义存储并激活私有云服务选项;如果您了解在之前Windows Server 2012/R2中激活的存储功能,可能知道可以通过SAS直连存储构建的SMB 3.0分布式文件服务器存储,并且通过这个服务上部署Hyper-V虚拟化环境的解决方案,这是一种松耦合结构的软件定义存储和计算的方法(如下图一); 但这种方式在国内并不多见,个人理解主要原因是对SAS共享存储硬件并且要求关闭存储的高级功能如RAID等限制。本文中介绍的在Windows Server 2016中提供的方式逻辑存储空间实际使用的是服务器本地的存储构建的分布式存储应用,这种方式不再有共享SAS存储的需求,完全可以利用本地SATA SSD/Flash闪存,NVMe低延迟PCIe闪存来提供更高的性能。那么结构也就有先前看到的图二,转化成了图三结构;部署,管理和监控仍然通过熟悉的System Center的SCVMM和SCOM或者PowerShell来实现。 其实构建存储空间直连模式的初衷就是用最高效的方式提供私有云存储,并且衍生出很多做法,包括: Hyper-V IaaS存储 作为备份和复制的存储目标 存储计算一体化的超融合架构 存储和计算分离的融合架构 以上架构,无论对于企业还是云供应商都可以加以使用构建。目前存储空间直连主要通过两种部署方式构建: 第一种就是私有云超融合结构,就是上述的存储空间和虚拟化层在同一台服务器上构建的结构。 第二种方法是融合结构,即存储计算非聚集模式,存储集群和计算集群(Hyper-V集群)分离。非聚集模式的好处是可以分别管理和扩充存储和计算单元,也可以有效防止过渡部署的情况出现。 注意这里涉及的架构之所以先进就是因为采用了无共享存储架构,因为这里引入的概念是利用每个服务器本机的本地物理存储而不是像Windows Server 2012 R2中采用所有存储服务器集群中共享的SAS物理存储构建;存储空间直连技术的魅力就在于通过池化所有网络连接的集群节点本地的存储设备,这些本地存储设备可以来自于不同的厂商和品牌;如前文所述,SAS共享存储对硬件有特殊的要求,并且物理连接和部署都需要人工介入,这种复杂程度远大于在网络共享环境中添加一个独立的物理服务器到集群环境中,如果构建的集群规模扩大复杂度也会成指数增长。当然,还有一个显而易见的好处,其实个人理解这也是融合架构的必经之路,我们需要一条足够宽速度足够快的跑道来并行起降我们的工作负载,这种结构我们采用的是SMB直连技术,如果您没有听说这个是在2年前微软提出的技术了,通过这个技术我们可以做到超高速在线迁移虚拟机等功能;这种技术的前提是我们需要在集群节点中激活带RDMA功能的网卡用户存储服务,RDMA的好处是可以提供一个高带宽延迟的网络,并且可以大幅度降低主机CPU的开销,就是我们说的这个"高速公路",有了这条宽带我们就有了部署融合架构的基础;SMB 3.0多通道技术也为了我们提供了更高的带宽聚合和更高的可用性,并且这是自适应的技术;也正是得以与这个通道我们才可以体验无共享式的存储服务。 最后在这里在脑补一个文件系统ReFS,在Windows Server 2016中默认针对所有存储相关服务均提供了ReFS文件系统,这个文件系统有N多超酷的功能,初了超强的稳定性以外,可以在其上构建集群卷及集群文件系统各方面对对大家熟知的NTFS文件系统都是大幅度的超越。这里举两个非常酷的例子,其一之前对于固定大小的虚拟机文件vhd/vhdx的写0操作我们希望快速创建的话通常需要通过offload(卸载)功能到硬件上,现在这个技术存储空间直连技术可以对Hyper-V通过ReFS文件系统无需特殊硬件就可以轻松秒建。此外你知道原来最容易出错也最耗费时间的虚拟机增量快照合并,通常需要无限次耗费IO的迭代拷贝合并,现在也可以指针位图合并轻松秒合。总而言之谁用谁知道:) 目前也有打包好的合作伙伴解决方案包括,思科,戴尔,富士通,惠普,因特尔和联想等,可以提供软硬一体化的存储空间直连技术来直接使用。 目前如果大家想尝鲜体验存储空间直连的威力,可直接下载Windows Server 2016 TP4 进行试用。关于部署和设置存储空间直连的方法可以参考这篇文章(英文的)。 本文转自 翟老猫 51CTO博客,原文链接:http://blog.51cto.com/3387405/1716500,如需转载请自行联系原作者
安装并配置以Cacti套件为主的各种工具包括AMP平台、SNMP数据采集工具、RRDTool工具、安装net-snmp软件包 安装依赖软件 AMP平台httpd、mysql、mysql-server、mysql-connector-odbc php、php-mysql、php-common、php-pdo SNMP数据采集工具 lm_sensors、net-snmp、net-snmp-utils RRDTool引擎 下载软件包:rrdtool-1.2.27.tar.gz 配置:./configure --prefix=/usr/local 编译安装: make && make install rrdtool的编译安装可能需要较长时间,建议另开一个终端进行编译 php-mysql软件包用于支持连接MySQL数据库 [root@localhost ~]# cd /var/www/html [root@localhost html]# tar zxvf /dlpkgs/cacti-0.8.7b-cn-utf8.tar.gz解压文件包至网页目录,并调整权限 [root@localhost html]# mv cacti-0.8.7b-cn-utf8 cacti [root@localhost html]# useradd cactiuser [root@localhost html]# chown -R cactiuser.cactiuser cacti/rra/ cacti/log [root@localhost html]# mysql -u root -p #建立监测数据库 mysql> create database cactidb default character set utf8; mysql> grant all on cactidb.* to cactiuser@localhost identified by '1234'; mysql> quit [root@localhost html]# mysql -u cactiuser -p cactidb < cacti/cacti.sql [root@localhost ~]# vi /var/www/html/cacti/include/config.php #修改cacti目录中的include/config.php配置文件 <?php $database_type = "mysql"; $database_default = "cactidb"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "1234"; $database_port = "3306"; $config['url_path'] = "/"; ?> [root@localhost ~]# vi /etc/httpd/conf/httpd.conf #调整httpd服务的配置 Listen 80 DocumentRoot "/var/www/html/cacti" <Directory "/var/www/html/cacti"> Options None AllowOverride None Order allow,deny Allow from all </Directory> DirectoryIndex index.php index.html AddDefaultCharset utf-8 #确认网页目录及字符集设置,然后重启httpd服务 确认httpd服务的字符集支持为” AddDefaultCharset utf-8“,否则有可能导致访问Cacti界面时网页显示为空白 1.登录Cacti管理平台(用户名及密码都是admin) 2.设置RRDtool工具的版本和中文字体路径 /usr/share/fonts/zh_CN/TrueType/zysong.ttf 3.添加被监测的设备或主机 指定被监测的主机地址等连接参数 指定需要监测的具体项目(CPU占用、内存使用等) 4.生成监测图像 根据设置的监测项目创建图像 将图像添加到监测树以方便查看 5.添加cron计划任务,以定期采集数据 以cactiuser用户身份采集数据 执行命令:php /var/www/html/cacti/poller.php 通过crontab设置每5分钟采集一次监测数据 6.查看图形化监测结果 按日、周、月、年等分别查看监测图像曲线 可以指定时间进行查询 本文转自 周小玉 51CTO博客,原文链接:http://blog.51cto.com/maguangjie/1869990,如需转载请自行联系原作者
yum install bind 出现GPG密钥失败 warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag 获取 GPG 密钥失败:[Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag 解决办法 1 rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt 本文转自 zouqingyun 51CTO博客,原文链接:http://blog.51cto.com/zouqingyun/1715956,如需转载请自行联系原作者
模板文件是在puppet模块下面templates目录中以”.erb”结尾的文件,puppet模板主要用于文件,例如各种服务的配置文件,相同的服务,不同的配置就可以考虑使用模板文件,例如Nginx和Apache的虚拟主机配置就可以考虑采用ERB模板,nginx的安装在这里建议用系统内部自带的YUM源来安装或其它第三方YUM源来安装,如果是用Nginx的官方源来安装nginx的话,我们可以查看下/etc/yum.repos.d/nginx.repo文件内容,如下所示: 1 2 3 4 5 [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1 第二种方式就是通过createrepo自建自己的YUM源,这种方式更加宁活,我们可以在nginx官网去下载适合自己的rpm包,然后添加进自己的YUM源,在自动化运维要求严格的定制环境中,绝大多数运维同学都会选择这种方法。大家通过此种方式安装nginx以后会发现,确实比源码安装Nginx方便多了,像自动分配了运行nginx的用户nginx:nginx,Nginx的日志存放会自动保存在/var/log/nginx下,其工作目录为/etc/nginx,这一点跟源码编译安装的nginx区别很大,请大家在实验过程也注意甄别。 像Puppet其它初级知识点我这里就略过了,我直接贴上文件内容,/etc/puppet的文件结构如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |-- auth.conf |-- fileserver.conf |-- manifests | |-- nodes | | |-- client.cn7788.com.pp | | `-- test.cn7788.com.pp | `-- site.pp |-- modules | `-- nginx | |-- files | |-- manifests | | `-- init.pp | `-- templates | |-- nginx.conf.erb | `-- nginx_vhost.conf.erb `-- puppet.conf site.pp的文件内容如下: 1 import "nodes/*.pp" client.cn7788.com.pp的文件内容如下所示: 1 2 3 4 5 6 7 node 'client.cn7788.com' { include nginx nginx::vhost {'client.cn7788.com': sitedomain => "client.cn7788.com" , rootdir => "client", } } test.cn7788.com.pp的文件内容如下所示: 1 2 3 4 5 6 7 node 'test.cn7788.com' { include nginx nginx::vhost {'test.cn7788.com': sitedomain => "test.cn7788.com" , rootdir => "test", } } /etc/puppet/modules/nginx/manifests/init.pp文件内容如下所示: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class nginx{ package{"nginx": ensure =>present, } service{"nginx": ensure =>running, require =>Package["nginx"], } file{"nginx.conf": ensure => present, mode => 644,owner => root,group => root, path => "/etc/nginx/nginx.conf", content=> template("nginx/nginx.conf.erb"), require=> Package["nginx"], } } define nginx::vhost($sitedomain,$rootdir) { file{ "/etc/nginx/conf.d/${sitedomain}.conf": content => template("nginx/nginx_vhost.conf.erb"), require => Package["nginx"], } } /etc/puppet/modules/nginx/templates/nginx.conf.erb文件内容如下所示: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 user nginx; worker_processes 8; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { use epoll; worker_connections 51200; } 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; } /etc/puppet/modules/nginx/templates/nginx_vhost.conf.erb文件内容如下所示: 1 2 3 4 5 6 7 8 9 server { listen 80; server_name <%= sitedomain %>; access_log /var/log/nginx/<%= sitedomain %>.access.log; location / { root /var/www/<%= rootdir %>; index index.php index.html index.htm; } } 最后我们可以在节点名为client.cn7788.com和test.cn7788.com的机器验证效果,命令如下所示: 1 puppetd --test --server server.cn7788.com 本文转自 抚琴煮酒 51CTO博客,原文链接:http://blog.51cto.com/yuhongchun/1569791,如需转载请自行联系原作者
串口命令行命令介绍 ac>system show (显示系统信息防火墙序列号、版本号) ac>interface show all (显示所有网络端口的ip) ac>interface set phy if fe3 ip 1.1.1.1 netmask 255.255.255.0 active on admin on ping on (设定fe3的ip为1.1.1.1/255.255.255.0 允许管理、ping) ac>admhost show (查看管理主机ip) ac>admhost add ip 192.168.0.1(添加一个地址为192.168.0.1的管理主机) ac>config save (保存防火墙配置) 指不了缺省路由只能用网关代替缺省路由 在配置映射规则后,还需要配置相应的包过滤规则才可以 当我们更改防火墙的网络接口的同时,要确认你已经添加了此接口网段的管理主机,否则你将无法管理防火墙。没有用的管理主机址尽量删除,因为管理主机的IP地址是做为管理防火墙的一个很重要的条件 在防火墙的内部程序中,有很多程序处理不了中文名字。所以在资源定义,导入导出,规则名称等地方尽量或不使用中文名字登陆防火墙后CPU利用率有时会变得很高,因为登陆时占用资源比较多,造成了瞬时CPU利用率增高 退出防火墙时点击界面上的“退出”按钮,不要直接关闭浏览器。按“退出”按钮,则防火墙可以判定这个会话结束了。如果直接关闭防火墙界面,会话就会一直保持到超时,所以登陆时会弹出超时界面. 本文转自 周小玉 51CTO博客,原文链接:http://blog.51cto.com/maguangjie/1877762,如需转载请自行联系原作者
一、使用以下的命令清理了空间: 1 2 1. cd /orabak 2. find . -type f -mtime +30 -exec rm -rf {} \; 二、然后开始使用rman备份的脚本进行备份,备份到最后出现以下报错 1 2 3 4 5 6 7 8 9 10 11 ------------------------------------------------------------------------------------------- archive log filename=/oralog/1_20800_812554797.dbf recid=20799 stamp=839154512 archive log filename=/oralog/1_20801_812554797.dbf recid=20800 stamp=839154513 released channel: ch1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of backup command on ch1 channel at 02/10/2014 10:33:46 ORA-19571: archived-log recid 19009 stamp 837863118 not found in control file ------------------------------------------------------------------------------------------- 三、分析及处理过程 1、当手工删除了归档日志以后,Rman备份会检测到日志缺失,从而无法进一步继续执行。 所以此时需要手工执行crosscheck过程,之后Rman备份可以恢复正常。 2、Crosscheck日志 1 2 3 $ rman target / RMAN> crosscheck archivelog all;#Oracle 9i及以后的版本用crosscheck archivelog all; RMAN> change archivelog all crosscheck; #Oracle 8i中用change archivelog all crosscheck; 3、再次运行备份脚本 1 2 3 4 5 6 7 -- archive log filename=/oralog/1_20887_812554797.dbf recid=20886 stamp=839198925 archive log filename=/oralog/1_20888_812554797.dbf recid=20887 stamp=839198982 archive log filename=/oralog/1_20889_812554797.dbf recid=20888 stamp=839199982 archive log filename=/oralog/1_20890_812554797.dbf recid=20889 stamp=839199982 Finished backup at 10-FEB-14 Starting backup at 10-FEB-14 channel ch1: starting full datafile backupset channel ch1: specifying datafile(s) in backupset including current control file in backupset channel ch1: starting piece 1 at 10-FEB-14 channel ch1: finished piece 1 at 10-FEB-14 piece handle=/orabak/control_11839200079688 tag=TAG20140210T230759 comment=NONE channel ch1: backup set complete, elapsed time: 00:00:01 Finished backup at 10-FEB-14 released channel: ch1 -- 完成 4、参考资料 http://www.eygle.com/archives/2004/12/rman_crosscheck.html 5、rman的备份脚本 1 2 3 4 5 6 7 8 9 10 11 run{ allocate channel ch1 device type DISK; backup full filesperset 50 database format'/orabak/full_%c_%p_%t_5s'; sql 'alter system archive log current'; backup filesperset 50 archivelog all format '/orabak/arch%c%p%t%s' delete input; backup current controlfile format '/orabak/control_%c%p%t%s'; release channel ch1; } 本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1891365,如需转载请自行联系原作者
为什么 Codis 比 twemproxy 慢? Codis 追求简洁的实现,我们没有针对内存进行优化,所以会比 twemproxy 还要多一倍拷贝。 Go 虽然使用 epoll,但是 IO 都不是直接完成的,而是通过 IO thread,所以需要更多的线程间通信和线程切换。 所以单 CPU 情况下, Codis 吞吐能到 twemproxy 的 1/2,redis 的 1/4,说明我的实现还是可以的。 Codis 是 Go 开发的,底层 IO 本质也是通过 epoll 实现的。Go 为开发带来了方便,但是所有的便利都是以牺牲性能作为代价的。 那需要 Codis 有什么用? 单 twemproxy:方便调整,性能不行 多 twemproxy:调整需要技巧,可能需要停止服,看具体业务需求,无论如何都很痛苦。 Codis? 适当的 CPU 就可以获得比 twemproxy 更好的性能和可靠性,同时具备横向扩展的能力 可动态调整。这一点就足够了。 对 redis 集群而言,CPU 和 内存,哪个更贵?而且通常 redis 集群 CPU 都是空闲的 如果你的业务需要 10G:没必要用 twemproxy 或者 Codis,影响心情,给自己添麻烦。 如果你的业务需要 400G:你可以选择 单/多 twemproxy + 多 redis,毕竟在相同吞吐下,twemproxy 比 codis 有更好地 CPU 利用率。 但是一旦你的业务需要迁移数据,比如机器上下线,容量调整,怎么办? 本文转自 抚琴煮酒 51CTO博客,原文链接:http://blog.51cto.com/yuhongchun/1900821,如需转载请自行联系原作者
组播使用的协议为PIM,有两种模式,一种为Dense-mode,一种为sparse-mode。使用 sparse-mode需要RP的存在。今天的这篇文档就是sparse-mode,实验的重点是rp的设置。 关键命令: 1.启用组播,作用为激活路由器组播转发功能 Router(config)#ip multicast-routing 2.在接口上是能Pim sparse-mode,使路由器用于组播转发的接口工作在稀疏模式 Router(config-if)#ip pim sparse-mode 3.在路由器上指定RP。组播源将组播转发到RP,由RP进行路径选择与转发;组播接受者向RP申请组播。 Router(config)#ip pim rp-address (ip#) [(acl#)] (ip#)用来指定RP的地址 (acl#)用来过滤组播组,作为源可以指定那些组播发往该RP;作为接受者可以设定那些组播从该RP接收。 这个实验是手动指定RP的,(注:在参与组播转发的每个路由器上进行设定。) 4.强制RP进行组播转发,禁止源转发。 Router(config-if)#ip the spt-threshold infinity 拓扑图 实验目的: 该网络的组播PIM设置为Sparse-mode,RP为10.1.1.1。所有组播强制由该RP转发。 具体配置: R1#sh run ! hostname R1 ! ip multicast-routing ! interface Serial0/0 ip address 192.168.1.1 255.255.255.252 ip pim sparse-mode serial restart-delay 0 ! interface Serial0/1 ip address 192.168.1.5 255.255.255.252 ip pim sparse-mode serial restart-delay 0 ! interface FastEthernet1/0 ip address 24.104.1.254 255.255.255.0 ip pim sparse-mode duplex auto speed auto ! router rip version 2 network 24.0.0.0 network 192.168.1.0 no auto-summary ! ip pim rp-address 10.1.1.1 ip pim spt-threshold infinity ! R2 ! ip multicast-routing ! interface Serial0/0 ip address 192.168.1.2 255.255.255.252 ip pim sparse-mode serial restart-delay 0 ! interface Serial0/1 ip address 192.168.1.9 255.255.255.252 ip pim sparse-mode serial restart-delay 0 ! interface FastEthernet1/0 ip address 24.104.2.254 255.255.255.0 ip pim sparse-mode duplex auto speed auto ! router rip version 2 network 24.0.0.0 network 192.168.1.0 no auto-summary ! ip pim rp-address 10.1.1.1 ip pim spt-threshold infinity R3 ip multicast-routing ! ! interface Loopback0 ip address 10.1.1.1 255.255.255.255 ip pim sparse-mode ! interface Serial0/0 ip address 192.168.1.6 255.255.255.252 ip pim sparse-mode serial restart-delay 0 ! interface Serial0/1 ip address 192.168.1.10 255.255.255.252 ip pim sparse-mode serial restart-delay 0 ! router rip version 2 network 10.0.0.0 network 192.168.1.0 no auto-summary ! ! ip pim rp-address 10.1.1.1 ip pim spt-threshold infinity ! 实验结果: R1 R1#sh ip mroute IP Multicast Routing Table Flags: D - Dense, S - Sparse, B - Bidir Group, s - SSM Group, C - Connected, L - Local, P - Pruned, R - RP-bit set, F - Register flag, T - SPT-bit set, J - Join SPT, M - MSDP created entry, X - Proxy Join Timer Running, A - Candidate for MSDP Advertisement, U - URD, I - Received Source Specific Host Report, Z - Multicast Tunnel, z - MDT-data group sender, Y - Joined MDT-data group, y - Sending to MDT-data group Outgoing interface flags: H - Hardware switched, A - Assert winner Timers: Uptime/Expires Interface state: Interface, Next-Hop or VCD, State/Mode (*, 239.255.255.250), 00:02:36/00:02:25, RP 10.1.1.1, flags: SC Incoming interface: Serial0/1, RPF nbr 192.168.1.6 Outgoing interface list: FastEthernet1/0, Forward/Sparse, 00:02:36/00:02:25 (*, 225.0.0.1), 00:22:16/stopped, RP 10.1.1.1, flags: SCF Incoming interface: Serial0/1, RPF nbr 192.168.1.6 Outgoing interface list: FastEthernet1/0, Forward/Sparse, 00:03:34/00:02:25 (24.104.1.2, 225.0.0.1), 00:22:16/00:03:25, flags: FT Incoming interface: FastEthernet1/0, RPF nbr 0.0.0.0 Outgoing interface list: Serial0/1, Forward/Sparse, 00:22:15/00:02:53 (*, 224.0.1.40), 00:22:16/00:02:25, RP 10.1.1.1, flags: SCL Incoming interface: Serial0/1, RPF nbr 192.168.1.6 Outgoing interface list: FastEthernet1/0, Forward/Sparse, 00:22:16/00:02:25 R2#sh ip mroute IP Multicast Routing Table Flags: D - Dense, S - Sparse, B - Bidir Group, s - SSM Group, C - Connected, L - Local, P - Pruned, R - RP-bit set, F - Register flag, T - SPT-bit set, J - Join SPT, M - MSDP created entry, X - Proxy Join Timer Running, A - Candidate for MSDP Advertisement, U - URD, I - Received Source Specific Host Report, Z - Multicast Tunnel, z - MDT-data group sender, Y - Joined MDT-data group, y - Sending to MDT-data group Outgoing interface flags: H - Hardware switched, A - Assert winner Timers: Uptime/Expires Interface state: Interface, Next-Hop or VCD, State/Mode (*, 239.255.255.250), 00:22:00/00:01:54, RP 10.1.1.1, flags: SC Incoming interface: Serial0/1, RPF nbr 192.168.1.10 Outgoing interface list: FastEthernet1/0, Forward/Sparse, 00:22:00/00:01:54 (*, 225.0.0.1), 00:22:39/00:02:59, RP 10.1.1.1, flags: SC //R2不需要知道具体的源,只需要知道从哪个RP获取该组播 Incoming interface: Serial0/1, RPF nbr 192.168.1.10 Outgoing interface list: FastEthernet1/0, Forward/Sparse, 00:22:39/00:02:56 (*, 224.0.1.40), 00:22:39/stopped, RP 10.1.1.1, flags: SPCL Incoming interface: Serial0/1, RPF nbr 192.168.1.10 Outgoing interface list: Null R3#sh ip mroute IP Multicast Routing Table Flags: D - Dense, S - Sparse, B - Bidir Group, s - SSM Group, C - Connected, L - Local, P - Pruned, R - RP-bit set, F - Register flag, T - SPT-bit set, J - Join SPT, M - MSDP created entry, X - Proxy Join Timer Running, A - Candidate for MSDP Advertisement, U - URD, I - Received Source Specific Host Report, Z - Multicast Tunnel, z - MDT-data group sender, Y - Joined MDT-data group, y - Sending to MDT-data group Outgoing interface flags: H - Hardware switched, A - Assert winner Timers: Uptime/Expires Interface state: Interface, Next-Hop or VCD, State/Mode (*, 239.255.255.250), 00:22:26/00:03:04, RP 10.1.1.1, flags: S Incoming interface: Null, RPF nbr 0.0.0.0 Outgoing interface list: Serial0/0, Forward/Sparse, 00:03:23/00:03:04 Serial0/1, Forward/Sparse, 00:22:19/00:02:50 (*, 225.0.0.1), 00:23:03/00:03:16, RP 10.1.1.1, flags: S Incoming interface: Null, RPF nbr 0.0.0.0 Outgoing interface list: Serial0/0, Forward/Sparse, 00:04:21/00:03:16 Serial0/1, Forward/Sparse, 00:23:01/00:03:13 (24.104.1.2, 225.0.0.1), 00:23:03/00:03:23, flags: T Incoming interface: Serial0/0, RPF nbr 192.168.1.5 Outgoing interface list: Serial0/1, Forward/Sparse, 00:23:01/00:03:13 (*, 224.0.1.40), 00:23:08/00:03:15, RP 10.1.1.1, flags: SJCL Incoming interface: Null, RPF nbr 0.0.0.0 Outgoing interface list: Serial0/1, Forward/Sparse, 00:23:00/00:03:09 Serial0/0, Forward/Sparse, 00:23:09/00:03:14 R1#sh ip pim neighbor PIM Neighbor Table Mode: B - Bidir Capable, DR - Designated Router, N - Default DR Priority, S - State Refresh Capable Neighbor Interface Uptime/Expires Ver DR Address Prio/Mode 192.168.1.2 Serial0/0 00:31:35/00:01:41 v2 1 / S 192.168.1.6 Serial0/1 00:31:41/00:01:33 v2 1 / S R1#sh ip pim rp Group: 239.255.255.250, RP: 10.1.1.1, v2, uptime 00:04:35, expires never Group: 225.0.0.1, RP: 10.1.1.1, v2, uptime 00:24:15, expires never Group: 224.0.1.40, RP: 10.1.1.1, v2, uptime 00:24:15, expires never R2#sh ip pim rp Group: 239.255.255.250, RP: 10.1.1.1, uptime 00:24:15, expires never Group: 225.0.0.1, RP: 10.1.1.1, uptime 00:24:54, expires never Group: 224.0.1.40, RP: 10.1.1.1, uptime 00:24:54, expires never R3#sh ip pim rp Group: 239.255.255.250, RP: 10.1.1.1, next RP-reachable in 00:00:51 Group: 225.0.0.1, RP: 10.1.1.1, next RP-reachable in 00:00:14 Group: 224.0.1.40, RP: 10.1.1.1, next RP-reachable in 00:00:0 本文转自 tiger506 51CTO博客,原文链接:http://blog.51cto.com/tiger506/396787,如需转载请自行联系原作者
关于NET130转载中署名错误一事,已解决。昨天刚发过邮件,今天就收到了回复,相关的四篇文章全都做了更正,这样的高效还是值得赞赏的。毕竟这样才可以安心地写一些东西出来。 [url]http://www.net130.com/CMS/Pub/cert1/cert_ccna1/cert_ccna_qt/2007_08_25_74061.htm[/url] [url]http://www.net130.com/CMS/Pub/special/special_route/2007_08_25_47980.htm[/url] 本文转自 ciscodocu51CTO博客,原文链接:http://blog.51cto.com/ciscodocu/52743,如需转载请自行联系原作者
如何从我自己的应用中启动App Store?同时如何链接到商店中我自己的应用? -[UIApplication openURL:] 可以处理传入的链接到应用和媒体NSURL 对象,启动对应的商店应用。根据以下步骤获取链接,可以是应用,歌曲,itunes中的专辑,同时链接它到你的iPhone应用。 在电脑中启动iTunes 搜索你要添加的项目 右击或者control点击在iTunes中的项目名称在弹出菜单中循选择"Copy iTunes Store URL" 使用-[UIApplication openURL:] 打开修改的URL字符串和NSURL 对象。 注意:你也可以使用iTunes Link Maker 工具来获取应用歌曲或者保存在iTuns中的专辑的链接。参见iTunes Link Maker FAQ了解更多关于工具的信息。 下面是从原生应用中启动App Store的例子。 NSString *iTunesLink = @http://itunes.apple.com/us/app/id284417350?mt=8; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]]; 有一些iTunes链接,包括iTunes相关链接,在链接到对应的应用程序前会返回多个重定向。你可以使用NSURLConnection静默的处理这些重定向,并在重定向完成时打开最终的URL。这能够让你的应用支持直接转换到商店而无需启动Safari。下面是展示如何完成这个动作。 注意:如果你的iTunes链接时在UIWebView中你可以使用这个方法在-[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] 委托方法中拦截链接。 在iPhone中处理iTunes相关的链接 // Process a LinkShare/TradeDoubler/DGM URL to something iPhone can handle - (void)openReferralURL:(NSURL *)referralURL { NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithreferralURL] delegate:self startImmediately:YES]; [con release]; } // Save the most recent URL in case multiple redirects occur // "iTunesURL" is an NSURL property in your class declaration - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response { self.iTunesURL = [response URL]; if( [self.iTunesURL.host hasSuffix:@"itunes.apple.com"]) { [connection cancel]; [self connectionDidFinishLoading:connection]; return nil; } else { return request; } } // No more redirects; use the last URL saved - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [[UIApplication sharedApplication] openself.iTunesURL];< /pre> } 本文转自 arthurchen 51CTO博客,原文链接:http://blog.51cto.com/arthurchen/1103201,如需转载请自行联系原作者
2.3 共性问题 2.31 虚拟客户脚本“Run-time Setting”中的线程和进程运行方式的区别? 如果选择“Run Vuser as a process”,则场景运行时会为每一个虚拟用户创建一个进程;选择“Run Vuser as a thread”则将每个虚拟用户作为一个线程来运行,在任务管理器中只看到一个mmdrv.exe,这种方式的运行效率更高,能造成更大的压力,时默认选 项。 另外,如果启用了IP欺骗功能,则先在Controller中选中Tools菜单下的“Expert Mode”,然后将Tools菜单下的“Options>General”标签页中的IP地址分配方式也设置为与Vuser运行方式一致,同为线程或进程方式。 2.32 thinktime与pacing的设置对脚本及场景的影响 在我测试的过程中在稳定性测试场景中有一次我对场景中的一个脚本取消了pacing设置,结果导致VU退出,出现了内存冲突的错误。 在我们测试中BancsLink_C63601_C63603_短信功能定制和删除、 BancsLink_C60422_C60423_活期与定期批次转出关联、BancsLink_C67050_C67000_修改客户信息提示等交易,不加thinktime时也会报错。 首先我们要明确设置他们的意义。 Pacing是通过设置两次迭代之间的间隔时间,来调整各个action之间的步调。从定义上来看,它是和iteration绑定在一起的。Pacing的设置可以调节系统压力的大小,影响系统处理事务的能力。在场景运行中pacing的设置是很重要的。 Think time是通过设置思考时间,来模拟真实用户在操作过程中的等待时间。从定义上来看,它是在iteration内部的某个action中各个步骤的间隔时间,主要目的在于模拟真实用户操作情况,在测试中使虚拟用户对业务的操作更接近实际。 示例:假设用户进行一次操作会消耗5秒钟的时间,即完成整个迭代需要5秒钟。如果用户不停顿,继续第二次重复操作,则同样耗费约5秒左右的时间。但是真实世 界中肯定是有停顿的。一个真正的用户,做完一系列操作后,会间隔一段时间。假定用户停顿了5秒,再第二次重复操作,则一共耗费10秒钟时间。映射到 loadrunner中,就需要在一次iteration中,设置一个thinktime = 1秒,然后在两个iteration之间,设置一个pacing为5秒。 2.33 在运行场景中两个vu并发时交易出现错误,在脚本中没有出现这种情况。 查看日志发现两vu所使用的参数值是一样的,所以在接收报文时VU不能对应的找到自己的接收报文。 解决办法 1、在场景中修改VU家在策略,有一次全部加载改为逐步加载。 2、改变取参策略,把数据分块,然后分到固定的VU。 2.34 题描述Deleted the current transaction ... since response time is not accurate 出现这个问题时TPS大幅下降,VU并没有掉。这个问题不多遇见,在调试稳定性测试场景中遇到几次。一般出现在压力机器上发生ping值为负数时,可以重新启动pc机或者打补丁,如果还不行把场景另存. 2.35 日志缓存过小:to Log cache is too small to contain the message. 由于场景中Auto Log cache默认设置为1k,但是遇到报文较长的交易时自动日志缓存的容量就太小了我们就得手动修改。 2.36 运行中掉VU。 1、出现Action.c(35): Error : save param parameter is invalid. Error code : 9005. Error -- memory violation : Exception ACCESS_VIOLATION received. 内存冲突的问题很普遍,有些程序设置之间的冲突也会导致这个错误,就脚本里来讲,HTTP录制的脚本里面关联错误会导致内存冲突;在socket协议的脚本里判断成功时我们一般采用字母、数字与存储在缓冲区里的报文做匹配,但是我们存在缓冲区里面的报文是二进制格式的,所以在场景中也会造成内存冲突,最后掉VU。可能一个很小的问题就会引起内存冲突。 2、内存资源不足:脚本中的事务执行后没有释放buffer,最好在每个事务结束后就释放buffer。 3、压力过大:压力过大导致本地存储收回报文的存储空间不足,写不了日志也会掉VU 4、参数取值不正确也可能导致掉VU 5、系统自身原因。 总体来说,解决方法就是调整脚本、分成多台压力机进行测试。 2.37 为什么Windows系统中的CPU、内存等资源仍然充足,但是模拟的用户数量却上不去? 在Windows计算机的标准设置下,操作系统的默认限制只能使用几百个Vuser,这个限制与CPU或内存无关,主要是操作系统本身规定了默认的最大线程数所导致。要想突破Windows这个限制,须修改Windows注册表。以Windows XP Professional为例。 (1)打开注册表后,进入注册表项HKEY_LOCAL_MACHINE中的下列关键字:System\CurrentControlSet\Control\Session Manager\SubSystems。 (2)找到Windows关键字,Windows关键字如下所示: %SystemRoot%\system32\csrss.exe bjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16 SharedSection=1024,3072,512关键字的格式为xxxx,yyyy,zzz。其中,xxxx定义了系统范围堆的最大值(以KB为单位),yyyy定义每个桌面堆得大小。 (3)将yyyy的设置从3072更改为8192(即8MB),增加SharedSection参数值。 通过对注册表的更改,系统将允许运行更多的线程,因而可以在计算机上运行更多的Vuser。这意味着能够模拟的最大并发用户数量将不受Windows操作系统的限制,而只受硬件和内部可伸缩性限制的约束。 2.38 问题描述open many files 问题一般都在压力较大的时候出现,由于服务器或者应用中间件本身对于打开的文件数有最大值限制造成,解决办法: 1、修改操作系统的文件数限制,aix下面修改limits下的nofiles限制条件,增大或者设置为没有限制,尽量对涉及到的服务器都作修改。 2、方法一解决不了情况下再去查看应用服务器weblogic的commonEnv.sh文件,修改其中的nofiles文件max-nofiles数增大,应该就可以通过了,具体就是查找到nofiles方法,修改其中else条件的执行体,把文件打开数调大。修改前记住备份此文件,防止修改出错。 3、linux上可以通过ulimit –HSn 4096来修改文件打开数限制,也可以通过ulimit -a 来查看。 4、linux上可以通过lsof -p pid | wc -l 来查看进程打开的句柄数。 2.38 LoadRunner与服务器连接时遇到的问题 (1)ERROR:sck connect Aborted 这种错误一般是软件造成连接中断。由于软件错误,造成一个已经建立的连接被取消,比如LoadRunner自身的bug,在发报文时多位。典型情况下,这意味着连接是由于协议或超时错误而被取消的。 (2)ERROR:Failed to connect to server 这个问题一般是客户端链接到服务失败,原因有两个客户端连接限制(也就是压力负载机器),一个网络延迟严重,解决办法: 1、 修改负载机器的tcpdelaytime注册表键值,将其改小改小; 2、 检查网络延迟情况,看问题出在什么环节; 为了减少这种情况,最好测试中有个干净的网络环境,每个负载机器的压力测试用户数不易过大,尽量平均每台负载器的用户数,这样以上问题出现的概率就会减小。 (3)ERROR:has shut down the connection prematurely 分为以下三种情况: 1.应用访问死掉 小用户时:程序上的问题或数据库的问题 ,应该查看一下sql执行效率和JAV的垃圾回收情况,具体定位问题。 2.应用服务没有死 应用服务参数设置问题 例如: 在许多客户端连接Weblogic应用服务大部分被拒绝,而在服务器端没有错误显示,则有可能是Weblogic中的server元素的AcceptBacklog属性值设得过低。如果连接时收到connection refused消息,说明应提高该值,每次增加25%。 Java连接池的大小设置,或JVM的设置等 3. 数据库的连接 在应用服务的性能参数可能太小了 数据库启动的最大连接数(跟硬件的内存有关) (4)ERROR: connection refused. 这种情况比较复杂,需要检查几个地方,不同的操作系统也会有不同的操作方式。 1.首先检查是不是连接weblogic服务大部分被拒绝,监控weblogic的连接等待情况,可能与上面的一样需要增加AcceptBacklog,如果没有解决问题,还要增加增加连接池,调整线程数,(连接池数*Statement Cache Size)的值应该小于数据库连接数的最大值。 2.查看服务器的操作系统中是否对连接数做了限制,AIX下可以直接编辑limit文件,修改连接数、端口数的限制以及tcp连接等待时间的间隔大小。若是windows系统,则要修改其注册表,修改TcpTimeWaitDelay(默认值30s)和MaxUserPort(可以调到小于最大值)项,键值在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Tcpip\Parameters\。因为当负载生成器的性能很好时,发数据包特别快,服务器响应也很快,从而导致负载生成器的端口在没有timeout之前就占满了。端口没有可用的时候就会出现错误,。执行netstat-na命令,可以查看端口。如果调整了TCP的timeout,情况会好点,在端口还没有占满前就有释放的了。 本文转自 小强测试帮 51CTO博客,原文链接:http://blog.51cto.com/xqtesting/2071012,如需转载请自行联系原作者
环境 CentOS 6 x64 服务端:puppet.test.org 客户端:apache01.test.org 服务端和客户端统一使用官方源,即目前的puppet 2.7版本 rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-5.noarch.rpm 客户端安装 # yum install puppet 设置固定IP,主机名为apache01.test.org,并在host文件中解析 编辑/etc/sysconfig/puppet,去掉两行注释,内容如下 PUPPET_SERVER=puppet.test.org PUPPET_PORT=8140 在/etc/puppet/puppet.conf 的【main】部分加上如下内容 server = puppet.test.org (鉴于不断爆发的人品,我加上了上面的内容来指定服务端。有些童鞋没加也能测试成功。) 服务端 设置固定IP,主机名为puppet.test.org,并在hosts文件中解析 安装服务端 #yum install puppet-server 编辑/etc/puppet/puppet.conf,添加如下内容 [master] autosign = true masterport = 8140 新建文件/etc/puppet/autosign.conf,内容如下 *.test.org autosign会有一些安全问题,在起初大规模部署时比较省力,部署后应该弃用。之后添加的个别的机器用puppet cert -s xxx来手动认证。 namespaceauth.conf文件,并根据情况修改,这里是“allow *.test.org” #cp /usr/share/doc/puppet-2.7.18/examples/etc/puppet/namespaceauth.conf /etc/puppet 建立一个简单的测试任务,创建文件/etc/puppet/manifests/site.pp,内容如下 file { "/etc/sudoers": owner => root, group => root, mode => 400, } 启动服务 chkconfig puppetmaster on /etc/init.d/puppetmaster start 关闭防火墙或者打开8140端口 测试结果 [root@apache01 ~]# puppet agent --test info: Creating a new SSL key for apache01.test.org info: Caching certificate for ca info: Creating a new SSL certificate request for apache01.test.org info: Certificate Request fingerprint (md5): 48:6F:F0:37:91:87:44:17:D9:94:5F:38:06:E0:3B:28 info: Caching certificate for apache01.test.org info: Caching certificate_revocation_list for ca info: Caching catalog for apache01.test.org info: Applying configuration version '1342493716' notice: /File[/etc/sudoers]/mode: mode changed '0440' to '0400' info: Creating state file /var/lib/puppet/state/state.yaml notice: Finished catalog run in 0.02 seconds 测试成功! 说明一下,保持时间一致是一个重要前提,建议使用ntp,最好是内网的ntp服务器。 puppet的文件服务 puppet经常需要做文件服务,目前只支持puppet自有的协议,即puppet:// 使用方法,依然以sudoers为例 file { "/etc/sudoers": owner => root, group => root, mode => 400, source => "puppet:///files/sudoers", } 客户端会定期检查sudoers的md5,如果发生变更,则用服务器上的文件覆盖本地文件。 puppet的文件服务很像rsync,都是用[方括号]表示一个类,然后export出去 fileserver.conf 默认全是注释,添加下面的内容 [files] path /etc/puppet/files alllow 192.168.1.0/24 邮件报告(可选) 每次客户端执行完任务会报告给服务端,服务端可以将报告通过邮件发给指定的地址 在服务端配置puppet.conf [master] reports = store,tagmail 创建文件/etc/puppet/tagmail.conf,多个邮件地址用逗号分隔,内容如下 all: admin@test.org,root@localhost all指所有消息,也可以是其他标签,比如err,info等,不细讲。 注:该功能需要sendmail或postfix支持,实现方式简单有效,适合小规模场合,如果客户端很多会比较麻烦,后面文章会讲到puppet-dashboard 。 有时候由于更换主机名,我们需要重新配置认证: (1)、首先在客户端删除 rm -rf /var/lib/puppet/ssl/文件夹 (2)、然后在服务器端删除客户端的证书:puppetca --clean apache01.test.org (3)、然后再在客户端执行puppetd --test 即可! puppet 支持客户端与服务端版本不一致,但是要注意两点 1、服务端版本大于等于客户端版本 2、版本差距不要太大,建议不要跨大版本号 3、不建议编译安装puppet,这会在后期维护时相当麻烦 注: DNS解析由ipa-server包办,也就是内网DNS,见另一篇博文。否则请在/etc/hosts文件中单独解析。 本文转自 紫色葡萄 51CTO博客,原文链接:http://blog.51cto.com/purplegrape/933454,如需转载请自行联系原作者
如果利用AD图形界面来创建大量用户帐户的话,将浪费很多时间用于重复操作相同的步骤。此时可以利用系统内置的工作csvde.exe、ldifde.exe、dsadd.exe等程序来节省创建用户帐户的时间。 csvde.exe: 可以利用它来添加用户帐户(或其他类型的对象),但是不能利用它来修改或删除用户帐户。您需要事先利用文本编辑器将用户帐户数据创建到纯文本文件内,然后利用csvde.exe将文件内的这些用户帐户一次性导入到AD数据库中。 ldifde.exe: 可以利用它来添加、删除、修改用户帐户(或其他类型的对象)。您需要事先利用文本编辑器将用户帐户数据创建到纯文本文件内,然后利用ldifde.exe将文件内的这些用户帐户一次性导入到AD数据库中。 dsadd.exe、dsmod.exe与dsrm.exe: dsadd.exe用来添加用户帐户(或其他类型的对象),dsmod.exe用来修改用户帐户,dsrm.exe用来删除用户帐户。您需要创建批处理文件,然后利用这3个程序将要进行添加、修改或删除的用户帐户创建到此批处理文件中。 对csvde.exe与ldifde.exe这两个程序,需要先利用可以编辑纯文本文件的程序(例如记事本)将用户帐户数据创建到文件内。在您创建文件前,请参考以下的说明: 1、必须指明用户帐户创建到何处,也就是需要指定存储路径(distinguished name,DN)。 2、必须包含对象的类型,例如user。 3、必须包含用户登录名称(windows2000原生)。 4、应该要包含用户登录名称(也就是user principal name,UPN)。 5、可以包含用户的其他信息,例如电话号码,地址等。 6、无法设置用户的密码。 7、由于所创建的用户帐户都没有密码,因此最好指定将该用户帐户禁用。 利用csvde.exe来添加用户帐户: 我们将利用记事本来说明如何创建供csvde.exe使用的文件,此文件的内容如下所示: DN,objectClass,sAMAccountName,userPrincipalName,displayName,userAccountControl "CN=王小溪,OU=上海,OU=业务部,DC=benet,DC=com",user,dennis,dennis@benet.com,王小溪,514 "CN=张中湖,OU=上海,OU=开发部,DC=benet,DC=com",user,steve,steve@benet.com,张中湖,514 上面以"CN=..."开头的就是一笔用户帐户的属性数据,各属性之间利用逗号(,)隔开。以DN开头的行是用来定义下面以CN开头的行相对应的每一个属性。 DN表示下面的"CN=王小溪,OU=上海,OU=业务部,DC=benet,DC=com",也就是存储路径。 objectClass表示对象类型,可以是user,也可以是group等等。 sAMAccountName表示用户登录名称(windows2000原生)。 userPrincipalName表示用户登录名称(UPN)。 diplayName表示显示名称。 userAccountControl表示是否禁用帐户,514表示禁用,512表示启用。 创建好文件后,打开命令提示符窗口,然后运行以下命令,假设文件名称为user.txt,且文件是位于c:\test文件夹内: csvde -i -f c:\test\user.txt 利用ldifde.exe来添加、修改与删除用户帐户: 同样用记事本来说明如何创建供ldifde.exe使用的文件。此文件的内容如下: DN:CN="林超峡",OU=上海,OU=业务部,DC=benet,DC=com changetype:add objectClass:user sAMAccountName:john userPrincipalName:john@benet.com displayName:林超峡 userAccountControl:514 DN:CN=张中湖,OU=上海,OU=开发部,DC=benet,DC=com changetype:delete DN:CN=陈大海,OU=上海,OU=业务部,DC=benet,DC=com changetype:modify replace:aAMAccountName sAMAccountName:robert - replace:userPrincipalName userPrincipalName:robert@benet.com 以上分别表示添加一笔用户帐户、删除一笔用户帐户、修改一笔用户帐户的两个属性。需要注意以下几个问题: 1、两笔数据之间必须至少空一行。 2、修改属性数据时,每个属性后面必须以减号结束。 若此文件最后还要增加其他帐户,请在减号之后至少空一行后再输入数据。保存时需要注意将编码选择Unicode,否则ldifde.exe无法正确识别中文,而被导入到AD数据库的中文也会变成乱码。 文件编辑完成后,打开命令提示符,运行以下命令,假设文件名称为user.txt,且文件是位于c:\test文件夹内: ldifde -i -f c:\test\user.txt 若要将数据导入到指定的域控制器,要加入“-s”参数,例如: ldifde -s dc1.benet.com -i -f c:\test\user.txt 利用dsadd.exe等程序来添加、修改与删除用户帐户: 下面同样用记事本来说明如何创建一个批处理文件(batch file),然后将dsadd、dsmod、dsrm命令输入到此文件内,并利用它们来添加、修改与删除用户帐户。文件内容大致如下: dsadd user "CN=许圆池,OU=上海,OU=业务部,DC=benet,dc=com" -samid Bob -upn bob@benet.com -display 许圆池 -disabled yes dsmod user "CN=王小溪,OU=上海,OU=业务部,DC=benet,DC=com" -upn edwin@benet.com -pwd 111aaAA -tel 27654321 dsrm "CN=李小洋,OU=上海,OU=业务部,DC=benet,DC=com" -noprompt pause 注意: dsadd命令用来添加一笔位于"CN=许圆池,OU=上海,OU=业务部,DC=benet,dc=com"的用户帐户,-samid Bob用来将其“用户登录名(windows2000以前版本)”设置为Bob,-upn bob@benet.com用来将其“用户登录名”设置为bob@benet.com,“-display 许圆池”用来将其显示名设置为许圆池,“-disabled yes”表示禁用此帐户。 dsmod命令用来修改位于"CN=王小溪,OU=上海,OU=业务部,DC=benet,DC=com"的用户帐户,其中“-upn edwin@benet.com”用来将其“用户登录名”更改为edwin@benet.com,“-pwd 111aaAA”用来设置帐户的密码,“-tel 27654321”用来设置用户的电话号码。 dsrm命令用来删除位于"CN=李小洋,OU=上海,OU=业务部,DC=benet,DC=com"的用户帐户,其中“-noprompt”表示不显示确认删除的画面。 最后一行的pause是为了让画面暂停,以便于查看运行的结果。 内容写好后将文本另存为bat或cmd文件,直接执行就可以了。 本文转自 忘情OK 51CTO博客,原文链接:http://blog.51cto.com/itchentao/1555165,如需转载请自行联系原作者
Priority and Bandwidth是我们在QOS里经常会用到的两个命令,但是他们的区别倒底是什么 Priority 在cisco官方文档里经常被这样描述:reserved bandwidth Bandwidth : Minimum bandwidth guarantee 一个是预留,一个是最低保障带宽,非常的含混模糊,几乎CISCO自已都难以分清。 其实两者有非常大的区别,但并不是在带宽上,Priority主要针对VOICE VIDEO等对延迟敏感数据,提高网络应用的响应速度。 两者在带宽上当然也有微小差别: Priority : 最低带宽保证,最高带宽保证,低延迟,限速(build-policier) Bandwidth:最低带宽保证,无最高带宽保证,无延迟保证,无限速机制 我们可以不太精确地总结为:priority指最大带宽,Bandwidth指最小带宽 分两种情况来看: 1、有拥塞: priority的带宽是被保证的,bandwidth的带宽也是被保证的 2、无拥塞: priority可提高带宽,bandwidth也可提高带宽,占用其它空余带宽。官方文档上是这么写的,但实际上priority即便占用了其它空余带宽,多占用的这些带宽也没有之前低延迟的特性,只能属于正常包,也就没有意义。 不论什么情况下,只要有空余带宽,都会被其它类别流量共享。 本文转自 ciscodocu51CTO博客,原文链接:http://blog.51cto.com/ciscodocu/74510,如需转载请自行联系原作者
Cisco路由器上配置DHCP全程详解 某单位使用Cisco 3620作为IOS DHCP Server,它和内网相连的fastethernet0端口的IP地址为192.168.1.4,二层交换机采用两台Cisco 2950,三层交换机采用一台Cisco 3550。 在整个网络中有二个VLAN,为简化描述,假设每个VLAN都采用24位网络地址,其中VLAN1的IP地址为192.168.1.254,VLAN2的IP地址为192.168.2.254。在Cisco设备上实现IOS DHCP Server功能以使各VLAN中的主机自动获得IP地址,如下图所示。 配置DHCP地址池、附加信息以及租约期限 DHCP服务器的数据库被组织成一个树形结构,树根是用于动态分配的所有网络段的地址池,树枝是子网地址池,树叶是手工绑定给节点的地址。具体操作步骤如下: 首先登陆到Cisco 3640路由器上: ghq>enable Password (输入路由器的特权口令) ghq #config terminal (进入配置模式) Enter configuration commands one per line. End with CNTL/Z. ghqconfig # ip dhcp pool global(配置一个根地址池,global是地址池的名称,你可以采用有意义的字符串来表示) ghq dhcp-config #network 192.168.0.0 255.255.0.0(动态分配的地址段) ghqdhcp-config #domain-name ghq.com(为客户机配置域后缀) ghqdhcp-config #dns-server 192.168.1.1(为客户机配置DNS服务器) ghqdhcp-config #netbios-name-server 192.168.1.1(为客户机配置wins服务器) ghqdhcp-config #netbios-node-type h-node(为客户机配置h节点模式) ghqdhcp-config #lease 30 (地址租用期为30天) ghqdhcp-config #ip dhcp pool vlan1 (为VLAN1配置地址池,本池是global池的子池,将从global继承域后缀、DNS服务器、wins服务器等参数) ghqdhcp-config #network 192.168.1.0 255.255.255.0 (VLAN1动态分配192.168.1这个网段内可以被分配的地址,没有被排除的地址) ghqdhcp-config#default-router 192.168.1.254 (为客户机配置默认的网关,即VLAN1的IP地址) ghqdhcp-config#ip dhcp pool vlan2 (为VLAN2配置地址池,本池是global池的子池,将从global继承域后缀、DNS服务器、wins服务器等可继承的参数) ghqdhcp-config#network 192.168.2.0 255.255.255.0 ghqdhcp-config#default-router 192.168.2.254 设置不能用于动态分配的IP地址 在整个网络中,有些IP地址需要静态的指定给一些特定的设备,例如路由器的端口、DNS服务器、wins服务器以及VLAN的地址等。显然,这些静态IP地址是不能用于动态分配的,这就需要将它们排除掉。其步骤如下: ghqconfig#ip dhcp excluded-address 192.168.1.1 192.168.1.5 (IP地址 192.168.1.1至192.168.1.5不能用于动态分配) ghqconfig# ip dhcp excluded-address 192.168.1.254 (IP地址192.168.1.254固定为VLAN1的地址,不能用于动态分配) ghqconfig# ip dhcp excluded-address 192.168.2.254 (IP地址192.168.2.254固定为VLAN2的地址,不能用于动态分配) 设置DHCP数据库代理 DHCP数据库代理是用于存储DHCP绑定信息的一台主机,它可以是FTP、TFTP或者是RCP服务器。当然,如有必要,你可以配置多个DHCP数据库代理。同样,不配置DHCP数据库代理也是允许的,但这是以不能在DHCP数据库代理上存储地址冲突日志为代价的。如果我们不想配置数据库代理,只要取消掉地址冲突日志的记录功能即可,操作命令如下: ghqconfig# no ip dhcp conflict logging (取消地址冲突记录日志) 配置路由器的静态路由表 要使客户机能从用作DHCP Server的路由器中自动获得IP地址,首要条件就是各个VLAN中的客户机都能和路由器通信,因此首先就需要在路由器中设置一个路由以使路由器能和各个客户机通信。我们可以按如下设置: ghqconfig#ip route 192.168.1.0 255.255.255.0 FastEthernet0 (FastEthernet0为路由器和内网相连的以太网接口,该命令的作用是在以太网接口和VLAN1 192.168.1.254间建立一条静态路由。) ghqconfig#ip route 192.168.2.0 255.255.255.0 FastEthernet0 (该命令在以太网接口和VLAN2 192.168.2.254间建立一条静态路由) 设置好之后,在配置模式中键入EXIT命令回到特权模式下,Ping一下VLAN1和VLAN2的IP地址192.168.1.254和192.168.2.254,如果能够Ping通则表明配置正确,可以直接进入下一步的保存过程。 在交换机上为不同的VLAN指定DHCP服务器地址 这一步骤只须在不同的VLAN中通过设置IP HELPER-ADDRESS即可搞定,指令如下: switch>enable (进入交换机的特权模式) Password switch #config t (进入配置模式) Enter configuration commandsone per line. End with CNTL/Z. switch config#interface vlan1 (配置VLAN1) switch config-if#ip helper-address 192.168.1.4(指定DHCP服务器的地址,即路由器的地址) ghqconfig-if#interface vlan2 (配置VLAN2) ghqconfig-if#ip helper-address 192.168.1.4 对所有直接连到客户机的二层访问端口开启Portfast功能 要使客户机正确获得IP地址,就需要将和客户机相连的交换机端口的Portfast功能打开(Cisco 2950)。这里需要特别注意的是,只能在连接一个单一客户机的二层端口上开启该功能,如果在一个连接到交换机或集线器的端口上开启该功就有可能引起广播风暴或“地址学习”问题。开启Portfast功能的步骤如下: switch #configure terminal switch config#interface interface-id switch config-if#spanning-tree portfast (开启portfast功能) switchconfig-if #end 经过以上规划与设置操作后,在路由器和交换机上的设置全部完成,剩下的工作只要在客户机上打开“自动获得IP地址”功能即可(如图2所示)。对于Windows 2000/2003 Server系统,还需要将“DHCP CLIENT”服务启用(如下图3所示),否则在Windows 2000/2003 Server中将不能自动得到IP地址。 图二 图三 至此,通过启用Cisco路由器的DHCP Server功能与客户端DHCP的配合使用,使局域网VLAN中的主机自动获得IP地址,真正实现了DHCP服务全部功能。相比在服务器上用windows/Linux 操作系统实现的DHCP服务器,从稳定性和功能上看,路由器实现的DHCP服务器要优越得多。 本文转自 liang831002 51CTO博客,原文链接:http://blog.51cto.com/leo0216/46791,如需转载请自行联系原作者
以下步骤用以生成一张证书: 第一步:发起证书请求:=============================在EMS中运行以下命令来生成一个证书请求: New-Exchangecertificate -generaterequest -path c:\certrequest.txt -domainname <公网FQDN>, <Exchange的内部FQDN>, <Exchange2007的NETBIOS名>, autodiscover.domain.com, autodiscover.domain.local, autodiscover, domain.com, domain.local -PrivatekeyExportable:$True -force 例如,您公司的公网FQDN为"mail.contoso.com", 内部EXCHANGE2007服务器的FQDN是"server.contoso.local" NetBIOS名是"server". 上述命令即为:New-Exchangecertificate -generaterequest -path c:\certrequest.txt -domainname mail.contoso.com, server.contoso.local, server, autodiscover.contoso.com, autodiscover.contoso.local, autodiscover, contoso.com, contoso.local -PrivatekeyExportable:$True -force 通过执行此条命令,即为mail.contoso.com申请了一张证书,而其余的名称也被涵盖在了SAN(Subject Alternative Name)区域中。第二步:生成一张证书========================请根据上面的证书请求生成一张证书。如果你决定从第三方证书机构购买一张证书,请将上面的证书请求发往第三方机构,他们会为你生成一张证书。第三步: 导入证书=======================将证书保存在Exchange2007服务器上,在EMS中运行以下命令以导入这张证书:Import-ExchangeCertificate -Path c:\certificates\certificate.cer注意:请根据实际情况选择导入证书的路径。第四步:启用证书======================在EMS中运行以下命令以启用这张证书Enable-ExchangeCertificate -Thumbprint 5113ae0233a72fccb75b1d0198628675333d010e -Services "IIS" 注意: Thumbprint参数指的是您新生成证书的唯一标示符。可通过Get-ExchangeCertificate命令来查看。 之后,您需要在每一台客户机上安装新生成的这张证书的根证书才能使所有客户机信任这张证书。 证书装完之后,请运行OWA或ACTIVESYNC来查看证书的运行情况。 本文转自 149banzhang 51CTO博客,原文链接:http://blog.51cto.com/149banzhang/584607,如需转载请自行联系原作者
涂黑是因为没必要在一个练习里面对号入座,这么想一个例子比较直观。 结果演示: 本文转自 tiger506 51CTO博客,原文链接:http://blog.51cto.com/tiger506/847854,如需转载请自行联系原作者
服务器需要强大的存储空间,由于服务器卡槽有限,存储器主要负责文件的存储,服务器需要与存储器配合使用,网线连接传输速率太低,光纤比较合理,考虑一根光纤不可靠,需要两根光纤同时进行,应用服务器较多存储器需要划空间各自存储,SAN交换机是传输介质,划zone来区分类似交换机vlan 售后电话:4006102058 默认管理地址 存储有两个控制器,A控制器默认配置IP是10.0.0.2,B控制器默认IP是10.0.0.3(在后端上下) 笔记本地址设置10.0.0.0网段,保证能ping通10.0.0.2或10.0.0.3 本PC连接A控制器 1、在IE浏览器中输入http://10.0.0.2/v2/index.html,用户名manage,密码!manage,选中文界面登录 2、SAN交换机和服务器都已经启动,那么在左侧主机中,可以看到所有在同一个zone中的服务器光纤卡的WWN号码 3、创建虚拟磁盘 4、定义虚拟磁盘名称、RAID级别、块大小默认,指定给自动 5、选择需要做RAID5的磁盘 6、创建卷 7、定义卷名称、卷的空间大小 8、映射选项默认是打勾开启的,这里做的是默认映射,比较适合服务器和盘柜直连的情况,如果我们通过光纤交换机连接,这种映射方法不适合,相对不安全,因此去掉映射右侧的对勾 9、映射卷 10、把卷映射给服务器,尾数为1ca的,由于是第一个卷,LUN还是输入1 本文转自 周小玉 51CTO博客,原文链接:http://blog.51cto.com/maguangjie/1915771,如需转载请自行联系原作者
Centos 6.3 x86_64安装与配置bacula 一,简介 Bacula是一款开源的跨平台的网络备份工具,基于c/s架构,通过它,管理员可以对数据进行备份,恢复,以及完整性验证等操作。 适合业务系统数据量巨大,每天都在迅速增长,还需要用以tar打包进行低级备份,并且没有相应的异地容灾策略,应该考虑bacula,bacula支持多种备份方式,还支持远程容灾备份。通过bacula,可以将数据备份到任意一个远程主机。用户只需要对bacula进行简单的设置即可自动完成数据备份。 二,工作原理 Bacula由下面5个部分组成 1,director daemon:负责监听所有的备份,恢复,验证,存档事务,以及定制备份和恢复文件计划等,将整个系统运行状况记录在一个数据库,支持mysql,postgresql,sqlite。配置文件bacula-dir.conf。监听端口9101 2,storage daemon (sd):在备份数据时,用来指定备份和恢复数据的存储介质,可以是本地磁盘,光纤磁盘阵列,磁带或dvd,恢复数据时将数据从存储介质中传送出去。配置文件:bacula-sd.conf 监听端口9103 3,file daemon(fd):是一个安装在需要备份数据的机器的上的守护进程,在备份数据时,它负责把文件传出,在恢复数据时,它负责接收数据并执行恢复操作。配置文件bacula-fd.conf 4,console:是一个管理控制台,用户可以通过这个控制台连接到director daemon进行管理备份与恢复操作。有三种方式,文本,gnone界面,wxwidgets界面。配置文件bconsole.conf 5,monitor:是一个进程监控端,负责监控director daemon,storage daemon和file daemon的守护进程。 三,工作流程 1、通过console连接到Director端,备份恢复操作开始。 2、Director端从自己的数据库中调出记录信息,对存储端SD与客户端FD的任务进行协调。 3、客户端FD负责验证Director的操作许可,如果验证通过,则允许连接到存储端SD 4、客户端FD根据Director发出的请求去连接SD,将FD端的数据备份到存SD指定的存储介质上,或者将SD端存储介质中的数据传回到客户端FD指定的位置上,完成备份恢复过程。 5,各个组件配置文件之间的关联,在下面配置时可以对照此图配置。 四,编译与安装bacula,在实际应用中并不会将五个部分分开安装。此次实验将dirctor ,sd,console安装在同一台机器,而客户端fd安装在另外一台机器,客户端可以有多台。 1,在服务端 #yum -y install mysql mysql-server mysql-devel (mysql可以选择编译,这里采用yum安装) #wget http://jaist.dl.sourceforge.net/project/bacula/bacula/5.2.13/bacula-5.2.13.tar.gz #tar xf bacula-5.2.13.tar.gz #cd bacula-5.2.13 #./configure --prefix=/usr/local/bacula --with-mysql (如果mysql是编译的则需要指定mysql安装的路径) #make && make install 安装完了之后,需要创建bacula对应的mysql数据库心及访问数据库的授权。 #cd /usr/local/bacula #./grant_mysql_privileges #./create_mysql_database #./make_mysql_tables 可以登录到mysql中查看bacula库的中表是否已经建立,上面三个脚本默认由空密码的root用户执行,因此需要确保mysql root的密码为空。 2,客户端 只是需要备份的客户端,因此只需要安装相应的客户端组件即可。 #cd bacula-5.2.13 #./configure --prefix=/usr/local/bacula --enable-client-only #make && make install 五,配置服务器端 1,配置console端 #cd /usr/local/bacula #vim etc/bconsole.conf Director { Name = server-dir 控制端名称,在bacula-dir.conf和bacula-sd.conf文件中的director段都会被用到 DIRport = 9101 address = 192.168.1.28 Password = "ZvLDkAPgWfJnre3+YDSDq6CAqyncBlTUklYspHtVAM/y" 控制端密码文件与bacula-dir中的director中的password要相同 } 2,配置director端 在bacula-dir.conf中共有10个逻辑段 Director 定义全局设置 Jobdefs 定义执行任务的一些共同属性,可以让任务继承,如果有冲突则以job中的为准。 job 自定义一个备份或恢复的任务 Fileset 定义备份哪些数据,不备份哪些数据 Sehedule 定义备份时间策略 Client 定义需要被备份的主机地址,也就是客户端地址 Storage 定义数据的存储方式 Catalog 定义后台数据库 Message 定义发送日志报告和记录日志的位置 Pool 定义供job使用的池属性 下面是一个已经配置好的文件 Director { # define myself Name = server-dir DIRport = 9101 # where we listen for UA connections QueryFile = "/usr/local/bacula/etc/query.sql" WorkingDirectory = "/usr/local/bacula/opt/bacula/working" PidDirectory = "/var/run" Maximum Concurrent Jobs = 1 # Console password 控制密码,与bconsole.conf中的对应的director.conf的password相同 Password = "ZvLDkAPgWfJnre3+YDSDq6CAqyncBlTUklYspHtVAM/y" Messages = Daemon } #定义执行任务的一些默认属性,后面定义的job可以继承,但是如果有冲突以job中为准 JobDefs { Name = "DefaultJob" Type = Backup #类型备份,还有restore,verify等值 Level = Incremental #备份级别,增量 Client = server-fd FileSet = "Full Set" Schedule = "WeeklyCycle" #备份策略,后面schedule有定义 Storage = File #备份数据的存储类型, Messages = Standard Pool = File #指定备份使用的pool属性,file在后面的pool逻辑段中有定义 Priority = 10 Write Bootstrap = "/usr/local/bacula/opt/bacula/working/%c.bsr" #指定备份的引导信息路径 } #定义一个名为backupclient1的增量备份的任务,defaultJob中定义的是incremental Job { Name = "BackupClient1" JobDefs = "DefaultJob" } #这个任务是新增的,后面实验需要有,不同的是级别为差异备份。 Job { Name = "BackupClient2" # Client = server2-fd JobDefs = "DefaultJob" Level = Differential } Job { Name = "BackupCatalog" JobDefs = "DefaultJob" Level = Full FileSet="Catalog" Schedule = "WeeklyCycleAfterBackup" # This creates an ASCII copy of the catalog # Arguments to make_catalog_backup.pl are: # make_catalog_backup.pl <catalog-name> RunBeforeJob = "/usr/local/bacula/etc/make_catalog_backup.pl MyCatalog" # This deletes the copy of the catalog RunAfterJob = "/usr/local/bacula/etc/delete_catalog_backup" Write Bootstrap = "/usr/local/bacula/opt/bacula/working/%n.bsr" Priority = 11 # run after main backup } Job { Name = "RestoreFiles" Type = Restore Client=server-fd FileSet="Full Set" Storage = File Pool = Default Messages = Standard Where = /tmp/bacula-restores #指定默认恢复数据到这个路径 } FileSet { Name = "Full Set" #定义一个名为full set的备份资源,指定需要备份哪些数据。 Include { Options { signature = MD5 } # File = /usr/local/bacula/sbin File=/data #指定需要备份的数据 } Exclude { #排除不需要备份的文件或者目录,可根据具体情况修改。 File = /usr/local/bacula/opt/bacula/working File = /tmp File = /proc File = /tmp File = /.journal File = /.fsck } } Schedule { Name = "WeeklyCycle" #定义一个名为weeklyclycle的备份策略 Run = Full 1st sun at 23:05 #第一周的星期日晚完全备份 Run = Differential 2nd-5th sun at 23:05 #第2-5周的星期日晚差异备份 Run = Incremental mon-sat at 23:05 #所有星期一至星期六晚进行增量备份 } Schedule { Name = "WeeklyCycleAfterBackup" #定义一个WeeklyCycleAfterBackup备份策略 Run = Full sun-sat at 23:10 } FileSet { Name = "Catalog" Include { Options { signature = MD5 } File = "/usr/local/bacula/opt/bacula/working/bacula.sql" } } Client { Name = server-fd Address = 192.168.1.29 #客户端IP FDPort = 9102 Catalog = MyCatalog Password = "LJxLG+wlZoSaVtUoSZ121NhcobsgzZhAQgG5pPYyjqFL" # password for FileDaemon File Retention = 30 days # 30 days Job Retention = 6 months # six months AutoPrune = yes # Prune expired Jobs/Files } #用来定义将客户端的数据备份到哪个存储设备上 Storage { Name = File Address = 192.168.1.28 # N.B. Use a fully qualified name here SDPort = 9103 #与bacula-sd.conf中director逻辑段密码相同 Password = "cXEx51B0y1FLklJpvQ52RIi0+5wORQIwQ+6oWsB134RB" Device = FileStorage #与bacula-sd.conf配置文件中的”device”逻辑段的”name”相同 Media Type = File #指定存储介质的类型,必须与bacula-conf中的device逻辑段的”media type”相同 } Catalog { Name = MyCatalog #定义关于日志和数据库设定 dbname = "bacula"; dbuser = "bacula"; dbpassword = "" } Messages { #设置director端如何保存日志,以及日志的格式,可以将日志信息发送到管理员邮箱,前提是必须开启sendmail服务。 Name = Standard mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r" operatorcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r" mail = 304749970@qq.com = all, !skipped operator = root@localhost = mount console = all, !skipped, !saved append = "/usr/local/bacula/opt/bacula/log/bacula.log" = all, !skipped catalog = all } Messages { Name = Daemon mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r" mail = 304749970@qq.com = all, !skipped console = all, !skipped, !saved append = "/usr/local/bacula/opt/bacula/log/bacula.log" = all, !skipped } Pool { Name = Default Pool Type = Backup Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 365 days # one year } Pool { Name = File Pool Type = Backup Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 365 days # one year Maximum Volume Bytes = 50G # Limit Volume size to something reasonable Maximum Volumes = 100 # Limit number of Volumes in Pool } Pool { Name = Scratch Pool Type = Backup } Console { #限制console利用tray-monitor获得director的状态信息 Name = server-mon Password = "EIOogja1xSbJxfPhwqUCl3c97HgX9Xzj54Nb1ofL+zH3" CommandACL = status, .status } 3,配置sd,sd可以是一台单独的服务器,在此交实验中跟director在一台机器上。 Vim bacula.conf Storage { # definition of myself Name = server-sd SDPort = 9103 # Director's port WorkingDirectory = "/usr/local/bacula/opt/bacula/working" Pid Directory = "/var/run" Maximum Concurrent Jobs = 20 } Director { Name = server-dir #与bacula-dir.conf中的director中name需要相同,密码也需要相同 Password = "cXEx51B0y1FLklJpvQ52RIi0+5wORQIwQ+6oWsB134RB" } Director { Name = server-mon #与bacula-dir.conf中的console中name需要相同,密码也是一样 Password = "EIOogja1xSbJxfPhwqUCl3c97HgX9Xzj54Nb1ofL+zH3" Monitor = yes } Device { Name = FileStorage #定义device,与bacula-dir.conf中storage段的device需要相同 Media Type = File Archive Device = /tmp #备份的数据存储的路径 LabelMedia = yes; # lets Bacula label unlabeled media 通过label命令来建立卷文件 Random Access = Yes; AutomaticMount = yes; # when device opened, read it RemovableMedia = no; AlwaysOpen = no; } Messages { Name = Standard director = server-dir = all } 六,配置客户端的fd Vim bacula.conf Director { Name = server-dir #与bacula-dir.conf中的director中name需要相同,密码也需要相同 Password = "LJxLG+wlZoSaVtUoSZ121NhcobsgzZhAQgG5pPYyjqFL" } Director { Name = server-mon #与bacula-dir.conf中的console中name需要相同,密码也是一样 Password = "EIOogja1xSbJxfPhwqUCl3c97HgX9Xzj54Nb1ofL+zH3" Monitor = yes } FileDaemon { # this is me Name = client-fd FDport = 9102 # where we listen for the director WorkingDirectory = /usr/local/bacula/opt/bacula/working Pid Directory = /var/run Maximum Concurrent Jobs = 20 } Messages { Name = Standard director = client-dir = all, !skipped, !restored } 七,启动与关闭bacula 1,可用/usr/local/bacula/sbin/bacula start 启动所有服务 2,可以/usr/local/bacula/etc/下的各个组件的单独启动方式 #./bacula-ctl-dir #./bacula-ctl-sd ./bacula-ctl-fd 由于将fd单独配置,需要可以不需要启动此服务 启动时需要先启动mysql,不然无法启动director daemon。 3,客户端也可以上面两种办法启动。 八,bacula备份过程 #/usr/local/bacula/sbin/bconsole Connecting to Director 192.168.1.28:9101 1000 OK: server-dir Version: 5.2.13 (19 February 2013) Enter a period to cancel a command. *label (作用其实就是建立备份文件名的作用) Automatically selected Catalog: MyCatalog Using Catalog "MyCatalog" Automatically selected Storage: File Enter new Volume name: test Defined Pools: 1: Default 2: File 3: Scratch Select the Pool (1-3): 1 Connecting to Storage daemon File at 192.168.1.28:9103 ... Sending label command for Volume "test" Slot 0 ... 3000 OK label. VolBytes=192 DVD=0 Volume="test" Device="FileStorage" (/tmp) Catalog record for Volume "test", Slot 0 successfully created. Requesting to mount FileStorage ... 3906 File device ""FileStorage" (/tmp)" is always mounted. You have messages. *run A job name must be specified. The defined Job resources are: 1: BackupClient1 2: BackupClient2 3: BackupCatalog 4: RestoreFiles Select Job resource (1-4): 1 Run Backup job JobName: BackupClient1 Level: Incremental Client: server-fd FileSet: Full Set Pool: File (From Job resource) Storage: File (From Job resource) When: 2013-04-17 01:07:36 Priority: 10 OK to run? (yes/mod/no): yes Job queued. JobId=17 *status Status available for: 1: Director 2: Storage 3: Client 4: All Select daemon type for status (1-4): 1 查看备份状态 server-dir Version: 5.2.13 (19 February 2013) x86_64-unknown-linux-gnu redhat Daemon started 16-Apr-13 17:36. Jobs: run=13, running=0 mode=0,0 Heap: heap=278,528 smbytes=96,076 max_bytes=378,820 bufs=267 max_bufs=306 Scheduled Jobs: Level Type Pri Scheduled Name Volume =================================================================================== Incremental Backup 10 17-Apr-13 23:05 BackupClient1 test Incremental Backup 10 17-Apr-13 23:05 BackupClient2 bingodegn Full Backup 11 17-Apr-13 23:10 BackupCatalog bingodegn 本文转自 deng304749970 51CTO博客,原文链接:http://blog.51cto.com/damondeng/1180044,如需转载请自行联系原作者
机房里面经常需要监视到几个方向的链路连通情况,出现中断或链路恢复的时候要有告警信息或其他提示方式。下面放一个perl编写的链路状态监视程序。 本文转自 tiger506 51CTO博客,原文链接:http://blog.51cto.com/tiger506/897890,如需转载请自行联系原作者
Description Functions to convert between character representations and objects of classes "POSIXlt" and "POSIXct" representing calendar dates and times. Usage ## S3 method for class 'POSIXct' format(x, format = "", tz = "", usetz = FALSE, ...) ## S3 method for class 'POSIXlt' format(x, format = "", usetz = FALSE, ...) ## S3 method for class 'POSIXt' as.character(x, ...) strftime(x, format = "", tz = "", usetz = FALSE, ...) strptime(x, format, tz = "") Arguments x An object to be converted: a character vector for strptime, an object which can be converted to "POSIXlt" for strftime. tz A character string specifying the time zone to be used for the conversion. System-specific (see as.POSIXlt), but "" is the current time zone, and "GMT"is UTC. Invalid values are most commonly treated as UTC, on some platforms with a warning. format A character string. The default for the format methods is "%Y-%m-%d %H:%M:%S" if any element has a time component which is not midnight, and "%Y-%m-%d"otherwise. If options("digits.secs") is set, up to the specified number of digits will be printed for seconds. ... Further arguments to be passed from or to other methods. usetz logical. Should the time zone be appended to the output? This is used in printing times, and more reliable than using "%Z". Details The format and as.character methods and strftime convert objects from the classes "POSIXlt" and "POSIXct" to character vectors. strptime converts character vectors to class "POSIXlt": its input x is first converted by as.character. Each input string is processed as far as necessary for the format specified: any trailing characters are ignored. strftime is a wrapper for format.POSIXlt, and it and format.POSIXct first convert to class "POSIXlt" by calling as.POSIXlt (so they also work for class "Date"). Note that only that conversion depends on the time zone. The usual vector re-cycling rules are applied to x and format so the answer will be of length of the longer of these vectors. Locale-specific conversions to and from character strings are used where appropriate and available. This affects the names of the days and months, the AM/PM indicator (if used) and the separators in formats such as %x and %X, via the setting of the LC_TIME locale category. The ‘current locale’ of the descriptions might mean the locale in use at the start of the R session or when these functions are first used. The details of the formats are platform-specific, but the following are defined by the POSIX standard and are likely to be widely available. A conversion specification is introduced by %, usually followed by a single letter or O or E and then a single letter. Any character in the format string not part of a conversion specification is interpreted literally (and %% gives %). Widely implemented conversion specifications include %a Abbreviated weekday name in the current locale. (Also matches full name on input.) %A Full weekday name in the current locale. (Also matches abbreviated name on input.) %b Abbreviated month name in the current locale. (Also matches full name on input.) %B Full month name in the current locale. (Also matches abbreviated name on input.) %c Date and time. Locale-specific on output, "%a %b %e %H:%M:%S %Y" on input. %C Century (00–99): the integer part of the year divided by 100. %d Day of the month as decimal number (01–31). %D Date format such as %m/%d/%y: ISO C99 says it should be that exact format. %e Day of the month as decimal number (1–31), with a leading space for a single-digit number. %F Equivalent to %Y-%m-%d (the ISO 8601 date format). %g The last two digits of the week-based year (see %V). (Accepted but ignored on input.) %G The week-based year (see %V) as a decimal number. (Accepted but ignored on input.) %h Equivalent to %b. %H Hours as decimal number (00–23). As a special exception strings such as 24:00:00 are accepted for input, since ISO 8601 allows these. %I Hours as decimal number (01–12). %j Day of year as decimal number (001–366). %m Month as decimal number (01–12). %M Minute as decimal number (00–59). %n Newline on output, arbitrary whitespace on input. %p AM/PM indicator in the locale. Used in conjunction with %I and not with %H. An empty string in some locales (and the behaviour is undefined if used for input in such a locale). Some platforms accept %P for output, which uses a lower-case version: others will output P. %r The 12-hour clock time (using the locale's AM or PM). Only defined in some locales. %R Equivalent to %H:%M. %S Second as decimal number (00–61), allowing for up to two leap-seconds (but POSIX-compliant implementations will ignore leap seconds). %t Tab on output, arbitrary whitespace on input. %T Equivalent to %H:%M:%S. %u Weekday as a decimal number (1–7, Monday is 1). %U Week of the year as decimal number (00–53) using Sunday as the first day 1 of the week (and typically with the first Sunday of the year as day 1 of week 1). The US convention. %V Week of the year as decimal number (00–53) as defined in ISO 8601. If the week (starting on Monday) containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. (Accepted but ignored on input.) %w Weekday as decimal number (0–6, Sunday is 0). %W Week of the year as decimal number (00–53) using Monday as the first day of week (and typically with the first Monday of the year as day 1 of week 1). The UK convention. %x Date. Locale-specific on output, "%y/%m/%d" on input. %X Time. Locale-specific on output, "%H:%M:%S" on input. %y Year without century (00–99). On input, values 00 to 68 are prefixed by 20 and 69 to 99 by 19 – that is the behaviour specified by the 2004 and 2008 POSIX standards, but they do also say ‘it is expected that in a future version the default century inferred from a 2-digit year will change’. %Y Year with century. Note that whereas there was no zero in the original Gregorian calendar, ISO 8601:2004 defines it to be valid (interpreted as 1BC): see http://en.wikipedia.org/wiki/0_(year). Note that the standards also say that years before 1582 in its calendar should only be used with agreement of the parties involved. For input, only years 0:9999 are accepted. %z Signed offset in hours and minutes from UTC, so -0800 is 8 hours behind UTC. Values up to +1400 are accepted as from R 3.1.1: previous versions only accepted up to +1200. %Z (Output only.) Time zone abbreviation as a character string (empty if not available). This may not be reliable when a time zone has changed abbreviations over the years. Where leading zeros are shown they will be used on output but are optional on input. Names are matched case-insensitively on input: whether they are capitalized on output depends on the platform and the locale. Note that abbreviated names are platform-specific (although the standards specify that in theC locale they must be the first three letters of the capitalized English name: this convention is widely used in English-language locales but for example French month abbreviations are not the same on any of Linux, OS X, Solaris and Windows). When %z or %Z is used for output with an object with an assigned time zone an attempt is made to use the values for that time zone — but it is not guaranteed to succeed. Not in the standards and less widely implemented are %k The 24-hour clock time with single digits preceded by a blank. %l The 12-hour clock time with single digits preceded by a blank. %s (Output only.) The number of seconds since the epoch. %+ (Output only.) Similar to %c, often "%a %b %e %H:%M:%S %Z %Y". May depend on the locale. For output there are also %O[dHImMUVwWy] which may emit numbers in an alternative locale-dependent format (e.g., roman numerals), and %E[cCyYxX] which can use an alternative ‘era’ (e.g., a different religious calendar). Which of these are supported is OS-dependent. These are accepted for input, but with the standard interpretation. Specific to R is %OSn, which for output gives the seconds truncated to 0 <= n <= 6 decimal places (and if %OS is not followed by a digit, it uses the setting of getOption("digits.secs"), or if that is unset, n = 3). Further, for strptime %OS will input seconds including fractional seconds. Note that %S ignores (and not rounds) fractional parts on output. The behaviour of other conversion specifications (and even if other character sequences commencing with % are conversion specifications) is system-specific. Some systems document that the use of multi-byte characters in format is unsupported: UTF-8 locales are unlikely to cause a problem. Value The format methods and strftime return character vectors representing the time. NA times are returned as NA_character_. strptime turns character representations into an object of class "POSIXlt". The time zone is used to set the isdst component and to set the "tzone" attribute if tz != "". If the specified time is invalid (for example "2010-02-30 08:00") all the components of the result are NA. (NB: this does means exactly what it says – if it is an invalid time, not just a time that does not exist in some time zone.) Printing years Everyone agrees that years from 1000 to 9999 should be printed with 4 digits, but the standards do not define what is to be done outside that range. For years 0 to 999 most OSes pad with zeros or spaces to 4 characters, and Linux outputs just the number. OS facilities will probably not print years before 1 CE (aka 1 AD) ‘correctly’ (they tend to assume the existence of a year 0: seehttp://en.wikipedia.org/wiki/0_(year), and some OSes get them completely wrong). Common formats are -45 and -045. Years after 9999 and before -999 are normally printed with five or more characters. Some platforms support modifiers from POSIX 2008 (and others). On Linux the format "%04Y" assures a minimum of four characters and zero-padding. The internal code (as used on Windows and by default on OS X) uses zero-padding by default, and formats %_4Y and %_Y can be used for space padding and no padding. Time zone offsets Offsets from GMT (also known as UTC) are part of the conversion between timezones and to/from class "POSIXct", but cause difficulties as they often computed incorrectly. They conventionally have the opposite sign from time-zone specifications (see Sys.timezone): positive values are East of the meridian. Although there have been time zones with offsets like 00:09:21 (Paris in 1900), and 00:44:30 (Liberia until 1972), offsets are usually treated as whole numbers of minutes, and are most often seen in RFC 822 email headers in forms like -0800 (e.g., used on the Pacific coast of the US in winter). Format %z can be used for input or output: it is a character string, conventionally plus or minus followed by two digits for hours and two for minutes: the standards say that an empty string should be output if the offset is unknown, but some systems use the offsets for the time zone in use for the current year. Note The default formats follow the rules of the ISO 8601 international standard which expresses a day as "2001-02-28" and a time as "14:01:02" using leading zeroes as here. (The ISO form uses no space to separate dates and times: R does by default.) For strptime the input string need not specify the date completely: it is assumed that unspecified seconds, minutes or hours are zero, and an unspecified year, month or day is the current one. Some components may be returned as NA (but an unknown tzone component is represented by an empty string). If the time zone specified is invalid on your system, what happens is system-specific but it will probably be ignored. Remember that in most time zones some times do not occur and some occur twice because of transitions to/from ‘daylight saving’ (also known as ‘summer’) time. strptime does not validate such times (it does not assume a specific time zone), but conversion by as.POSIXct will do so. Conversion by strftime and formatting/printing uses OS facilities and may return nonsensical results for non-existent times at DST transitions. Much less comprehensive support for output specifications was provided on Windows before R 3.1.0. In a C locale %c is required to be "%a %b %e %H:%M:%S %Y". As Windows does not comply (and uses a date format not understood outside N. America), that format is used by R on Windows in all locales. That %A %a %B %b on input match both full and abbreviated names caused problems in some locales prior to R 3.0.3: e.g. in French on OS X juillet was matched by jui, the abbreviation for June. References International Organization for Standardization (2004, 2000, ...) ISO 8601. Data elements and interchange formats – Information interchange – Representation of dates and times. For links to versions available on-line see (at the time of writing) http://dotat.at/tmp/ISO_8601-2004_E.pdf andhttp://www.qsl.net/g1smd/isopdf.htm; for information on the current official version, see http://www.iso.org/iso/iso8601. The POSIX 1003.1 standard, which is in some respects stricter than ISO 8601. See Also DateTimeClasses for details of the date-time classes; locales to query or set a locale. Your system's help page on strftime to see how to specify their formats. (On some systems, including Windows, strftime is replaced by more comprehensive internal code.) Examples ## locale-specific version of date() format(Sys.time(), "%a %b %d %X %Y %Z") ## time to sub-second accuracy (if supported by the OS) format(Sys.time(), "%H:%M:%OS3") ## read in date info in format 'ddmmmyyyy' ## This will give NA(s) in some locales; setting the C locale ## as in the commented lines will overcome this on most systems. ## lct <- Sys.getlocale("LC_TIME"); Sys.setlocale("LC_TIME", "C") x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960") z <- strptime(x, "%d%b%Y") ## Sys.setlocale("LC_TIME", lct) z ## read in date/time info in format 'm/d/y h:m:s' dates <- c("02/27/92", "02/27/92", "01/14/92", "02/28/92", "02/01/92") times <- c("23:03:20", "22:29:56", "01:03:30", "18:21:03", "16:56:26") x <- paste(dates, times) strptime(x, "%m/%d/%y %H:%M:%S") ## time with fractional seconds z <- strptime("20/2/06 11:16:16.683", "%d/%m/%y %H:%M:%OS") z # prints without fractional seconds op <- options(digits.secs = 3) z options(op) ## time zones name are not portable, but 'EST5EDT' comes pretty close. (x <- strptime(c("2006-01-08 10:07:52", "2006-08-07 19:33:02"), "%Y-%m-%d %H:%M:%S", tz = "EST5EDT")) attr(x, "tzone") ## An RFC 822 header (Eastern Canada, during DST) strptime("Tue, 23 Mar 2010 14:36:38 -0400", "%a, %d %b %Y %H:%M:%S %z") 本文转自 tiger506 51CTO博客,原文链接:http://blog.51cto.com/tiger506/1609392,如需转载请自行联系原作者
Linux环境解决Oracle 中文乱码 1)查看数据库字符集 1 2 3 4 03:12:58 SQL> select userenv('language') from dual; USERENV('LANGUAGE') ---------------------------------------------------- AMERICAN_AMERICA.ZHS16GBK 2)编辑linux 的NLS_LANG变量 [oracle@oraserv ~]$ pwd /home/oracle [oracle@oraserv ~]$ ls -a 1 2 3 4 5 6 7 8 . cr_dbprod.sql .gconfd .ICEauthority .rman_history .Xauthority .. cr_db.sql .gnome logmnr sel.sql .xsession-errors .bash_history cr_dict.sql .gnome2 .metacity sql.log 中国 .bash_logout Desktop .gnome2_private .mozilla sqlnet.log .bash_profile .dmrc .gstreamer-0.10 .nautilus .sqlplus_history .bashrc .eggcups .gtkrc-1.2-gnome2 ora.sh s.sh close_bak_command.sql ftp.msg hot_bak_cmd.sql ora.txt start.sh cold_bak.sql .gconf hot_bak.sql .redhat .Trash [oracle@oraserv ~]$ vi .bashrc 1 2 3 4 5 6 7 8 9 # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK ".bashrc" 10L, 167C written 3)注销oracle用户,重新登录 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 [oracle@oraserv ~]$ su - oracle [oracle@oraserv ~]$ env |grep LANG NLS_LANG=AMERICAN_AMERICA.ZHS16GBK LANG=en_US.UTF-8 [oracle@oraserv ~]$ export ORACLE_SID=prod [oracle@oraserv ~]$ env |grep LANG NLS_LANG=AMERICAN_AMERICA.ZHS16GBK LANG=en_US.UTF-8 通过sqlplus验证: [oracle@oraserv ~]$sqlplus '/as sysdba'; SQL*Plus: Release 10.2.0.1.0 - Production on Fri Apr 8 03:15:59 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options 03:16:02 SQL> conn scott/tiger Connected. 03:16:08 SQL> select * from tab; TNAME TABTYPE CLUSTERID ------------------------------ ------- ---------- DEPT TABLE EMP TABLE BONUS TABLE SALGRADE TABLE 03:16:16 SQL> update dept set dname='财务' where deptno=10; 1 row updated. 03:16:47 SQL> select * from dept; DEPTNO DNAME LOC ---------- -------------- ------------- 10 财务 NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 注意:解决问题的原则,客户端的字符集和oracle 数据库的字符集保持一致。 本文转自 客居天涯 51CTO博客,原文链接:http://blog.51cto.com/tiany/730998,如需转载请自行联系原作者
制作集成SATA、RAID和AHCI驱动的Windows XP sp3 安装光盘。 微软已经把Windows XP SP3发布了,是个好消息。只是在安装过程中发现有一个问题还是没解决。 就是安装SATA、RAID和AHCI驱动还要用按F8键,用软驱安装相应程序(软驱毕竟很少用了)。 解决办法如下: 一、所需要的一些软件工具: 1、准备一张纯净版的Windows XP sp3 系统盘(或下载的系统映像文件)。 2、下载主板驱动 下载自己电脑主板的最新驱动程序。(或准备攒机用的主板驱动,本文用的是技嘉主板:GA-M770-DS3的主板驱动程序,支持AMD处理器)。 nLite 1.4.1(自用)新版下载地址(该软件免激活,使用满意后可以捐款赞助)。 http://www.duote.com/soft/7360.htmlnLite需要Microsoft .NET Framework Version 2.0支持。 下载地址: http://www.duote.com/soft/4039.htmlULtraISO v9.0.0.2336.V9.0.0.2336(该软件需要激活码,网上可以找到。) (可以配合nLite使用,不用单独准备系统安装盘,它可以直接提取下载的系统映像文件到指定位置)。 下载地址: http://www.duote.com/sofe/2808.html3、 刻录软件:用Nero 7.9.6.0或者其它的刻录软件也可以。 4、空700M CD刻录光盘一张(要质量好的)。 二、制作光盘前的准备工作。 1、在可用空间1G以上的分区中建立一个文件夹,如D:\CD(nLite不支持中文名称,主要是放XP安装程序及驱动)。 2、在"CD"文件夹下再建立两个文件夹,如:XP和Driver。 3、用UltraISO把原版XP光盘里的(或下载的镜像文件)所有东西都提取到 D:\CD\XP 文件夹下。 4、把下载的主板驱动解压到 D:\CD\Driver 文件夹下。 5、准备工作完成。 三、把主板驱动整合到XP中,刻录光盘: 1、启动nLite,选择语言(选择Simplified Chinese为简体中文),点击“前进”。 2、在浏览中选择刚才复制到硬盘上的XP文件夹. D:\CD\XP ,选择完后软件开始检测.如果你的XP不是原版的,这一步会报错.说明你的XP安装文件是修改过的.找到原版的盘再试.如果没问题的话,点击"前进" 3、再点击"前进" 4、然后选中““驱动”和“可引导ISO镜像”两项,点击“前进”。 5、在“插入”中选择“多个驱动所在的文件夹”在弹出的对话框中,选择驱动的目录D:\CD\Driver。 6、在弹出的对话框中选择,刚才添加的驱动路径,点击“确定”。 7、在"文本模式整合选项"中会出现很多驱动,我们只选X86、SATA、RAID和AHCI。 8、选中后点击"确定"现在在界面中就应该有我们选择的驱动了,然后点击“前进”。 9、软件提示:“需要现在处理吗?点击是。处理完后,点击“前进”。 10、选择"创建ISO"指定一个地方”, 如E:winxpsp3,点“前进”就开始制作XP的镜像文件了。 11、镜像做完后,这样这个ISO镜像文件就集成SATA和sp3的驱动了。 12、找到镜像文件,选择用刻录软件刻录光盘映像文件。 最后一张图片点击“前进”按钮,可以指定一个文件夹(如:E:winxpsp3)制作系统映像文件。用相关刻录软件找到它,即可刻录成系统光盘。 刻录完成后,就制作好一张集成SATA驱动的WindowsXPsp3的安装盘。 制作完成后的文件大小为:600多MB,一张CD刻录盘就可以了。 图片资料是用我已经制作完成的资源做的(只为演示制作过程)。不同硬件结果不尽相同,制作方法、过程基本一样(本文以技嘉主板GA-MA770-DS3为例)。 此方法是新硬件遭遇老系统的解决办法之一。使新硬盘(SATA)不在工作在IDE模式了,且不用启动按F8键装入软盘了,软驱已经很少了。可以组成磁盘阵列。 制作过程中也可以把声卡、显卡、网卡等硬件驱动程序集成进去,方便自己以后使用。 (缺点:只能用在自己电脑重装系统,只集成SATA驱动可以用在其他需要SATA驱动的电脑上) 本文转自 149banzhang 51CTO博客,原文链接:http://blog.51cto.com/149banzhang/623216,如需转载请自行联系原作者
.NET如何反编译?如何不劳而获?如何破解别人的软件?如何查看到别人的源代码,这些问题常常是一个新手所最关心的事情。 当然了,作为一个从业时间较长的我来说,对这种行为谈不上厌恶与否,只是不赞成也不反对。有句话说的好,只是本身是没有错的,就像刀剑本身是没有正邪之分的,就看你怎么用了。 好了,那么接下来我们就介绍如何反编译。 其实很简单且并不神秘,就是需要Reflector这个工具,大家可以到Reflector官方网站(http://www.aisto.com/roeder/dotnet/)下载最新版本下载后解压缩会用一个Reflector.exe直接双击它,就可以运行呢,界面如下. 点击file->open 选择需要反编译的DLL,打开后控件的命名空间会出现在左边的列表中,如上面的dataaccesscommon.点需要反编的类如下面 看到了吧,反编译后的代码和原代码基本上没有什么区别. Reflector本身没有将代码导入到文件功能,需要用到相关插件.下面介绍一个插件用法及用途. (1) Reflector.FileDisassembler和Reflector.FileGenerator这两个插件的用的用途都是一样的,将反编译后的代码导出到相关文件,我这里只介绍Reflector.FileDisassemble的用法,Reflector.FileGenerator用法类似Reflector.FileDisassemble 下截地址: http://www.denisbauer.com/Download.aspx?File=Reflector.FileDisassembler.zip (a) 启动Reflector,点击view---add-ins….. 选择Reflector.FileDisassembler.dll (下载Reflector. FileDisassembler解压后有这个文件)添加成功后,在tools菜单中会有file disassembler选项. (b) 选择需要导出的类再选择toolsàfile disassembler 出现以下对话框. (c) 在文本框中,输入导出文件的目录,然后点击genrate生成文件. (2) Reflector.VisualStudio插件,将Reflector工具嵌入到vs.net里.下载 Reflector.VisualStudio后,将解压后的文件和Reflector.exe放在一起,点击 Reflector.VisualStudio.exe,即可导入.这时我们运行vs.net,可以通过菜单栏里的"外部程序- Reflector"运行Reflector. 下截地址: http://www.testdriven.net/downloads/ReflectorVsAddin.zip (3) Reflector.SQL2005Browser 添加方法同(1)该插件用来查看SQL Server 2005 (Yukon) database中的存储集合. 下截地址: http://www.denisbauer.com/Download.aspx?File=Reflector.SQL2005Browser.zip (4) Reflector.CodeMetrics插件,添加方法同(1)该插件用来分析.net assemblies 和显示该组件的性能参数 下截地址: http://projectdistributor.net/GetFile.aspx?type=b &id=55 (5) Reflector.Graph插件添加方法同(1)该插件用来绘制集合的结构图. 下截地址: http://projectdistributor.net/GetFile.aspx?type=b &id=56 我这里只介绍了五个插件的应用.有什么说的不对的,大家可以指出. 不过Reflector对那些加密混淆的就没有办法啦,仅仅使作这个工具是不行的,还需要更扎实的计算机基础知识. 本文转自 OH51888 51CTO博客,原文链接:http://blog.51cto.com/rozbo/1240784,如需转载请自行联系原作者
v一.一个实现了Runnable接口的类 class MyThread implements Runnable{ private static int num = 0; @Override public void run() { while(true){ synchronized(MyThread.class){ ++num; try{ Thread.sleep(500); } catch(Exception e){ System.out.println(e.toString()); } System.out.println(Thread.currentThread().getName() + " " + num); } } } } v1. newCachedThreadPool()方法 CacheThreadPool会为每一个任务创建一个线程。非常常见的情况是,单个的Executor被用来创建和管理系统中的任务。shutdown()方法可以防止新的任务被提交给这个Executor。如果在shutdown()方法之后提交新任务,则会抛出java.util.concurrent.RejectedExecutionException异常。 public class Main{ public static void main(String[] args){ ExecutorService exes = Executors.newCachedThreadPool(); for(int i=0; i<5; ++i) exes.execute(new MyThread()); exes.shutdown(); } } v2.FixedThreadPool()方法 FixedThreadPool使用了优先的线程集来执行所提交的任务。有了它,你就可以一次性预先执行代价高的线程分配。也就是说如果设置的最大线程数量是x,而提交的线程数y,那么(y-x)对应的这些线程要等到前x个线程执行完毕才会执行。 下面的例子中,线程6一直不会有机会执行。因为run()方法中是 while(true), 可以将while(true)去掉,前5个线程执行完毕后,才会执行第6个线程。 public class Main{ public static void main(String[] args){ ExecutorService exes = Executors.newFixedThreadPool(5); for(int i=0; i<6; ++i) exes.execute(new MyThread()); exes.shutdown(); } } v3.newSingleThreadExecutor()方法 public class Main{ public static void main(String[] args){ ExecutorService exes = Executors.newSingleThreadExecutor(); for(int i=0; i<5; ++i) exes.execute(new MyThread()); exes.shutdown(); } SingleThreadExecutor就像是线程数量为1的FixedThreadPool。这对于你希望在另一个线程中连续运行的事物(长期存活的任务)来说,都是很有用的。如果想SingleThreadExecutor提交了多个任务,那么这些任务将排队,每个任务都会在下一个任务开始之前结束,所有的任务将使用相同的线程。 v二.一个实现了Callable<E>接口的类(从任务中产生返回值) class MyThread implements Callable<String>{ private static int num = 0; @Override public String call() throws Exception { for(int i=0; i<5; ++i){ synchronized(MyThread.class){ ++num; Thread.sleep(200); System.out.println(Thread.currentThread().getName() + " " + num); } } return Thread.currentThread().getName() + " success!"; } } v1.ExecutorService.submit()方法 public class Main{ public static void main(String[] args){ ExecutorService exes = Executors.newCachedThreadPool(); ArrayList<Future<String>> rets = new ArrayList<Future<String>>(); for(int i=0; i<5; ++i) rets.add(exes.submit(new MyThread())); for(Future<String> fs : rets){ try { System.out.println(fs.get()); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } } } submit()会产生Future对象,它用Callable返回结果的特定类型进行了参数化。可以调用Future的isDone()方法来查询Future是否已经完成。调用Future的get()方法来获取最终线程的执行结果。另外,Future的get()方法是一个阻塞方法,直到结果准备就绪。 v 三.线程的优先级 class MyThread implements Runnable{ private int priority; public MyThread(){ } public MyThread(int priority){ this.priority = priority; } private static int num = 0; private volatile double d; @Override public void run() { Thread.currentThread().setPriority(priority); while(true){ for(int i=0; i<100000; ++i){ d += (Math.PI+Math.E)/(double)i; if(i%1000 == 0) Thread.yield(); } synchronized(MyThread.class){ ++num; try{ Thread.sleep(500); } catch(Exception e){ System.out.println(e.toString()); } System.out.println(Thread.currentThread().getName() + " " + num); } } } } public class Main{ public static void main(String[] args){ ExecutorService exes = Executors.newCachedThreadPool(); for(int i=0; i<5; ++i) exes.execute(new MyThread(Thread.MIN_PRIORITY)); exes.execute(new MyThread(Thread.MAX_PRIORITY)); exes.shutdown(); } } volatile变量保证编译器对循环不进行任何的优化,如果不加入这些运算的话,就不会看到设置线程优先级的效果。数学运算是可以中断的,向控制台打印不能被中断。这里预案算时间足够的长,因此线程调度机制才来的及介入,交换任务并关注优先级,是的最高优先级被优先选择。 v四.后台线程 class SimpleDaemons implements Runnable{ @Override public void run() { while(true){ try{ TimeUnit.MILLISECONDS.sleep(200); System.out.println(Thread.currentThread().getName()); } catch(InterruptedException e){ System.out.println(Thread.currentThread().getName() + " : InterruptException!"); e.printStackTrace(); } } } } public class Main{ public static void main(String[] args) throws InterruptedException{ for(int i=0; i<10; ++i){ Thread daemon = new Thread(new SimpleDaemons()); daemon.setDaemon(true); daemon.start(); } System.out.println("All daemons started"); TimeUnit.MILLISECONDS.sleep(1000); } } 所谓后台线程,是指程序运行的时候在后台提供一种通用的服务的线程,并且这种线程并不属于程序中不可或缺的部分。因此,当所有的非后台线程结束时,程序也就终止了,同时会杀死进程中的所有的后台线程。反过来说,只要任何非后台线程还在运行,程序就不会终止。 通过定制自己的ThreadFactory, 可以定制有Executor创建的线程的属性(后台,优先级,名称) class DaemonThreadFactory implements ThreadFactory{ @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setDaemon(true); return t; } } class DaemonFromFactory implements Runnable{ @Override public void run() { try{ TimeUnit.MILLISECONDS.sleep(100); System.out.println(Thread.currentThread().getName()); } catch (InterruptedException e){ e.printStackTrace(); } } } public class Main{ public static void main(String[] args) throws InterruptedException{ ExecutorService exes = Executors.newCachedThreadPool(new DaemonThreadFactory()); for(int i=0; i<5; ++i) exes.execute(new DaemonFromFactory()); System.out.println("All Daemos Started!"); TimeUnit.MILLISECONDS.sleep(1000); } } 本文转自 小眼儿 博客园博客,原文链接:http://www.cnblogs.com/hujunzheng/p/5097470.html,如需转载请自行联系原作者
1.root用户加密 [root@localhost ~]# passwd --加密当前用户 Changing password for user root. New password: BAD PASSWORD: it is based on a dictionary word BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully. [root@localhost ~]# 2.破解root用户的密码 (1)重启系统安Esc键 (2)进入引导的编辑模式,选中高亮按e键 (3)选中引导菜单按e键 (4)在末尾输入1进入单用户模式,然后回车 (5)按b键重启 (6)系统重启后进入密码文件,修改密码 (7)查看root用户的密文 (8)删除root用户的密文,并保存退出 (9)输入reboot重启系统 (10)登陆系统,root用户的密码为空 3.给系统的grub加密,使用户无法进行单用户模式 [root@localhost ~]# grub-md5-crypt Password: --输入密码 Retype password: --确认密码 $1$Bvp0X1$lzZrrThfQuLECYdk4wtAk1 --这是密钥,复制一下 [root@localhost ~]# vim /boot/grub/grub.conf default=1 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu password --md5 $1$Bvp0X1$lzZrrThfQuLECYdk4wtAk1 --添加这一行 root (hd0,0) kernel /vmlinuz-2.6.32-358.el6.i686 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-358.el6.i686.img [root@localhost ~]# reboot 系统重启后不能编辑grub菜单 4.破解grub密码 (1)放入系统光盘进入修复模式 (2)选择语言 (3)选择键盘 (4)选择系统光盘的位置 (5)选择网络环境(不需要网络) (6)选择进入系统修复模式 (7)将系统挂载到/mnt/sysimage(chroot /mnt/sysimage可以改变根目录) (8)挂载系统 (9)选择shell环境 (10)进入grub.conf文件 (11)删除grub.conf文件中的密码行 (12)重启系统 5.对系统的分区加密 [root@localhost ~]# yum install cryptsetup -y --安装软件 [root@localhost ~]# fdisk -cu /dev/sdb --分区 Command (m for help): p Disk /dev/sdb: 157 MB, 157286400 bytes 255 heads, 63 sectors/track, 19 cylinders, total 307200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2c917867 Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (2048-307199, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-307199, default 307199): +100M Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@localhost ~]# partx -a /dev/sdb BLKPG: Device or resource busy [root@localhost ~]# cryptsetup luksFormat /dev/sdb1 --对/dev/sdb1分区进行加密 WARNING! ======== This will overwrite data on /dev/sdb1 irrevocably. Are you sure? (Type uppercase yes): YES --一定是大写 Enter LUKS passphrase: --输入密码 Verify passphrase: --确认密码 [root@localhost ~]# cryptsetup luksOpen /dev/sdb1 tong --为分区创建别名 Enter passphrase for /dev/sdb1: [root@localhost ~]# mkfs.ext4 /dev/mapper/tong --格式化分区 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 25168 inodes, 100352 blocks 5017 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 13 block groups 8192 blocks per group, 8192 fragments per group 1936 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 31 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# mount /dev/mapper/tong /mnt/sdb/ --挂载成功 [root@localhost ~]# cd /mnt/sdb/ [root@localhost sdb]# mkdir 12 --写入数据 [root@localhost sdb]# cd [root@localhost ~]# umount /mnt/sdb/ --卸载设备 [root@localhost ~]# cryptsetup luksClose /dev/mapper/tong --关闭加密分区 [root@localhost ~]# df -TH Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 6.9G 6.4G 177M 98% / tmpfs tmpfs 262M 0 262M 0% /dev/shm /dev/sda1 ext4 508M 48M 435M 10% /boot [root@localhost ~]# cryptsetup luksOpen /dev/sdb1 tong --想使用分区必须输入密码 Enter passphrase for /dev/sdb1: [root@localhost ~]# mount /dev/mapper/tong /mnt/sdb/ [root@localhost ~]# df -TH Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 6.9G 6.4G 177M 98% / tmpfs tmpfs 262M 0 262M 0% /dev/shm /dev/sda1 ext4 508M 48M 435M 10% /boot /dev/mapper/tong ext4 100M 5.8M 89M 7% /mnt/sdb [root@localhost ~]# vim /etc/crypttab --修改配置文件 name /dev/sdb1 --启用这行,系统开机必须输入密码 [root@localhost ~]# 进入系统要求输入sdb1分区的密码 开机不要求输入密码 [root@localhost ~]# vim /etc/crypttab name /dev/sdb1 /home/sdb1.key --保存密码文件 [root@localhost ~]# echo "system" > /home/sdb1.key --system是密码 [root@localhost ~]# chown root.root /home/sdb1.key --修改权限 [root@localhost ~]# chmod 600 /home/sdb1.key [root@localhost ~]# cryptsetup luksAddKey /dev/sdb1 /home/sdb1.key 6.关于分区解密目前不能破解 本文转自 z597011036 51CTO博客,原文链接:http://blog.51cto.com/tongcheng/1349963,如需转载请自行联系原作者
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 关键字有:(排版有些问题、实际上是一行3个关键字,粘贴过来原来的表格格式丢失了) ADD ALL ALTER ANALYZE AND AS ASC ASENSITIVE BEFORE BETWEEN BIGINT BINARY BLOB BOTH BY CALL CASCADE CASE CHANGE CHAR CHARACTER CHECK COLLATE COLUMN CONDITION CONNECTION CONSTRAINT CONTINUE CONVERT CREATE CROSS CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR DATABASE DATABASES DAY_HOUR DAY_MICROSECOND DAY_MINUTE DAY_SECOND DEC DECIMAL DECLARE DEFAULT DELAYED DELETE DESC DESCRIBE DETERMINISTIC DISTINCT DISTINCTROW DIV DOUBLE DROP DUAL EACH ELSE ELSEIF ENCLOSED ESCAPED EXISTS EXIT EXPLAIN FALSE FETCH FLOAT FLOAT4 FLOAT8 FOR FORCE FOREIGN FROM FULLTEXT GOTO GRANT GROUP HAVING HIGH_PRIORITY HOUR_MICROSECOND HOUR_MINUTE HOUR_SECOND IF IGNORE IN INDEX INFILE INNER INOUT INSENSITIVE INSERT INT INT1 INT2 INT3 INT4 INT8 INTEGER INTERVAL INTO IS ITERATE JOIN KEY KEYS KILL LABEL LEADING LEAVE LEFT LIKE LIMIT LINEAR LINES LOAD LOCALTIME LOCALTIMESTAMP LOCK LONG LONGBLOB LONGTEXT LOOP LOW_PRIORITY MATCH MEDIUMBLOB MEDIUMINT MEDIUMTEXT MIDDLEINT MINUTE_MICROSECOND MINUTE_SECOND MOD MODIFIES NATURAL NOT NO_WRITE_TO_BINLOG NULL NUMERIC ON OPTIMIZE OPTION OPTIONALLY OR ORDER OUT OUTER OUTFILE PRECISION PRIMARY PROCEDURE PURGE RAID0 RANGE READ READS REAL REFERENCES REGEXP RELEASE RENAME REPEAT REPLACE REQUIRE RESTRICT RETURN REVOKE RIGHT RLIKE SCHEMA SCHEMAS SECOND_MICROSECOND SELECT SENSITIVE SEPARATOR SET SHOW SMALLINT SPATIAL SPECIFIC SQL SQLEXCEPTION SQLSTATE SQLWARNING SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT SSL STARTING STRAIGHT_JOIN TABLE TERMINATED THEN TINYBLOB TINYINT TINYTEXT TO TRAILING TRIGGER TRUE UNDO UNION UNIQUE UNLOCK UNSIGNED UPDATE USAGE USE USING UTC_DATE UTC_TIME UTC_TIMESTAMP VALUES VARBINARY VARCHAR VARCHARACTER VARYING WHEN WHERE WHILE WITH WRITE X509 XOR YEAR_MONTH ZEROFILL 如果表名和关键字一样的话(如表名也叫range),则冲突的表名要用反引号, 例如 alter `range` xxxxxxx; 本文转自 lirulei90 51CTO博客,原文链接:http://blog.51cto.com/lee90/1773532,如需转载请自行联系原作者
Cocoa 新的依赖管理工具:Carthage 说到 iOS 的依赖管理工具,大家一定首先想到的是 CocoaPods ,不错,CocoaPods 确实是一个很好依赖管理工具,已然成为了 Cocoa 依赖管理的标准,丰富的支持库、文档等等,CocoaPods 相关的文章有很多,这里就不一一赘述了。 今天要介绍的是一款新的依赖管理工具,名曰 “Carthage”,名字有点难理解,简单方便,完全独立,不修改 XCode 项目文件或配置。 简介 我之前很少用 CocoaPods,很大一部分原因就是因为麻烦,仅个人感觉,需要牵扯 XCode 项目文件;而 Carthage 就很好的解决了我之前的烦恼,轻耦合,更灵活;使用 xcodebuild 工具来编译依赖项目成二进制 Framework,再引入到项目中去。 Carthage 是由 Swift 语言写的,只支持动态框架,只支持 iOS8+。 Carthage 的大致工作流程如下: 创建一个 Cartfile 文件,写好你要哪些依赖库 执行 carthage update 命令拉取源代码并编译为 Framework 把编译后的 .framework 拖到项目中去即可 (官方是这么说的,不过更好的办法是把 Carthage 编译的 Framework 路径加入到 Build Setting 中的 Framework Search Path,详情见后文) 执行 update 命令后,你的项目目录结构大致如下: Cartfile Cartfile.resolved Carthage - Build - iOS - Alamofire.framework - Mac - Alamofire.framework - Checkouts - Alamofire - ... xxx.xcodeproj ... Cartfile 文件用来标注你需要哪些依赖库,对应版本或者 Git 分支 (需要提交到 Git) Cartfile.resolved 文件用来跟踪项目当前所用的依赖版本号,为了保持多端开发一致 (需要提交到 Git) Carthage 文件夹用来存放依赖库的源文件和编译后的文件 (不需要提交到 Git) 其实工作方式有点和 Cocoapods 大致相似,只不过 Cartfile 多了一个自动编译过程且与 Project 耦合更低,Cartfile 利用 xcode-select 命令来编译 Framework,如果你想用测试版的 Xcode 进行编译,执行下面这条命令,把 xcode-select 的路径改为另一版本 Xcode 就可以了 sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer 其中 Xcode-beta.app 就是对应你的 Xcode 版本,你也可以改成其他版本的 Xcode 注:写完才发现,原来 Xcode -> Preferences -> Locations 中已经有切换 Command Line Tools 版本的选项... 安装 推荐使用 Homebrew 进行安装,简单方便,也便于维护: brew install carthage 安装前最好先 update 一下,之前我就是因为没有 update,结果安装了老版本的 Carthage brew update 使用 添加 Cartfile 文件 类似于 CocoaPods 中的 Podfile 文件,把需要的包写进去就行了,具体可参阅官方说明,如: # 必须最低 2.3.1 版本 github "ReactiveCocoa/ReactiveCocoa" >= 2.3.1 # 必须 1.x 版本 github "Mantle/Mantle" ~> 1.0 # (大于或等于 1.0 ,小于 2.0) # 必须 0.4.1 版本 github "jspahrsummers/libextobjc" == 0.4.1 # 使用最新的版本 github "jspahrsummers/xcconfigs" # 使用一个私有项目,在 "development" 分支 git "https://enterprise.local/desktop/git-error-translations.git" "development" 暂只支持 GitHub 和 git 源,在执行 carthage update 命令后会在根目录创建一个 Cartfile.resolved 文件,这个文件是生成后的依赖关系,不能修改。 引入 Framework 在项目中引入依赖的 Framkework,只需要在对应 Target 中的 Build Setting 中的 Framework Search Path 项加入以下路径,Xcode 便会自动搜索目录下的 Framework: $(SRCROOT)/Carthage/Build/iOS 如果是 OSX 项目则把末尾的 iOS 改为 Mac 在 Git 中忽略 如果不想把 Carthage 的依赖库 push 到 Git 仓库里,则修改 .gitignore 文件,增加忽略 Carthage 文件夹就行了: #Carthage Carthage 可用命令 archive : Archives a built framework into a zip that Carthage can usebootstrap : Check out and build the project's dependenciesbuild : Build the project's dependenciescheckout : Check out the project's dependenciescopy-frameworks : In a Run Script build phase, copies each framework specified by a SCRIPT_INPUT_FILE environment variable into the built app bundlefetch : Clones or fetches a Git repository ahead of timehelp : Display general or command-specific helpupdate : Update and rebuild the project's dependenciesversion : Display the current version of Carthage 本文转自 h2appy 51CTO博客,原文链接:http://blog.51cto.com/h2appy/1872670,如需转载请自行联系原作者
简介: FTP上传文件权限继承有很多的方法能解决!最常用的是ACL,这里我通过Inotify的实现 Inotify下载地址: https://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz 编译安装 1、[root@localhost down]# wget --no-check-certificate https://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz \\ --no-check-certificate参数是支持https 2、[root@localhost down]# tar -zxf inotify-tools-3.14.tar.gz 3、[root@localhost inotify-tools-3.14]# ./configure 4、[root@localhost inotify-tools-3.14]# make ;make install 检查 1、查看是否支持内核 [root@localhost inotify-tools-3.14]# ll /proc/sys/fs/inotify total 0 -rw-r--r-- 1 root root 0 Jul 9 19:43 max_queued_events -rw-r--r-- 1 root root 0 Jul 9 19:43 max_user_instances -rw-r--r-- 1 root root 0 Jul 9 19:43 max_user_watches 2、检查软件是安装成功 [root@localhost inotify-tools-3.14]# ls /usr/local/bin/inotifywait /usr/local/bin/inotifywait 使用 1、我的FTP目录是/var/www 使用如下命令监测运行下 /usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e modify,delete,create,attrib /var/www 2、OK,现在我们在/var/www创建一个testfile文件。 [root@localhost www]# touch testfile 3、哈哈成功显示出来信息 [root@localhost inotify-tools-3.14]# /usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e modify,delete,create,attrib /var/www 09/07/11 20:01 /var/www/testfile 4、利用这个输出,写个SHELL自动继承 #!/bin/bash #inofp.sh src=/var/www /usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' \ -e modify,delete,create,attrib \ ${src} \ | while read file do chmod -R 777 $file 2>/dev/null done 5、执行这个shell sh inofp.sh &>/dev/null & 6、去/var/www/新建个文件夹和文件试试 [root@localhost www]# touch file [root@localhost www]# mkdir directory 7、我脚本里面设的权限是777 看看成功否 [root@localhost www]# ll total 4 drwxrwxrwx 2 root root 4096 Jul 9 21:22 directory -rwxrwxrwx 1 root root 0 Jul 9 21:25 file 8、OK成功全部777 本文转自 ibelieveme 51CTO博客,原文链接:http://blog.51cto.com/skyson/607314,如需转载请自行联系原作者
一、遇到的问题: 今天有朋友问我,说在CentOS上写好的脚本,在Ubuntu上没法正常使用,当时没在意,以为是权限没配置好,后来看了下,发现ubuntu跟CentOS的默认shell是不同的,如是记录下,避免以后忘记: 1 2 3 1、ubuntu默认的shell是连接到dash,而我们通常写的shell脚本使用的时bash。 2、bash和dash在一些方面是不兼容的。因此执行同一个脚本,两者结果不同,可能用./*sh可以执行,而sh *.sh报错。 3、Ubuntu之所以使用dash是因为其体积小,兼容性高,但是对于经常使用CentOS的人来说,这就比较悲剧,一些bash可执行的脚步在dash下不能执行了,脚本的可移植性不能保证。 二、解决方法: 1 2 1、检查脚本是否有x权限,如果有,则进行第二步 2、sudo dpkg-reconfigure dash,然后出现的界面中选择 NO 本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1947107,如需转载请自行联系原作者
最近看了下公司之前的CentOS6的开机配置脚本,简单调整了下: 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 #!/bin/bash #created by molewan #set env export PATH=$PATH:/bin:/sbin:/usr/sbin hostname=$1 if [ $UID != "0" ];then echo "Please run as root" exit 1 fi Usage(){ echo $"USAGRE:/bin/bash $0 hostname" exit 1 } if [ "$#" -ne "1" ];then Usage fi #define cmd var SERVICE=`which service` CHKCONFIG=`which chkconfig` function mod_yum(){ ping -c 2 -w 2 mirrors.aliyun.com >/dev/null 2>&1 if [ $? -eq 0 ];then wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo yum install -y vim lsof telnet lrzsz wget openssh-clients unix2dos dos2unix gcc gcc-c++ openssl-devel openssl-perl bc yum clean all else echo "your must check network" exit 1 fi } function disable_selinux(){ sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux setenforce 0 >/dev/null 2>$1 } function disable_iptables(){ /sbin/iptables -F && /sbin/iptables -X && /sbin/iptables -Z /etc/init.d/iptables save /etc/init.d/iptables stop && chkconfig iptables off } function least_service(){ export LANG=en chkconfig|awk '{print "chkconfig",$1,"off"}'|bash chkconfig|egrep "crond|sshd|network|rsyslog|sysstat"|awk '{print "chkconfig",$1,"on"}'|bash } function charset(){ cp /etc/sysconfig/i18n /etc/sysconfig/i18n.bak echo 'LANG="zh_CN.UTF-8"'>/etc/sysconfig/i18n source /etc/sysconfig/i18n } function ntp_time_sync(){ ntpdate -u 202.120.2.101 && hwclock -w >/dev/null 2>&1 echo "05 23 * * * /usr/sbin/ntpdate -u 202.120.2.101">>/var/spool/cron/root } function com_line_set(){ if [ `egrep "TMOUT|HISTSIZE|ISTFILESIZE" /etc/profile|wc -l` -lt 3 ] then echo 'export TMOUT=300'>>/etc/profile echo 'export HISTSIZE=5'>>/etc/profile echo 'export HISTFILESIZE=5'>>/etc/profile source /etc/profile fi } function open_file_set(){ if [ `grep 65535 /etc/security/limits.conf|wc -l` -lt 1] then echo '*-nofile65535'>>/etc/security/limits.conf tail -1 /etc/security/limits.conf fi } function set_kernel(){ cat >>/etc/sysctl.conf<<EOF net.ipv4.tcp_fin_timeout = 2 net.ipv4.tcp_tw_resue = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_keepalive_time = 600 net.ipv4.ip_local_port_range = 4000 65000 net.ipv4.tcp_max_syn_backlog = 16384 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.icmp_ignore_bogus_error_responses = 1 net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.default.accept_source_route = 0 net.ipv4.tcp_rmem = 4096 87380 8388608 net.ipv4.tcp_wmem = 4096 87380 8388608 EOF sysctl -p } function set_sercurity_limits.conf(){ echo ' ' >> /etc/security/limits.conf echo '* soft nofile 65535' >> /etc/security/limits.conf echo '* hard nofile 65535' >> /etc/security/limits.conf echo '* soft nproc 65535' >> /etc/security/limits.conf echo '* hard nproc 65535' >> /etc/security/limits.conf } function set_ssh(){ sed -i '/#Port 22/Port 5272/g' /etc/sysconfig/sshd_config sed -i '/#UseDNS yes/a\UseDNS no' /etc/ssh/sshd_config sed -i 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/g' /etc/ssh/sshd_config sed -i 's/GSSAPIAuthentication yes/#GSSAPIAuthentication yes/g' /etc/ssh/sshd_config /etc/init.d/sshd reload } function set_hostname(){ echo 'NETWORKING=yes' >> /etc/sysconfig/network echo "HOSTNAME=${hostname}" >> /etc/sysconfig/network } function ctrl_alt_del_deny(){ sed -i 's/start on control-alt-delete/#start on control-alt-delete/g' /etc/init/control-alt-delete.conf } function shutdown_ipv6(){ echo 'alias net-pf-10 off' >> /etc/modprobe.d/dist.conf echo 'alias ipv6 off' >> /etc/modprobe.d/dist.conf } function alter_bootmenu_time(){ sed -i '/timeout=5/d' /boot/grub/menu.lst sed -i '/default/a\timeout=1' /boot/grub/menu.lst } main(){ mod_yum disable_selinux disable_iptables least_service charset ntp_time_sync com_line_set open_file_set set_kernel set_sercurity_limits.conf set_ssh set_hostname ctrl_alt_del_deny shutdown_ipv6 alter_bootmenu_time } main 本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1956057,如需转载请自行联系原作者
在虚拟化中,虚拟机一般中vmware tools一般都会设置与esxi同步时间,所以esxi的时间就十分重要;建议方法是使用ntp客户端进行时间同步。 Esxi启用ntp过程 点击esxi主机,选择 “配置”—“时间配置”—“属性” 勾选“NTP客户端启用”,然后点击“选项” 勾选“与主机一起启动和停止”,因为目前ntp的状态是停止的,所以点击“启动”,然后点击“NTP设置”添加ntp服务器 点击“添加”,输入NTP服务器的地址,然后确定 ESXi设置完成后,通知需要在虚拟机中vmware tools中启用与esxi时间同步。 或者对每个虚拟机也采用ntp的时间同步。 本文转自 waydee 51CTO博客,原文链接:http://blog.51cto.com/waydee/816858,如需转载请自行联系原作者
1、在服务器上编写一个脚本,然后提示“设备上没有空间” 2、查看i节点的使用情况,发现空间还真被占满了 可以通过以下命令快速查找文件目录下的文件个数: for i in /*; do echo $i; find $i | wc -l; done 3、衍生出的问题 后来发现,一个同事在写测试脚本的时候,生成了大量的小文件在根目录的/test,使用rm -rf /test目录时,报错,可能是文件数太多: 解决方法: 1 2 mkdir -p /blanktest rsync -a --delete /blanktest/ /test 文件很快被删除了 小结:把文件系统的目录与书籍的目录做类比,rm删除内容时,将目录的每一个条目逐个删除(unlink),需要循环重复操作很多次;rsync删除内容时,建立好新的空目录,替换掉老目录,基本没开销。 4、监控注意事项 我们在做监控的时候,除了传统的资源利用率外,最好也能将一些比较重要的分区的i节点进行监控,做好监控,可以及时的发现并解决问题。 本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1964513,如需转载请自行联系原作者
1、下载android sdk http://developer.android.com/sdk/index.html 然后解压到指定目录即可,目录结构如下 2、进入eclipse目录,启动eclipse,先check of update下 依次window》sdk manager安装更新必要的插件 3、再到window》preferences里查看sdk是否有效,无效则会报错 5、创建一个android project,然后run config里配置下 6、点击window》android vdm》new一个新的出来,然后点击start,如下图 PS: 如果这个选项出不来,那么先执行如下的步骤: 6、当上一步完全启动后,右键工程名上,run as》 android app即可运行 7、配置环境变量PATH,在我自己的电脑上如下 F:\adt-bundle-windows-x86-20130219\sdk\platform-tools;F:\adt-bundle-windows-x86-20130219\sdk\tools; 这个是用于以后使用adb和emulator命令(http://developer.android.com/tools/help/adb.html) PS:安装包下载地址: http://pan.baidu.com/share/link?shareid=445649&uk=1495773032 本文转自 小强测试帮 51CTO博客,原文链接:http://blog.51cto.com/xqtesting/1147868,如需转载请自行联系原作者
Sc 08/31/2016 2 minutes to read Applies To: Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows Server 2003 with SP2, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2012, Windows Server 2003 with SP1, Windows 8 Communicates with the Service Controller and installed services. The SC.exe program provides capabilities similar to those provided in Services in the Control Panel. For the syntax of any of the commands in the following table, click the command name. Sc Commands Sc command Description Sc boot Indicates whether the last boot should be saved as the last-known good boot configuration. Sc config Modifies the value of a service's entries in the registry and in the Service Control Manager database. Sc continue Sends a CONTINUE control request to a paused service. Sc control Sends a control to a service. Sc create Creates a subkey and entries for the service in the registry and in the Service Control Manager database. Sc delete Deletes a service subkey from the registry. Sc description Sets the description string for a service. Sc enumdepend Lists the services that cannot run unless the specified service is running. Sc failure Specifies one or more actions to be taken if a particular service fails. Sc failureflag Specifies whether to trigger recovery actions when a service stops as the result of an error. Sc getdisplayname Gets the display name associated with a particular service. Sc getkeyname Gets the key name associated with a particular service, using the display name as input. Sc interrogate Sends an INTERROGATE control request to a service. Sc lock Locks the Service Control Manager's database. Sc pause Sends a PAUSE control request to a service. Sc qc Queries the configuration information for a service. Sc qdescription Displays a service's description string. Sc qfailure Displays the actions that will be performed if the specified service fails. Sc query Obtains and displays information about the specified service, driver, type of service, or type of driver. Sc queryex Obtains and displays detailed information about the specified service, driver, type of service, or type of driver. Sc querylock Queries and displays the lock status for the Service Control Manager database. Sc sdset Sets a service's security descriptor, using Security Descriptor Definition Language (SDDL). Sc sdshow Displays a service's security descriptor, using SDDL. Sc start Starts a service. Sc stop Sends a STOP control request to a service. Remarks SC.exe retrieves and sets control information about services. You can use SC.exe for testing and debugging service programs. Service properties stored in the registry can be set to control how service applications are started at boot time and can be run as background processes. You can use the SC.exe parameters to configure a specific service, retrieve the current status of a service, and stop and start a service. You can create batch files that call various SC.exe commands to automate the startup or shutdown sequence of services. 本文转自 h2appy 51CTO博客,原文链接:http://blog.51cto.com/h2appy/2062197,如需转载请自行联系原作者
搭建DHCP服务实现动态分配IP地址 一:实验内容 DHCP服务器工作原理 使用DHCP为局域网中的机器分配IP地址 使用DHCP为服务器分配固定IP地址 二:实验环境: 服务端:xuegod63 IP:192.168.1.70 客户端:RHEL-6.2-64-71 IP:192.168.1.71 客户端:RHEL-6.2-64-72 IP:192.168.1.72 三:实验步骤 第一块:概述 1:DHCP服务概述: 名称:DHCP - Dynamic Host Configuration Protocol 动态主机配置协议 功能:DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作, 主要有两个用途: 1、 给内部网络或网络服务供应商自动分配IP地址,主机名,DNS服务器,域名 2、 配和其它服务,实现集成化管理功能。如:无人执守安装服务器 3、 特点: C/S 模式 客户端/服务端 自动分配IP地址,方便管理 DHCP不会同时租借相同的IP地址给两台主机 DHCP管理员可以约束特定的计算机使用特定的IP地址 客户机在不同子网间移动时不需要重新设置IP地址。每次都自动获取IP地址就可以了。 2:DHCP的缺点: 当网络上存在多服务器时,一个DHCP服务器不能查出已被其它服务器租出去的IP地址; DHCP服务器不能跨路由器与客户机通信,除非路由器允许BOOTP协议转发 你的DHCP只能在一个局域网里工作 3:端口: DHCP服务使用:端口67(bootps) 68(bootpc) 。 67是服务端 68是客户端 [root@xuegod63~]#vim/etc/services bootp协议:引导程序协议(BOOTP)。它可以让无盘工作站从一个中心服务器上获得IP地址,为局域网中的无盘工作站分配动态IP地址,并不需要每个用户去设置静态IP地址。 BOOTP有一个缺点:您在设定前须事先获得客户端的硬件地址,而且,MCA地址与IP的对应是静态的。换而言之,BOOTP非常缺乏“动态性 ”,若在有限的IP资源环境中,BOOTP的一对一对应会造成非常可观的浪费。 DHCP可以说是BOOTP的增强版本,它分为两个部分:一个是服务器端,而另一个是客户端。所有的IP网络设定数据都由DHCP服务器集中管理,并负责处理客户端的DHCP要求;而客户端则会使用从服务器分配下来的IP环境数据。比较BOOTP, DHCP透过“租约”的概念,有效且动态的分配客户端的TCP/IP设定,而且,作为兼容考虑,DHCP也完全照顾了BOOTP Client的需求。 4:DHCP服务运行原理: DHCP客户端向服务端请求IP地址过程 注释: -------DHCP DISCOVER -------> udp 目标67 源IP0.0.0.0 目的IP:255.255.255.255 即DHCP客户机寻找DHCP服务器的阶段。DHCP客户机以广播方式(因为DHCP服务器的IP地址对于客户机来说是未知的)发送DHCP discover信息来寻找DHCP服务器,即向地址255.255.255.255发送特定的广播信息。网络上每一台安装了TCP/IP协议的主机都会接收到这种广播信息,但只有DHCP服务器才会做出响应 <------DHCP OFFER ----------udp 68 源IP是DHCP服务器的IP, 目的IP: 255.255.255.255,即DHCP服务器提供IP地址的阶段。在网络中接收到DHCP discover发现信息的DHCP服务器都会做出响应,它从尚未出租的IP地址中挑选一个分配给DHCP客户机,向DHCP客户机发送一个包含出租的回复信息。 -------DHCP REQUEST -------->udp 67 源IP0.0.0.0目的IP:255.255.255.255,即DHCP客户机选择某台DHCP服务器提供的IP地址的阶段。如果有多台DHCP服务器向DHCP客户机发来的DHCP offer提供信息,则DHCP客户机只接受第一个收到的DHCP offer提供信息,然后它就以广播方式回答一个DHCP request请求信息,该信息中包含向它所选定的DHCP服务器请求IP地址的内容。之所以要以广播方式回答,是为了通知所有的DHCP服务器,他将选择某台DHCP服务器所提供的IP地址。 <------DHCP ACK ------------udp 68 源IP是服务器的IP 目的IP: 255.255.255.255,即DHCP服务器确认所提供的IP地址的阶段。当DHCP服务器收到DHCP客户机回答的DHCP request请求信息之后,它便向DHCP客户机发送一个包含它所提供的IP地址和其他设置的DHCP ack确认信息,告诉DHCP客户机可以使用它所提供的IP地址。然后DHCP客户机便将其TCP/IP协议与网卡绑定,另外,除DHCP客户机选中的服务器外,其他的DHCP服务器都将收回曾提供的IP地址 注意: 客户端执行DHCP DISCOVER 后,如果没有DHCP 服务器响应客户端的请求,客户端会随机使用169.254.0.0/16 网段中的一个IP 地址,配置本机地址。169.254.0.0/16是windows的自动专有IP寻址范围,也就是在无法通过DHCP获取IP地址时,由系统自动分配的IP地址段。早先的Linux上并不会产生这条路由,现在有这条路由大概是为了和windows兼容 [root@xuegod63 ~]# route –n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 5:安装软件包 [root@xuegod63 ~]# rpm -ivh /mnt/Packages/dhcp-common-4.1.1-25.P1.el6.x86_64.rpm [root@xuegod63 ~]# rpm -ivh /mnt/Packages/dhcp-4.1.1-25.P1.el6.x86_64.rpm 查看包被安装在哪里 /etc/dhcp/dhcpd.conf #包的配置文件 Linux下的所有安装包都在/mnt/Packages/下面 [root@xuegod63 ~]# vim /etc/dhcp/dhcpd.conf [root@xuegod63 ~]# vim /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample [root@xuegod63 ~]# cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.back [root@xuegod63~]#cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf cp:是否覆盖"/etc/dhcp/dhcpd.conf"? 注: 当DHCP 主程序包安装好后会自动生成主配置文件的范本文件 /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample 而在/etc 目录下会建立一个空白的dhcpd.conf 主配置文件。 ls /etc/dhcp/dhcpd.conf 现在我们将范本配置文件复制到/etc 目录下替换掉空白dhcpd.conf 主配置文件。 [root@xuegod63 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 6:服务启动关闭脚本,查看端口 [root@xuegod63 ~]# /etc/init.d/dhcpd start [root@xuegod63 ~]# chkconfig dhcpd on [root@xuegod63 ~]# chkconfig --list dhcpd dhcpd 0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭 修改其启动级别 [root@xuegod63 ~]# chkconfig --level 6 dhcpd on [root@xuegod63 ~]# chkconfig --level 3 dhcpd off [root@xuegod63 ~]# chkconfig --list dhcpd dhcpd 0:关闭1:关闭2:启用3:关闭4:启用5:启用6:启用 7:DHCP配置文件参数说明 说明: dhcp 范本配置文件内容包含了部分参数、声明以及选项的用法,其中注释部分可以放在任何位 置,并以“#”号开头,当一行内容结束时,以“;”号结束,大括号所在行除外 可以看出整个配置文件分成全局和局部两个部分。但是并不容易看出哪些属于参数,哪些属于声明和选项。 概念与协议: 作用域:可以分配IP的范围 subnet 地址池:可以分配给客户端的IP,range包括的IP 保留地址:指定某个客户端使用一个特定IP,通过host配置的 租约(时间):客户端可以使用这个IP地址的时间 配置文件:/etc/dhcp/dhcpd.conf 部分配置解释 # option definitions common to all supported networks... #定义全局配置,通用于所有支持的网络选项. option domain-name "example.org"; #为客户端指定所属的域 option domain-name-servers ns1.example.org, ns2.example.org; #为客户端指定DNS服务器地址 default-lease-time number(数字) default-lease-time 600; 作用:定义默认IP 租约时间,以秒为单位的租约时间。 50%:续约。(续不上继续用) 87.5%:再次续约。(续不上找别人) DHCP工作站除了在开机的时候发出 DHCPrequest 请求之外,在租约期限一半的时候也会发出 DHCPrequest ,如果此时得不到 DHCP服务器的确认的话,工作站还可以继续使用该IP;当租约期过了87.5%时,如果客户机仍然无法与当初的DHCP服务器联系上,它将与其它 DHCP服务器通信。如果网络上再没有任何DHCP协议服务器在运行时,该客户机必须停止使用该IP地址,并从发送一个Dhcpdiscover数据包开 始,再一次重复整个过程。要是您想退租,可以随时送出 DHCPRELEASE 命令解约,就算您的租约在前一秒钟才获得的。 (4)max-lease-time 7200; (数字) 作用:定义客户端IP租约时间的最大值,当客户端超过租约时间,却尚未更新IP 时,最长可以使用该IP 的时间; 例: 比如,机器在开机获得IP地址后,然后关机了。这时,当时间过了default-lease-time 600秒后,没有机器向DHCP续约,DHCP会保留7200秒,保留此IP地址不用于分配给其它机器。 当超过7200秒后,将不再保留此IP地址给此机器。 注意:(3)、(4)都是以秒为单位的租约时间,该项参数可以作用在全局配置中,也可以作用在局部配置中。 log-facility local7; #定义日志类型为 local7 声明一般用来指定IP 作用域、定义为客户端分配的IP 地址池等等 声明格式如下: subnet 网络号 netmask 子网掩码 { 选项或参数 } 常见声明的使用如下: (1)subnet 网络号 netmask 子网掩码 {......} 作用:定义作用域,指定子网 如: 注意:网络号必须与DHCP 服务器的网络号相同 下面介绍以下每个选项的含意: (1)range 起始IP 地址 结束IP 地址 作用:指定动态IP 地址范围 注意:可以在subnet(子网) 声明中指定多个range,但多个range 所定义IP 范围不能重复 常用选项介绍 选项通常用来配置DHCP 客户端的可选参数,比如定义客户端的DNS 地址、默认网关等等。选项 内容都是以option 关键字开始。 常见选项使用如下: (1)option routers IP 地址 作用:为客户端指定默认网关 如:option routers 10.5.5.1; (3)option domain-name-servers IP 地址 作用:为客户端指定DNS 服务器地址 注意:(1)、(2)、(3)选项可以用在全局配置中,也可以用在局部配置中。 租约数据库文件 租约数据库文件用于保存一系列的租约声明,其中包含客户端的主机名、MAC 地址、分配到的IP地址,以及IP地址的有效期等相关信息。这个数据库文件是可编辑的ASCII 格式文本文件。每 当发生租约变化的时候,都会在文件结尾添加新的租约记录。 DHCP 刚安装好后租约数据库文件dhcpd.leases 是个空文件 /var/lib/dhcpd/dhcpd.leases 当DHCP 服务正常运行后就可以使用cat 命令查看租约数据库文件内容了 实例: 1:分配IP地址 公司有60 台计算机,IP 地址段为192.168.1.2-192.168.1.254,子网掩码是255.255.255.0,网关为192.168.1.1,保留地址段192.168.1.2-192.168.1.30 网段地址给服务器配置,客户端可以使用的地址段为192.168.1.100—192168.1.200,其余剩下的IP 地址为保留地址。 实验环境: 我的虚拟机使用桥接模式是否可行? 不行,因为你的局域网中有可能就有DHCP服务器,这样你就很难让你的客户端是从你的DHCP服务器获得IP地址。另外,也可能造成公司局域网中其它机器因为获得了你DHCP服务器上的IP地址,而上不了网。 xuegod63.cn :192.168.0.63 虚拟机网卡: vmnet4 xuegod64.cn :192.168.0.64 虚拟机网卡: vmnet4 [root@xuegod63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 [root@xuegod63 ~]# service network restart 1):修改DHCP配置文件 [root@xuegod63 ~]# vim /etc/dhcp/dhcpd.conf 只保留: subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.100 192.168.0.200; option domain-name-servers 192.168.0.1; option domain-name "internal.example.org"; option routers 192.168.0.1; option broadcast-address 192.168.0.255; default-lease-time 600; max-lease-time 7200; } 2):重启dhcp服务 [root@xuegod63 ~]# service dhcpd restart 然后xuegod64改为自动获取IP地址。 将xuegod63和xuegod64 的网卡模式改为: 然后xuegod64改为自动获取IP地址。 查看: [root@xue63 ~]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0C:29:12:EC:1E inet addr:192.168.0.200 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe12:ec1e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5084 errors:0 dropped:0 overruns:0 frame:0 TX packets:5087 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:664380 (648.8 KiB) TX bytes:521089 (508.8 KiB) 3)查看默认网关 [root@xue63 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 4)查看DNS [root@xue63 ~]# cat /etc/resolv.conf ; generated by /sbin/dhclient-script search internal.example.org com nameserver 192.168.0.1 5)查看租约数据库文件 [root@xuegod64 dhcp]# cat /var/lib/dhcpd/dhcpd.leases # The format of this file is documented in the dhcpd.leases(5) manual page. # This lease file was written by isc-dhcp-4.1.1-P1 server-duid "\000\001\000\001\030\233\206H\000\014)H\200\237"; lease 192.168.0.200 { starts 3 2013/01/30 07:30:16; ends 3 2013/01/30 07:40:16; cltt 3 2013/01/30 07:30:16; binding state active; next binding state free; hardware ethernet 00:0c:29:12:ec:1e; } 2:IP 地址绑定 在DHCP 中的IP 地址绑定用于给客户端分配固定IP 地址。比如服务器需要使用固定IP 地址就可以使用IP 地址绑定,通过MAC 地址与IP 地址的对应关系为指定的物理地址计算机分配固定IP地址。 整个配置过程需要用到 host 声明和hardware、fixed-address 参数。 (1)host 主机名 {......} 作用:用于定义保留地址 (2)hardware 类型 硬件地址 作用:定义网络接口类型和硬件地址。常用类型为以太网(ethernet),地址为MAC 地址。 (3)fixed-address IP 地址 作用:定义DHCP 客户端指定的IP 地址。 [root@xuegod63 ~]# vim /etc/dhcp/dhcpd.conf # 找到对应的子网范围,修改成以下内容 subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.100 192.168.0.200; option domain-name-servers 192.168.0.1; option domain-name "internal.example.org"; option routers 192.168.0.1; option broadcast-address 192.168.0.255; default-lease-time 600; max-lease-time 7200; host xuegod63 { #这一段内容,要写在subnet字段中,和subnet配合使用。 hardware ethernet 00:0C:29:12:ec:1e; fixed-address 192.168.0.251; } } 本文转自 于学康 51CTO博客,原文链接:http://blog.51cto.com/blxueyuan/1881045,如需转载请自行联系原作者
之前一直在找除了reboot能识别出新添加lun的方式,偶然的一次机会在微博上发现了,在这里share出来,感谢EMC support网站! 介绍 Linux系统扫描SCSI磁盘有几种方式?Linux新增LUN之后,能否不重启主机就认出设备?如果安装了PowerPath,动态添加/删除LUN的命令是什么?本文总结了Linux主机对磁盘设备进行重新配置的方式,并附加命令实例。 更多信息 Linux系统提供多重机制以重新扫描SCSI总线并重认系统中加入的SCSI设备。在2.4内核方案中,由于动态LUN扫描机制不具备一致性,往往需要中断I/O。 2.6内核里,LUN扫描有了显著改进并添加了动态LUN扫描机制。Linux目前缺乏像drvconfig或ioscan那样允许动态SCSI通道重配的命令。 Linux主机对磁盘设备进行重新配置的方式包括: 重启系统 卸载并重新加载HBA驱动模块 Echo /proc下的SCSI设备列表 通过/sys下的属性设置运行SCSI扫描 通过HBA厂商脚本运行SCSI扫描 系统重启 重启主机是检测新添加磁盘设备的可靠方式。在所有I/O停止之后方可重启主机,同时静态或以模块方式连接磁盘驱动。系统初始化时会扫描PCI总线,因此挂载其上的SCSI host adapter会被扫描到,并生成一个PCI device。之后扫描软件会为该PCI device加载相应的驱动程序。加载SCSI host驱动时,其探测函数会初始化SCSI host,注册中断处理函数,最后调用scsi_scan_host函数扫描scsi host adapter所管理的所有scsi总线。 重新加载HBA驱动 通常情况下,HBA驱动在系统中以模块形式加载。从而允许模块被卸载并重新加载,在该过程中SCSI扫描函数得以调用。通常,在卸载HBA驱动之前,SCSI设备的所有I/O都应该停止,卸载文件系统,多路径服务应用也需停止。如果有代理或HBA应用帮助模块,也应当中止。 命令示例: 例如,rac节点上某台服务器执行fdisk –l命令看不到共享磁盘,可尝试执行如下命令: # modprobe -r lpfc(卸载驱动) # modprobe lpfc(加载驱动) /proc下SCSI扫描 2.4内核中,/proc文件系统提供了可用SCSI设备的列表。如果系统中SCSI设备重新配置,那么所有这些改变通过echo /proc接口反映到SCSI设备中。添加一个设备,主机,channel,target ID,以及磁盘设备的LUN编号会被添加到/proc/scsi/,需指定scsi编号。 命令示例: # echo "scsi add-single-device 0 1 2 3" > /proc/scsi/scsi 0:主机ID 1:channel ID 2:target ID 3:LUN编号 该命令会将新磁盘设备添加到/proc/scsi/scsi文件中。如果没有找到相应文件,需为/dev路径下新增磁盘设备创建设备文件名。 如果要删除一个磁盘设备,使用适当的主机,channel,target ID及LUN编号运行如下格式命令: # echo "scsi remove-single-device 0 1 2 3" > /proc/scsi/scsi 0:主机ID 1:channel ID 2:target ID 3:LUN编号 /sys下SCSI扫描 2.6内核中,HBA驱动将SCAN功能导出至/sys目录下,可用来重新扫描该接口下的SCSI磁盘设备。命令如下: # cd /sys/class/scsi_host/host4/ # ls -al scan # echo ‘- - -’ > scan ‘- - -’代表channel,target和LUN编号。以上命令会导致hba4下所有channel,target以及可见LUN被扫描。 RHEL5 或SUSE10: echo ‘- - -’ > /sys/class/scsi_host/host0/scan /sys/class/scsi_host/ 下面有几个host 就扫描几次 RHEL4 或SUSE9: echo 1 >> /sys/class/scsi_host/host0/issue_lip 同样是/sys/class/scsi_host/ 下面有几个host 就执行几次 echo ‘- - -’ >> /sys/class/scsi_host/host0/scan 在现有PowerPath环境中增加LUN: 1. 1.确保存储端已配置好LUN并输出给Linux 主机 2. 2.通过powermt命令获得HBA 卡列表,并扫描列表中所有的HBA echo ‘- - -’ > /sys/class/scsi_host/host#/scan 例如, 如果powermt 显示列出HBA 4 和5, 使用如下命令开始扫描: echo ‘- - -’ > /sys/class/scsi_host/host4/scan echo ‘- - -’ > /sys/class/scsi_host/host5/scan 3. 3.运行powermt config 配置新认到的磁盘,生成虚拟设备 4. 4.用powermt display 检查新认到的LUN 及设备路径 在现有PowerPath环境中动态删除 LUN 注意,必须严格遵守操作次序,如果次序有误可能会造成主机OS panic。 1. 1.在将要删除的设备上停止所有的I/O。 2. 2.通过以下命令确定虚拟设备对应的原始SCSI设备: powermt display dev=emcpower<id> 3. 3.删除虚拟设备 powermt remove dev=emcpower<id> 4. 4.回收虚拟设备号以备后用 powermt release 如果此命令失败,已删除的虚拟设备仍会存在于/dev 和/sys/block 下,并且在以后动态添加新LUN时可能会引发问题。 5. 5.对每个原始SCSI 设备执行以下命令: echo 1 > /sys/block/sd<id>/device/delete 此命令使PowerPath 停止这些原始sd 设备上的I/O 并且将其从/dev 和/sys/block下移除。如此命令执行不成功,在以后动态添加新LUN时可能会引发问题。 6. 6.在存储阵列中删除对应的LUN,执行powermt display 验证设备已被删除。 通过HBA厂商脚本进行SCSI扫描 QLogic 利用QLogic FC HBA LUN Scan Utility 脚本即可无需重启动系统而识别新添加的LUN。也无需对QLogic FC driver 的重新加载。 命令示例: 通过以下命令重新扫描所有HBA: # ./ql-dynamic-tgt-lun-disc.sh # ./ql-dynamic-tgt-lun-disc.sh -s # ./ql-dynamic-tgt-lun-disc.sh –scan 重新扫描并删除丢失的LUN,使用以下两个命令其中任何一个: # ./ql-dynamic-tgt-lun-disc.sh -s -r # ./ql-dynamic-tgt-lun-disc.sh --scan –refresh Emulex 使用 Emulex LUN Scan Utility 脚本可以动态扫描新添加的LUN。 命令示例: # gunzip lun_scan.sh.gz # chmod a+x lun_scan 扫描所有lpfc HBA: # lun_scan all 扫描scsi主机编号2的lpfc HBA: # lun_scan 2 之后确认OS 识别到新设备: # fdisk -l 如果系统中有PowerPath ,还需要运行: # powermt config 参考 EMC Host Connectivity Guide for Linux 应用于 Linux主机Kernel 2.4、2.6版本 RHEL, SUSE 本文转自 taojin1240 51CTO博客,原文链接:http://blog.51cto.com/taotao1240/1078687,如需转载请自行联系原作者
系统 # uname -a ------ 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue ------ 查看操作系统版本 # cat /proc/cpuinfo ------ 查看CPU信息 # hostname ------ 查看计算机名 # lspci -tv ------ 列出所有PCI设备 # lsusb -tv ------ 列出所有USB设备 # lsmod ------列出加载的内核模块 # env ------查看环境变量 资源 # free -m ------ 查看内存使用量和交换区使用量 # df -h ------ 查看各分区使用情况 # du -sh ------ 查看指定目录的大小 # grep MemTotal /proc/meminfo ------ 查看内存总量 # grep MemFree /proc/meminfo ------ 查看空闲内存量 # uptime ------ 查看系统运行时间、用户数、负载 # cat /proc/loadavg ------ 查看系统负载 磁盘和分区 # mount | column -t ------查看挂接的分区状态 # fdisk -l ------ 查看所有分区 # swapon -s ------ 查看所有交换分区 # hdparm -i /dev/hda ------ 查看磁盘参数(仅适用于IDE设备) # dmesg | grep IDE ------查看启动时IDE设备检测状况 网络 # ifconfig ------ 查看所有网络接口的属性 # iptables -L ------ 查看防火墙设置 # route -n ------查看路由表 # netstat -lntp ------ 查看所有监听端口 # netstat -antp ------ 查看所有已经建立的连接 # netstat -s ------ 查看网络统计信息 进程 # ps -ef ------ 查看所有进程 # top ------ 实时显示进程状态 用户 # w ------查看活动用户 # id ------ 查看指定用户信息 # last ------ 查看用户登录日志 # cut -d: -f1 /etc/passwd ------查看系统所有用户 # cut -d: -f1 /etc/group ------ 查看系统所有组 # crontab -l ------ 查看当前用户的计划任务 服务 # chkconfig --list ------ 列出所有系统服务 # chkconfig --list | grep on ------ 列出所有启动的系统服务 程序 # rpm -qa ------ 查看所有安装的软件包 本文转自 kk5234 51CTO博客,原文链接:http://blog.51cto.com/kk5234/379429,如需转载请自行联系原作者
我们在使用Hibernate构建的项目中可以快速的添加搜索功能。在这里我只想更详解的介绍一下,它们结合时使用的工作原理。了解了工作原理,至于程序怎么实现就可以。 首先,我们知道Hibernate是比较有名的ORM框架,它的主要作用,就是让我们的开发更接近现实生活。现在虽然有很多数据库已经是“对象型的数据库”,但在我们还是比较喜欢用一些关系型数据库。好像我们已经习惯了用这些数据库。只要有关系数据库,要想让我们的程序真正的OOP(面向对象编程)。就少不了这样一个中间组件,对象关系映射(ORM)。这个框架很方便的帮助我们实现了,把以前对关系数据库的操作,变成了我们大家都比较熟悉的面向一些简单的java类操作,也就是对一些又简单又古老的对象(pojo)的操作。 简单的了解一下Hibernate。 <1>hibernate技术本质上是一个提供数据服务的中间件。是一个面向Java环境的对象/关系数据库映射工具。把Java 类对应到数据库的table中,并且采用了xml技术。JavaReflection技术等。同时也提供了数据查询和恢复等机制。可以大幅度减少开发时人工使用SQL和JDBC处理数据的时间。 <2>是一个开发源代码的对象关系映射框架。它对JDBC进行了非常轻量级的对象封装。可以应用到任何可以使用JDBC的场合。 上面的简单的介绍了一下hiberante。而compass又是对lucene的简单的封装。好比hibernate对JDBC的封装。它们很相似的。Compass的设计原则就是按照Hibernate的使用习惯而设计的,所以对Hibernate了解的,对学习Compass也是很简单的。 Compass和Hibernate的结合使用,Hibernate就是充当了中间桥梁。Hibernate主要负责对象到数据库的映射。而Compass又可以充分利用已有的对象,间接的与数据库联系,来实现搜索。在利用Compass时,我们首先要对每个表对应的pojo为基础建立索引。同时保持数据的同步。我们可以简单的用图表示如下: 希望看来这个图示,可以让你对了解Compass和Hibernate的结合使用。 不明的地方,可以提出,我会尽力解答的。 本文转自 weijie@java 51CTO博客,原文链接:http://blog.51cto.com/weijie/74656,如需转载请自行联系原作者
在我们域环境中,经常需要执行备份操作,以防域数据在错误操作的时候丢失,当我们想还原的时候就需要我们日常备份和非授权还原了! 下面我们看看在windows 2008 R2中怎样执行备份操作和怎么执行非授权还原? 下面看具体步骤: (1)安装具体windows server backup组件: (2)在管理工具里打开windows server backup,然后执行一次性备份(记得如果备份不要备份到C盘,可以备份到D盘或者其他盘,也可以备份到网络服务器) (3)备份选项(看你是对C盘执行完全备份,还是 只需要对DC状态备份),不过我们DC一般没有特许安装其他东西的话,执行自定义,做DC状态备份就可以了)。 (4)执行备份路径选择,然后我们再\\cnshe02wk6026看到具体数据了。 到这里,我们备份选项已经完成了, (5)备份前我们DC的用户数据 (6)我们删除Longsimiao这个用户,执行非授权还原 下面截图是我们删除该用户的状态: 我们接下来操作备份的系统状态还原。 (1)我们用本地管理员登陆DC,执行 windows server backup,然后执行还原操作: (2)选择还原系统状态,将我们刚刚存在网络路径的系统状态输入: (3)下图就是具体的恢复系统状态过程了: (4)我们重新用域管理员账户登陆DC,此时看到,我们已经成功还原了DC误删的用户,实验已经成功: 另外一种备份方法(用命令行): 注:backuptarget是用来指定存储备份的位置。 1:备份系统状态: wbadmin start systemstatebackup -backuptarget: \\cnshe02wk6026\backup 2:或许备份状态文件的版本号: wbadmin get versions -backuptarget: \\cnshe02wk6026\backup 3:根据获得的版本号执行还原操作: wbadmin start systemstaterecovery -version: 04/23/2012-01:13 -backuptarget: \\cnshe02wk6026\backup 总结:通过以上一系列操作,已经成功的还原了误删的用户,在实际工作中,我们一定要认识到备份的重要性,可以用光盘,U盘,移动硬盘,一定要多做灾难恢复,模拟实际故障,不要等到服务器真的出了问题而乱了方寸,最后是老板不高兴,你自己也处于尴尬的境地。 下篇我们可能会讲到:授权还原,当有两台域控,另一台域控是可写的时候,要恢复系统状态和用户的具体操作 本文转自 149banzhang 51CTO博客,原文链接:http://blog.51cto.com/149banzhang/841455,如需转载请自行联系原作者
1 介绍部分 1.1 前言 弟弟店铺要安装监控,故向其推荐企业级别的监控UBNT的产品Unifi-Video(笔者推荐UBNT的原因是其一直坚持软件免费,相比某些厂商软件按点数收取授权费的劣举UBNT算是非常有良心)。 由于官方的监控主机Unifi NVR配置比较低(其实是硬盘太小)价格相对贵,故自己定制6端口的工控机作为监控主机(可同时当路由和交换机用^_^,省钱),以下是硬件的截图。 1.2 功能简介 1)具有数字监控主机功能 2)充当路由功能(1口自动获取IP地址,2口待定) 3)充当交换机功能(3至6口可接摄像头) 1.3 系统架构图 注:以下实践部分就是定制软路由(工控主机)的配置过程。 2 实践部分 2.1 环境配置 2.1.1 系统环境 hostnanme=ubnt.cmdschool.org eth0=dhcp br0=10.168.1.1 eth[2-5]=10.168.1.x/24 OperatingSystem=Debian8.6 如果读者跟我一样是Debian的初学者,可参考以下系统层的配置教程: http://cmdschool.blog.51cto.com/2420395/1877915 2.1.2 下载安装包 网页下载安装包 https://www.ubnt.com/download/unifi-video 命令行下载 1 wget http://dl.ubnt.com/firmwares/unifi-video/3.5.2/unifi-video_3.5.2~Debian7_amd64.deb 2.1.3 配置apt源 1 vi /etc/apt/sources.list 注解掉以下行 1 #deb cdrom:[Debian GNU/Linux 8.6.0 _Jessie_ - Official amd64 DVD Binary-1 20160917-14:25]/ jessie contrib main 保存退出后运行以下命令: 1 2 3 4 echo "deb http://ftp.cn.debian.org/debian Debian8.6 main" | tee /etc/apt/sources.list.d/debian.list echo "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" | tee /etc/apt/sources.list.d/mongodb-10gen.list echo "deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti" | tee /etc/apt/sources.list.d/unifi.list apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50; apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 更新源仓库: 1 apt-get update 2.1.4 安装包管理工具并更新库 1 2 apt-get install aptitude; apt-get install -f; apt-get clean aptitude update 2.1.5 配置时区 1 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 2.1.6 时间同步 1)安装时间同步相关包 1 aptitude install chrony 2)同步时间 1 chronyc sources 2.2 安装unifi-video程序 2.2.1 安装unifi-video并解决依赖关系兼清理包缓存 1 dpkg -i unifi-video_3.5.2~Debian7_amd64.deb; apt-get install -f; apt-get clean 2.2.2 命令行检查服务启动 1 netstat -antp | grep unifi-video 显示如下: 1 2 3 4 tcp6 0 0 :::7080 :::* LISTEN 7381/unifi-video tcp6 0 0 127.0.0.1:7081 :::* LISTEN 7381/unifi-video tcp6 0 0 :::7443 :::* LISTEN 7381/unifi-video [...] 2.2.3 浏览器确认服务正常 2.3 修改数据存储位置 2.3.1 确定视频存储位置 1 find / -name \*.mp4\* 注:需要先配置枪录制视频(界面部分不详述) 显示如下: 1 2 3 4 [...] /var/lib/unifi-video/videos/e7219371-8d34-3744-a4b5-89acba09907c/2016/12/03/1480745255035_1480745257035_1480737512125_9603951.mp4 /var/lib/unifi-video/videos/e7219371-8d34-3744-a4b5-89acba09907c/2016/12/03/1480743257037_1480743259037_1480737512125_7605951.mp4 [...] 基于以上,可确定存储目录为(2TB的硬盘应挂在到这目录下): 1 /var/lib/unifi-video 2.3.2 确认系统检测到安装的硬盘 1 fdisk -l 显示如下: 1 2 3 [...] Disk /dev/sdb doesn't contain a valid partition table [...] 2.3.3 硬盘分区 1 fdisk /dev/sdb 显示如下: 1 2 3 4 5 6 7 8 [...] Command (m for help): n [...] Select (default p): p Partition number (1-4, default 1): [...] Command (m for help): w [...] 发现新分区: 1 partx /dev/sdb 2.3.4 创建PV 1 pvcreate /dev/sdb1 2.3.5 创建VG 1 vgcreate dataStore /dev/sdb1 2.3.6 创建LV 1 lvcreate -L 1999g -n data dataStore 2.3.7 格式化分区 1 mkfs.ext4 /dev/mapper/dataStore-data 2.3.8 取得格式化过分区的UUID 1 blkid /dev/mapper/dataStore-data 显示如下: 1 /dev/mapper/dataStore-data: UUID="0d1dc121-7bd0-46bd-8d85-5577ab322efc" TYPE="ext4" 2.3.9 停止unifi-video服务 1 2 /etc/init.d/unifi-video stop /etc/init.d/mongodb stop 2.3.10 数据迁移 1 2 3 mount /dev/mapper/dataStore-data /mnt/ mv /var/lib/unifi-video/* /mnt umount /mnt 2.3.11 挂载卷 1 2 echo 'UUID="0d1dc121-7bd0-46bd-8d85-5577ab322efc" /var/lib/unifi-video ext4 defaults 1 2' >> /etc/fstab mount -a 2.3.12 启动unifi-video服务 1 2 /etc/init.d/mongodb start /etc/init.d/unifi-video start 2.4 安装桌面环境 2.4.1 lxde的最小安装 1)安装相关包 1 2 aptitude install xinit slim lightdm aptitude install --without-recommends lxde-core 2)配置启动方式 1 2 echo 'exec startlxde' > ~/.xinitrc update-alternatives --config x-session-manager 3)配置自动登录 1 vi /etc/slim.conf 修改配置如下: 1 2 default_user ubnt auto_login yes 2.4.2 安装谷歌浏览器 1)下载安装包 下载页面: http://www.google.cn/chrome/browser/desktop/index.html 下载的命令: 1 https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 2)启动安装 1 dpkg -i google-chrome-stable_current_amd64.deb;apt-get install -f 2.4.3 支持中文 1 aptitude install fonts-droid 2.5 集成路由与交换功能 2.5.1 增加网桥 1)安装桥套件 1 aptitude install bridge-utils 2)创建桥接口 1 brctl addbr br0 注,删除请使用 1 brctl delbr br0 2.5.2 给网卡接口分配特定功能 1 vim /etc/network/interfaces 加入如下配置: 1 2 3 4 5 6 7 8 9 10 auto eth0 allow-hotpulg eth0 iface eth0 inet dhcp auto br0 iface br0 inet static address 10.168.1.1 netmask 255.255.255.0 bridge_ports eth2 eth3 eth4 eth5 up /usr/sbin/brctl stp br0 on 注:eth0自动获取IP,eth2-5网桥模式(相当于交换机) 重启服务使配置生效: 1 /etc/init.d/networking restart 2.5.3 开启路由转发功能 1)临时开启路由转发 1 echo 1 > /proc/sys/net/ipv4/ip_forward 2)永久开启路由转发 1 vim /etc/sysctl.conf 去掉此行的注解: 1 net.ipv4.ip_forward = 1 2.5.4 配置具有SNAT功能防火墙规则 1)创建防火墙规则 1 vim /etc/iptables.up.rules 输入如下配置: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 # Generated by iptables-save v1.4.21 on Mon Dec 5 07:48:46 2016 *filter :INPUT DROP [40:2032] :FORWARD ACCEPT [100631:98411806] :OUTPUT ACCEPT [61262:3785634] -A INPUT -i lo -j ACCEPT -A INPUT -i br0 -j ACCEPT -A INPUT -i eth0 -p icmp -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p tcp -m tcp --dport 7080 -j ACCEPT -A INPUT -p tcp -m tcp --dport 7443 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT COMMIT # Completed on Mon Dec 5 07:48:46 2016 # Generated by iptables-save v1.4.21 on Mon Dec 5 07:48:46 2016 *nat :PREROUTING ACCEPT [1094:127184] :INPUT ACCEPT [112:7768] :OUTPUT ACCEPT [53:3815] :POSTROUTING ACCEPT [77:13304] -A POSTROUTING -s 10.168.1.0/24 -o eth0 -j MASQUERADE COMMIT # Completed on Mon Dec 5 07:48:46 2016 2)配置开机自动加载 1 2 3 echo '#!/bin/sh' > /etc/network/if-pre-up.d/iptables echo '/sbin/iptables-restore < /etc/iptables.up.rules' >> /etc/network/if-pre-up.d/iptables chmod +x /etc/network/if-pre-up.d/iptables 2.5.5 配置DHCP服务 1)安装DHCP服务 1 aptitude install isc-dhcp-server 2)修改主配置文件 1 2 cp /etc/default/isc-dhcp-server /etc/default/isc-dhcp-server.default vi /etc/default/isc-dhcp-server 配置参数如下: 1 2 DHCPD_CONF=/etc/dhcp/dhcpd.conf INTERFACES="br0" 3)配置加载的子配置文件 1 2 cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.default vi /etc/dhcp/dhcpd.conf 配置如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 ddns-update-style none; option domain-name "cmdschool.org"; option domain-name-servers 202.96.128.86,202.96.128.166; default-lease-time 600; max-lease-time 7200; log-facility local7; subnet 10.168.1.0 netmask 255.255.255.0 { range 10.168.1.51 10.168.1.199; option routers 10.168.1.1; option broadcast-address 10.168.1.255; default-lease-time 600; max-lease-time 7200; } 4)启动服务 1 /etc/init.d/isc-dhcp-server start 2.5.6 配置花生壳域名解析 1)安装软件包 1 aptitude install curl 2)创建解析脚本 1 2 mkdir ~/script/ vim ~/script/pusoray.sh 输入如下配置(假设域名是cmdschool.org): 1 2 3 4 5 #!/bin/bash domain="cmdschool.org" user="username" pwd="password" /usr/bin/curl "http://$user:$pwd@ddns.oray.com/ph/update?hostname=$domain" 3)自动调用解析脚本 1 crontab -e 输入如下配置: 1 */3 * * * * sh ~/script/pusoray.sh 本文转自 tanzhenchao 51CTO博客,原文链接:http://blog.51cto.com/cmdschool/1878771,如需转载请自行联系原作者
也许: 您会问我,为什么会有超速-更新-地址簿? 项目中经常会遇到,客户负责人说,我新建了用户,我马上要可以查询到。 或许: 您会告诉他: 1) 新建用户 2) 启用邮箱 3) 启用Lync 4) 正常是晚上1:30服务器自动更新地址簿 5) 正常是大约1小时左右客户端更新地址簿 6) 也就是说,你今天新建的用户,没问题,明天可以看到,可以查询到 其实: 第4步,可以利用Windows计划任务让任何每1小时更新一次,或者每10分钟更新一次,更离谱是每1分钟更新一次。 第5步,你可以参照如下: Lync 小技巧-1-解决搜索不到联系人的方法 http://bbs.51cto.com/thread-1039629-1.html 我们今天就来做一下第4步中的操作,做完了,你才知道,其它太简单。 1) 准备-脚本 2) 准备-Windows 计划任务-xml Update-CsAddressBook-Lync.xml 3) 新建-Windows计划任务 注意:你也可以手动创建这个任务,我只是为了简单,省事。 注意-更新用户或组: 改为你自己的用户。 4) 检查 5) 同步成功 注意,下一次同步传递的启动时间:2013/8/26 1:30 这个时间不是你想要的,看下面的才是你想要的。 本文转自 CTO_LiuJinFeng 51CTO博客,原文链接:http://blog.51cto.com/dynamic/1282477,如需转载请自行联系原作者
1.命令行提示符,运行DISKPART,运行入提示符变成"DISKPART>";2.使用"LIST DISK"命令确定你的移动硬盘的##号;3.使用"Select DISK 0"将你的移动磁盘设置成当前操作磁盘;4.使用"Select PARTITION 1"将第一个分区设置成当前的操作分区;5.使用"INACTIVE"命令解除当前分区的活动状态。 本文转自 lgpqdwjh 51CTO博客,原文链接:http://blog.51cto.com/itchenyi/1011159,如需转载请自行联系原作者
一、故障现象: 查看ceph的集群状态:too many PGs per OSD (698 > max 300) 1 2 3 4 5 6 7 8 9 10 11 12 13 # ceph -s cluster e2ca994a-00c4-477f-9390-ea3f931c5062 health HEALTH_WARN too many PGs per OSD (698 > max 300) monmap e1: 3 mons at {hz-01-ops-tc-ceph-02=172.16.2.231:6789/0,hz-01-ops-tc-ceph-03=172.16.2.172:6789/0,hz-01-ops-tc-ceph-04=172.16.2.181:6789/0} election epoch 14, quorum 0,1,2 hz-01-ops-tc-ceph-03,hz-01-ops-tc-ceph-04,hz-01-ops-tc-ceph-02 osdmap e54: 5 osds: 5 up, 5 in flags sortbitwise,require_jewel_osds pgmap v1670: 1164 pgs, 3 pools, 14640 kB data, 22 objects 240 MB used, 224 GB / 224 GB avail 1164 active+clean # ceph --show-config | grep mon_pg_warn_max_per_osd mon_pg_warn_max_per_osd = 300 二、调整ceph配置信息 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 # cd /my-cluster # vim ceph.conf 添加如下参数: mon_pg_warn_max_per_osd = 1024 # ceph-deploy --overwrite-conf config push hz-01-ops-tc-ceph-04 hz-01-ops-tc-ceph-02 hz-01-ops-tc-ceph-03 [ceph_deploy.conf][DEBUG ] found configuration file at: /root/.cephdeploy.conf [ceph_deploy.cli][INFO ] Invoked (1.5.39): /usr/bin/ceph-deploy --overwrite-conf config push hz-01-ops-tc-ceph-04 hz-01-ops-tc-ceph-02 hz-01-ops-tc-ceph-03 [ceph_deploy.cli][INFO ] ceph-deploy options: [ceph_deploy.cli][INFO ] username : None [ceph_deploy.cli][INFO ] verbose : False [ceph_deploy.cli][INFO ] overwrite_conf : True [ceph_deploy.cli][INFO ] subcommand : push [ceph_deploy.cli][INFO ] quiet : False [ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7fb51b241320> [ceph_deploy.cli][INFO ] cluster : ceph [ceph_deploy.cli][INFO ] client : ['hz-01-ops-tc-ceph-04', 'hz-01-ops-tc-ceph-02', 'hz-01-ops-tc-ceph-03'] [ceph_deploy.cli][INFO ] func : <function config at 0x7fb51bac8320> [ceph_deploy.cli][INFO ] ceph_conf : None [ceph_deploy.cli][INFO ] default_release : False [ceph_deploy.config][DEBUG ] Pushing config to hz-01-ops-tc-ceph-04 [hz-01-ops-tc-ceph-04][DEBUG ] connected to host: hz-01-ops-tc-ceph-04 [hz-01-ops-tc-ceph-04][DEBUG ] detect platform information from remote host [hz-01-ops-tc-ceph-04][DEBUG ] detect machine type [hz-01-ops-tc-ceph-04][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf [ceph_deploy.config][DEBUG ] Pushing config to hz-01-ops-tc-ceph-02 [hz-01-ops-tc-ceph-02][DEBUG ] connected to host: hz-01-ops-tc-ceph-02 [hz-01-ops-tc-ceph-02][DEBUG ] detect platform information from remote host [hz-01-ops-tc-ceph-02][DEBUG ] detect machine type [hz-01-ops-tc-ceph-02][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf [ceph_deploy.config][DEBUG ] Pushing config to hz-01-ops-tc-ceph-03 [hz-01-ops-tc-ceph-03][DEBUG ] connected to host: hz-01-ops-tc-ceph-03 [hz-01-ops-tc-ceph-03][DEBUG ] detect platform information from remote host [hz-01-ops-tc-ceph-03][DEBUG ] detect machine type [hz-01-ops-tc-ceph-03][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf 在mon节点上重启服务: # systemctl restart ceph-mon.target 三、然后在管理节点上再次查看集群 1 2 3 4 5 6 7 8 9 10 11 12 # ceph -s cluster e2ca994a-00c4-477f-9390-ea3f931c5062 health HEALTH_OK monmap e1: 3 mons at {hz-01-ops-tc-ceph-02=172.16.2.231:6789/0,hz-01-ops-tc-ceph-03=172.16.2.172:6789/0,hz-01-ops-tc-ceph-04=172.16.2.181:6789/0} election epoch 20, quorum 0,1,2 hz-01-ops-tc-ceph-03,hz-01-ops-tc-ceph-04,hz-01-ops-tc-ceph-02 osdmap e54: 5 osds: 5 up, 5 in flags sortbitwise,require_jewel_osds pgmap v1779: 1164 pgs, 3 pools, 14640 kB data, 22 objects 240 MB used, 224 GB / 224 GB avail 1164 active+clean # ceph --show-config | grep mon_pg_warn_max_per_osd mon_pg_warn_max_per_osd = 1024 本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/2061192,如需转载请自行联系原作者
NTOP是一种灵活且功能齐全的用来监控解决局域网问题的工具,它同时提供命令行输入和Web界面,可以用于嵌入式Web服务。本文介绍如何在RHEL5中构建NTOP监测系统。 一.安装NTOP监测系统所需的软件包: 1.安装NTOP软件包需要libpcap、libcap-devel、libpng、gdbm、gd等软包包的支持,先检查你的RHEL5系统中是否已经安装这些包,如果没有安装,只需挂载RHEL5系统光盘,来安装对应的RPM包即可: [root@linux5234~]#rpm -qa |grep libpcap [root@linux5234~]#rpm -qa |grep libpcap-devel [root@linux5234~]#rpm -qa |grep libpng [root@linux5234~]#rpm -qa |grep gdbm [root@linux5234~]#rpm -qa |grep gd 检查以上包是否安装,如果没安装,挂载RHEL5光盘一一安装 2.安装RRDtool绘图工具包(rrdtool-1.2.27.tar.gz ): [root@linux5234~]#tar zxf rrdtool-1.2.27.tar.gz [root@linux5234~]#cd rrdtool-1.2.27 [root@linux5234~]#./configure --prefix=/usr/local [root@linux5234~]#make && make install 3.编译安装NTOP软件包(ntop-3.3.7.tar.gz): [root@linux5234 ~]# tar zxf ntop-3.3.7.tar.gz [root@linux5234 ~]# cd ntop-3.3.7 [root@linux5234 ntop-3.3.7]# ./autogen.sh --with-tcpwrap [root@linux5234 ntop-3.3.7]# make && make install 配置--with-tcpwrap选项用于支持TCP Wrappers访问控制 二.配置NTOP监测系统: 1.设置NTOP数据存放目录,NTOP系统默认以低权限用户nobody身份运行,为了使ntop可以读写数据,需要对默认的存放目录/usr/local/var/ntop进行权限调整: [root@linux5234~]#chown -R nobody /usr/local/var/ntop 2.为NTOP管理员设置密码,NTOP默认的管理员为admin,为安全起见,需要为其设置一个密码。另外,通过web页面修改NTOP设置或者关闭NTOP服务时,必须使用管理员用户名和密码进行验证: [root@linux5234 ~]# ntop -A Tue Oct 19 10:05:15 2010 NOTE: Interface merge enabled by default Tue Oct 19 10:05:15 2010 Initializing gdbm databases ntop startup - waiting for user response! Please enter the password for the admin user: //输入密码 Please enter the password again: //重复输入密码 Tue Oct 19 10:05:43 2010 Admin user password has been set 3.设置TCP Wrapper权限,在编译ntop时我们使用了--with-tcpwrap配置项,因此可以通过TCP Wrapper策略对ntop的访问进行控制: [root@linux5234 ~]# echo 'ntop:192.168.0.88' >> /etc/hosts.allow //只允许主机192.168.0.88访问NTOP服务 [root@linux5234 ~]# echo 'ntop:ALL' >> /etc/hosts.deny //其它用户均拒绝 4.运行NTOP服务: [root@linux5234 ~]# ntop -d -i eth0 //以后台守护进程的方式(-d)运行NTOP服务,并监测eth0网卡所连接的流量 如果有多块网卡,可以使用以下命令连接不同的局域网段: [root@linux5234 ~]# ntop -d -i eth0,eth1 -M 另外ntop程序的各选项可以写入到配置文件中(每行一条选项),然后通过“ntop@配置文件”的形式启动服务。以下为ntop程序常用的选项: 选项名称 含义 -c / --sticky-hosts 保留非活动主机的记录 -P / --db-file-path 指定新的数据存放记录 -u / --user 指定运行程序的用户身份 -b / --disable-decoders 关闭协议解码器 -n / --numeric-ip-address 使用数字形式的主机标识(不做NDS解析) -w / --http-server 指定监听HTTP访问的端口(默认为3000) 三.使用NTOP监测网络流量 1.从指定主机192.168.0.88访问NTOP的流量监测页面 在浏览器中输入“http://192.168.0.66:3000”访问NTOP服务器: 2.查看局域网各主机总的网络吞吐率: 在打开的NTOP界面中,鼠标移动到页面上方的"ALL Protocols",点击下拉菜单中的“Throughput”(吞吐率)即可,如下图所示: 3.按时间段查看各主机的带宽占用情况: 在NTOP web界面中将鼠标移动到页上方“All Protocols”,点击下拉菜单中的“Activity”即可: 4.按应用层协议分类查看各主机流量统计信息: 在NTOP系统的web界面中,将鼠标移动到页面上方的“IP”,依次点击下拉菜单中的“Summary”,“Traffic”即可: 5.关闭NTOP服务: 在NTOP的web界面中,将鼠标移动到页面上方的“Admin”,点击下拉菜单中的“Shutdown”,在弹出的对话框中输入管理员用户名和密码即可: 本文转自 kk5234 51CTO博客,原文链接:http://blog.51cto.com/kk5234/407510,如需转载请自行联系原作者
1、查看OSD的分布信息: 1 2 3 4 5 6 7 8 9 10 11 12 13 # ceph osd tree ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY -1 0.21950 root default -2 0.04390 host hz-01-ops-tc-ceph-01 0 0.04390 osd.0 up 1.00000 1.00000 -3 0.04390 host hz-01-ops-tc-ceph-02 1 0.04390 osd.1 up 1.00000 1.00000 -4 0.04390 host hz-01-ops-tc-ceph-03 2 0.04390 osd.2 up 1.00000 1.00000 -5 0.04390 host hz-01-ops-tc-ceph-04 3 0.04390 osd.3 up 1.00000 1.00000 -6 0.04390 host hz01-dev-ops-wanl-01 4 0.04390 osd.4 up 1.00000 1.00000 2、将osd.4移除OSD 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # ceph osd out 4 marked out osd.4. # ceph -s cluster e2ca994a-00c4-477f-9390-ea3f931c5062 health HEALTH_WARN 56 pgs degraded 1 pgs recovering 55 pgs recovery_wait 56 pgs stuck unclean recovery 604/1692 objects degraded (35.697%) monmap e1: 3 mons at {hz-01-ops-tc-ceph-02=172.16.2.231:6789/0,hz-01-ops-tc-ceph-03=172.16.2.172:6789/0,hz-01-ops-tc-ceph-04=172.16.2.181:6789/0} election epoch 20, quorum 0,1,2 hz-01-ops-tc-ceph-03,hz-01-ops-tc-ceph-04,hz-01-ops-tc-ceph-02 osdmap e89: 5 osds: 5 up, 4 in flags sortbitwise,require_jewel_osds pgmap v68654: 1172 pgs, 4 pools, 2159 MB data, 564 objects 5491 MB used, 174 GB / 179 GB avail 604/1692 objects degraded (35.697%) 1116 active+clean 55 active+recovery_wait+degraded 1 active+recovering+degraded recovery io 87376 kB/s, 1 keys/s, 23 objects/s 3、在被删除OSD的那台ceph节点上的操作: 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 # systemctl stop ceph-osd@4 # ceph osd tree ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY -1 0.21950 root default -2 0.04390 host hz-01-ops-tc-ceph-01 0 0.04390 osd.0 up 1.00000 1.00000 -3 0.04390 host hz-01-ops-tc-ceph-02 1 0.04390 osd.1 up 1.00000 1.00000 -4 0.04390 host hz-01-ops-tc-ceph-03 2 0.04390 osd.2 up 1.00000 1.00000 -5 0.04390 host hz-01-ops-tc-ceph-04 3 0.04390 osd.3 up 1.00000 1.00000 -6 0.04390 host hz01-dev-ops-wanl-01 4 0.04390 osd.4 down 0 1.00000 # ceph osd crush remove osd.4 removed item id 4 name 'osd.4' from crush map # ceph auth del osd.4 updated # ceph osd tree ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY -1 0.17560 root default -2 0.04390 host hz-01-ops-tc-ceph-01 0 0.04390 osd.0 up 1.00000 1.00000 -3 0.04390 host hz-01-ops-tc-ceph-02 1 0.04390 osd.1 up 1.00000 1.00000 -4 0.04390 host hz-01-ops-tc-ceph-03 2 0.04390 osd.2 up 1.00000 1.00000 -5 0.04390 host hz-01-ops-tc-ceph-04 3 0.04390 osd.3 up 1.00000 1.00000 -6 0 host hz01-dev-ops-wanl-01 4 0 osd.4 down 0 1.00000 # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 39G 1.8G 37G 5% / devtmpfs 486M 0 486M 0% /dev tmpfs 497M 84K 497M 1% /dev/shm tmpfs 497M 26M 472M 6% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/vda1 1014M 121M 894M 12% /boot /dev/mapper/cl-home 19G 33M 19G 1% /home /dev/vdb1 45G 237M 45G 1% /var/lib/ceph/osd/ceph-4 tmpfs 100M 0 100M 0% /run/user/0 # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom vda 252:0 0 60G 0 disk ├─vda1 252:1 0 1G 0 part /boot └─vda2 252:2 0 59G 0 part ├─cl-root 253:0 0 38.3G 0 lvm / ├─cl-swap 253:1 0 2G 0 lvm [SWAP] └─cl-home 253:2 0 18.7G 0 lvm /home vdb 252:16 0 50G 0 disk ├─vdb1 252:17 0 45G 0 part /var/lib/ceph/osd/ceph-4 └─vdb2 252:18 0 5G 0 part # ceph -s cluster e2ca994a-00c4-477f-9390-ea3f931c5062 health HEALTH_OK monmap e1: 3 mons at {hz-01-ops-tc-ceph-02=172.16.2.231:6789/0,hz-01-ops-tc-ceph-03=172.16.2.172:6789/0,hz-01-ops-tc-ceph-04=172.16.2.181:6789/0} election epoch 20, quorum 0,1,2 hz-01-ops-tc-ceph-03,hz-01-ops-tc-ceph-04,hz-01-ops-tc-ceph-02 osdmap e79: 4 osds: 4 up, 4 in flags sortbitwise,require_jewel_osds pgmap v68497: 1164 pgs, 3 pools, 2159 MB data, 564 objects 6655 MB used, 173 GB / 179 GB avail 1164 active+clean 本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/2063598,如需转载请自行联系原作者
一、工厂方法模式简介(Brief Introduction) 工厂方法模式(Factory Method Pattern),定义一个用于创建对象的接口,让子类决定实例化哪一个类,工厂方法使一个类的实例化延迟到其子类中。 二、解决的问题(What To Solve) 工厂方法模式较简单工厂模式,修改时关闭的,扩展时开放的,完全符合开放-封闭原则。工厂方法使一个类的实例化延迟到其子类中。 三、工厂方法模式分析(Analysis) 1、工厂方法模式结构 Product抽象类,定义工厂方法所创建的对象接口。 ConcreteProduct实现类,具体的产品,实现Product接口。 Factory抽象类,声明工厂方法,该方法返回一个Product类型的对象。 ConcreteFactory类,抽象工厂类Factory的具体实现,返回一个ConcreteProduct实例 四.实例分析(Example) 1、场景 一个简单计算器,具有简单的加操作和减操作。结构如下图所示 Factory:抽象工厂方法类. AddFactory:加法工厂 SubFactory,减法工厂. Operation:抽象操作类 AddOperation:加法操作 SubOperation:减法操作 2、代码 1、抽象操作类Operation,及其具体实现类AddOperation、SubOperation /// <summary> /// 抽象操作类 /// </summary> public abstract class Operation { public int numberA; public int numberB; public abstract int GetResult(); } /// <summary> /// 加法操作 /// </summary> public class AddOperation : Operation { public override int GetResult() { return (this.numberA + this.numberB); } } /// <summary> /// 减法操作 /// </summary> public class SubOperation : Operation { public override int GetResult() { return (this.numberA - this.numberB); } } 2、抽象工厂类Factory及其具体工厂类AddFactory、SubFactory public abstract class Factory { public abstract Operation CreateOperation(); } public class AddFactory : Factory { public override Operation CreateOperation() { return new AddOperation(); } } public class SubFactory:Factory { public override Operation CreateOperation() { return new SubOperation(); } } 3、客户端代码 static void Main(string[] args) { Console.WriteLine("使用工厂方法进行计算"); Factory factory1 = new AddFactory(); Operation operation1= factory1.CreateOperation(); operation1.numberA = 10; operation1.numberB = 20; Console.WriteLine("{0}+{1}={2}", operation1.numberA, operation1.numberB, operation1.GetResult()); Factory factory2 = new SubFactory(); Operation operation2 = factory2.CreateOperation(); operation2.numberA = 10; operation2.numberB = 20; Console.WriteLine("{0}+{1}={2}", operation2.numberA, operation2.numberB, operation2.GetResult()); Console.Read(); } 3、实例运行结果 五、总结(Summary) 本文对工厂方法模式(Factory Method Pattern)的概念及其设计结构图简单地进行了描述,同样也以一个计算器的实例进行了说明,工厂方法模式较简单工厂模式,修改时关闭的,扩展时开放的,完全符合开放-封闭原则. 本文转自 灵动生活 51CTO博客,原文链接:http://blog.51cto.com/smartlife/259703,如需转载请自行联系原作者
一、文件或目录权限chmod rw- r-- r-- 。 ——— ——— ——— —— 所有者 所属组 其他人 受selinux限制 r可读=4 w可写=2 x可执行=1 chmod + 数字 +文件名 修改权限 -R 目录下所有子文件和子目录都批量的修改权限 chmod + u/g/o + 文件名 修改权限 a = ugo a - x 所有权限都减去执行权限 取消selinux限制有两种办法。 1,暂时性关闭selinux 2,永久性,修改selinux配置文件 二、更改所有者和所属组chown chown change owner 更改所有者 chown + 用户:组 + 文件 一次性更改用户和所属组 chgrp change group 更改所有组 chown -R 批量更改目录下所有文件的所有者或所属组 三、umask umask 决定默认文件目录权限 root umask默认值 0022 目录和文件的的不同。目录一定有x权限,进入目录就是执行目录,所以必须会有x权限 所以目录 777 减去 umask 文件则是由 666 减去 umask 例外:umask为003时,文件目录为664 666 - 003 =(rw-rw-rw-) - (-------wx)= rw-rw-r-- = 664 777 - 003 = (rwxrwxrwx)- (---------wx)=rwxrwxr-- = 774 四、隐藏权限lsattr_chattr chattr change file attributes on a linux file system chattr 设置隐藏权限命令 +i 将文件更改为只读文件,不可更改,不可删除,不能重命名 对目录而言,不能删除,不能创建新文件,不能重命名,但不能限制写已经存在的子文件内容 -i 取消i权限 (vi命令更改一个文件时,会保存一个缓存文件,例如修改1.txt时,会出现1.txt~文件,当wq保存退出后,会覆盖原文件。 设置隐藏权限i后,文件无法保存,会自动生成一个1.txt~缓存文件。) +a 对文件只能追加,可以更改时间信息(touch) 。不能删除,不能更改。不能重命名。例如日志、 对目录可以增加子文件,也可以更改子文件内容, -a 取消a权限 lsattr 查看隐藏权限命令 查看文件本身 或者 目录下的子目录和子文件 -R 查看目录和子目录下的文件的隐藏权限 -a 连隐藏文件的隐藏权限也查看 本文转自 小新锐 51CTO博客,原文链接:http://blog.51cto.com/13407306/1975419,如需转载请自行联系原作者