DirectAdmin汉化

Standard

请执行以下命令:


cd /usr/local/directadmin/data/skins/enhanced/lang/


wget https://www.ilovn.com/uploads/directadmin-cn.zip


unzip directadmin-cn.zip


sed -i 's/language=en/language=cn/g' /usr/local/directadmin/data/users/admin/user.conf


service directadmin restart

Ubuntu安装Pritunl简易教程

Standard

如果你看到这里的时候,还不知道Pritunl是干什么的,那么请先搜索一下。

这里仅介绍Pritunl的简易安装方法,保存方便以后使用(本次安装环境是在DO的VPS上)。

1、安装Pritunl

  • user@do$> sudo apt-get update   ##更新apt数据

  • user@do$> sudo apt-get install -y python-software-properties ##安装add-apt-repository

  • user@do$> sudo add-apt-repository -y ppa:pritunl/ppa ##添加pritunl的PPA源

  • user@do$> sudo apt-get update  ##再次更新apt数据

  • user@do$> sudo apt-get install -y pritunl  ##安装pritunl

  • user@do$>sudo apt-get upgrade -y  ##以后有版本更新的时候使用

 

2、配置Pritunl

安装完成后,通过浏览器访问

https://<SERVER_ADDRESS>:9700/

输入默认的用户名 “admin”和默认的密码 “admin”;

如果弹出修改密码的设置,可以设置新的用户名和密码后保存或者点击“Set Later”;

  • 点击顶部标签”Users”

  • 点击”Add Organization”,然后输入一个名字然后点击”Add”

  • 点击”Add User”,然后输入信息,完成后点击”Add”

  • 切换到标签”Servers”

  • 点击”Add Server”,输入服务名称后点击”Add”

  • 点击 “Attach Organization”后确认”Attach”

  • 点击”Start Server”启动服务

 

3、配置客户端(主要介绍Windows和Android)

Windows

  • 点击标签 “Users”

  • 点击用户右边的下载图标,下载配置文件(.tar,请解压)

  • 下载Pritunl Windows客户端

  • 安装客户端后,点击图标,点击”Import Profile”,选择下载的配置文件

  • 选择已经导入的配置文件,点击”Connect”

Android

  • 点击标签”Users”

  • 点击用户右边的”get key links”图标,在浏览器打开第二个链接,点击”Download Key”然后保存

  • 在Google Play中搜索并下载”OpenVPN Connect”

  • 启动”OpenVPN Connect”,在应用菜单中选择”Import”,选择”Import Profile from SD card”,通过文件浏览器找到刚才下载的文件

  • 在应用中选择配置,然后点击”Connect”

 

NFS配置简单记录

Standard

以下是一次nfs服务的配置记录文本,添加了注释:

NFS配置记录
配置说明:
1、仅单向nfs配置,nfs服务器192.168.1.100,客户端192.168.1.102
2、在centos6.x系统中,原来的portmap改名为rpcbind;
3、在启动nfs服务器前先启动portmap(rpcbind)

[code lang=”shell”]
#192.168.1.100 server
login as: root
root@192.168.1.100’s password:
Last login: Tue Oct 9 04:50:30 2012 from 192.168.1.252
[root@lovn ~]# cd /home
[root@lovn home]# ll
总用量 65656
drwxr-xr-x. 25 root root 4096 9月 1 19:50 android
drwxr-x—. 5 12275 5000 4096 8月 10 04:19 android-sdk-linux
-rw-r–r–. 1 root root 67206726 8月 30 23:55 jdk-7u4-linux-i586.rpm
drwx——. 4 smb1 samba 4096 10月 7 06:58 smb1
drwx——. 4 smb2 samba 4096 10月 9 04:52 smb2
drwx——. 4 test test 4096 10月 9 04:55 test

