1. Trang chủ
  2. » Công Nghệ Thông Tin

Topic 11 File Sharing

8 6 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 8
Dung lượng 581,12 KB
File đính kèm Topic11_FileSharing.rar (565 KB)

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Triển khai một máy tính làm việc Linux với các tính năng về đồ họa, vi tính văn phòng,… Hệ thống vận hành: cài đặt, cấu hình, quản trị, xử lý sự cố,… Vận hành hệ điều hành Linux: cài đặt, cấu hình mạng, máy trong, sử dụng thành thạo các công cụ quản lý mạng, cấu hình nhân, DFS, lập kế hoạch cho việc lưu trữ và phục hồi dữ liệu, TCP IP , config device,… Liên kết cơ bản kỹ năng đến Internet: kết nối, email, bảo mật, DNS, Apache, SSH, NTP,…

Trang 1

Topic 11: File Sharing

NFS Server Configuration Samba Server Configuration

Trang 2

154 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

[root@localhost ~]# rpm -qa | grep nfs

libnfsidmap-0.25-17.el7.x86_64

nfs4-acl-tools-0.3.3-15.el7.x86_64

nfs-utils-1.3.0-0.48.el7.x86_64

NFS Server Configuration NFS: là dịch vụ chia sẻ file giữa các máy linux

1 Cài đặt NFS

NFS là dịch vụ hỗ trợ cơ chế chia sẻ tài nguyên giữa các máy chủ Linux

- Kiểm tra NFS đã được cài đặt hay chưa:

Ngoài ra NFS còn đỏi hỏi phải có một Daemon quan trọng dùng để quản lý các kết nối đó là rpcbind Mặc định rpcbind được cài đặt sẵn trên hệ thống rpcbind listen trên TCP port 111

- Kiểm tra rpcbindđã được cài đặt trên hệ thống:

[root@localhost Desktop]# rpm -qa rpcbind

rpcbind-0.2.0-26.el7.x86_64

2 Cấu hình NFS server

# vi /etc/idmapd.conf

5 Domain = nhatnghe.com

file dùng để cấu hình NFS là /etc/exports

- Tạo một thư mục chia sẻ như sau:

[root@may1 ~]# mkdir -p /data/{software,dulieu,database}

[root@may1 ~]# cp -rv /etc/* /data/dulieu/

- Cấp quyền truy cập vào thư mục /share:

[root@may1 ~]# chmod 777 /data/dulieu/

[root@may1 ~]# chmod 777 /data/database/

- Sửa file /etc/exports thêm vào dòng sau:

/data/software *(ro,sync) /data/dulieu 192.168.1.0/24(rw,sync) /data/database 192.168.1.100/32(rw,sync) NFS Gồm có các quyền truy cập thông dụng như sau:

secure : Port từ client requests phải nhỏ hơn 1024

noaccess : Denied access root_squash : Ngăn remote root users no_root_squash : Cho phép remote root users

- Khởi động các dich vụ:

# systemctl restart rpcbind

# systemctl start nfs-server

#systemctl start nfs-lock

#systemctl start nfs-idmap

Trang 3

# systemctl enable rpcbind

# systemctl enable nfs-server

# systemctl enable nfs-lock

# systemctl enable nfs-idmap

- Kiểm tra rpcbind daemon:

[root@may1 ~]# netstat -nltp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1471/rpcbind

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 8502/sshd

Lưu ý: sau khi thay đổi file /etc/exports bạn phải restart daemon nfs hay dùng các lệnh sau:

exportfs -a : Reload lại toàn bộ cấu hình cho NFS exportfs -r : Reload lại những thay đổi trong cấu hình cho NFS

- Do NFS cần mở một số port khi chạy như (111, 2049 ) nên ta cần cấu hình firewall mở các port này hay tắt firewall:

- Kiểm tra nfs đã được quản trị bởi rpcinfo

[root@may

100000 1 ~]# rpcin 4 tcp6 o ::.0.111 portmapper superuser

100000 3 tcp6 ::.0.111 portmapper superuser

100000 4 udp6 ::.0.111 portmapper superuser

100000 3 udp6 ::.0.111 portmapper superuser

100000 4 tcp 0.0.0.0.0.111 portmapper superuser

100000 3 tcp 0.0.0.0.0.111 portmapper superuser

100000 2 tcp 0.0.0.0.0.111 portmapper superuser

100000 4 udp 0.0.0.0.0.111 portmapper superuser

3 Cấu hình NFS client:

3.1 Cấu hình truy cập bằng tay

- Tạo thư mục:

[root@localhost ~]# mkdir -p /server/{software,dulieu,database}

- Mount NFS file:

[root@localhost ~]# mount -t nfs 192.168.1.101:/data/software /server/software

[root@localhost ~]# mount -t nfs 192.168.1.101:/data/dulieu /server/dulieu

[root@localhost ~]# mount -t nfs 192.168.1.101:/data/database /server/database

- Kiểm tra các mount point trên hệ thống:

Trang 4

156 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

[root@localhost ~]# vi /etc/fstab

[root@may1 ~]# rpcinfo -p localhost

program vers proto

100000

100000

100000

100000

100000

100000

100024

100024

4

3

2

4

3

2

1

1

port service tcp 111 portmapper tcp 111 portmapper tcp 111 portmapper udp 111 portmapper udp 111 portmapper udp 111 portmapper udp 34563 status tcp 41552 status

- Kiểm tra:

3.2 Cấu hình truy cập trong file /etc/fstab

- Sửa file /etc/fstab như sau:

[root@localhost ~]# vi /etc/fstab

192.168.1.101:/data/software /server/software nfs soft,nfsvers=2 0 0

