f 一月 2021 ~ 迪貝之家

Microsoft SQL Server Log Shipping

SQL 7就有的技術,簡單的說就是資料庫複本資料同步的技術,而這份複本可以開放讀取的功能以分散營業資料庫的負載,也可純粹當成備援資料庫,不管是在本地還是異地。怎麼達成? 透過SQL Agent自動化排程進行備份、傳檔及復原等作業。

Oracle GolGateden

機房搬遷跨Site能即時同步資料庫利器

Nagios 資料庫維運自動化

一開始設計這架構時,就排除使用remote agent的想法因為在專業分工的組織下,要求安裝新軟體於既有系統是一件不太可行的方案,既然身為DBA就只能把資料庫instance當作是一個最大的agent 想辦法在資料庫內做到我想做的事情

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Ansible 出現這個錯誤 Could not find the requested service apache2: host

 

這是check syntac 的執行記錄
我昨天測了一下午
ansible-playbook playbook.yml -C
這個劇本就是測不過
去找了Internet
怪了~~ 文不對題
這是output
$ ansible-playbook playbook.yml -C

PLAY [drupal] ************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************
The authenticity of host '192.168.88.7 (192.168.88.7)' can't be established.
ECDSA key fingerprint is SHA256:cWVg1Hfzq9h5YHIKUWwhE+jz1d+f8IltzWWvB9jbr5Y.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
ok: [192.168.88.7]
TASK [Update apt cache if needed.] ***************************************************************************************************
changed: [192.168.88.7]
TASK [Get software for apt repository management.] ***********************************************************************************
changed: [192.168.88.7]
TASK [Add ondrej repository for later versions of PHP.] ******************************************************************************
changed: [192.168.88.7]
TASK [Install Apache, MySQL, PHP, and other dependencies.] ***************************************************************************
changed: [192.168.88.7]
TASK [Disable the firewall (since this is for local dev only).] **********************************************************************
changed: [192.168.88.7]
TASK [Start Apache, MySQL, and PHP.] *************************************************************************************************
failed: [192.168.88.7] (item=apache2) => {"ansible_loop_var": "item", "changed": false, "item": "apache2", "msg": "Could not find the requested service apache2: host"}
failed: [192.168.88.7] (item=mysql) => {"ansible_loop_var": "item", "changed": false, "item": "mysql", "msg": "Could not find the requested service mysql: host"}
PLAY RECAP ***************************************************************************************************************************
192.168.88.7 : ok=6 changed=5 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
今天我腦袋瓜應該是清楚了點
我突然想到了
-C 是syntax check
根本不會真的進行安裝的TASK
playbook裏頭有一段是要啟動服務
在沒安裝套件的狀況下
是要怎麼啟動該服務阿...
豬頭.....
這是最簡單的邏輯阿
因此我把-C拿掉後執行
哈哈...一切正常了
PLAY [drupal] ************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************
ok: [192.168.88.7]
TASK [Update apt cache if needed.] ***************************************************************************************************
ok: [192.168.88.7]
TASK [Get software for apt repository management.] ***********************************************************************************
changed: [192.168.88.7]
TASK [Add ondrej repository for later versions of PHP.] ******************************************************************************
changed: [192.168.88.7]
TASK [Install Apache, MySQL, PHP, and other dependencies.] ***************************************************************************
TASK [Disable the firewall (since this is for local dev only).] **********************************************************************
changed: [192.168.88.7]
TASK [Start Apache, MySQL, and PHP.] *************************************************************************************************
ok: [192.168.88.7] => (item=apache2)
ok: [192.168.88.7] => (item=mysql)
TASK [Enable Apache rewrite module (required for Drupal).] ***************************************************************************
changed: [192.168.88.7]
TASK [Add Apache virtualhost for Drupal.] ********************************************************************************************
changed: [192.168.88.7]
TASK [Enable the Drupal site.] *******************************************************************************************************
changed: [192.168.88.7]
TASK [Disable the default site.] *****************************************************************************************************
changed: [192.168.88.7]
TASK [Adjust OpCache memory setting.] ************************************************************************************************
changed: [192.168.88.7]
TASK [Create a MySQL database for Drupal.] *******************************************************************************************
changed: [192.168.88.7]
TASK [Create a MySQL user for Drupal.] ***********************************************************************************************
TASK [Create a MySQL user for Drupal.] ***********************************************************************************************
ok: [192.168.88.7]
TASK [Download Composer installer.] **************************************************************************************************
changed: [192.168.88.7]
TASK [Run Composer installer.] *******************************************************************************************************
changed: [192.168.88.7]
TASK [Move Composer into globally-accessible location.] ******************************************************************************
changed: [192.168.88.7]
TASK [Ensure Drupal directory exists.] ***********************************************************************************************
changed: [192.168.88.7]
TASK [Check if Drupal project already exists.] ***************************************************************************************
ok: [192.168.88.7]
TASK [Create Drupal project.] ********************************************************************************************************
changed: [192.168.88.7]
TASK [Add drush to the Drupal site with Composer.] ***********************************************************************************
changed: [192.168.88.7]
TASK [Install Drupal.] ***************************************************************************************************************
RUNNING HANDLER [restart apache] *****************************************************************************************************
changed: [192.168.88.7]
PLAY RECAP ***************************************************************************************************************************
192.168.88.7 : ok=24 changed=19 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

