使用 PXE Server 自動安裝 Ubuntu Server 16.04.2

參考網頁:
Ubuntu 16.04 / Debian 8: Run PXE boot server for automated install – Narrow Escape
B.4. Contents of the preconfiguration file (for xenial)
https://help.ubuntu.com/16.04/installation-guide/example-preseed.txt
system installation – How do I create a completely unattended install of Ubuntu? – Ask Ubuntu

CentOS 7 PXE Server:192.168.131.241
與 頭城國小資訊組 | 使用 PXE Server 來安裝 Ubuntu Server 16.04.2 相同,底下僅列出不一樣的地方
1. 修改設定檔 /var/lib/tftpboot/pxelinux.cfg/default
# vim
/var/lib/tftpboot/pxelinux.cfg/default
LABEL Ubuntu Server 16.04.2 x64 Auto Install
MENU LABEL Ubuntu Server 16.04.2 Auto Install
kERNEL /netboot/ubuntu_server/ubuntu-installer/amd64/linux
APPEND auto=true priority=critical vag=788 initrd=/netboot/ubuntu_server/ubuntu-installer/amd64/initrd.gz url=ftp://192.168.131.241/pub/Ubuntu16042/preseed/preseed.cfg preseed/interactive=false[@more@]2. 建立設定檔
/var/ftp/pub/Ubuntu16042/preseed/preseed.cfg
取消自動化的部份:
建立一個普通的使用者及設定密碼
取消硬碟自動分割
# vim /var/ftp/pub/Ubuntu16042/preseed/preseed.cfg

d-i debian-installer/locale string en_US
d-i debian-installer/language string en
d-i debian-installer/country string TW
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
#d-i passwd/user-fullname string
#d-i passwd/username string ubuntu
#d-i passwd/root-password password ubuntu
#d-i passwd/root-password-again password ubuntu
#d-i passwd/user-password password ubuntu
#d-i passwd/user-password-again password ubuntu
#d-i user-setup/allow-password-weak boolean true
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i mirror/country string manual
#d-i mirror/http/hostname string http://tw.archive.ubuntu.com
d-i mirror/http/hostname string http://free.nchc.org.tw
d-i apt-setup/services-select multiselect security
d-i apt-setup/security_host string free.nchc.org.tw
d-i apt-setup/security_path string /ubuntu

d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i clock-setup/utc boolean false
d-i clock-setup/ntp boolean true
d-i time/zone string Asia/Taipei
#d-i partman/confirm boolean true
#d-i partman/choose_partition select finish
#d-i partman/confirm_nooverwrite boolean true
#d-i partman-auto/disk string /dev/[sv]da
#d-i partman-auto/method string lvm
#d-i partman-auto/choose_recipe select atomic
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-lvm/confirm boolean true
#d-i partman-lvm/confirm_nooverwrite boolean true
#d-i partman-auto-lvm/guided_size string max
#d-i partman-partitioning/confirm_write_new_label boolean true
#d-i grub-installer/grub2_instead_of_grub_legacy boolean true
#d-i grub-installer/only_debian boolean true
#d-i grub-installer/bootdev string /dev/[sv]da
d-i pkgsel/update-policy select none
#d-i pkgsel/include string unity ubuntu-desktop openssh-server
# 安裝 lamp 及 openssh Server
tasksel tasksel/first multiselect lamp-server, openssh-server
d-i finish-install/reboot_in_progress note

3.
處理 SELinux
# restorecon -R -F -v /var/ftp/pub/

4. Client 端以 PXE 網路開機


使用 PXE Server 來安裝 Ubuntu Server 16.04.2

參考網頁:
Ubuntu 16.04 / Debian 8: Run PXE boot server for automated install – Narrow Escape

CentOS 7 PXE Server:192.168.131.241
1. 下載 Ubuntu Server netboot image 網路開機檔
# wget http://archive.ubuntu.com/ubuntu/ubuntu/dists/xenial/main/installer-amd64/current/images/netboot/netboot.tar.gz -O ubuntu-16.04-netboot.tar.gz

2. 建立目錄
# mkdir /var/lib/tftpboot/ubuntu_server
# mkdir ubuntu-16.04-netboot

