備份 Server 資料到 NAS – CentOS Server 篇

主要是利用 autofs 和 NFS Server,將 Server 的資料備份到 NAS,備份到 NAS 的資料,可能是 Server 的設定檔、網頁或資料庫及師生檔案。
設定檔的部分可以加上每天的日期區別,網頁或資料庫可以使用 tarball 的方式來做備份,也可以加上日期做區隔,數量比較大的師生檔案,可以採用 rsync 或是 mirrordir 的方式來做同步。
NAS Server IP:192.168.1.5
CentOS 6.x Server IP:192.168.1.1

@at NAS Server
1. 建立 NFS Server,並限定連線來源

2. 建立要備份資料時儲放的資料

[@more@]
@at CentOS Server
1. 開啟必要服務 autofs / rpcbind / nfslock
# chkconfig –level 3 autofs on
# chkconfig –level 3 rpcbind on
# chkconfig –level 3 nfslock on
for CentOS 7.x
# yum install autofs nfs-utils rpcbind
# systemctl enable autofs
# systemctl enable rpcbind

2. 啟用服務
# service autofs start
# service rpcbind start
# service nfslock start
for CentOS 7.x
# systemctl start autofs
# systemctl start rpcbind

3. 修改 autofs 設定檔
# echo “/mnt/nasnfs     /etc/auto.nas” >> /etc/auto.master
# echo “drbl 192.168.1.5:/volume1/homes/t850008/Server/drbl” > /etc/auto.nas

4. 重新啟動 autofs 服務
# service autofs restart
for CentOS 7.x
# systemctl restart autofs

5. 開啟防火牆讓 CentOS Server 可以連線到 NAS 的 NFS Server,預設情況是有限制對外連線
# iptables -P OUTPUT DROP
# iptables -A OUTPUT -o eth0 -p tcp -d 192.168.1.5 –dport 2049 –syn -m state –state NEW -j ACCEPT
# iptables -A OUTPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

6. 切換到 /mnt/nasnfs/drbl 目錄,如果可以正常切換到該目錄,代表上面的設定成功
# cd /mnt/nasnfs/drbl

7. 將要備份的設定檔及資料寫入到 Script,並放入工作排程
例:
# cat /usr/local/bin/backuptonas
!/bin/bash
# 備份帳號密檔
cp /etc/passwd /mnt/nasnfs/drbl/set/passwd_`date +%F`
cp /etc/shadow /mnt/nasnfs/drbl/set/shadow_`date +%F`
cp /etc/group /mnt/nasnfs/drbl/set/group_`date +%F`
cp /etc/gshadow /mnt/nasnfs/drbl/set/gshadow_`date +%F`
# mirror 網頁資料
# /mnt/nasnfs/drbl/html 目錄要先建好
/usr/bin/mirrordir /var/www/html /mnt/nasnfs/drbl/html

8. 更改檔案屬性
# chmod +x /usr/local/bin/backuptonas

9. 加入工作排程,每天早上 3 時備份
# echo “0 3 * * * /usr/local/bin/backuptonas” >> /var/spool/cron/root

製作了縣網 Windows 10 Enterprise x86_x64 整合版

從 Windows 10 在 7/29 釋出後,自己也在思考要不要把部分工作平台轉移到 Windows 10,最後我放棄了,主要有二個原因:
1. Windows 10 的中文輸入法很麻煩,系統常常會自動判別輸入的地方是要中文還是英文,但就我來說,常常是錯了,我還要再切換一下回英文,尤其是 Microsoft Edge更是嚴重,讓人有時真想把鍵盤給砸了!
2. 公文系統雖然是可以使用,但有時會有些問題、不太正常,無法正常開啟公文,在 Windows 8.1 則完全正常!

不過還是先完成縣網的 Windows 10 Enterprise x86_x64 整合版,往後要安裝會方便些。
[@more@]這一個版本和 頭城國小資訊組 | 客製化 Windows 10 Enterprise x64 一樣,主要是把 KMS 啟動用的批次檔直接放在桌面方便使用。

OSSII OxOffice Community Edition Linux 版本

以 Ubuntu Linux MATE 14.04 x86 為例
下載
http://sourceforge.net/projects/ossii-oxoffice/files/Linux/

$ wget http://jaist.dl.sourceforge.net/project/ossii-oxoffice/Linux/x86/OxOffice_R5C2_Linux_x86_deb.tar.gz
$ wget http://jaist.dl.sourceforge.net/project/ossii-oxoffice/Linux/x86/OxOffice_R5C2_Linux_x86_deb_langpack_zh-TW.tar.gz[@more@]

解壓縮
$ tar xvzf OxOffice_R5C2_Linux_x86_deb.tar.gz
OxOffice_R5_Linux_x86_deb/
OxOffice_R5_Linux_x86_deb/DEBS/
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-extension-report-builder_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-en-us-math_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-en-us-res_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-writer_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-filter-data_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-calc_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-extension-pdf-import_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-base_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-extension-javascript-script-provider_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-gnome-integration_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-extension-beanshell-script-provider_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-en-us_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-pyuno_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-xsltfilter_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-writer_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-calc_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-ure_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-dict-en_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-draw_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-ooofonts_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-en-us_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-ogltrans_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-base_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-debian-menus_5.2-1_all.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-en-us-base_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-graphicfilter_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-images_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-extension-nlpsolver_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-en-us-writer_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-extension-mediawiki-publisher_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-ooolinguistic_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-math_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-core_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-impress_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-en-us-calc_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-impress_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-postgresql-sdbc_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxobasisr5-python-script-provider_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-math_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/DEBS/oxoffice5-draw_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb/readmes/
OxOffice_R5_Linux_x86_deb/readmes/README_en-US

