2015年5月25日 星期一

新增硬碟

[ 新增硬碟 - 大於2TB ]

# fdisk -l 查看目前實體硬碟狀態
# fdisk /dev/sdb
   n 新增
   p 查看
   w 寫入
# cat /proc/partitions  查看分割區
# mkfs -t ext4 /dev/sdb1
# mkdir /mnt/data1
# mount /dev/sdb1  /mnt/data1

若硬碟大於2TB,出現 GPT,fdisk無法支援。要使用parted
# parted /dev/sdc
   (parted)  print
   (parted) mklabel gpt
   (parted) mkpart   建立分割
     partition name? primary
     start? 0
     end? -1
   (parted) quit
# fdisk -l  查看是否使用了GPT格式
# mkfs -t ext4 /dev/sdc1

設定開機即掛載裝置
# /etc/fstab
  加入
  /dev/sdb1      /mnt/data1      ext4      default      1   2
# mount -a   依照/etc/fstab的資料,將所有未掛載的裝置掛載起來
# df 查看是否掛載成功

[ ln 連結 ]

ln 來源檔 目的檔   (此為實體連結hard link,增加檔案的副本位置,不佔空間)
ln -s 來源檔 目的檔  (此為符號連結symbolic link,相當於windows的捷徑)

ln -s 符號連結才可以對目錄進行連結,但要必須要用絕對路徑,相對路徑不會成功。

2015年5月6日 星期三

Samba Server

[ Samba Server ]

NetBIOS 是無法跨路由的(Router Gateway)
NetBIOS over TCP/IP

nmbd:管理工作群組、Netbios name解析等,使用port 137、138
smbd:管理samba主機分享的目錄.檔案,使用port 139、(port 445 讓windows可以使用 \\ip )

Samba所須要的軟體:samba, samba-client, samba-common

samba.conf 設定好工作群組、NetBios name、分享的目錄參數、檔案權限、可使用的帳號資料
其1是伺服器整體參數 global全域,其2是分享的資訊

[global]
             workgroup = 工作群組名稱
             netbios name = 主機netbios name名稱
             security = share    (使用者認證層級)
             display charset
             unix charset
             dos charset
[temp]

# locale -a 看linux 支援的語系
# locale 查看 LANG 設定的語系
而整體系統預設的語系在 /etc/sysconfig/i18n 裡
# cat /etc/sysconfig/i18n
例如     LANG="ZH_TW.UTF-8"

設定 Samba Server

[ 設定 Samba Server ]


1. 安裝
  • rpm -ql samba  (發現並未安裝)
  • 安裝 samba套件
           # yum search samba*  
           # yum list samba*
           # yum install samba
  • cat /etc/sysconfig/i18n       查看伺服器語系是否為utf-8
  • # cd /etc/samba
  • # cp smb.conf smb.conf.raw    備份一份
  • # vim smb.conf
    [global]
          workgroup = MYGROUP
          netbios name = cd2
          security = share    (不須帳密的分享)
          load printers = no
    [temp]
         common  = temporary file space
         path = /tmp
         writable = yes
         browseable = yes
         guest ok = yes
    •  vim 語法:命令模式下    「/搜尋字串」 「nyy,向下複製n行」 「p 貼上」
  •  # testparm   檢查 smb.conf 語法是否有誤
  • ulimit -n 16834
  • /etc/init.d/smb start   (啟動smb)
  • /etc/init.d/nmb start
  • chkconfig smb ok     (設定開機即啟動)
  • chkconfig nmb ok
  • netstat -tlnup | grep mbd
    • 此時會看到 port 137、138、139、445
2. 調整防火牆
  •  # getenforce  查看SElinux 為 enforcing
  •  # setenforce 0  暫時關閉selinux
  •  # /etc/selinux/config  中把 selinux=enforcing 改為 disable (永久關閉)
  •  # service iptables status  查看iptables的狀態
  •  # service iptables stop  暫時關閉防火牆
  •  # chkconfig iptables off 永久關閉防火牆
3. # chmod 775 (777) share的資料夾

4. 設定須要帳號密碼的分享
  • # vim smb.conf
    [global]
          workgroup = MYGROUP
          netbios name = cd2
          security =user
          passdb backend = tdbsam
          load printers = no
    [home]
    [pic]
         common  = share file
         path = /home/pic
         writable = yes
         browseable = yes
         write list = @users
  • # chgrp users /home/pic
  • # chmod 2770 /home/pic
  • # ll -d /home/pic
  • # useradd -G users user  (新增user帳號且為users群組)
  • # passed user
  • # pdbedit -L  (查看samba 資料庫裡的帳號)
  • # pdbedit -a -u user  (新增samba 帳號)
  • # smbpasswd user  (修改samba裡的帳號之密碼)
  • /etc/init.d/smb restart
  • /etc/init.d/nmb restart
  • # smbclient -L //127.0.0.1 -U user

2015年4月28日 星期二

CentOS 6.5 安裝

[ CentOS 6.5 安裝 ]


1.光碟片安裝
  •  2顆80GB硬碟,先做硬體Raid 1
  •  自定磁碟分割
              / boot     500MB
              /             10GB
              / home   50GB
              / swap    8GB      (自動變成延伸磁碟) 
  •  安裝時選 Basic Server
2.完成進入Centos
  •  /etc/sysconfig/network-scripts/ifcfg-eth0 設定網卡
         ONBOOT="yes"
         NM_controlled="no"
         BOOTPROTO=none
         IPADDR=172.18.x.x
         NETMASK=255.255.255.0
         GATEWAY=172.18.x.254  
  • /etc/sysconfig/resolv.conf   設定DNS
         nameserver  校內dns
         nameserver 168.95.1.1

      # /etc/init.d/network  restart
      # ping www.google.com
      # dig www.google.com    測試DNS是否順利運作了

3.  adduser  yuan
     passwd yuan

  • /etc/ssh/sshd_config    修正ssh安全
        PermitRootLogin no
        UseDNS no
        allowusers yuan

     # /etc/init.d/sshd restart   
     # netstat -tlnp | grep ssh     查看ssh是否啟用22 port了