#检查必备的相关包 portmap
[root@lovn home]# rpm -qa | grep portmap
#没有,则安装
[root@lovn home]# yum install portmap
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* updates: mirrors.sin3.sg.voxel.net
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package rpcbind.i686 0:0.2.0-8.el6 will be updated
—> Package rpcbind.i686 0:0.2.0-9.el6 will be an update
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
rpcbind i686 0.2.0-9.el6 base 51 k

Transaction Summary
================================================================================
Upgrade 1 Package(s)

Total download size: 51 k
Is this ok [y/N]: y
Downloading Packages:
rpcbind-0.2.0-9.el6.i686.rpm | 51 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : rpcbind-0.2.0-9.el6.i686 1/2
Cleanup : rpcbind-0.2.0-8.el6.i686 2/2
Verifying : rpcbind-0.2.0-9.el6.i686 1/2
Verifying : rpcbind-0.2.0-8.el6.i686 2/2

Updated:
rpcbind.i686 0:0.2.0-9.el6

Complete!

#portmap 改叫rpcbind了~~~
#检查nfs的相关包
[root@lovn home]# rpm -qa |grep nfs
nfs-utils-lib-1.1.5-4.el6.i686
nfs-utils-1.2.3-15.el6.i686
nfs4-acl-tools-0.3.3-5.el6.i686

#创建一个目录
[root@lovn home]# mkdir /home/nfs
#编辑nfs的默认配置文件
[root@lovn home]# vi /etc/exports
#添加
/home/nfs 192.168.1.0/24(rw,root_squash,no_all_squash,sync)

[root@lovn home]# exportfs -r

##
#配置文件每行分为段:
#第一段为共享的目录,使用绝对路径
#第二段为客户端地址及权限:
#地址可以使用完整IP或网段,例如192.168.1.1或192.168.1.0/24,192.168.1.0/255.255.255.0也可以
#地址可以使用主机名,DNS解析的和本地/etc/hosts解析的都行,支持通配符,例如:*.domainname
#权限有:
#rw:read-write,可读写;(该目录分享的权限是可擦写 (read-write) 或只读 (read-only),但最终能不能读写,还是与文件系统的 rwx 及身份有关。)
#ro:read-only,只读;
#sync:文件同时写入硬盘和内存;
#async:文件暂存于内存,而不是直接写入内存;
#no_root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,也拥有root权限。显然开启这项是不#安全的。
#root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,拥有匿名用户权限,通常他将使用nobod#y或nfsnobody身份;
#all_squash:不论NFS客户端连接服务端时使用什么用户,对服务端分享的目录来说都是拥有匿名用户权限;
#anonuid:匿名用户的UID值,通常是nobody或nfsnobody,可以在此处自行设定;
#anongid:匿名用户的GID值。

#启动portmap(rpcbind)
[root@lovn home]# service rpcbind start
#查看portmap(rpcbind)的状态
[root@lovn home]# service rpcbind status
rpcbind (pid 2895) 正在运行…
#启动nfs
[root@lovn home]# service nfs start
启动 NFS 服务: [确定]
关掉 NFS 配额: [确定]
启动 NFS 守护进程: [确定]
启动 NFS mountd: [确定]
[root@lovn home]#
[root@lovn home]# showmount –help
Usage: showmount [-adehv]
[–all] [–directories] [–exports]
[–no-headers] [–help] [–version] [host]

#测试
[root@lovn home]# showmount -e 192.168.1.100
Export list for 192.168.1.100:
/home/nfs 192.168.1.0/24
[root@lovn home]#