3. 解壓縮,並移動到 /var/lib/tftpboot/ubuntu_server 目錄下
# tar zxf ubuntu-16.04-netboot.tar.gz -C ubuntu-16.04-netboot
# mv ubuntu-16.04-netboot/ubuntu-installer /var/lib/tftpboot/ubuntu_server[@more@]
4. 修改設定檔 /var/lib/tftpboot/pxelinux.cfg/default
#
vim
/var/lib/tftpboot/pxelinux.cfg/default
LABEL Ubuntu Server 16.04.2 x64 FTP Install
MENU LABEL Ubuntu Server 16.04.2 FTP Install
kERNEL /netboot/ubuntu_server/ubuntu-installer/amd64/linux
APPEND initrd=/netboot/ubuntu_server/ubuntu-installer/amd64/initrd.gz url=ftp://192.168.131.241/pub/Ubuntu16042/preseed/ubuntu-server.seed

5. 下載 Ubuntu Server 16.04.2 ISO
# wget http://debian.linux.org.tw/ubuntu-releases/16.04.2/ubuntu-16.04.2-server-amd64.iso

6. 掛載光碟
# mount -o loop ubuntu-16.04.2-server-amd64.iso /mnt

7. 複製檔案到 FTP Server
# mkdir /var/ftp/pub/Ubuntu16042
# cp -a /mnt/* /var/ftp/pub/Ubuntu16042

8. 處理 SELinux
# restorecon -R -F -v /var/lib/tftpboot/
# restorecon -R -F -v /var/ftp/pub/

9. Client 端以 PXE 網路開機

客製化 Ubuntu Server 16.04.2 安裝光碟

本來一直以為 Debian/Ubuntu 只能透過 LiveCD 來進行客製化,偶然在以下的網站發現 Debian/Ubuntu 也能像 RedHat/CentOS 的 kickstart 一樣,透然編輯文字檔的方式來達成自動安裝的工作。
參考網站:
ubuntu-autoinstaller/txt.cfg at master · express42/ubuntu-autoinstaller · GitHub
InstallCDCustomization – Community Help Wiki
Ubuntu 16.04 / Debian 8: Run PXE boot server for automated install – Narrow Escape
B.4. Contents of the preconfiguration file (for xenial)
https://help.ubuntu.com/16.04/installation-guide/example-preseed.txt
system installation – How do I create a completely unattended install of Ubuntu? – Ask Ubuntu

1. 下載 Ubuntu Server 16.04.2 ISO
# wget http://debian.linux.org.tw/ubuntu-releases/16.04.2/ubuntu-16.04.2-server-amd64.iso

2. 掛載光碟
# mount -o loop ubuntu-16.04.2-server-amd64.iso /mnt

3. 複製檔案
# mkdir ~/Ubuntu16042
# cp -a /mnt/* ~/Ubuntu16042
# cp -r /mnt/.disk ~/Ubuntu16042[@more@]
4. 修改 ~/Ubuntu16042/isolinux/txt.cfg
# vim ~/Ubuntu16042/isolinux/txt.cfg
default ainstall
label ainstall
  menu label ^Auto Install Ubuntu Server
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/aubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet debian-installer/language=en debian-installer/country=TW console-setup/ask_detect=false keyboard-configuration/layoutcode=us debian-installer/locale=en_US —
label install
  menu label ^Install Ubuntu Server
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet —

5. 建立 ~/Ubuntu16042/preseed/aubuntu-server.seed
    預設安裝 LAMP / OpenSSH Server
# vim ~/Ubuntu16042/preseed/aubuntu-server.seed
d-i debian-installer/locale string en_US.UTF-8
#d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layout string USA
d-i debian-installer/language string en
d-i debian-installer/country string TW
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
# Default user, change
d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
d-i user-setup/encrypt-home boolean false
d-i user-setup/allow-password-weak boolean true
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i mirror/country string manual
#d-i mirror/http/hostname string http://tw.archive.ubuntu.com
d-i mirror/http/hostname string http://free.nchc.org.tw
d-i mirror/http/directory string /ubuntu
d-i apt-setup/services-select multiselect security
d-i apt-setup/security_host string free.nchc.org.tw
d-i apt-setup/security_path string /ubuntu
d-i mirror/http/proxy string
d-i clock-setup/utc boolean false
d-i clock-setup/ntp boolean true
d-i time/zone string Asia/Taipei
#d-i partman/confirm boolean true
#d-i partman/choose_partition select finish
#d-i partman/confirm_nooverwrite boolean true
#d-i partman-auto/disk string /dev/[sv]da
#d-i partman-auto/method string lvm
#d-i partman-auto/choose_recipe select atomic
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-lvm/confirm boolean true
#d-i partman-lvm/confirm_nooverwrite boolean true
#d-i partman-auto-lvm/guided_size string max
#d-i partman-partitioning/confirm_write_new_label boolean true
#d-i grub-installer/grub2_instead_of_grub_legacy boolean true
#d-i grub-installer/only_debian boolean true
#d-i grub-installer/bootdev string /dev/[sv]da
d-i pkgsel/update-policy select none
#d-i pkgsel/include string unity ubuntu-desktop openssh-server
tasksel tasksel/first multiselect lamp-server, openssh-server
#d-i pkgsel/include string openssh-server ntp build-essential rsync less vim ethtool curl lsscsi dstat htop strace
d-i finish-install/reboot_in_progress note

