-
安裝 quota 套件:
#yum -y install quota
-
使用 xfs_quota 指令與格式
xfs_quota [option] [mount_point]
[option]- -x:專家模式
- -c:配合專家模式,在後面追加下列指令:
- print:列出目前主機內的檔案系統參數資料
- df:與系統指令 df 功能相同
- report:列出 quota 資料,可用參數包含 -ugr (user/group/project) 及 -bi (block/inode)
- state:顯示目前 quota 資訊
- limit:限制配額空間,針對 user/group 來限制
指令格式: limit [-ug] b[soft|hard]=N i[soft|hard]=N name
bsoft/bhard : block 限制值,後面可以加上空間單位
isoft/ihard : inode 限制值
name:用戶/群組名稱
- timer:設定 grace time
指令格式:timer [-ug] [-bir] Ndays
- 檔案系統掛載點
-
使用範例與測試:
範例一:-
編輯 /etc/fstab 檔案,加入 quota 功能:
#vim /etc/fstab UUID=XXXX /webhome xfs defaults,usrquota,grpquota 0 0
-
重新掛載檔案系統:
#mount -o remount -a
-
查看所有相關的訊息:
#xfs_quota -x -c "print" #xfs_quota -x -c "df -h" /home #xfs_quota -x -c "report -ubih" /home #xfs_quota -x -c "state"
-
編寫設定:
#xfs_quota -x -c "limit -u bsoft=1024M bhard=1500M user1" /webhome #xfs_quota -x -c "timer -u -b 30days" /webhome
-
測試:
#su - user1 $dd if=/dev/zero of=/webhome/123.img bs=1M count=1300 $ls -al /webhome/123.img $exit #xfs_quota -x -c "report -ubh" /webhome
-
編輯 /etc/fstab 檔案,加入 quota 功能:
2016年3月29日 星期二
XFS 檔案系統管理
Quota (磁碟配額) 的使用
在 CentOS7/RHEL7 上安裝設定 E-mail Server(一)
快速設定流程:
-
安裝 Postfix 套件:
#yum -y install postfix dovecot
-
編修設定檔 /etc/postfix/main.cf:
#vim /etc/postfix/main.cf myhostname = mail.example.com mydomain = example.com myorigin = $mydomain mynetworks_style = class mynetworks = 127.0.0.0/8, 192.168.100.0/24 inet_interfaces = all mydestination = $mydomain, $myhostname, localhost.$mydomain, localhost mail_spool_directory = /var/mail home_mailbox = Maildir/ mailbox_size_limit = 0 #原設定參數沒有 message_size_limit = 0 #請自己加上即可
-
編修設定檔 /etc/dovecot/dovecot.conf:
#vim /etc/dovecot/dovecot.conf protocols = imap pop3
-
編修設定檔 /etc/dovecot/conf.d/10-mail.conf:
#vim /etc/dovecot/conf.d/10-mail.conf mail_location = mbox:~/mail:INBOX=/var/mail/%u
-
設定防火牆,放行 smtp 與 imap 的服務:
#firewall-cmd --permanent --add-service=smtp #firewall-cmd --permanent --add-port=110/tcp #firewall-cmd --permanent --add-port=143/tcp #firewall-cmd --reload
-
設定 SELinux :
#setsebool -P postfix_local_write_mail_spool on
-
啟動 smtp 與 imap 的服務:
#systemctl enable postfix #systemctl enable dovecot #systemctl start postfix #systemctl start dovecot
-
發送 mail ,檢測服務是否運作正常:
#mail student@mail.example.com Subject: test Hello World! .
-
查看一下 /var/log/maillog 的記錄 :
#tail /var/log/maillog
-
可以利用 mutt 或 thunderbird 來檢測:
#yum -y install thunderbird mutt
mutt 的小設定#su - student $vim ~/.muttrc set mbox_type=Maildir set folder="~/Maildir" set mask="!^\\.[^.]" set mbox="~/Maildir" set record="+.Sent" set postponed="+.Drafts" set spoolfile="~/Maildir"
使用 mutt 來測試:$mutt
- http://www.nurdletech.com/linux-notes/mail-server/postfix.html
- http://blog.kevinlinul.idv.tw/?p=225#comment-16
- http://www.elho.net/mutt/maildir/
2016年3月28日 星期一
在 CentOS7/RHEL7 上安裝設定 BIND
快速設定流程:
-
安裝 BIND 套件:
#yum -y install bind bind-libs bind-chroot bind-utils
-
編修設定檔 /etc/named.conf:
#vim /etc/named.conf options { listen-on port 53 { any; }; //listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { localhost; 192.168.100.0/24; }; recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key"; zone "." IN { type hint; file "named.ca"; }; //設定所管轄的網域名稱對IP正解析 zone "example.com" IN { type master; file "example.zone"; }; //設定所管轄的網域名稱對IPv4反解析 zone "100.168.192.in-addr.arpa" IN { type master; file "example.reverse"; }; -
編修example.com網域正解析記錄檔 /var/named/example.zone:
#vim /var/named/example.zone $TTL 10 @ IN SOA dns1.example.com. root ( 2016032901; 1H; 2D; 3W; 10 ) @ IN NS dns1.example.com. @ IN A 192.168.100.183 @ IN MX 10 mail dns1.example.com. IN A 192.168.100.183 mail IN A 192.168.100.183 ftp IN A 192.168.100.183 www IN A 192.168.100.183 -
編修example.com網域正解析記錄檔 /var/named/example.reverse:
#vim /var/named/example.reverse $TTL 10 @ IN SOA dns1.example.com. root ( 2016032901; 1H; 2D; 3W; 10 ) @ IN NS dns1.example.com. 183 IN PTR dns1.example.com. 183 IN PTR mail.example.com. 183 IN PTR www.example.com. 183 IN PTR ftp.example.com. -
設定防火牆,放行 DNS 服務:
#firewall-cmd --permanent --add-service=dns #firewall-cmd --reload
-
啟動 DNS Server 服務:
#systemctl stop named #systemctl disable named #systemctl enable named-chroot #systemctl start named-chroot
-
設定本機查詢的 DNS Server:
#vim /etc/resolv.conf search example.com nameserver 192.168.100.183
-
利用 rndc 工具:
#rndc status #rndc reload
-
利用 dig 工具:
#dig example.com NS #dig example.com A #dig -x 192.168.100.183
2016年3月21日 星期一
在 CentOS7/RHEL7 上安裝 MariaDB
快速設定流程:
安裝 phpMyAdmin 管理程式:
-
安裝 MySQL/MariaDB 套件:
#yum -y install mariadb mariadb-server mariadb-bench
-
啟動 MySQL Server :
#systemctl start mariadb.service #systemctl enable mariadb.service
-
查詢預設 root 密碼:
#systemctl status mariadb -l #less /var/log/messages
-
設定 root 密碼:
#/usr/bin/mysqladmin -u root password 'a123456!' #/usr/bin/mysqladmin -u root -h localhost.localdomain password 'a123456!'
※PS:可以執行 mysql_secure_installation 指令來設定 root 密碼
-
開通防火牆設定:
#firewall-cmd --permanent --add-service=mysql #firewall-cmd --reload
-
測試 MariaDB:
#mysql -u root -p
安裝 phpMyAdmin 管理程式:
-
下載 phpMyAdmin 套件:
#wget -d /var/www/html/ https://files.phpmyadmin.net/phpMyAdmin/4.4.15.5/phpMyAdmin-4.4.15.5-all-languages.tar.gz
-
解開 phpMyAdmin 套件:
#cd /var/www/html #tar zxvf phpMyAdmin-4.4.15.5-all-languages.tar.gz #mv phpMyAdmin-4.4.15.5-all-languages phpMyAdmin
在 CentOS7/RHEL7 上設定 Web Server
基本設定流程:
安裝 PHP 模組:
-
安裝 Web Server 套件:
#yum -y install httpd
-
設定啟動 Web Server 服務:
#systemctl enable httpd.service #systemctl start httpd.service #systemctl status httpd.service
-
設定開通防火牆:
#firewall-cmd --permanent --add-service=http #firewall-cmd --reload
- 主要設定檔:/etc/httpd/conf/httpd.conf
- 設定檔目錄:/etc/httpd/conf.d/
- 網頁放置目錄:/var/www/html
安裝 PHP 模組:
-
安裝 PHP 模組套件:
#yum -y install php php-bcmath php-cli php-common php-dba php-devel php-embedded php-enchant php-fpm php-gd php-intl php-ldap php-mbstring #yum -y install php-mysqlnd php-odbc php-pdo php-process php-pspell php-recode php-snmp php-soap php-xml php-xmlrpc rrdtool-php uuid-php php-pecl-memcache
或是#yum -y install php-* --skip-broken php-mysql
-
重新啟動 Web Server 服務:
#systemctl restart httpd.service
在 CentOS7/RHEL7 上架設 Samba Server
基本設定流程:
-
安裝 Samba Server 套件:
#yum -y install samba
-
設定欲分享目錄:
#mkdir /sharedpath
-
設定 SELinux 限定規則:
#semanage fcontext -a -t samba_share_t '/sharedpath(/.*)?' #restorecon -RFvv /sharedpath
-
設定 Samba Server 設定檔:
#vim /etc/samba/smb.conf [global] workgroup = WORKGROUP interfaces = lo eth0 192.168.1.1/24 hosts allow = 127. 192.168.1. [myshare] path = /sharedpath writable = no valid users = fred, @management
-
開啟 SELinux 存取規則:
#setsebool -P samba_enable_home_dirs=on #restorecon -RFvv /sharedpath
-
在 Samba Server 上,検查設定項目是否正確:
#testparm
-
在 Samba Server 上,新增一般的使用者帳號與密碼:
#useradd -s /sbin/nologin fred
-
在 Samba Server 上,安裝管理使用者的套件:
#yum -y install samba-client
-
在 Samba Server 上,設定可存取 Samba Server的使用者帳號與密碼:
#smbpasswd -a fred
-
啟動 Samba Server:
#systemctl start smb nmb #systemctl enable smb nmb
-
在 Samba Server 上,開啟防火牆設定:
#firewall-cmd --permanent --add-service=samba #firewall-cmd --reload
-
在 client 端,掛載 Samba Server 所分享目錄:
#mkdir /mnt/myshare #mount -t cifs -o username=fred //server/myshare /mnt/myshare
在 CentOS7/RHEL7 上架設 NFS Server
基本設定流程:
-
設定 NFS Server 之前,須安裝 nfs-utils 套件:
#yum -y install nfs-utils
-
啟動 NFS Server :
#systemctl start nfs-server.service #systemctl enable nfs-server.service
-
開通防火牆:
#firewall-cmd --permanent --add-service=nfs #firewall-cmd --reload
-
在 NFS Server 上,建立分享目錄:
#mkdir /myshare
-
在 NFS Server 上,設定分享目錄權限:
#vim /etc/exports /myshare *.example.com(rw) 10.0.0.0/8(ro)
-
在 NFS Server 上,發佈分享目錄:
#exportfs -r
-
在 NFS Server 上,啟動 SELiux 放行規定:
#setsebool -P nfs_export_all_rw on #setsebool -P nfs_export_all_ro on
-
在 NFS Server 上,查詢分享狀態:
#showmount -e
-
在 client 端,掛載 NFS Server 所分享目錄:
#mkdir /mnt/nfsshare #mount -t nfs server:/myshare /mnt/nfsshare
訂閱:
文章 (Atom)