[root@lovn home]# rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 44251 status
100024 1 tcp 55169 status
100011 1 udp 875 rquotad
100011 2 udp 875 rquotad
100011 1 tcp 875 rquotad
100011 2 tcp 875 rquotad
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 2 tcp 2049 nfs_acl
100227 3 tcp 2049 nfs_acl
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 2 udp 2049 nfs_acl
100227 3 udp 2049 nfs_acl
100021 1 udp 52231 nlockmgr
100021 3 udp 52231 nlockmgr
100021 4 udp 52231 nlockmgr
100021 1 tcp 43585 nlockmgr
100021 3 tcp 43585 nlockmgr
100021 4 tcp 43585 nlockmgr
100005 1 udp 42985 mountd
100005 1 tcp 45622 mountd
100005 2 udp 47913 mountd
100005 2 tcp 56059 mountd
100005 3 udp 46379 mountd
100005 3 tcp 54646 mountd

[root@lovn home]# service iptables stop
iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
[root@lovn home]#

[root@lovn home]# cd nfs
[root@lovn nfs]# ll
总用量 0
[root@lovn nfs]# echo "hello,nfs on 192.168.1.100" >> nfs100.txt
[root@lovn nfs]# ll
总用量 4
-rw-r–r–. 1 root root 27 10月 11 04:48 nfs100.txt
[root@lovn nfs]#

[root@lovn home]# chmod 777 nfs
[root@lovn home]# ll
总用量 65660
drwxr-xr-x. 25 root root 4096 9月 1 19:50 android
drwxr-x—. 5 12275 5000 4096 8月 10 04:19 android-sdk-linux
-rw-r–r–. 1 root root 67206726 8月 30 23:55 jdk-7u4-linux-i586.rpm
drwxrwxrwx. 2 root root 4096 10月 11 04:48 nfs
drwx——. 4 smb1 samba 4096 10月 7 06:58 smb1
drwx——. 4 smb2 samba 4096 10月 9 04:52 smb2
drwx——. 4 test test 4096 10月 9 04:55 test

#客户端写入测试后查看
[root@lovn home]# ll nfs
总用量 8
-rw-r–r–. 1 root root 27 10月 11 04:48 nfs100.txt
-rw-r–r–. 1 nfsnobody nfsnobody 36 10月 11 04:56 nfs102.txt

##192.168.1.102 client ##################################
login as: root
root@192.168.1.102’s password:
[root@lovn ~]# rpm -qa | grep nfs
nfs-utils-lib-1.1.5-4.el6.i686
nfs-utils-1.2.3-15.el6.i686
nfs4-acl-tools-0.3.3-5.el6.i686

[root@lovn ~]# showmount -e 192.168.1.100
clnt_create: RPC: Port mapper failure – Unable to receive: errno 113 (No route to host)
[root@lovn ~]#
[root@lovn ~]# rpcinfo -p 192.168.1.100
rpcinfo: can’t contact portmapper: RPC: Remote system error – No route to host
[root@lovn ~]# ping 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=1.62 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=3.82 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=64 time=2.98 ms
64 bytes from 192.168.1.100: icmp_seq=4 ttl=64 time=0.381 ms
^C
— 192.168.1.100 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3046ms
rtt min/avg/max/mdev = 0.381/2.205/3.825/1.312 ms
[root@lovn ~]#

#192.168.1.100关闭防火墙后
[root@lovn ~]# showmount -e 192.168.1.100
Export list for 192.168.1.100:
/home/nfs 192.168.1.0/24
[root@lovn ~]#

#创建挂载点
[root@lovn ~]# mkdir /mnt/nfsdata
#挂载
[root@lovn ~]# mount -t nfs 192.168.1.100:/home/nfs /mnt/nfsdata
[root@lovn ~]#
#检查
[root@lovn ~]# mount
/dev/mapper/vg_lovn-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/CentOS_6.2_Final type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
192.168.1.100:/home/nfs on /mnt/nfsdata type nfs (rw,vers=4,addr=192.168.1.100,clientaddr=192.168.1.102)
[root@lovn ~]#

[root@lovn ~]# ll /mnt/nfsdata/
总用量 4
-rw-r–r–. 1 root root 27 10月 11 04:48 nfs100.txt
[root@lovn ~]# cat /mnt/nfsdata/nfs100.txt
hello,nfs on 192.168.1.100
[root@lovn ~]#