192.168.1.101:/data/dulieu /server/dulieu nfs soft,nfsvers=2 0 0

192.168.1.101:/data/database /server/database nfs soft,nfsvers=2 0 0

- Reboot lại hệ thống: init 6

- mount, kiểm tra các mount point đã được tạo

chú ý: sử dụng lệnh man nfsstat để xem thêm các option của lênh nfsstat

- Liệt kê danh sách các portmapper đã đăng ký trên host

Trang 5

[root@localhost Desktop]# systemctl start smb

[root@localhost Desktop]# systemctl start nmb

Samba server

1 Cài đặt samba:

Là dịch vụ hỗ trợ chia sẻ tài nguyên từ hệ thống Linux với các hệ thống khác như Linux, Windows

- Kiểm tra samba đã được cài đặt hay chưa:

# rpm -qa | grep samba samba-common-4.1.12-21.el7_1.x86_64 samba-4.1.12-21.el7_1.x86_64

samba-client-4.1.12-21.el7_1.x86_64 samba-libs-4.1.12-21.el7_1.x86_64

2 Cấu hình samba server

- Tạo cây thư mục chia sẻ như sau:

[root@may1 ~]# mkdir -p /nhatnghe/{giaovien,hocsinh,baithi,software}

[root@may1 ~]# chmod 777 /nhatnghe/giaovien/

[root@may1 ~]# chmod 777 /nhatnghe/hocsinh [root@may1 ~]# chmod 777 /nhatnghe/baithi [root@may1 ~]#

- Sửa file /etc/samba/smb.conf sửa các dòng sau:

[root@may1 ~]# vi /etc/samba/smb.conf Thêm dòng

66 unix charset = UTF-8 Sửa dòng:

89 workgroup = WORKGROUP

124 passdb backend = smbpasswd

- Tạo user truy cập

[root@may1 ~]# groupadd giaovien [root@may1 ~]# groupadd hocsinh [root@may1 ~]# useradd -G giaovien gv1 [root@may1 ~]# useradd -G giaovien gv2 [root@may1 ~]# useradd -G hocsinh hs1 [root@may1 ~]# useradd -G hocsinh hs2

- Tạo mật khẩu cho người dùng samba

[root@may1 ~]# smbpasswd -a gv1 [root@may1 ~]# smbpasswd -a gv2 [root@may1 ~]# smbpasswd -a hs1 [root@may1 ~]# smbpasswd -a hs2

- Start daemon smb:

Trang 6

158 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

[global]

workgroup = MYGROUP server string = Samba Server Version %v passdb backend = smbpasswd

log file = /var/log/samba/log.%m max log size = 50

create mask = 0766 directory mask = 0777

cups options = raw [homes]

- Do samba cần mở một số port khi chạy như (139,445, ) nên ta cần cấu hình firewall mở các port này hay tắt firewall:

3 Cấu hình samba client

3.1 Trên Windows

Vào Start menu -> chọn Run: \\192.168.1.101

Nhập user hs1, password: 123

3.2 Trên Linux

- Tạo thư mục:

[root@localhost ~]# mkdir /giaovien/

- Mount smb file:

[root@localhost ~]# mount -o username=gv1,password=123 //192.168.1.20/gv1 /giaovien

4 Share tài nguyên file

[root@localhost Desktop]# systemctl enable smb

ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-

user.target.wants/smb.service'

[root@localhost Desktop]# systemctl enable nmb

ln -s '/usr/lib/systemd/system/nmb.service' '/etc/systemd/system/multi-

user.target.wants/nmb.service'

Trang 7

comment = Home Directories read only = No

browseable = No [printers]

comment = All Printers path = /var/spool/samba printable = Yes

browseable = No

# Tạo share hocsinh: mọi user có thể đọc, ghi

[Hocsinh]

comment = Du lieu dung chung path = /nhatnghe/hocsinh read only = No

# Tạo share Baithi: nhóm giaovien được đọc, ghi, nhóm

hocsinh chỉ có thể đọc

[Baithi]

comment = Bai thi hoc ky path = /nhatnghe/baithi valid users = +hocsinh, +giaovien write list = +giaovien

# Tạo share Giaovien, gv1 tạo, gv2 không thể xem

[Giaovien]

comment = Bai thi hoc ky path = /nhatnghe/giaovien valid users = +giaovien write list = +giaovien create mask = 0760 directory mask = 0770

# Tạo share Software mọi user chỉ đọc

[Software]

comment = Phan mem co ban path = /nhatnghe/software

# Tạo share ẩn bgh chỉ có user ht mới có thể truy cập

[bgh]

comment = Ban giam hieu path = /nhatnghe/bgh valid users = ht read only = No browseable = No Tại client thử truy cập: \\192.168.1.101

Trang 8

160 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

Ngày đăng: 27/09/2022, 02:35

HÌNH ẢNH LIÊN QUAN

exportfs -r : Reload lại những thay đổi trong cấu hình cho NFS - Topic 11 File Sharing
exportfs r : Reload lại những thay đổi trong cấu hình cho NFS (Trang 3)
3.2. Cấu hình truy cập trong file /etc/fstab - Topic 11 File Sharing
3.2. Cấu hình truy cập trong file /etc/fstab (Trang 4)
3. Cấu hình samba client - Topic 11 File Sharing
3. Cấu hình samba client (Trang 6)
- Do samba cần mở một số port khi chạy như (139,445,..) nên ta cần cấu hình firewall mở các port này hay tắt firewall:  - Topic 11 File Sharing
o samba cần mở một số port khi chạy như (139,445,..) nên ta cần cấu hình firewall mở các port này hay tắt firewall: (Trang 6)
w