參考網頁:
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