#写文件测试
[root@lovn ~]# echo "hello,nfs server from 192.168.1.102" >> /mnt/nfsdata/nfs102.txt
-bash: /mnt/nfsdata/nfs102.txt: 权限不够
[root@lovn ~]#

#服务器端文件夹开放权限后
[root@lovn ~]# echo "hello,nfs server from 192.168.1.102" >> /mnt/nfsdata/nfs102.txt
[root@lovn ~]# ll /mnt/nfsdata/
总用量 8
-rw-r–r–. 1 root root 27 10月 11 04:48 nfs100.txt
-rw-r–r–. 1 nfsnobody nfsnobody 36 10月 11 04:56 nfs102.txt
[/code]

常见错误及解决:

[code lang=”shell”]
①Cannot register service: RPC
[root@lovn ~]# service nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
#解决方法:
[root@lovn ~]# service portmap start
#要先启动portmap才行

②mount: 192.168.1.100:/home/nfs failed, reason given by server: Permission denied
#解决方法:
#把该客户端的ip加入服务端的/etc/exports
#或者服务端的和客户端规则要统一,要么都使用主机名(注意每台机器的hosts文件),要么都使用IP

③客户端挂载超时
#解决方法:
[root@lovn ~]# service portmap restart
[root@lovn ~]# service nfs restart