Ansible YAML 好重Ident 阿

 我在測底下的playbook

- name: Install Remi repo.

  yum:

   name: "http://rpms.remirepo.net/enterprise/remi-release-7.rpm"

   state: present


- name: Import Remi GPG key.

   rpm_key:

   key: "http://rpms.remirepo.net/RPM-GPG-KEY-remi"

   state: present


- name: Install EPEL repo.

   yum: name=epel-release state=present


- name: Ensure firewalld is stopped (since this is for testing).

   service: name=firewalld state=stopped


- name: Install Node.js and npm.

   yum: name=npm state=present enablerepo=epel


- name: Install Forever (to run our Node.js app).

   npm: name=forever global=yes state=present

一直出現format錯誤


fatal: [192.168.60.4]: FAILED! => {"reason": "We were unable to read either as JSON nor YAML, these are the errors we got from each:\nJSON: No JSON object could be decoded\n\nSyntax Error while loading YAML.\n mapping values are not allowed here\n\nThe error appears to be in '/home/p10303550/VMs/npm_test/test.yml': line 7, column 11, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n- name: Import Remi GPG key.\n rpm_key:\n

後來我調整了ident

居然ok了~~~
用diff 來看兩個檔案的差異
test.yml 是可以執行的
test2.yml是parse 錯誤的
我用紅線抓了一個對齊線
也不過就差了一個空白
應該說
要執行的各模組要align
挖................
真是......

Ansible Loop

 

正在研究ansible
這東西雖然不用錢
但是不好測阿....
我測試的版本是2.10
照著ansible自己出版的書
測了一下with_items的loop
真的是很不work
最後在stackoverflow 內找到了解法
我的測試scenario是要安裝兩個http的套件
httpd
httpd-devel
它是透過loop 執行了多次的單一的yum install來達成目的的
我原來的環境就已經安裝了httpd
所以執行output只會看到httpd-devel的output
如圖,ansible 是執行test10.yml的劇本
我們來看它的內容

它是透過loop
來兩次執行的yum_apache內的工作
執行過程中
把httpd及httpd-devel當成數值
帶進了yum_apache內的item變數
它不好測的原因可能也在於版本的差異
連四個月前被po在github的yaml檔案也不work
才差4個月ㄝ....
ansible - example of looping yum packages with different setting for one of them
這是書上的語法
不管怎麼測,出現的錯誤都是
fatal: [192.168.60.6]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined\n\nThe error appears to be in '/home/p10303550/VMs/test8.yml': line 4, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: Install the required rpms\n ^ here\n"}
變數宣告問題