糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > linux学习笔记 第七篇 (samba(一))(iscsi)

linux学习笔记 第七篇 (samba(一))(iscsi)

时间:2022-08-16 05:32:02

相关推荐

linux学习笔记 第七篇 (samba(一))(iscsi)

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 createiqn.-.example:storage1

创建key认证

/iscsi/iqn.-.example:storage1/tpg1/aclscreate iqn.-.example:key1

创建新设备和key的联系

/iscsi/iqn.-.example:storage1/tpg1/lunscreate /backstores/block/westos:storage1

/iscsi/iqn.-.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.-.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.-.example:storage1 -odelete(永久)

fdisk -l

iscsiadm -m node -T iqn.-.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

如果觉得《linux学习笔记 第七篇 (samba(一))(iscsi)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。