alias:
alias xie='vim'(退出再登陸不可用)
alias
vim .bashrc(只有root用戶可用:用戶級變量)
alias xie='vim'
source .bashrc
vim /etc/bashrc(系統級別變量:其他用戶可用)
函數:
vthmunge () {
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
}
...
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
ISCSI概念
ISCSI(InternetSCSI)支持從客戶端(發起端)通過IP向遠程服務器上的
SCSI存儲設備(目標)發送SCSI命令。iSCSI限定名稱用於確定發起端和目
標,並採用iqn.yyyy-mm.{reverse domain}:label的格式。默認情況下,網絡
通信是至iSCSI目標上的端口3260/tcp的明文。
ISCSI發起端:需要訪問原始SAN存儲的客戶端。
ISCSI目標:從ISCSI服務器提供的遠程硬盤磁盤,或“目標門戶”
ISCSI目標門戶:通過網絡向發起端提供目標的服務器。
IQN:“iSCSI限定名稱”。每個發起端和目標需要唯一名稱進行標識,
最好的做法是使用一個在Internet上可能獨一無二的名稱。
SCSI目標軟件包:
systemclt stop firewalld
yum install -y targetcli
啓動服務:
systemctl enabletarget
systemctl starttarget
進入iSCSI目標交互式配置模式:
targetcli
給共享取名字
/backstores/blockcreate westos:storage1 /dev/vdb1 (名字:westos:storage1)
客戶端能看到的名字,以iqn這種方式共享
/iscsi create iqn.2016-12.com.example:storage1
創建key認證
/iscsi/iqn.2016-12.com.example:storage1/tpg1/aclscreate iqn.2016-12.com.example:key1
創建新設備和key的聯繫
/iscsi/iqn.2016-12.com.example:storage1/tpg1/lunscreate /backstores/block/westos:storage1
/iscsi/iqn.2016-12.com.example:storage1/tpg1/portalscreate 172.25.254.131
exit
netstat antlpe|grep 3260
訪問iSCSI存儲
yum search iscsi (查找要安裝的軟件包)
yum installiscsi-intiator-utils -y
systemctl stopfirewalld
systemctl restartiscsi
iscsiadm -mdiscovery -t st -p 172.25.254.131(-m 動作 -t type)
查找iscsi服務器所提供的iscsi目標(IP:目標門戶)
iscsiadm -m node-T iqn.2016-12.com.example:storage1 -p 172.25.254.131 -l(登陸)
此時,得到一塊新磁盤
fdisk -l
fdisk /dev/sda (給新磁盤分區)
mkfs.xfs /dev/sda(格式化)
mount /dev/sda1/mnt(磁盤還是在服務器端)
刪除客戶端:
iscsiadm -m node -T iqn.2016-12.com.example:storage1 -odelete(永久)
fdisk -l
iscsiadm -m node -T iqn.2016-12.com.example:storage1 -u(臨時,重啓服務後依然生效)
fdisk -l
刪除服務器端:
clearconfig confirm=true
高級網絡配置:
##(所有東西都能虛擬出來,惟獨網卡不行)##
橋接:
網卡驅動默認情況下,只能真機去管理
在真機裏面安裝虛擬機時,虛擬機器裏面與真機處於同一網段的ip是通過地址轉換得到的,(在真機裏面:ifconfig "virbr1")但是每個
文件都地址轉換,會減慢速度,現在,我們在真機的網卡,開一個接口,使虛擬機也能使用這個網卡(virbr0:nat 網絡地址轉換)
vim ifcfg-dd
BOOTPROTO=none
DEVICE=enp0s25
File:/home/kiosk/Desktop/12.181 Page 2 of 3
ONBOOT=yes
BRIDGE=br0
vim ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.31
NETMASK=255.255.255.0
TYPE=Bridge
systemctl stopNetworkManager.service
systemctl restartnetwork
此時:
在http安裝虛擬機時,會出現
在環境打開的情況下,得到的ip就是和真機處於同一網段(不用地址轉換)
命令方式添加br0:
brctl addbr br0
brctl show
ifconfig br0172.25.254.131 network 255.255.255.0
brctl addif br0eth0
ifconfig eth0 up
刪除:
brctl delif br0eth0
ifconfig br0 down
brctl delbr br0
br0 show
網卡bond最多支持兩塊網卡 (如果一塊網卡掛掉,另一塊補充)
添加一塊網卡:
nmcli connectionadd con-name bond0 ifname bond0 type bond mode active-backup ip4172.25.254.131/24
建立bond
此時ping不通
nmcli connectionadd con-name eth0 ifname eth0 type bond-slave master bond0
插入物理設備
可以ping通
如果:ifconfig eth0 down
則eth1立刻頂替
網卡team 最多支持八塊網卡(##輪詢)
nmcli connectionadd con-name team0 ifname team0 type team config'{"runner":{"name":"activebackup"}}'
ip4172.25.254.131/24
nmcli connectionadd con-name eth0 ifname eth0 type team-slave master team0
nmcli connectionadd con-name eth1 ifname eth1 type team-slave master team0
Samba:
yum insatll sambasamba-common samba-client –y
systemctl stopfirewalld
smbpasswd -ausername(本地存在的用戶)
pdbddit –L
smbclient -L//172.25.254.131 -U username
smbclient//172.25.254.131/username -U username
設定共享目錄:
vim/etc/samba/smb.conf
[dd]
comment = sambadirectory
path = /samba
mkdir /samba
touch file
selinux:
semanage fcontext -a -t samba_share_t '/samba(/.*)?'
restorecon -RvvF /samba
smbclient//172.25.254.131/dd -U dd
vim /etc/samba/smb.conf
[yy]
comment = mntdirectory
path = /mnt
cd /mnt
touch file
setsebool -P samba_export_all_ro on (安全性不如上下文標籤安全性高,但修改/mnt文件的標籤會使其他文件文件使用這個目錄
時出現問題)
smbclient//172.25.254.131/yy -U yy
##默認情況下匿名用戶不能訪問##
vim/etc/samba/smb.conf
security = user
passdb backend =tdbsam
map to guest = baduser
[dd]
comment = sambadirectory
guest ok = yes
path = /samba
systemctl restartsmb.service