安裝CentOS8注意事項
大概就是一些心得, 安裝後要更新,要加上epel-release
1. vi /etc/profile export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 export LC_COLLATE=C export LC_CTYPE=en_US.UTF-8 2. dnf install epel-release dnf update sync;reboot 3.後續遇到再補
大概就是一些心得, 安裝後要更新,要加上epel-release
1. vi /etc/profile export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 export LC_COLLATE=C export LC_CTYPE=en_US.UTF-8 2. dnf install epel-release dnf update sync;reboot 3.後續遇到再補
Zimbra我是最近從節神大大(http://blog.jason.tools/)得知是一套優質的郵件服務器,
在此之前我推薦的是 iredmail , 安裝非常簡單,可以多網域管理, 但iredmail免費版並沒有整合microsoft active directory,不建議有AD的企業使用.
Zimbra社群版本,能跟AD整合,還滿適合企業使用, 以下節錄一些心得與重點, 不會紀錄詳細的安裝方式.
Zimbra Container
我通常會優先尋找container的方式安裝, 原因是想快速體驗.不過官方網站的docker停留在2017年的版本, 安裝的時候會失敗, 於是就作罷, 後續接手應該就是 Zimbra X版本了.
手動安裝
只要準備好Linux OS(我使用CenOS 7), 下載最新相對應的檔案(我使用8.8.15), 解開後,執行裡面的 install.sh 就可以依照指示安裝, 安裝前需要搞定hostname. 要修改/etc/hosts 以及執行hostnamectl set-hostname , 這部分install.sh也會提示您.
解除安裝
畢竟不是container, 若解除安裝有問題, 可能造成OS不穩定或是常駐無用服務的狀況, 好險到目前為止安裝很順利, 解除安裝也很簡單, 只要執行 ./install.sh -u 就可以進行解除安裝程序.
解除安裝曾遇到一個問題,就是CentOS有個套件移除不乾淨,需要手動移除, 可以使用rpm -qa|grep zimbra的方式找出相關套件, 手動移除, 這樣才可以移除乾進,才能重新安裝哦.
登入帳號與郵件不同如何處理
su - zimbra
zmlocalconfig -e alias_login_enabled=false
zmcontrol restart mailbox
安裝前請關閉CentOS7上預設的Mail Server
因為zimbra自帶mail server , 所以用不到Linux內建的, 請關閉,否則會衝突
systemctl stop postfix ; systemctl disable postfix
zimbra proxy啟動失敗, 出現invalid port in "0" of the "listen"錯誤
cd /opt/zimbra/libexec ./zmproxyconfig -e -w -H <zimbra host name> ./zmproxyconfig -e -m -H <zimbra host name>
自動取得Let's Encrypt證書
yum install epel-release mod_ssl certbot -y
#下載certbot_zimbra
wget https://raw.githubusercontent.com/YetOpen/certbot-zimbra/master/certbot_zimbra.sh -P /usr/local/bin
chmod +x /usr/local/bin/certbot_zimbra.sh
#確定主機名稱
/opt/zimbra/bin/zmhostname
# 自動獲取證書
##單一主機名稱)
certbot_zimbra.sh -n
##或是多主機
certbot_zimbra.sh -n -e <第二主機名稱>
有些套件需要先設定正確的主機名稱, centos 7以後要改用 hostnamectl 指令更新, 而且有時候還要手動修改 /etc/hosts ( IP 完整名稱, 簡稱)
hostnamectl set-hostname <主機完整名稱>
第一次安裝CentOS 8 , 也第一次在上面安裝docker-ce版本,因此記錄下來版本不一致衝突的解決方式
簡單的敘述就是 CentOS 8 目前的containerd-io 版本低於 1.2.2-3 , 無法安裝docker-ce 19版本 , 處理方式就是先手動安裝大於1.2.2-3的containerd-io
dnf install -y epel-release dnf update dnf install -y yum-utils device-mapper-persistent-data lvm2 dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo ## containerd.io-1.2.2-3以上 wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm rpm -Uvh containerd.io-1.2.6-3.3.el7.x86_64.rpm dnf -y install docker-ce-cli docker-ce --nobest systemctl enable docker systemctl start docker ################################################ ## 安裝完畢,請更改預設存放路徑 ## 編輯 /lib/systemd/system/docker.service ## 找出 ## ExecStart=/usr/bin/docker ## 改成 ## ExecStart=/usr/bin/docker -g <你的新路徑> ################################################
建立volume
docker volume create nextcloud-www docker volume create nextcloud-app docker volume create nextcloud-config docker volume create nextcloud-data docker volume create nextcloud-theme
確認 mariadb 資料庫伺服器是否準備好
執行docker指令
docker run -d -p <對應的port>:80 -v nextcloud-www:/var/www/html -v nextcloud-app:/var/www/html/custom_apps -v nextcloud-config:/var/www/html/config -v nextcloud-data:/var/www/html/data -v nextcloud-theme:/var/www/html/themes/mycustom --link <docker資料庫名稱>:mysql -e MYSQL_DATABASE=nextcloud -e MYSQL_USER=root -e MYSQL_PASSWORD=<密碼> -e MYSQL_HOST=mysql --restart=always --name nextcloud nextcloud
若有apache或是nginx作為反向proxy, 將https帶到nextcloud, 需設定trust_domain(網站會提醒)
httpd設定
# for CalDav RewriteEngine On RewriteRule ^/\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L] RewriteRule ^/\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
# form redirect <VirtualHost *:80> ServerName <server name> Redirect permanent / https://<server name>/ </VirtualHost> <VirtualHost *:443> # form security <IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains" </IfModule> </VirtualHost>
nextcloud config設定
若使用httpd proxy 的方式需要加入以下設定, 以免登入轉圈圈無法進入頁面, 修改 config.php 檔案
'overwritehost' => '<主機名稱>', 'overwriteprotocol' => 'https',
執行command
docker exec --user www-data <CONTAINER_ID> php occ
紅色的部份需要注意, 此外若出現 kafeiou.pw 請記得取代掉
#郵件過濾功能(mail gateway),請參考此文章
#2011年曾經寫過類似文章當時是CentOS6,應該大同小異
1. 修改 /etc/postfix/main.cf ,
############################################################### myhostname = mail.kafeiou.pw mydestination=/etc/postfix/local-host-names inet_interfaces = all # Enable IPv4, and IPv6 if supported inet_protocols = all mynetworks = 127.0.0.0/8,192.168.1.0/24 queue_directory = /var/spool/postfix mail_owner = postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix unknown_local_recipient_reject_code = 550 home_mailbox = Maildir/ sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man ############################################################### smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_destination, smtpd_client_restrictions = permit_sasl_authenticated, smtpd_sender_restrictions = permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain ############################################################### message_size_limit = 150600000 mailbox_size_limit = 250600000 virtual_mailbox_limit = 250600000 disable_vrfy_command = yes strict_rfc821_envelopes = yes bounce_queue_lifetime = 1d ############################################################### smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_sasl_local_domain = ############################################################### smtpd_helo_required = yes smtpd_delay_reject = yes smtpd_helo_restrictions = permit_mynetworks, permit ############################################################## virtual_mailbox_domains = /etc/postfix/domains virtual_mailbox_base = /home/vmail virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf # 1001 is id of user "vmail" created in linux virtual_uid_maps = static:1001 virtual_gid_maps = static:1001 virtual_alias_maps = hash:/etc/aliases,ldap:/etc/postfix/ldap-aliases.cf ############################################################## recipient_bcc_maps = hash:/etc/postfix/recipient_bcc sender_bcc_maps = hash:/etc/postfix/sender_bcc #inet_protocols = ipv4 smtpd_tls_security_level = may smtpd_tls_key_file = /etc/letsencrypt/live/mail.kafeiou.pw/privkey.pem smtpd_tls_cert_file = /etc/letsencrypt/live/mail.kafeiou.pw/fullchain.pem # smtpd_tls_CAfile = /etc/pki/tls/root.crt smtpd_tls_loglevel = 1 smtpd_tls_session_cache_timeout = 3600s smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_tls_cache tls_random_source = dev:/dev/urandom tls_random_exchange_name = /var/lib/postfix/prng_exch # 強制使用TLS smtpd_tls_auth_only = yes smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes # # Disable SSLv2, SSLv3 # smtpd_tls_protocols = !SSLv2 !SSLv3 smtpd_tls_mandatory_protocols = !SSLv2 !SSLv3 smtp_tls_protocols = !SSLv2 !SSLv3 smtp_tls_mandatory_protocols = !SSLv2 !SSLv3 lmtp_tls_protocols = !SSLv2 !SSLv3 lmtp_tls_mandatory_protocols = !SSLv2 !SSLv3 dovecot_destination_recipient_limit = 1 #performance smtpd_error_sleep_time = 0 default_process_limit = 150 qmgr_message_active_limit = 40000 qmgr_message_recipient_limit = 40000 default_destination_concurrency_limit=100 default_destination_recipient_limit=100 default_process_limit=200 smtp_mx_session_limit=100 smtpd_client_connection_count_limit=100 smtp_destination_concurrency_limit=100 maximal_backoff_time = 1000s minimal_backoff_time = 300s
2. 修改 /etc/postfix/local-host-names , 加上主機名稱
mail.kafeiou.pw
3. 修改 /etc/postfix/domains , 加上網域
kafeiou.pw
4.新增使用者 vmail , 並紀錄該使用者id , 並更新到 main.cf 裡面的id(可參考步驟1)
useradd vmail
5. 綁定網域帳號
裡面的 mail=%s 代表郵件紀錄在網域的mail欄位
vi /etc/postfix/ldap-users.cf
server_host = <主機ip> search_base = ou=taipei,dc=kafeiou,dc=pw version = 3 query_filter = (&(objectclass=*)(mail=%s)) result_attribute = samaccountname #Account from DC result_format = %s/Maildir/ bind = yes bind_dn = cn=ldap,cn=Users,dc=kafeiou,dc=pw bind_pw = <cn=ldap的密碼>
6. 綁定aliases, 網域設定群組
vi /etc/postfix/ldap-aliases.cf
server_host = <主機ip> search_base = ou=aliases,dc=kafeiou,dc=pw #scope = sub query_filter = (memberOf:1.2.840.113556.1.4.1941:=CN=%s,ou=aliases,dc=kafeiou,dc=pw) result_attribute = mail result_format = %s version = 3 bind = yes bind_dn = cn=ldap,cn=Users,dc=kafeiou,dc=pw bind_pw = <cn=ldap的密碼>
7. 取得letsencrypt, 更新步驟1相關的證書
按此連結到本站能找到資源 , 記得輸入guest/guest
8. 設定收發備份
/etc/postfix/recipient_bcc 與 /etc/postfix/sender_bcc
william收發信都會備份到, public , 記得改完套用 postmap /etc/postfix/recipient_bcc 與 /etc/postfix/sender_bcc
william@kafeiou.pw public@kafeiou.pw
9. 設定submission(TLS加密,使用587 port)
vi /etc/postfix/master.cf
submission inet n - n - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_reject_unlisted_recipient=no # -o smtpd_client_restrictions=$mua_client_restrictions # -o smtpd_helo_restrictions=$mua_helo_restrictions # -o smtpd_sender_restrictions=$mua_sender_restrictions -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
10, 修改 /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so # on. This directory must already exist. SOCKETDIR=/run/saslauthd # Mechanism to use when checking passwords. Run "saslauthd -v" to get a list # of which mechanism your installation was compiled with the ablity to use. #MECH=pam MECH=ldap # Additional flags to pass to saslauthd on the command line. See saslauthd(8) # for the list of accepted flags. FLAGS="-O /etc/postfix/saslauthd.conf -c -r"
11. 修改 /etc/postfix/saslauthd.conf
ldap_servers: ldap://<網域伺服器IP>:389/ ldap_search_base: ou=taipei,dc=kafeiou,dc=pw ldap_auth_method: bind ldap_version: 3 ldap_bind_dn: cn=ldap,cn=Users,dc=kafeiou,dc=pw ldap_bind_pw: <cn=ldap的密碼> ldap_filter: (sAMAccountName=%u) #ldap_filter: (mail=%u)
以上應該就能夠讓smtp 綁定網域, 以及擁有TLS(port 587)功能
偶的郵件伺服器使用postfix + amavisd-new+clamav
最近很不好意思的發現 clamav 很早以前就支援google Safe Browsing , 除了防毒外,還可以過濾掉一些不正當的連結, 作法如下:
1. 修改/etc/freshclam.conf , 加上:
SafeBrowsing yes
2. 重啟clamav service, 或是postfix 透過amavisd不需要重啟service, 只要執行freshclam這個指令即可
oracle 11g是很久的資料庫, 當時是配合鼎新tiptop 5.1 GP版本安裝, 安裝於centos 5.5 final ,
tiptop系統分成topprod, topstd , 與toptest , 但是到最後很少用到 topstd與toptest,
所以可以預設停用這兩個用不到的instance,
我們可以修改 /etc/oratab 這個檔案, 長得如下:
toptest:/u2/oracle/product/11.2.0/db_1:Y
topstd:/u2/oracle/product/11.2.0/db_1:Y
topprod:/u2/oracle/product/11.2.0/db_1:Y
請停掉database後, 把Y改成N, 以後重啟就不會啟動用不到的instance
咖啡偶最近進行一系列從esxi轉到pve的工作, 其中出現轉CentOS 5這種老舊vm失敗的狀況, 錯誤如下:
Unable to access resume device (LABEL=SWAP-hda3)
mount: could not find filesystem ‘/dev/root’
測試過很多方式, 例如改ide, sata, scsi 等方式都不行, 最後終於找到重建開機程序 initrd 的方式解決,
解決方式如下: