#!/bin/bash
#title :sendsms.sh
#description :This script will send
#author :Mike1Hsieh
#date :2016-10-19
#version :1.6
#usage :bash sendsms.sh
#notes :
#bash_version :
# 1.6 add
#
#==============================================================================
VER=1.6
reset='\e[39m\e[49m' # Text Reset
green='\e[32m' # Text Reset
red='\e[31m' # Text Reset
white='\e[97m' # Text Reset
Color_yellow='\e[33m' # Text Reset
print_HELP(){
echo -e "
${white}Script: $0 ${reset}
${white}Script Version : $VER${reset}
${white}參數說明 ${reset}
${green}\t\$1 : 簡訊內容 ${reset}
${green}\t\$2 : 簡訊群組 ${reset}
${green}\t\$3 : 簡訊等級 ${reset}
${white}$0 sendtxt group Level ${reset}
${white}舊有模式範例${reset}
${green}\t$0 \"SENDTXT\" \"444\" \"100\" ${reset}
${red} =========================${reset}
${green}\t -m | -M : 簡訊內容 ${reset}
${green}\t -g | -G : 簡訊群組 ${reset}
${green}\t -l | -L : 簡訊等級 ${reset}
${white}$0 -m sendtxt -g group -l Level ${reset}
${white}範例${reset}
${green}\t$0 -m \"SENDTXT\" -g \"444\" -l \"100\" ${reset}
"
exit ;
}
[ $# -eq 0 ] && print_HELP
while getopts ":l:L:m:M:g:G:H:h:" opt; do
case $opt in
m|M)
omessage="$OPTARG"
;;
g|G)
group="$OPTARG"
;;
l|L)
leval="$OPTARG"
;;
h|H)
echo "H"
print_HELP
exit
;;
esac
done
[ "$omessage" == "" ] && [ "$group" == "" ] && group="$2"
[ "$omessage" == "" ] && [ "$leval" == "" ] && leval="$3"
[ "$omessage" == "" ] && omessage="$1"
[ "$group" == "" ] && group="444"
[ "$leval" == "" ] && leval="100"
message=`echo $omessage | sed s'/ /%20/g'`
# echo "$1 $2 $3 $4 $5 $6"
echo -e " ${white} Message ==> $message ${reset}"
echo -e " ${white} Group ==> $group ${reset}"
echo -e " ${white} Level ==> $leval ${reset}"
echo "grp=${group}&level=${leval}&msg=${message}&encoding=BIG5"
[ "$leval" == "" ] && leval="100"
message=`echo $omessage | sed s'/ /%20/g'`
2017年3月25日 星期六
bash getopts Sendsms
2017年3月19日 星期日
YUM 6
RHEL6
使用CENTOS 安來裝
#!/bin/bash
# For YUM Packages Update From CentOS
mirrordir -v ftp://ftp.nsysu.edu.tw/Unix-like/CentOS/6.6/os/x86_64/ /var/www/html/yum/centos/6.6/os/x86_64
rpm --import /var/www/html/yum/centos/6.6/os/x86_64/RPM-GPG-KEY-CentOS-6
yum-arch /var/www/html/yum/centos/6.6/os/x86_64
createrepo /var/www/html/yum/centos/6.6/os/x86_64
使用CENTOS 安來裝
# For YUM Packages Update From CentOS
mirrordir -v ftp://ftp.nsysu.edu.tw/Unix-like/CentOS/6.6/os/x86_64/ /var/www/html/yum/centos/6.6/os/x86_64
rpm --import /var/www/html/yum/centos/6.6/os/x86_64/RPM-GPG-KEY-CentOS-6
yum-arch /var/www/html/yum/centos/6.6/os/x86_64
createrepo /var/www/html/yum/centos/6.6/os/x86_64
2016年4月18日 星期一
02_LVM
1.再VM加一個硬碟後,到OS下指令
# echo "- - -" > /sys/class/scsi_host/host0/scan
2.查看硬碟狀況
(假設新增的硬碟為/dev/sdb)
[root@AD-Content1 ~]# fdisk -l
Disk /dev/sda: 45.1 GB, 45097156608 bytes
64 heads, 32 sectors/track, 43008 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00095823
Device Boot Start End Blocks Id System
/dev/sda1 * 2 101 102400 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 102 2149 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 2150 43008 41839616 8e Linux LVM
Partition 3 does not end on cylinder boundary.
Disk /dev/mapper/VolGroup-LogVol00: 64.3 GB, 64311263232 bytes
255 heads, 63 sectors/track, 7818 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
64 heads, 32 sectors/track, 20480 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf82ed6f9
3.建立partition
#fdisk /dev/sdbm---查看有哪些指令
n---新增partition
出現詢問建立方式
Command (m for help): n
Command action <==因為是全新磁碟,因此只會問extended/primary而已,選 "p"
e extended
p primary partition (1-4)
p <==選擇 Primary 分割槽
Partition number (1-4): 1 <==設定為 1 號!
First cylinder (1-5005, default 1): <==直接按下[enter]按鍵決定!
Using default value 1 <==啟始磁柱就選用預設值!
Last cylinder or +size or +sizeM or +sizeK (1-5005, default 5005): <==直接按下[enter]按鍵決定!
p---查看partiton的狀態
t---選擇partiton 檔案ID (LVG選8e)
w---寫入並離開
4.建立PV
-- raw device 為 /dev/sdb format過後 會加1 p=1 剛剛的設定
#pvcreate /dev/sdb1 <==把sdb1這個partition轉換成pv
5.查詢VG名稱
# -- 查看現有VG,發現有個名叫 VolGroup00
[root@AD-Content1 ~]# vgdisplay
File descriptor 63 (pipe:[1133205204]) leaked on vgdisplay invocation. Parent PID 21722: -bash
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 59.89 GiB
PE Size 4.00 MiB
Total PE 15333
Alloc PE / Size 15333 / 59.89 GiB
Free PE / Size 0 / 0
VG UUID Mm60hX-raIB-Ew8H-wHN8-G0Z1-7JGV-1B0ZXI
#vgextend VolGroup00 /dev/sdb1 <==把sdb1這個pv 加入到 VolGroup00
6.擴建LV
#lvdisplay <==
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00 <== LV 的全名
VG Name VolGroup00
LV UUID pKnp0w-U365-Bfy1-YX1t-lgTZ-BQPA-M0bOOD
LV Write Access read/write
LV Status available
# open 1
LV Size 30.94 GB
Current LE 990
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
#vgdisplay
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 44.81 GB
PE Size 32.00 MB
Total PE 1434
Alloc PE / Size 1115 / 34.84 GB
Free PE / Size 319 / 9.97 GB <== VG還有多少空間
VG UUID iNuEfu-nvif-VyKP-wybl-ydrZ-BT6N-bQ6b07
那個+號很重要
#lvresize -l +319 /dev/VolGroup00/LogVol00 <==把"VolGroup00"這個VG裡還有319的PE空間,增加到"LogVol00" 這個LV
如果出現要你按 y/n要注意,就是你指令下錯了
7.將檔案系統的容量確實增加
這時候df -h 容量還沒增加
LV Name
#resize2fs /dev/VolGroup00/LogVol00
2016年4月6日 星期三
yum cd rom
yum cd rom
# 1 Mount CROM
mount -o loop /ISO/CDROM6.7 /mnt/cdrom
2 Edit file
vi /etc/yum.repos.d/media.repo
[InstallMedia]
name=Red Hat Enterprise Linux 6.7
mediaid=1435823078.298912
metadata_expire=-1
gpgcheck=0
cost=500
baseurl=file:///mnt/cdrom/
[HighAvailability]
name=ha
baseurl=file:///mnt/cdrom/HighAvailability
enabled=1
gpgcheck=0
[ResilientStorage]
name=rs
baseurl=file:///mnt/cdrom/ResilientStorage
enabled=1
gpgcheck=0
2015年11月8日 星期日
Linux Nic Config Bond 網路卡 bond
網路卡 bond
鳥哥那邊很多資訊
https://mieklefield.wordpress.com/2011/12/02/network-channel-bonding-for-failover/
如果使用X window 模式 需關閉 NetworkManager
這個會害死你
chkconfig NetworkManager --level 2345 off
1 載入 bonding 模組,並將介面取名為 bond0
在 CentOS 5.x 以後,Linux 的模組對應表已經寫入到 /etc/modprobe.d/*.conf 檔案內了~這個目錄內的檔名是可以自己取的,不過副檔名必須是 .conf 就是了。 我們取個名為 bonding.conf 的檔案好了,內容這樣寫即可:
鳥哥那邊很多資訊
https://mieklefield.wordpress.com/2011/12/02/network-channel-bonding-for-failover/
如果使用X window 模式 需關閉 NetworkManager
這個會害死你
chkconfig NetworkManager --level 2345 off
1 載入 bonding 模組,並將介面取名為 bond0
在 CentOS 5.x 以後,Linux 的模組對應表已經寫入到 /etc/modprobe.d/*.conf 檔案內了~這個目錄內的檔名是可以自己取的,不過副檔名必須是 .conf 就是了。 我們取個名為 bonding.conf 的檔案好了,內容這樣寫即可:
[root@centos ~]# vim /etc/modprobe.d/bonding.conf alias bond0 bonding # bond0 為我們需要的介面, bonding 則是 Linux 的核心模組之意! |
2 修改 bond0 所管理的各個實體網卡設定檔:
在鳥哥的這個案例中,Linux 系統的 eth0 為對 Internet 連線的介面,所以 bond0 管理的介面有 eth1, eth2, eth3 這 3 個!那這三張網卡的設定檔該如何修改呢? 很簡單,如底下這樣設定即可。(注意,被 bonding 所管理的各張網卡,習慣上,我們都會稱之為 slave 網卡!)
在鳥哥的這個案例中,Linux 系統的 eth0 為對 Internet 連線的介面,所以 bond0 管理的介面有 eth1, eth2, eth3 這 3 個!那這三張網卡的設定檔該如何修改呢? 很簡單,如底下這樣設定即可。(注意,被 bonding 所管理的各張網卡,習慣上,我們都會稱之為 slave 網卡!)
[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE="eth1" HWADDR="00:1B:21:3E:8C:47" < 可以不用給予==某些情況下,可能要對應好網卡卡號,才能夠讓網卡正確取得代號 NM_CONTROLLED="yes" ONBOOT="yes" MASTER=bond0 SLAVE=yes USERCTL=no # 最重要的是那個 MASTER 與 SLAVE 兩個設定項目。且因為是受 bond0 管理,所以不需要網路參數。 # 至於 eth2, eth3 則是依樣畫葫蘆,這裡就不示範囉!自行修訂即可。 |
3 建立 bond0 新介面的設定檔:
現在開始,這 eth1~eth3 這 3 張網卡都是歸 bond0 所管,那當然要建立一個名為 ifcfg-bond0 的網路參數設定檔囉!鳥哥目前管理的這個教室的網域參數為 192.168.42.0/24 這一段,因此這樣設定我的伺服器:[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 USERCTL=no BOOTPROTO=none ONBOOT=yes IPADDR=192.168.42.254 NETMASK=255.255.255.0 BONDING_OPTS="miimon=100 mode=6" TYPE=Unknown IPV6INIT=no # 重點是 BONDING_OPTS 這一串!mode=6 不用談,當然就是各個模式!這裡我們用 6 , # 至於那個 miimon 指的是『多久偵測一次各個 slave 網卡的連線狀態』的意思, # 這個值的單位是『毫秒』,就是 10 的 -3 次方秒~1000毫秒為一秒~ # 也就是說,我們大約 0.1 秒就偵測一次每張網卡的狀態!據以進行網路容錯測試! |
You must put following two command lines into /etc/rc.local when server boot
############################################################
/sbin/modprobe bonding
/sbin/service network restart
############################################################
load the bonding module, enter:
# modprobe bonding
Restart the networking service in order to bring up bond0 interface, enter:
# service network restart
############################################################
訂閱:
文章 (Atom)
RHEL install EPEL
https://www.linuxtechi.com/install-epel-repo-on-rhel-system/ EPEL dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest...
-
轉自 ORA-01722 during upgrade 10.2 to 11.2 Yesterday I was trying to upgrade my 10.2 database to 11.2 version in new host and I got below e...
-
記事本開啟 HKEY_CLASSES_ROOT\*\shell] [HKEY_CLASSES_ROOT\*\shell\NotePad] @="用記事本開啟" [HKEY_CLASSES_ROOT\*\shell\NotePad\command] @=...
-
爆笑到不行