Samba-Server

Samba server installation on CentOS 6.5
=======================================


Basic-samba Server
==================


Install the samba package

# yum install samba samba-client samba-common

Check the version of installed samba

# smbd --version


Configure the samba service to start automatically at boot time:

# chkconfig smb on
# chkconfig nmb on



Add these Iptables rules/Disable IPTables

# iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
# iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
# iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
# service iptables save


Backup the smb.conf file and create the new one:

# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
# >/etc/samba/smb.conf
# vi /etc/samba/smb.conf


#====== Global Settings =====
[global]
workgroup = WORKGROUP
security = share
map to guest = bad user
#==== Share Definitions =====
[Samba-Share]
path = /SMB/Data
browsable =yes
writable = yes
guest ok = yes
read only = no


#

Save the smb.conf file and restart the service:

# service smb restart
# service nmb restart


Change permission for samba share:

# chmod -R 0777 /SMB/Data



Secured - Samba
===============

Add a group in your CentOS server:

# useradd test
# groupadd smbgrp
# usermod -a -G smbgrp test
# smbpasswd -a test


Create a new share, set the permission on the share:

# mkdir /SMB/Data-Sec
# chown test:smbgrp /SMB/Data-Sec
# chmod 0770 /SMB/Data-Sec


Edit the smb.conf file:

# vi /etc/samba/smb.conf


#====== Global Settings =====
[global]
workgroup = SambA
security = user
#==== Share Definitions =====
[Secure]
path = /SMB/Data-Sec
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes
create mask = 0644
directory mask = 0755


#


Restart the samba service:

# service smb restart
# service nmb restart



Check the syntax error with testparm:

# testparm


For Printer-Sharing
=====================


# vi /etc/samba/smb.conf
[global]
    workgroup = SambA
    log file = /var/log/samba/log.%m
    max log size = 50
    security = user
    passdb backend = tdbsam
    load printers = yes
    printing = cups
    printcap name = cups
[printers]
    comment = All Printers
    path = /var/spool/samba
    browseable = yes
    guest ok = yes
    printable = yes
        read only = yes 
        create mask = 0700
[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers
    browseable = yes
    read only = yes
    guest ok = yes

#


===================================

"Soft" and "ISO" Shares as ReadOnly and "Data" share as Writable


# egrep -v "^#|^$" /etc/samba/smb.conf
[global]
    workgroup = SambA
    log file = /var/log/samba/log.%m
    max log size = 50
    security = user
    passdb backend = tdbsam
    load printers = yes
    printing = cups
    printcap name = cups
[printers]
    comment = All Printers
    path = /var/spool/samba
    browseable = yes
    guest ok = yes
    printable = yes
    read only = yes 
    create mask = 0700
[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers
    browseable = yes
    read only = yes
    guest ok = yes
[Softs]
    comment = 4-Clone
    path = /Clone/Samba/Softs
    public = yes
    writable = no
    printable = no
    valid users = test
    create mask = 0644
    directory mask = 0755

[ISO]
    comment = 4-Clone
    path = /Clone/Samba/ISO
    public = yes
    writable = yes
    printable = no
    valid users = centos, test
    create mask = 0644
    directory mask = 0755
[Data]
    comment = 4-Clone
    path = /Clone/Samba/Public
    public = yes
    writable = yes
    printable = no
    guest ok = yes
    create mask = 0777
    directory mask = 0777

#

# ls -ld /Clone/Samba/ISO
drwxr-xr-x 9 centos centos 4096 Dec 15 15:16 /Clone/Samba/ISO
#

 Here user "centos" have the write permission on samba share "/Clone/Samba/ISO" while user test doesn't have even though defined in Samba conf.Because the system directory permission not allow the user to write.






GlusterFS on Ubuntu/CentOS

GlusterFS
===============


Gluster File System is a distributed files system allowing you to create a single volume of storage which spans multiple disks,
multiple machines and even multiple data centres.
Install the required packages on both Ubuntu/CentOS machines. If have more than two servers,
perform this command on all of the servers required for the volume.


IP 192.168.1.20, hostname centos-gfs1
IP 192.168.1.21, hostname centos-gfs1


GlusterFS server installation
---------------------------------------------------------



On-CentOS
-------------------------

# cd /etc/yum.repos.d/
# wget http://download.gluster.org/pub/gluster/glusterfs/3.4/3.4.0/EPEL.repo/glusterfs-epel.repo
# yum install glusterfs-server
# chkconfig --level 235 glusterd on



On-Ubuntu
---------------------------

# apt-get install glusterfs-server

# glusterfs --version


Now it is mandatory that both machines must listen to each other with their hostname, so update both  machines with the entries in /etc/hosts:

# vi /etc/hosts

192.168.1.20    centos-gfs1    gfs1
192.168.1.21    centos-gfs2    gfs2


#


Note:---Disable SELinux and iptables---

Now in both machines run the command  gluster peer probe

run this on first machine as follows:

# gluster peer probe gfs1
# gluster peer probe gfs2
# gluster peer status



Again same thing repeat on second machine:

# gluster peer probe gfs1
# gluster peer probe gfs2
# gluster peer status




Now I will create a common folder on both machines.

# mkdir /GluFS


Run Below commands Only in One Machine

Now we need to create the volume where the data will reside.
The volume will be called datapoint. Now run on any machine:

# gluster volume create gfsv1 replica 2 transport tcp gfs1:/GluFS gfs2:/GluFS force

# gluster volume start gfsv1

Running either of the below commands should indicate that GlusterFS is up and running.
The ps command should show the command running with both servers in the argument.
netstat should show a connection between both nodes.

# ps aux | grep gluster
# netstat -tap | grep glusterfsd



As a final test, to make sure the volume is available, run gluster volume info. As shown below:

# gluster volume info

It shows that two bricks are fully functional.
Now we have a GlusterFS volume which will maintain replication across two nodes.
In the same way you can use N numbers of brick as nodes.


Install and Configure the Client Components
============================================


# yum install glusterfs-client
# apt-get install glusterfs-client

# mkdir /Test

# mount -t glusterfs centos-gfs1:/gfsv1 /Test

OR
# mount -t glusterfs 192.168.1.20:/gfsv1 /Test


Restrict Access to the Volume
===============================



Currently, any computer can connect to our storage volume without any restrictions.
We can change this by setting an option on our volume.

# gluster volume set gfsv1 auth.allow gluster_client1_ip,gluster_client2_ip

If you need to remove the restriction at any point

# gluster volume set gfsv1 auth.allow *



GlusterFS-Commands
======================