Setting Up A Standalone Storage Server With GlusterFS And Samba On Debian Squeeze - Page 3
6 Configuring SambaIn this case, we assume that we have 3 departments. node1/node2 apt-get install samba Next, we need to configure /etc/samba/smb.conf on both nodes: node1/node2 cp /etc/samba/smb.conf /etc/samba/smb.conf_orig [global] netbios name = CLUSTER [public] comment = Public directory path = /home/public force user = nobody force group = nogroup read only = No create mask = 0664 directory mask = 0775 guest ok = Yes [homes] comment = Home directory %S valid users = %S read only = No create mask = 0700 directory mask = 0700 browseable = No [Dep_1] comment = Department 1 path = /home/Dep_1 guest ok = no browseable = yes writeable = yes create mask = 0660 directory mask = 0770 write list = @Dep_1 [Dep_2] comment = Department 2 path = /home/Dep_2 guest ok = no browseable = yes writeable = yes create mask = 0660 directory mask = 0770 write list = @Dep_2 [Dep_3] comment = Department 3 path = /home/Dep_3 guest ok = no browseable = yes writeable = yes create mask = 0660 directory mask = 0770 write list = @Dep_3 Create users groups on both nodes: node1/node2 groupadd Dep_1 Create the directories and set privileges (only on node1): on node1 mkdir /home/public Make sure, that all is fine... ls -l /home/ ... as result, you should se:
drwxrwx--- 2 root Dep_1 4096 12-25 13:50 Dep_1
7 Custom scripts and settings to make life easier ;)How many times did You hear "where is my very important file?" Sometimes users remove wrong files of their shares. With samba, we can avoid this. At least we can recover that file, if we were using the "recycle" module. Append following lines into the /etc/samba/smb.conf in global section node1/node2 vi /etc/samba/smb.conf [global] ... #RECYCLE BIN recycle:repository = /home/TRASH/%u_%I_%S recycle:keeptree = TRUE recycle:versions = TRUE recycle:touch = TRUE ... And next append following line in section [homes]: [homes] ... vfs objects = recycle ... Create TRASH directory: mkdir /home/TRASH Of course after that we need to restart SAMBA, thats mean We have to login on every one node and run command like: /etc/init.d/samba restart It would be easier if We don't need to login twice. We may do that in few simple steps: on node1 ssh-keygen -t rsa Command ssh-keygen -t rsa generate two files, one of them contains private key and another contain public key.
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys and on node2 run following command: on node2 mkdir /root/.ssh That's it, now we may run on node1 following command, and we dont have to enter any passwords: ssh node2 /etc/init.d/samba restart
8 The very last partTo make sure that both nodes could be accessed via SMB, and there are the same users accounts, we need to add Linux and Samba users accounts on both nodes. Of course we don't want to let users login to any node shell. We can do it in that way (run following command): on node1 Remember, be nice and say hello to every new user.
mkdir /root/skel Next we create a useful script. touch /root/add_user.sh #!/bin/bash backup_time=`date +%Y.%m.%d_%H:%M` USER=$1 DEPARTMENT=$2 PASSWORD=$3 #Add Linux user account /usr/sbin/useradd -d /home/$DEPARTMENT/$USER -g $DEPARTMENT -G users,$DEPARTMENT -m -k /root/skel -s /bin/false $USER #Setup directory permission chmod 700 /home/$DEPARTMENT/$USER #Setup SAMBA user - password echo -ne "$PASSWORD\n$PASSWORD\n" | smbpasswd -s -a $USER #Make a copy, and move on node2 cp /etc/passwd /root/passwd.copy.$backup_time cp /etc/group /root/group.copy.$backup_time tar czvf /root/tdb_$backup_time.tgz /var/lib/samba ssh node2 /etc/init.d/samba stop scp /etc/passwd node2:/etc/passwd scp /etc/group node2:/etc/group scp -r /var/lib/samba/* node2:/var/lib/samba/ ssh node2 /etc/init.d/samba start From now, if you want to add next user, just run ...
cd /root
Lets make some tests:On MS Windows client: Press START -> Run -> and try to get access to \\192.168.20.106 If everything ok, do it on node2: \\192.168.20.107 On both servers you should have access to Johns directory and public directory. ls /home/TRASH ... you should see that result ... john_192.168.20.7_Dep_1 ... next run ... ls /home/TRASH/john_192.168.20.7_Dep_1 ... you should see all removed files and directories. Of course You may want to use CTDB Cluster to manage the Samba, and You probably should.
References
|



Recent comments
14 hours 26 min ago
21 hours 7 min ago
1 day 58 min ago
1 day 2 hours ago
1 day 11 hours ago
1 day 20 hours ago
1 day 21 hours ago
2 days 53 min ago
2 days 5 hours ago
2 days 5 hours ago