$ tar xvzf OxOffice_R5C2_Linux_x86_deb_langpack_zh-TW.tar.gz
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/oxobasisr5-zh-tw-calc_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/oxobasisr5-zh-tw-base_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/oxobasisr5-zh-tw_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/oxobasisr5-zh-tw-math_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/oxoffice5-zh-tw_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/oxobasisr5-zh-tw-res_5.2-1_i386.deb
OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/oxobasisr5-zh-tw-writer_5.2-1_i386.deb

安裝
$ sudo dpkg -i OxOffice_R5_Linux_x86_deb/DEBS/*.deb
$ sudo dpkg -i OxOffice_R5_Linux_x86_deb_langpack_zh-TW/DEBS/*.deb

安裝完成後在功能表的位置

執行畫面
OxOffice Writer

OxOffice Calc

OxOffice Impress

應該會把 OxOffice 加入到自行修改的 Ubuntu Linux MATE 光碟中。

OSSII OxOffice Community Edition

OSSII OxOffice Community Edition 釋出基於 LibreOffice,並修正在中文環境中常見中文問題,詳細可以參考在 SourceForge 的網站。
OSSII OxOffice Community Edition 網站:http://sourceforge.net/projects/ossii-oxoffice/
[@more@]目前釋出的版本有支援 Windows / Linux(bananapi / armhf / x86 & x86_64 deb) / Source Code
底下以在 Windows 10 Enterprise x64 安裝為例:

1. 按 下一步(N) 繼續

2. 按 下一步(N) 繼續

3. 選擇 安裝(I)

4. 安裝過程

5. 完成安裝

6. Logo

7. OxOffice Writer

8. 畫廊的圖庫有比較多一些

9. OxOffice Calc

10. OxOffice Impress

11. 簡報的背景有比較多一些

用起來整體感覺很不錯,我應該會把這一個版本納入新學期電腦教室更新的軟體之一。

CentOS 6.x Samba 備份

1. 進行備份學生帳號及密碼
# tar cvjfp /Backup/Stu_account.tar.bz2 /etc/passwd /etc/shadow /etc/group /etc/gshadow
2. 學生檔案備份
# tar cvjfp /Backup/Stu.tar.bz2 /etc/samba/smb.conf /home/s0990 /home/s0100 /var/lib/samba/private
3. 資料還原
# tar xvjfp /Backup/Stu.tar.bz2 -C /[@more@]4. 處理 Samba 與 SELinux 之間的安全性設定
# getsebool -a | grep samba
bacula_use_samba –> off
samba_create_home_dirs –> off
samba_domain_controller –> off
samba_enable_home_dirs –> on
samba_export_all_ro –> off
samba_export_all_rw –> off
samba_load_libgfapi –> off
samba_portmapper –> off
samba_run_unconfined –> off
samba_share_fusefs –> off
samba_share_nfs –> off
sanlock_use_samba –> off
use_samba_home_dirs –> off
virt_use_samba –> off
# setsebool -P samba_enable_home_dirs on
# chcon -R -t samba_share_t /home/s0990
# chcon -R -t samba_share_t /home/s0100

5. 防火牆設定
# iptables -A INPUT -s 192.168.1.0/24 -m state –state NEW -m udp -p udp –dport 137 -j ACCEPT
# iptables -A INPUT -s 192.168.1.0/24 -m state –state NEW -m udp -p udp –dport 138 -j ACCEPT
# iptables -A INPUT -s 192.168.1.0/24 -m state –state NEW -m tcp -p tcp –dport 139 -j ACCEPT
# iptables -A INPUT -s 192.168.1.0/24 -m state –state NEW -m tcp -p tcp –dport 445 -j ACCEPT
# iptables -A INPUT -s 192.168.1.0/24 -m state –state NEW -m udp -p udp –dport 445 -j ACCEPT

解決在 CentOS Linux 重新啟動網路時出現的警告訊息

重新安裝了一台 CentOS Linux 6.x,重新啟動網路時會出現如下面的警告訊息
看訊息似乎 IP 已經有別的電腦使用了,但很確定是沒有其它的電腦正在使用。
而且網路也可以正常執行,只是看到這樣的訊息,有些礙眼。
Determining if ip address xxx.xxx.xxx.xxx is already in use for device eth0…
[@more@]解決方式:
參考網站:Linux下network提示Determining if ip address_百度经验

在每一片網路卡的設定中加入 ARPCHECK=no
不做 arp 的檢查

重新啟動網路後,就沒有再出現警告的訊息了!
# /etc/init.d/network restart

或 參考:RHEL/CentOS 6 ip address is already in use for device eth0 | SingleRack Hosting Solution
一次完成

# find /etc/sysconfig/network-scripts -name ifcfg* -type f -exec sh -c ‘echo ARPCHECK=no >> $1’ — {} ;