④Error: RPC MTAB does not exist.
[root@lovn ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
Starting RPC idmapd: Error: RPC MTAB does not exist.

#解决方法:
#手动执行
[root@lovn ~]# mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs/
#需要时加入开机启动时,加入下面两行到/etc/fstab
rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0
nfsd /proc/fs/nfsd nfsd defaults 0 0
[/code]

原始文本下载

一次SMB服务的配置记录

Standard

以下是一次简单的smb服务的配置记录,基本上都有注释:

[code lang=”shell”]
SMB服务
login as: root
root@192.168.1.103’s password:
Last login: Wed Sep 12 05:27:12 2012 from 192.168.202.1
[root@lovn ~]# ls
anaconda-ks.cfg install.log 公共的 视频 文档 音乐
bin install.log.syslog 模板 图片 下载 桌面
[root@lovn ~]# who
root tty1 2012-10-07 05:50 (:0)
root pts/0 2012-10-07 05:51 (192.168.1.252)

使用Samba服务器需要防火墙开放以下端口
UDP 137 UDP 138 TCP 139 TCP 445

[root@lovn ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
~
~
"/etc/sysconfig/iptables" 13L, 476C

-A INPUT -m state –state NEW -m tcp -p tcp –dport 139 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 445 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 137 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 138 -j ACCEPT
#像下面这样
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state NEW -m tcp -p tcp –dport 139 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 445 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 137 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 138 -j ACCEPT
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
~
~
— INSERT —

#重启防火墙,使规则生效
[root@lovn ~]# service iptables restart
iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
iptables:应用防火墙规则: [确定]
[root@lovn ~]#

#关闭系统的 SELinux(不关闭会无权限)
[root@lovn ~]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted

~
~
"/etc/selinux/config" 13L, 456C
#修改如下
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加

#改完Selinux需要重启
[root@lovn ~]#reboot
Broadcast message from root@lovn.cn
(/dev/pts/0) at 6:30 …

The system is going down for reboot NOW!

#检查Samba服务包是否已安装
[root@lovn ~]# rpm -qa | grep samba
samba-common-3.5.10-114.el6.i686
samba-winbind-clients-3.5.10-114.el6.i686
samba-client-3.5.10-114.el6.i686
samba4-libs-4.0.0-23.alpha11.el6.i686

#缺少相关包则安装
[root@lovn ~]# yum install samba
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package samba.i686 0:3.5.10-125.el6 will be installed
–> Processing Dependency: samba-winbind-clients = 3.5.10-125.el6 for package: samba-3.5.10-125.el6.i686
–> Processing Dependency: samba-common = 3.5.10-125.el6 for package: samba-3.5.10-125.el6.i686
–> Running transaction check
—> Package samba-common.i686 0:3.5.10-114.el6 will be updated
–> Processing Dependency: samba-common = 3.5.10-114.el6 for package: samba-client-3.5.10-114.el6.i686
—> Package samba-common.i686 0:3.5.10-125.el6 will be an update
—> Package samba-winbind-clients.i686 0:3.5.10-114.el6 will be updated
–> Processing Dependency: samba-winbind-clients = 3.5.10-114.el6 for package: libsmbclient-3.5.10-114.el6.i686
—> Package samba-winbind-clients.i686 0:3.5.10-125.el6 will be an update
–> Running transaction check
—> Package libsmbclient.i686 0:3.5.10-114.el6 will be updated
—> Package libsmbclient.i686 0:3.5.10-125.el6 will be an update
—> Package samba-client.i686 0:3.5.10-114.el6 will be updated
—> Package samba-client.i686 0:3.5.10-125.el6 will be an update
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
samba i686 3.5.10-125.el6 base 4.9 M
Updating for dependencies:
libsmbclient i686 3.5.10-125.el6 base 1.6 M
samba-client i686 3.5.10-125.el6 base 11 M
samba-common i686 3.5.10-125.el6 base 13 M
samba-winbind-clients i686 3.5.10-125.el6 base 1.1 M

Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 4 Package(s)

Total download size: 32 M

#同意安装
Is this ok [y/N]: y
Downloading Packages:
(1/5): libsmbclient-3.5.10-125.el6.i686.rpm | 1.6 MB 00:05
(2/5): samba-3.5.10-125.el6.i686.rpm | 4.9 MB 00:14
(3/5): samba-client-3.5.10-125.el6.i686.rpm | 11 MB 00:33
(4/5): samba-common-3.5.10-125.el6.i686.rpm | 13 MB 00:44
(5/5): samba-winbind-clients-3.5.10-125.el6.i686.rpm | 1.1 MB 00:01
——————————————————————————–
Total 279 kB/s | 32 MB 01:56
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : samba-winbind-clients-3.5.10-125.el6.i686 1/9
Updating : samba-common-3.5.10-125.el6.i686 2/9
Updating : samba-client-3.5.10-125.el6.i686 3/9
Installing : samba-3.5.10-125.el6.i686 4/9
Updating : libsmbclient-3.5.10-125.el6.i686 5/9
Cleanup : samba-client-3.5.10-114.el6.i686 6/9
Cleanup : samba-common-3.5.10-114.el6.i686 7/9
Cleanup : libsmbclient-3.5.10-114.el6.i686 8/9
Cleanup : samba-winbind-clients-3.5.10-114.el6.i686 9/9
Verifying : samba-winbind-clients-3.5.10-125.el6.i686 1/9
Verifying : samba-common-3.5.10-125.el6.i686 2/9
Verifying : samba-client-3.5.10-125.el6.i686 3/9
Verifying : samba-3.5.10-125.el6.i686 4/9
Verifying : libsmbclient-3.5.10-125.el6.i686 5/9
Verifying : libsmbclient-3.5.10-114.el6.i686 6/9
Verifying : samba-common-3.5.10-114.el6.i686 7/9
Verifying : samba-client-3.5.10-114.el6.i686 8/9
Verifying : samba-winbind-clients-3.5.10-114.el6.i686 9/9

Installed:
samba.i686 0:3.5.10-125.el6

Dependency Updated:
libsmbclient.i686 0:3.5.10-125.el6
samba-client.i686 0:3.5.10-125.el6
samba-common.i686 0:3.5.10-125.el6
samba-winbind-clients.i686 0:3.5.10-125.el6

Complete!

#再次检查
[root@lovn ~]# rpm -qa | grep samba
samba-common-3.5.10-125.el6.i686
samba-winbind-clients-3.5.10-125.el6.i686
samba-3.5.10-125.el6.i686
samba-client-3.5.10-125.el6.i686
samba4-libs-4.0.0-23.alpha11.el6.i686

#配置samba
[root@lovn ~]#vi /etc/samba/smb.conf
[global] #找到这一行(全局设置标签),在此行下面修改:
workgroup = WORKGROUP #工作组名称改为 Windows 网络所定义的工作组名,这里默认是MYGROUP,改一下
server string = Samba Server Version %v #设置samba服务器的主机名称
security = user #设置samba服务器安全级别为user,即以账号和口令访问

#保存配置

#添加用于samba的用户和组(这里可以用添加用户的参数,指定samba用户不能直接登陆到系统,本例不处理)
[root@lovn ~]# groupadd samba
[root@lovn ~]# useradd -g samba smb1
[root@lovn ~]# useradd -g samba smb2
#创建用户密码
[root@lovn ~]# smbpasswd -a smb1
New SMB password:
Retype new SMB password:
tdbsam_open: Converting version 0.0 database to version 4.0.
tdbsam_convert_backup: updated /var/lib/samba/private/passdb.tdb file.
account_policy_get: tdb_fetch_uint32 failed for type 1 (min password length), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 2 (password history), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 3 (user must logon to change password), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 4 (maximum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 5 (minimum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 6 (lockout duration), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 7 (reset count minutes), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 8 (bad lockout attempt), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 9 (disconnect time), returning 0
account_policy_get: tdb_fetch_uint32 failed for type 10 (refuse machine password change), returning 0
Added user smb1.
#另外一个用户的密码
[root@lovn ~]# smbpasswd -a smb2
New SMB password:
Retype new SMB password:
Added user smb2.
#这里设置的密码是用户登录该机的Samba共享的密码,不是登陆系统的密码;

#重启Samba服务器
[root@lovn ~]# service smb restart
关闭 SMB 服务: [确定]
启动 SMB 服务: [确定]

######################################################################################################3
#以上配置是默认的用户登陆后能看到自己家目录的内容
#下面的配置将会增加一个公共的共享目录(公共的意思并不是不需要登陆就能看到,而是登陆的用户都能看到)
#编辑Samba配置文件
[root@lovn ~]# vi /etc/samba/smb.conf
[any]
comment = any!
path = /home/android #指定目录
public = yes #公开目录(不公开目录与它的区别在于访问到目录是是否直接显示)
writable = no #不可写(公共目录,只读)
#保存退出

#重启Samba服务器
[root@lovn ~]# service smb restart
关闭 SMB 服务: [确定]
启动 SMB 服务: [确定]

#如果哪有其他权限问题,尝试关闭iptables
[root@lovn ~]# service iptables stop
iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
[/code]

原始文本下载

Linux网站及数据库自动备份并FTP上传备份脚本

Standard

准备工作:

需要提前在VPS安装好lftp,CentOS直接执行:

yum install lftp

需要在VPS上创建/home/backup/ 目录,在FTP上创建backup目录。

下面将备份脚本进行部分注释:
#!/bin/bash
#Funciont: Backup website and mysql database
#Author: licess
#Website: http://lnmp.org
#IMPORTANT!!!Please Setting the following Values!

######~Set Directory you want to backup~######将下面的目录修改成自己要备份的目录,一般按我的都是在/home/websites/下面所有直接写了需要备份的目录。可以继续再加:Backup_Dir6=你的目录 ,Backup_Dir后面的数字依次递增。如果不足5个,直接删除不需要的就可以,同时修改下面tar zcf 部分。

Backup_Dir1=xx.xx
Backup_Dir2=xx.xx
Backup_Dir3=xx.xx
Backup_Dir4=xx.xx
Backup_Dir5=xx.xx

######~Set MySQL UserName and password~######设置MySQL的用户名和密码,最好是root,其他用户可能因为权限问题无法导出部分数据库。

MYSQL_UserName=user
MYSQL_PassWord=psw

######~Set MySQL Database you want to backup~######设置要部分的数据库,可以继续再加:Backup_Database_Name5=数据库名,Backup_Database_Name后面的数字依次递增。

Backup_Database_Name1=emlog
Backup_Database_Name2=xx
Backup_Database_Name3=xx
Backup_Database_Name4=xx
Backup_Database_Name5=xx

######~Set FTP Information~######设置用来存放备份数据的FTP信息
FTP_HostName=ftp.xx.xx //FTP服务器的IP或者域名
FTP_UserName=ftp_user //FTP服务器用户名
FTP_PassWord=ftp_psw //FTP服务器用户对应的密码
FTP_BackupDir=backup //备份到FTP上的目录,需要提前创建好。

#Values Setting END!

TodayWWWBackup=*-$(date +”%Y%m%d”).tar.gz
TodayDBBackup=db-*-$(date +”%Y%m%d”).sql
OldWWWBackup=*-$(date -d -3day +”%Y%m%d”).tar.gz
OldDBBackup=db-*-$(date -d -3day +”%Y%m%d”).sql

tar zcf /home/backup/web-$Backup_Dir1-$(date +”%Y%m%d”).tar.gz -C /home/websites/ $Backup_Dir1
tar zcf /home/backup/web-$Backup_Dir2-$(date +”%Y%m%d”).tar.gz -C /home/websites/ $Backup_Dir2
tar zcf /home/backup/web-$Backup_Dir3-$(date +”%Y%m%d”).tar.gz -C /home/websites/ $Backup_Dir3
tar zcf /home/backup/web-$Backup_Dir11-$(date +”%Y%m%d”).tar.gz -C /home/websites/ $Backup_Dir4 –exclude=uploaded
tar zcf /home/backup/web-$Backup_Dir12-$(date +”%Y%m%d”).tar.gz -C /home/websites/ $Backup_Dir5 –exclude=cache

###上面为备份网站文件数据,网站目录下面有些目录属于临时目录并不需要备份,所以可以在上面加上–exclude=不备份的目录。

/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name1 > /home/backup/db-$Backup_Database_Name1-$(date +”%Y%m%d”).sql
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name2 > /home/backup/db-$Backup_Database_Name2-$(date +”%Y%m%d”).sql
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name3 > /home/backup/db-$Backup_Database_Name3-$(date +”%Y%m%d”).sql
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name4 > /home/backup/db-$Backup_Database_Name4-$(date +”%Y%m%d”).sql
/usr/local/mysql/bin/mysqldump -u$MYSQL_UserName -p$MYSQL_PassWord $Backup_Database_Name5 > /home/backup/db-$Backup_Database_Name5-$(date +”%Y%m%d”).sql

rm $OldWWWBackup
rm $OldDBBackup
###删除3天前的备份###

cd /home/backup/

###下面为自动上传部分####
lftp $FTP_HostName -u $FTP_UserName,$FTP_PassWord << EOF
cd $FTP_BackupDir
mrm $OldWWWBackup
mrm $OldDBBackup
mput $TodayWWWBackup
mput $TodayDBBackup
bye
EOF

脚本下载地址:http://dl.ilovn.com/uploaded/2012/06/08/backup.sh

将脚本放到/root/ 下面,按上面的注释修改脚本中的参数,并保存。执行:chmod +x /root/backup.sh 为脚本添加执行权限,执行:crontab -e 添加定时执行

在crontab中加入:

0 3 * * * /root/backup.sh

凌晨3点自动执行/root/bakcup.sh 脚本,备份vps上的数据并上传到FTP上。

ps:文章参考http://www.vpser.net/security/linux-autobackup-ftp.html,亲测可行。感谢军哥的教程,本地保存,以备不时之需。