6. 製作成 ISO 光碟
# cd ~/Ubuntu16042
# mkisofs -r -V “Ubuntu-Server 16.04.2” -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul -boot-load-size 4 -boot-info-table -o ~/ubuntu-16.04.2-server-amd6_0501.iso .

7. 進行安裝測試
選擇安裝語言


選擇 Auto Install Ubuntu Server

不知道為什麼,要重新再選擇一次 locales

設定 root 密碼

分割硬碟

設定 MySQL Server 管理者密碼

安裝完成,重新啟動

Debian / Ubuntu 安裝 Let’s Encrypt 到 Apache

參考網站:
Debian / Ubuntu 安裝 Let’s Encrypt 到 Apache – Linux 技術手札

1. 安裝 Apache Web Server
# apt-get install apache2

2. 啟用 SSL 模組並重新啟動 Apache Web Server
# a2enmod ssl
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Enabling module socache_shmcb.
Enabling module ssl.
See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
  service apache2 restart

# a2ensite default-ssl.conf
Enabling site default-ssl.
To activate the new configuration, you need to run:
  service apache2 reload

# /etc/init.d/apache2 restart
or
# systemctl restart apache2.service[@more@]3. 安裝 git 套件
# apt-get install git

4. 下載 Let’s Encrypt 的目錄
# cd /usr/local
# git clone https://github.com/letsencrypt/letsencrypt
Cloning into ‘letsencrypt’…
remote: Counting objects: 43808, done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 43808 (delta 40), reused 0 (delta 0), pack-reused 43732
Receiving objects: 100% (43808/43808), 12.74 MiB | 2.16 MiB/s, done.
Resolving deltas: 100% (31283/31283), done.
Checking connectivity… done.

5. 產生憑證
# ./letsencrypt-auto –apache -d test.ilc.edu.tw -d www.test.ilc.edu.tw

Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to
cancel):

——————————————————————————-
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
——————————————————————————-
(A)gree/(C)ancel: A

