[root@web1 ~]# yum -y remove firewalld
[root@web1 ~]# setenforce 0
[root@web1 ~]# yum -y install wget
[root@web1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@es_001 ~]# yum repolist
已加载插件:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
源标识 源名称 状态
!dvd centos7.5 9,911
repolist: 9,911
[root@es_001 ~]# yum makecache
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
dvd | 3.6 kB 00:00
(1/2): dvd/other_db | 2.5 MB 00:00
(2/2): dvd/filelists_db | 6.9 MB 00:00
元数据缓存已建立
root@es_001 ~]# yum clean all
[root@es_001 ~]# yum makecache
[root@es_001 ~]# yum repolist all
[root@es_001 ~]# yum -y install epel-release.noarch
[root@es_001 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo epel.repo nginx.repo
dvd.repo epel-testing.repo
[root@es_001 ~]# yum -y install --downloadonly --downloaddir=./soft/ nginx
[root@es_001 ~]# tree ./soft/
./soft/
├── nginx-1.20.1-10.el7.x86_64.rpm
├── nginx-filesystem-1.20.1-10.el7.noarch.rpm
├── openssl11-libs-1.1.1k-7.el7.x86_64.rpm
[root@es_001 ~]# yum -y install createrepo
[root@es_001 ~]# createrepo ./soft/
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@es_001 ~]# tree ./soft/
./soft/
└── repodata
├── 01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2
├── 401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz
├── 5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2
├── 6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz
├── 7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2
├── dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
└── repomd.xml
1 directory, 7 files
[root@es_001 ~]# vim /etc/yum.repos.d/nginx.repo
[root@es_001 ~]# cat /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx
baseurl=/root/soft/
gpgcheck=0
enable=1
[root@es_001 ~]# yum -y install nginx
[root@es_001 ~]# rpm -qa|grep nginx
nginx-1.20.1-10.el7.x86_64
nginx-filesystem-1.20.1-10.el7.noarch
[root@es_001 ~]# yum list installed |grep nginx
Repository 'nginx': Error parsing config: Error parsing "baseurl = '/root/soft/'": URL must be http, ftp, file or https not ""
nginx.x86_64 1:1.20.1-10.el7 @epel
nginx-filesystem.noarch 1:1.20.1-10.el7 @epel
[root@es_001 ~]# rpm -ql nginx
/etc/nginx/win-utf
/usr/bin/nginx-upgrade
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx/modules
/usr/sbin/nginx
/usr/share/doc/nginx-1.20.1
[root@es_001 ~]# tree /usr/share/nginx/html/
/usr/share/nginx/html/
├── 404.html
├── 50x.html
├── en-US -> ../../doc/HTML/en-US
├── icons
│ └── poweredby.png -> ../../../pixmaps/poweredby.png
├── img -> ../../doc/HTML/img
├── index.html -> ../../doc/HTML/index.html
├── nginx-logo.png
└── poweredby.png -> nginx-logo.png
3 directories, 6 files
[root@es_001 ~]# which nginx
/usr/sbin/nginx
[root@es_001 ~]# nginx
[root@es_001 ~]# netstat -lnput|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2461/nginx: master
tcp6 0 0 :::80 :::* LISTEN 2461/nginx: master
[root@es_001 ~]# ps -aux|grep nginx
root 2461 0.0 0.0 39308 944 ? Ss 10:52 0:00 nginx: master process nginx
nginx 2462 0.0 0.1 39696 1900 ? S 10:52 0:00 nginx: worker process
root 2470 0.0 0.0 112720 984 pts/0 R+ 10:53 0:00 grep --color=auto nginx
⼀、SAMBA⽂件共享
1、什么是SAMBA SMB(Server Message Block)协议实现⽂件共享,也称为CIFS(Common Internet File System ) 是Windows和类Unix系统之间共享⽂件的⼀种协议 客户端==主要是Windows==;⽀持多节点同时挂载以及并发写⼊ 主要⽤于windows和Linux下的⽂件共享、打印共享 实现==匿名与本地⽤户==⽂件共享 2、SAMBA主要进程 smbd进程 控制发布共享⽬录与权限、==负责⽂件传输== ==TCP 139 445== nmbd进程 ⽤于名称解析netbios ==UDP 137 138== ; 基于NETBIOS协议获得 计算机名称——>解析为相应IP地址,实现信息通讯 NetBIOS是Network Basic Input/Output System的简称,⼀般指⽤于局域⽹通信的 ⼀套API 3、SAMBA环境准备
第⼀步:从模板机中克隆⼀台Linux服务器,叫做SAMBA
第⼆步:更改主机名称与IP地址
第三步:关闭防⽕墙与SELinux
第四步:配置yum源 # hostnamectl set-hostname samba.itcast.cn # su # vim /etc/sysconfig/network-scripts/ifcfg-ens33 BOOTPROTO=none IPADDR=10.1.1.10 NETMASK=255.255.255.0 GATEWAY=10.1.1.2 DNS1=8.8.8.8 DNS2=114.114.114.114 # systemctl restart network 扩展:如果是多张⽹卡,建议使⽤ifdown ens33以及ifup ens33实现重启⽹络操作 # systemctl stop firewalld # systemctl disable firewalld # setenforce 0 # vim /etc/selinux/config SELINUX=disabled 4、SAMBA软件安装(服务器搭建) SAMBA也是⼀个C/S架构的软件,Client主要是Windows 5、了解smb的配置⽂件 # yum clean all # yum makecache # yum install samba -y # rpm -qa |grep ^samba # vim /etc/samba/smb.conf [global] 全局选项 workgroup = MYGROUP 定义samba服务器所在的⼯作组 server string = Samba Server Version %v smb服务的描述 log file = /var/log/samba/log.%m ⽇志⽂件 max log size = 50 ⽇志的最⼤⼤⼩KB security = user 认证模式:share匿名|user⽤户密 码|server外部服务器⽤户密码 passdb backend = tdbsam 密码格式 load printers = yes 加载打印机 cups options = raw 打印机选项 [homes] 局部选项(共享名称) comment = Home Directories 描述 browseable = no 隐藏共享名称 writable = yes 可读可写 [printers] 共享名称 comment = All Printers 描述 path = /var/spool/samba 本地的共享⽬录 6、SAMBA综合案例 搭建⼀个SAMBA服务,共享⼀个⽬录/samba/share,客户端使⽤user01/123通过 windows或者Linux可以在该⽬录⾥创建⽂件删除⽂件
第⼀步:SAMBA服务器环境准备 更改主机名称、IP地址、关闭防⽕墙、SELinux、配置YUM源
第⼆步:安装SAMBA软件
第三步:查询SAMBA⽣成⽂件列表(rpm -ql) browseable = no 隐藏 guest ok = no ——> public = no 需要帐号和密码访问 writable = no ——> read only =yes 不可写 printable = yes 打印选项 [share] path = /dir1 guest ok = no writable = yes # yum install samba -y # rpm -aq|grep ^samba # rpm -ql samba /usr/sbin/smbd /usr/sbin/nmbd /usr/lib/systemd/system/smb.service /usr/lib/systemd/system/nmb.service
第四步:在服务器端创建⼀个共享⽬录
第五步:编辑/etc/smb.conf配置⽂件,实现SAMBA共享
第六步:创建⼀个user01⽤户,然后添加到samba认证中,设置密码为123 以上操作完成后,则SAMBA系统中增加了⼀个user01的账号以及123的密码 第七步:启动nmb与smb服务 # mkdir /samba/share -p # vim /etc/samba/smb.conf ... [smb_share] comment = samba service path = /samba/share guest ok = no writable = yes 或者 [samba_share] path = /samba/share public = no writable = yes 备注:guest ok === public # useradd user01 # smbpasswd -a user01 New SMB password:123 Retype new SMB password:123 Added user user01. # systemctl start nmb # systemctl start smb 第⼋步:基于Windows或Linux实现⽂件共享 Windows: ① ⾸先安装SAMBA⽀持Windows + X,选择控制⾯板