centos 6.7 install
建立資料夾
/sysvol/hs
#W3000/Data/內容需全部 user:user
chown root:user
/sysvol/share
chown user:user
mkdir /backup/log
mkdir /backup/bak/month
mkidr /backup/mis
mkdir /backup/mis/log
—————————————–
vi /etc/sh/uptime.sh
/usr/sbin/ntpdate tock.stdtime.gov.tw && /sbin/hwclock -w &> /dev/null
————————————–
vi /etc/sysconfig/selinux
SELINUX=disabled
————————————
CentOS 6關閉IPv6功能
/etc/sysctl.conf
#Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
service ip6tables stop
chkconfig ip6tables off
———————————–
updatedb && yum install epel-* -y && yum update -y && init 6
———————————–
vi /etc/ssh/sshd_confg
拿掉#
#Port 22 ——>Port 7822
拿掉#並改為no
#PermitRootLogin no
———————————–
安裝apc-ups
yum install apcupsd -y
systemctl enable apcupsd
systemctl start apcupsd
install unix2dos screen lm-sensors vncserver
———————————–
vi /etc/default/useradd
SHELL=/bin/bash—————>SHELL=/bin/nologin
=================================
samba———————————–satart
vi /etc/samba/smb.conf
啟動 smbd 時加上 -D 參數
# vi /etc/sysconfig/samba
SMBDOPTIONS="-D"
設置 rlimit_max 數值
# vi /etc/security/limits.conf
# 加入以下內容
* – nofile 16384
( "*" 要加)
立即生效
# ulimit -n 16384
vi /etc/samba/smb.conf
dns proxy = no
getwd cache = yes
#優化傳輸速度
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
———————————————-
範例1.Linux作業系統編碼為 big5 (換句話說,/etc/sysconfig/i18n裡面所設定的預設編碼是 Big5 時),而Samba Server要分享檔案給繁體中文的 Windows 系統時,則伺服器該如下設定:
display charset = cp950
dos charset = cp950
unix charset = cp950
範例2.Linux作業系統編碼為Unicode,而Samba Server要分享檔案給繁體中文的 Windows 系統時,則伺服器該如下設定:
display charset = UTF8
dos charset = cp950
unix charset = UTF8
——————————————-
# 徹底停用印表機分享
load printers = no
;cups options = raw
printcap name = /dev/null
;disable spools = yes
printing = bsd
——————————————
#匿名存取
[publlic]
path = /sysvol/public
browsable =yes
writable = yes
guest ok = yes
read only = no
create mask = 0700
directory mask = 0700
#設定目錄
chown nobody.nobody /sysvol/public
chmod 700 /sysvol/public
samba———————————–end
#uptime
vi /etc/sh/uptime.sh
#!/bin/bash
/usr/sbin/ntpdate tock.stdtime.gov.tw && /sbin/hwclock -w &> /dev/null
crontab -e
0 9 * * * /etc/sh/uptime.sh
———————————————————————————————————————-
一般人可能碰到一個問題叫做檔案鎖住?
為了避免一個檔案時被同時開啟,並各自變更資料而不知道,因
此有一種,機制叫lock,一個檔案開啟後另一個檔案只能以唯讀,
或被限制開啟
而Windows的網路芳鄰則有另一種機制,oplock:這一種方法是
予陶s接端可以暫存一些原本要存在server端的資料,且關閉時
不會直接關掉連線,如同所有的cache的作用,可以增加效能,然而
我的結果是檔案明明關閉很久,檔案卻一直被鎖住了,
以下是samba的oplock說明
oplocks (S)
This boolean option tells smbd whether to issue oplocks
(opportunistic locks) to file open requests on this share. The
oplock code can dramatically (approx. 30% or more) improve
the speed of access to files on Samba servers. It allows the
clients to aggressively cache files locally and you may want to
disable this option for unreliable network environments (it is
turned on by default in Windows NT Servers). For more
information see the file Speed.txt in the Samba docs/
directory.
這是我找到原說明中可以改善的這個問題
oplock break wait time (G)
This is a tuning parameter added due to bugs in both
Windows 9x and WinNT. If Samba responds to a client too
quickly when that client issues an SMB that can cause an
oplock break request, then the network client can fail and not
respond to the break request. This tuning parameter (which is
set in milliseconds) is the amount of time Samba will wait
before sending an oplock break request to such (broken)
clients.
DO NOT CHANGE THIS PARAMETER UNLESS YOU HAVE READ
AND UNDERSTOOD THE SAMBA OPLOCK CODE.
Default: oplock break wait time = 0
原意好像是說:有一些機器反應太快以至於無法中斷連線,因此
我調整oplock break wait time =20 至50,結果問題有效解決了
然而95還是有問題,因此我又加了keepalive=120 ,兩分鐘
因為網路內只有五,六台電腦,因此設兩分鐘,讓server檢
查使用者的電腦的連線回應
————————————————————
#======================= Global Settings =====================================
[global]
# ———————– Network Related Options ————————-
#
workgroup = WORKGROUP
# server string = Samba Server Version %v
netbios name = win2000
getwd cache = yes
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
; dos charset = cp950
; unix charset= utf8
; display charset = cp950
display charset = UTF8
dos charset = cp950
unix charset = UTF8
; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
; hosts allow = 127. 192.168.12. 192.168.13.
# ————————— Logging Options —————————–
# 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 ————————
security = user
passdb backend = tdbsam
#passdb backend = smbpasswd
#將guest權限設nobody
guest account = nobody
#電腦無須號密碼登入
; map to guest = bad user
# ———————– Domain Members Options ————————
; security = domain
; passdb backend = tdbsam
; realm = MY_REALM
; password server =
# ———————– Domain Controller Options ————————
#
; security = user
; passdb backend = tdbsam
; domain master = yes
; domain logons = yes
# the login script name depends on the machine name
; logon script = %m.bat
# the login script name depends on the unix user used
; logon script = %u.bat
; logon path = \\%L\Profiles\%u
# disables profiles support by specifing an empty path
; logon path =
; add user script = /usr/sbin/useradd "%u" -n -g users
; add group script = /usr/sbin/groupadd "%g"
; add machine script = /usr/sbin/useradd -n -c "Workstation (%u)" -M -d /nohome -s /bin/false "%u"
; delete user script = /usr/sbin/userdel "%u"
; delete user from group script = /usr/sbin/userdel "%u" "%g"
; delete group script = /usr/sbin/groupdel "%g"
# ———————– Browser Control Options —————————-
; local master = no
; os level = 33
; preferred master = yes
#—————————– Name Resolution ——————————-
; wins support = yes
; wins server = w.x.y.z
; wins proxy = yes
dns proxy = no
# ————————— Printing Options —————————–
# load printers = yes
load printers = no
# cups options = raw
; printcap name = /etc/printcap
#obtain list of printers automatically on SystemV
; printcap name = lpstat
printcap name = /dev/null
; printing = cups
printing = bsd
# ————————— Filesystem Options —————————
; map archive = no
; map hidden = no
; map read only = no
; map system = no
; store dos attributes = yes
#============================ Share Definitions ==============================
;[homes]
; comment = Home Directories
; browseable = no
; writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S
;[printers]
; comment = All Printers
; path = /var/spool/samba
; browseable = no
; guest ok = no
; writable = no
; printable = yes
# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
; comment = Network Logon Service
; path = /var/lib/samba/netlogon
; guest ok = yes
; writable = no
; share modes = no
# Un-comment the following to provide a specific roving profile share
# the default is to use the user’s home directory
; [Profiles]
; path = /var/lib/samba/profiles
; browseable = no
; guest ok = yes
# 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
[hs]
#chown root:user
comment = W3000
path = /sysvol/hs
public = no
writable = yes
create mode=0775
directory mode=0775
browseable=yes
printable = no
[share]
#chown user:user
comment = share
path = /sysvol/share
public = no
writable = yes
create mode=0775
directory mode=0775
browseable=yes
printable = no
[bak]
comment = 每周備份
path = /backup/bak
public = no
writable = no
create mode=0775
directory mode=0775
browseable=yes
printable = no
[log]
comment = 備份訊息
path = /backup/log
public = no
writable = no
create mode=0775
directory mode=0775
browseable=yes
printable = no
[mis$]
comment = mis
path = /backup/mis
public = no
writable = no
create mode=0775
directory mode=0775
browseable=yes
printable = no