——————————————————————————-
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let’s Encrypt project and the non-profit
organization that develops Certbot? We’d like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
——————————————————————————-
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
tls-sni-01 challenge for test.ilc.edu.tw
tls-sni-01 challenge for www.test.ilc.edu.tw
Waiting for verification…
Cleaning up challenges
Failed authorization procedure. nxi.tces.ilc.edu.tw (tls-sni-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Failed to connect to 192.168.1.1:443 for TLS-SNI-01 challenge

IMPORTANT NOTES:
 – If you lose your account credentials, you can recover through
   e-mails sent to t850008@gmail.com.
 – The following errors were reported by the server:

   Domain: www.test.ilc.edu.tw
   Type:   connection
   Detail: Failed to connect to 192.168.1.1:443 for TLS-SNI-01
   challenge

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you’re using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.
 – Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

Ubuntu 16.04 LTS 安裝 iSCSI Initiator

參考網站:
Ubuntu 16.04 LTS : iSCSI Taregt(iscsitarget) : Server World
Ubuntu 16.04 LTS : iSCSI Initiator(Ubuntu) : Server World
Ubuntu 16.04 LTS : iSCSI Taregt(targetcli) : Server World

1. 安裝 open-iscsi 套件
# apt-get -y install open-iscsi

2. 修改 /etc/iscsi/initiatorname.iscsi 設定檔
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-04.tces.test:linux-pc

3. 修改 /etc/iscsi/iscsid.conf  設定檔
# cp /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.$(date +%F)
# vim /etc/iscsi/iscsid.conf

#node.session.auth.authmethod = CHAP
#node.session.auth.username = username
#node.session.auth.password = password
修改成
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = password

4. 重新啟動 iscsid open-iscsi 服務
# systemctl restart iscsid open-iscsi

5. 尋找 iSCSI Server 分享的設備
# /usr/bin/iscsiadm -m discovery -t sendtargets -p 192.168.1.16
192.168.1.16:3260,1 iqn.2017-04.tces.test:linux-pc

6. 登入使用 iSCSI 設備
# /usr/sbin/iscsiadm -m node –login
Logging in to [iface: default, target: iqn.2017-04.tces.test:linux-pc, portal: 192.168.1.16,3260] (multiple)
Login to [iface: default, target: iqn.2017-04.tces.test:linux-pc, portal: 192.168.1.16,3260] successful.

Ubuntu 16.04 LTS 安裝 iSCSI Taregt – iscsitarget

參考網站:
Ubuntu 16.04 LTS : iSCSI Taregt(iscsitarget) : Server World
Ubuntu 16.04 LTS : iSCSI Initiator(Ubuntu) : Server World
Ubuntu 16.04 LTS : iSCSI Taregt(targetcli) : Server World

1. 安裝 iscsitarget 套件
# apt-get -y install iscsitarget iscsitarget-dkms

2. 建立目錄
# mkdir /iscsi_disks

3. 建立分享檔案
# dd if=/dev/zero of=/iscsi_disks/linux-disk.img count=0 bs=1 seek=10G
0+0 records in
0+0 records out
0 bytes copied, 0.000299606 s, 0.0 kB/s[@more@]
4. 修改 /etc/default/iscsitarget,將 ISCSITARGET_ENABLE 的值改成 true
# sed -i ‘s/ISCSITARGET_ENABLE=false/ISCSITARGET_ENABLE=true/’ /etc/default/iscsitarget

5. 建立 /etc/iet/ietd.conf 設定檔
# vim /etc/iet/ietd.conf
Target iqn.2017-04.tces.test:ubuntu1604
    Lun 0 Path=/iscsi_disks/linux-disk.img,Type=fileio
    initiator-address 192.168.1.0/24
    incominguser username password

6. 重新啟動 iscsitarget 服務
# systemctl restart iscsitarget

7. 檢查是否有正常啟動
# netstat -antulp | grep :3260
tcp        0      0 0.0.0.0:3260            0.0.0.0:*               LISTEN      25926/ietd
tcp6       0      0 :::3260                 :::*                    LISTEN      25926/ietd

8. 防火牆設定
# iptables -A INPUT -s 192.168.1.0/24 -m tcp -p tcp -m state –state NEW –dport 3260 -j ACCEPT

Ubuntu 16.04 LTS 安裝 iSCSI Taregt – targetcli

參考網站:
Ubuntu 16.04 LTS : iSCSI Taregt(iscsitarget) : Server World
Ubuntu 16.04 LTS : iSCSI Initiator(Ubuntu) : Server World
Ubuntu 16.04 LTS : iSCSI Taregt(targetcli) : Server World

1. 安裝 targetcli 套件
# apt-get -y install targetcli

2. 建立目錄
# mkdir /iscsi_disks

[@more@]3. 進入 iscsi 管理介面
# /usr/bin/targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli 3.0.pre4.1~ga55d018 (rtslib 3.0.pre4.1~g1b33ceb)
Copyright (c) 2011-2014 by Datera, Inc.
All rights reserved.

/> cd backstores/fileio
/backstores/fileio> create linux-disk /iscsi_disks/linux-disk.img 10G
Using buffered mode.
Created fileio linux-disk.
/backstores/fileio> cd /iscsi
/iscsi> create iqn.2017-04.tces.test:linux.disk
Created target iqn.2017-04.tces.test:linux.disk.
Selected TPG Tag 1.
Created TPG 1.

/iscsi> cd iqn.2017-04.tces.test:linux.disk/tpg1/portals
/iscsi/iqn.20…/tpg1/portals> create 0.0.0.0
Using default IP port 3260
Created network portal 0.0.0.0:3260.

/iscsi/iqn.20…/tpg1/portals> cd ../luns
/iscsi/iqn.20…isk/tpg1/luns> create /backstores/fileio/linux-disk
Selected LUN 0.
Created LUN 0.

/iscsi/iqn.20…isk/tpg1/luns> cd ../acls
/iscsi/iqn.20…isk/tpg1/acls> create iqn.2017-04.tces.test:linux-pc
Created Node ACL for iqn.2017-04.tces.test:linux-pc
Created mapped LUN 0.
/iscsi/iqn.20…isk/tpg1/acls> cd iqn.2017-04.tces.test:linux-pc
/iscsi/iqn.20…test:linux-pc> set auth userid=username
Parameter userid is now ‘username’.
/iscsi/iqn.20…test:linux-pc> set auth password=password
Parameter password is now ‘password’.
/iscsi/iqn.20…test:linux-pc> exit
Comparing startup and running configs…
Some changes need saving.
Save configuration? [Y/n]: y
Saving new startup configuration

4. 檢查是否有正常執行
# netstat -antulp | grep :3260
tcp        0      0 0.0.0.0:3260            0.0.0.0:*               LISTEN      –

5. 設定開機啟動
# systemctl enable target.service
target.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable target

解決 Cacti 出現 RRDTool version does not match configured version 的訊息

在 Cacti 管理畫面 Console / System Utilities / Technical Support 畫面中,出現的警告訊息:
ERROR: Installed RRDTool version does not match configured version.
Please visit the Configuration Settings and select the correct RRDTool Utility Version.

檢查系統安裝的 RRD Tool 版本,是 1.5.5-4
# dpkg -l | grep rrd
ii  librrd4:amd64                      1.5.5-4                            amd64        time-series data storage and display system (runtime library)
ii  rrdtool                            1.5.5-4                            amd64        time-series data storage and display system (programs)

可是在 Console / Settings / General 頁面中,RRDTool Utility Version 只有 1.0~1.4 版可以選擇

[@more@]解決方式:
參考 Cacti + RRDtool 錯誤訊息 @mini box 迷你盒子 – nidBox親子盒子

# cp /usr/share/cacti/site/utilities.php /usr/share/cacti/site/utilities.php.$(date +%F)
# vim /usr/share/cacti/site/utilities.php

if (preg_match(“/^RRDtool 1.4/”, $out_array[0])) {
    $rrdtool_version = “rrd-1.4.x”;
}else if (preg_match(“/^RRDtool 1.3./”, $out_array[0])) {
    $rrdtool_version = “rrd-1.3.x”;
}else if (preg_match(“/^RRDtool 1.2./”, $out_array[0])) {
    $rrdtool_version = “rrd-1.2.x”;
}else if (preg_match(“/^RRDtool 1.0./”, $out_array[0])) {
    $rrdtool_version = “rrd-1.0.x”;
}

 修改成

 if (preg_match(“/^RRDtool 1.6/”, $out_array[0])) {
     $rrdtool_version = “rrd-1.6.x”;
  } elseif (preg_match(“/^RRDtool 1.5/”, $out_array[0])) {
       $rrdtool_version = “rrd-1.5.x”;
  } elseif (preg_match(“/^RRDtool 1.4/”, $out_array[0])) {
       $rrdtool_version = “rrd-1.4.x”;
  }else if (preg_match(“/^RRDtool 1.3./”, $out_array[0])) {
       $rrdtool_version = “rrd-1.3.x”;
  }else if (preg_match(“/^RRDtool 1.2./”, $out_array[0])) {
      $rrdtool_version = “rrd-1.2.x”;
  }else if (preg_match(“/^RRDtool 1.0./”, $out_array[0])) {
      $rrdtool_version = “rrd-1.0.x”;
  }

 
# cp /usr/share/cacti/site/include/global_arrays.php /usr/share/cacti/site/include/global_arrays.php.$(date +%F)
# vim /usr/share/cacti/site/include/global_arrays.php

$rrdtool_versions = array(
        “rrd-1.0.x” => “RRDTool 1.0.x”,
        “rrd-1.2.x” => “RRDTool 1.2.x”,
        “rrd-1.3.x” => “RRDTool 1.3.x”,
        “rrd-1.4.x” => “RRDTool 1.4.x”);

修改成

$rrdtool_versions = array(
        “rrd-1.0.x” => “RRDTool 1.0.x”,
        “rrd-1.2.x” => “RRDTool 1.2.x”,
        “rrd-1.3.x” => “RRDTool 1.3.x”,
        “rrd-1.4.x” => “RRDTool 1.4.x”,
        “rrd-1.5.x” => “RRDTool 1.5.x”,
        “rrd-1.6.x” => “RRDTool 1.6.x”);

 

OpenNMS – Apache Cassandra 安裝與 Newts 設定 – Ubuntu

參考網頁:
OpenNMS Installation Guide
雜亂的學習筆記本: OpenNMS – OpenNMS 安裝篇(04) – Cassandra 的安裝與 Newts 的設定

根據官方網站上的解釋:
Newts 是基於 Apache Cassandra 的時間序列資料儲存,是一個持久性的策略,可以用來取代 JRobin 或是 RRDtool。

在 Ubuntu 16.04 下安裝
1. 新增 DataStax 套件庫設定檔
# vim /etc/apt/sources.list.d/cassandra.sources.list
deb https://debian.datastax.com/community stable main

2. 安裝 GPG Key
# wget -O – https://debian.datastax.com/debian/repo_key | apt-key add –

3. 更新套件庫
# apt-get update[@more@]
4. 安裝 Cassandra 3.0.x package
# apt-get install dsc30
如果出現下面的錯誤訊息,請下載 python-support 進行安裝
The following packages have unmet dependencies:
 dsc30 : Depends: python-support (>= 0.90.0) but it is not installable
E: Unable to correct problems, you have held broken packages.

# wget http://launchpadlibrarian.net/109052632/python-support_1.0.15_all.deb
# dpkg -i python-support_1.0.15_all.deb
Selecting previously unselected package python-support.
(Reading database … 72575 files and directories currently installed.)
Preparing to unpack python-support_1.0.15_all.deb …
Unpacking python-support (1.0.15) …
Setting up python-support (1.0.15) …
Processing triggers for man-db (2.7.5-1) ...

5. 設定 OpenNMS Horizon
# cp /usr/share/opennms/etc/opennms.properties /usr/share/opennms/etc/opennms.properties.$(date +%F)
將 false 改為 true
# sed -i ‘/rrd.storeByForeignSource/s/false/true/’ /usr/share/opennms/etc/opennms.properties
取消前面的註解,並將 rrd 改為 newts
# sed -i ‘/^#org.opennms.timeseries/s/#org.opennms.timeseries.strategy=rrd/org.opennms.timeseries.strategy=newts/’ /usr/share/opennms/etc/opennms.properties
取消前面的註解
# sed -i ‘/newts.config.hostname/s/^#org/org/’ /usr/share/opennms/etc/opennms.properties
# sed -i ‘/keyspace/s/^#org/org/’ /usr/share/opennms/etc/opennms.properties
# sed -i ‘/9042/s/^#org/org/’ /usr/share/opennms/etc/opennms.properties

6. 初始化 newts
# /usr/share/opennms/bin/newts init

7. 進行驗證
# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.9 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cqlsh> use newts;
cqlsh:newts> describe table terms;

CREATE TABLE newts.terms (
    context text,
    field text,
    value text,
    resource text,
    PRIMARY KEY ((context, field, value), resource)
) WITH CLUSTERING ORDER BY (resource ASC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = {‘keys’: ‘ALL’, ‘rows_per_partition’: ‘NONE’}
    AND comment = ”
    AND compaction = {‘class’: ‘org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy’, ‘max_threshold’: ’32’, ‘min_threshold’: ‘4’}
    AND compression = {‘chunk_length_in_kb’: ’64’, ‘class’: ‘org.apache.cassandra.io.compress.LZ4Compressor’}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = ’99PERCENTILE’;

cqlsh:newts> describe table samples;

CREATE TABLE newts.samples (
    context text,
    partition int,
    resource text,
    collected_at timestamp,
    metric_name text,
    attributes map<text, text>,
    value blob,
    PRIMARY KEY ((context, partition, resource), collected_at, metric_name)
) WITH CLUSTERING ORDER BY (collected_at ASC, metric_name ASC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = {‘keys’: ‘ALL’, ‘rows_per_partition’: ‘NONE’}
    AND comment = ”
    AND compaction = {‘class’: ‘org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy’, ‘max_threshold’: ’32’, ‘min_threshold’: ‘4’}
    AND compression = {‘chunk_length_in_kb’: ’64’, ‘class’: ‘org.apache.cassandra.io.compress.LZ4Compressor’}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = ’99PERCENTILE’;

cqlsh:newts> quit

8.重新啟動 OpenNMS
# systemctl restart opennms