CentOS 6.8 に共有ディレクトリを作成したくて、Sambaというものでできるらしい。
Sambaの環境構築を行ったので記載。
参考URL)フルアクセスの共有フォルダ作成
Sambaのインストール手順
以下コマンドを入力
1 |
[root@localhost ~]# yum install samba |
yを押下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
--> トランザクションの確認を実行しています。 ---> Package samba-winbind.x86_64 0:3.6.23-36.el6_8 will be インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================ パッケージ アーキテクチャ バージョン リポジトリー 容量 ================================================================================ インストールしています: samba x86_64 3.6.23-36.el6_8 updates 5.1 M 依存性関連でのインストールをします。: samba-common x86_64 3.6.23-36.el6_8 updates 10 M samba-winbind x86_64 3.6.23-36.el6_8 updates 2.2 M samba-winbind-clients x86_64 3.6.23-36.el6_8 updates 2.0 M トランザクションの要約 ================================================================================ インストール 4 パッケージ 総ダウンロード容量: 19 M インストール済み容量: 69 M これでいいですか? [y/N] |
インストール完了!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
合計 5.2 MB/s | 19 MB 00:03 rpm_check_debug を実行しています トランザクションのテストを実行しています トランザクションのテストを成功しました トランザクションを実行しています インストールしています : samba-winbind-clients-3.6.23-36.el6_8.x86_64 1/4 インストールしています : samba-common-3.6.23-36.el6_8.x86_64 2/4 インストールしています : samba-winbind-3.6.23-36.el6_8.x86_64 3/4 インストールしています : samba-3.6.23-36.el6_8.x86_64 4/4 Verifying : samba-3.6.23-36.el6_8.x86_64 1/4 Verifying : samba-common-3.6.23-36.el6_8.x86_64 2/4 Verifying : samba-winbind-clients-3.6.23-36.el6_8.x86_64 3/4 Verifying : samba-winbind-3.6.23-36.el6_8.x86_64 4/4 インストール: samba.x86_64 0:3.6.23-36.el6_8 依存性関連をインストールしました: samba-common.x86_64 0:3.6.23-36.el6_8 samba-winbind.x86_64 0:3.6.23-36.el6_8 samba-winbind-clients.x86_64 0:3.6.23-36.el6_8 完了しました! |
共有ディレクトリ作成手順
共有ディレクトリの作成
1 |
[root@localhost ~]# mkdir /home/share |
共有ディレクトリに読み書きを設定
1 |
[root@localhost ~]# chmod 777 /home/share/ |
以下「smb.conf」設定ファイルに設定を記載する。
1 |
[root@localhost ~]# vi /etc/samba/smb.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# # netbios name can be used to specify a server name not tied to the hostname # # Interfaces lets you configure Samba to use multiple interfaces # If you have multiple network interfaces then you can list the ones # you want to listen on (never omit localhost) # # Hosts Allow/Hosts Deny lets you restrict who can connect, and you can # specifiy it as a per share option as well # # ADD unix charset = UTF-8 dos charset = CP932 # MOD #workgroup = MYGROUP workgroup = WORKGROUP server string = Samba Server Version %v ; netbios name = MYSERVER ; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 ; hosts allow = 127. 192.168.12. 192.168.13. # ADD hosts allow = 127. 192.168.xxx. # --------------------------- Logging Options ----------------------------- # # Log File let you specify where to put logs and how to split them up. # # Max Log Size let you specify the max size log files should reach # logs split per machine log file = /var/log/samba/log.%m # max 50KB per log file, then rotate max log size = 50 # ----------------------- Standalone Server Options ------------------------ # # Scurity can be set to user, share(deprecated) or server(deprecated) # # Backend to store user information in. New installations should # use either tdbsam or ldapsam. smbpasswd is available for backwards # compatibility. tdbsam requires no further configuration. security = user passdb backend = tdbsam # ADD map to guest = Bad User # ----------------------- Domain Members Options ------------------------ # |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# A publicly accessible directory, but read only, except for people in # the "staff" group ; [public] ; comment = Public Stuff ; path = /home/samba ; public = yes ; writable = yes ; printable = no ; write list = +staff # ADD [Share] path = /home/share/ writable = yes guest ok = yes guest only = yes create mode = 0777 dirctory mode = 0777 |
SMBを起動
1 2 |
[root@localhost ~]# service smb start SMB サービスを起動中: [ OK ] |
NMBを起動
1 2 |
[root@localhost ~]# service nmb start NMB サービスを起動中: [ OK ] |
PCが立ち上がった際に、自動起動できるように設定
SMB設定と確認
1 2 3 |
[root@localhost ~]# chkconfig smb on [root@localhost ~]# chkconfig --list smb smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
NMB設定と確認
1 2 3 |
[root@localhost ~]# chkconfig nmb on [root@localhost ~]# chkconfig --list nmb nmb 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
SELinuxにSMBを許可する
1 2 |
[root@localhost ~]# setsebool -P samba_enable_home_dirs on [root@localhost ~]# restorecon -R /home/share |
※以下は、一時的にSELinuxを解除する方法を記載
1 2 3 4 5 |
[root@localhost ~]# getenforce Enforcing [root@localhost ~]# setenforce 0 [root@localhost ~]# getenforce Permissive |
ファイアウォールの設定。Sambaを許可する。
☆終了☆
Windowsからアクセス可能です。
【補足】
ログの場所。(上手く接続できない場合に、ログを除くと参考になるかも)
1 |
[root@localhost ~]# vi /etc/samba/smb.conf |
1 2 3 4 5 6 7 8 9 10 |
# --------------------------- Logging Options ----------------------------- # # Log File let you specify where to put logs and how to split them up. # # Max Log Size let you specify the max size log files should reach # logs split per machine log file = /var/log/samba/log.%m # max 50KB per log file, then rotate max log size = 50 |
Sambaのアンインストール手順
コマンドを入力
1 |
[root@localhost ~]# yum remove samba* |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
samba-winbind x86_64 3.6.23-36.el6_8 @updates 7.7 M samba-winbind-clients x86_64 3.6.23-36.el6_8 @updates 6.5 M 依存性関連での削除をします。: gnome-vfs2-smb x86_64 2.24.2-6.el6 @anaconda-CentOS-201311272149.x86_64/6.5 32 k gvfs-smb x86_64 1.4.3-18.el6 @base 303 k libsmbclient x86_64 3.6.23-36.el6_8 @updates 5.9 M system-config-printer x86_64 1.1.16-23.el6 @anaconda-CentOS-201311272149.x86_64/6.5 1.9 M system-config-printer-libs x86_64 1.1.16-23.el6 @anaconda-CentOS-201311272149.x86_64/6.5 3.4 M system-config-printer-udev x86_64 1.1.16-23.el6 @anaconda-CentOS-201311272149.x86_64/6.5 29 k トランザクションの要約 ================================================================================ 削除 10 パッケージ インストール済み容量: 80 M これでいいですか? [y/N] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Verifying : gvfs-smb-1.4.3-18.el6.x86_64 4/10 Verifying : samba-common-3.6.23-36.el6_8.x86_64 5/10 Verifying : system-config-printer-udev-1.1.16-23.el6.x8 6/10 Verifying : samba-winbind-3.6.23-36.el6_8.x86_64 7/10 Verifying : gnome-vfs2-smb-2.24.2-6.el6.x86_64 8/10 Verifying : system-config-printer-libs-1.1.16-23.el6.x8 9/10 Verifying : samba-winbind-clients-3.6.23-36.el6_8.x86_6 10/10 削除しました: samba.x86_64 0:3.6.23-36.el6_8 samba-common.x86_64 0:3.6.23-36.el6_8 samba-winbind.x86_64 0:3.6.23-36.el6_8 samba-winbind-clients.x86_64 0:3.6.23-36.el6_8 依存性の削除をしました: gnome-vfs2-smb.x86_64 0:2.24.2-6.el6 gvfs-smb.x86_64 0:1.4.3-18.el6 libsmbclient.x86_64 0:3.6.23-36.el6_8 system-config-printer.x86_64 0:1.1.16-23.el6 system-config-printer-libs.x86_64 0:1.1.16-23.el6 system-config-printer-udev.x86_64 0:1.1.16-23.el6 完了しました! |
以上。