yuuki-kawada-yksmh / yksmh

0 stars 0 forks source link

cacti構築-centOS7 #1

Open yuuki-kawada-yksmh opened 7 years ago

yuuki-kawada-yksmh commented 7 years ago

~~まず古いcactiをyumでインストールしてそのあと1.04を置き換える。 ~~最後にphpのバージョンアップをしている。

... ★★参考 http://qiita.com/Kenji_TAJIMA/items/91965a94c624fa0c89ca

■net-snmp インストール http://www.server-memo.net/server-setting/snmp/net-snmp.html

    yum install net-snmp
    yum -y install net-snmp-utils

    /etc/snmp/snmpd.conf ←この編集はしない。

    systemctl start snmpd  起動
    systemctl enable snmpd 自動起動設定

■RRDTool インストール yum install rrdtool

■wgetインストール yum install wget

■MySQLインストール

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

rpm -Uvh mysql-community-release-el7-5.noarch.rpm

yum -y install php-mysql

chkconfig mysqld on

systemctl enable mysqld 自動起動設定

#

これではインストールされなかった

■MySQLインストール http://weblabo.oscasierra.net/installing-mysql57-centos7-yum/

    yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

    yum -y install mysql-community-server
    systemctl enable mysqld.service

    systemctl start mysqld.service

...

★★ここからこちらに従う http://www.unix-power.net/linux/cacti.html

■cactiインストール cd /usr/local/src/

wget http://pkgs.repoforge.org/cacti/cacti-0.8.8b-1.el6.rf.noarch.rpm

 ←ダメだった

yum install epel-release
vi /etc/yum.repos.d/epel.repo
------------------------------------------------------------------------
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=0           ←ここを1→0に変更する。
gpgcheck=1
------------------------------------------------------------------------

    yum --enablerepo=epel install cacti

■mysql設定 /usr/bin/mysqladmin -u root password 'MyNewPass4!'

    mysql -u root -p   ←上記で設定したパスワードを設定
    create database cacti;
    grant all privileges on cacti.* to cactiuser@localhost identified by 'MyNewPass4!';
    exit

■cactiの設定 vi /usr/share/cacti/include/config.php

    30c30
    < $database_password = "cactiuser";
    ---
    > $database_password = "MyNewPass4!";
    ----------------------------------------------------

    mysql -u cactiuser -p cacti < /usr/share/doc/cacti-0.8.8h/cacti.sql     ←上

記で設定したcactiuserパスワード指定

    vi /etc/cron.d/cacti
    ----------------------------------------------------
    < #*/5 * * * *  cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev

/null 2>&1

    > */5 * * * *   cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev

/null 2>&1

■apacheの設定 vi /etc/httpd/conf.d/cacti.conf DROP DATABASE cacti;

    ----------------------------------------------------
    <               Require host localhost
    ---
    >               Require all granted
    23c23
    <               Allow from localhost
    ---
    >               Allow from all
    ----------------------------------------------------

■phpの設定 ※デフォルト設定だとアクセスするたびにphpエラーが出力されるため  これを防ぐために以下設定をする。 vi /etc/php.ini

    >
    > date.timezone = 'Asia/Tokyo'
    >
    ----------------------------------------------------

    systemctl restart httpd

■接続確認 http://35.167.250.10/cacti/install/

    ※接続できない場合以下を実施
    systemctl status firewalld
    systemctl stop firewall.d

    これでcactiのトップが表示される

■cacti verUP cd /usr/share mv cacti cacti_old

    wget http://www.cacti.net/downloads/cacti-1.0.4.tar.gz
    tar xzvf cacti-1.0.4.tar.gz

    mv cacti-1.0.4 cacti

    cd /usr/share/cacti

■cactiの設定 vi /usr/share/cacti/include/config.php

    30c30
    < $database_password = "cactiuser";
    ---
    > $database_password = "MyNewPass4!";
    ----------------------------------------------------

    mysql -u root -p
    DROP DATABASE cacti;

    create database cacti;
    grant all privileges on cacti.* to cactiuser@localhost identified by 'MyNewPass4!';
    exit

    mysql -u cactiuser -p cacti < /usr/share/cacti/cacti.sql        ←上記で設定し

たcactiuserパスワード指定

■posix インストール

    yum install php-process    

インストール後はhttpdのrestart
systemctl restart httpd

■ldap インストール yum install php-ldap

インストール後はhttpdのrestart
systemctl restart httpd

■mbstring インストール yum install php-mbstring

インストール後はhttpdのrestart
systemctl restart httpd

■gd インストール yum install php-gd

インストール後はhttpdのrestart
systemctl restart httpd

■mysqlチューニング vi /etc/my.cnf

>
> [mysqld]
> max_heap_table_size=50M
> max_allowed_packet=20971520
> tmp_table_size=68M
> join_buffer_size=68M
> innodb_buffer_pool_size=256M
> innodb_doublewrite=OFF
> innodb_additional_mem_pool_size=80M
> innodb_flush_log_at_timeout=3
> innodb_read_io_threads=32
> innodb_write_io_threads=16
>
>
    ----------------------------------------------------

systemctl restart mysqld.service

...

■接続確認 http://35.167.250.10/cacti

...

cacti表示後のインストール作業 以下のエラーが出ていて次にすすめない。

ERROR: Your Cacti database login account does not have access to the MySQL TimeZone database. Please provide the Cacti database account "select" access to the "time_zone_name" table in the "mysql" database, and populate MySQL's TimeZone information before proceeding.

エラー:CactiデータベースのログインアカウントにMySQL TimeZoneデータベースへの アクセス権がありません。 「mysql」データベースの「time_zone_name」テーブルへの Cactiデータベースアカウントの「選択」アクセスを提供し、 処理を続ける前にMySQLのTimeZone情報を入力してください。

タイムゾーン対処ページ http://tmtms.hatenablog.com/entry/2015/08/22/mysql-timezone

MyNewPass4!

★対応 mysql -u root -p grant all privileges on . to cactiuser@localhost identified by 'MyNewPass4!'; show grants;

↓ まだ以下のエラーが残っている。

エラー:MySQL TimeZoneデータベースにデータが入力されていません。 続行する前にこのデータベースにデータを入力してください。

★対応 mysql -u root -p USE mysql SHOW TABLES LIKE '%time_zone%'; SELECT * FROM time_zone; ←まだタイムゾーンが追加されていない。 exit

mysql_tzinfo_to_sql /usr/share/zoneinfo mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot mysql  ←登録

mysql -u root -p USE mysql SHOW TABLES LIKE '%time_zone%'; SELECT * FROM time_zone; ←登録された。

↓ エラー解消

ログイン情報 http://35.167.250.10/cacti/ admin Kccs0000!

SPINEインストール ソース場所:http://www.cacti.net/downloads/spine/cacti-spine-1.0.4.tar.gz

cd /usr/local/src;pwd wget http://www.cacti.net/downloads/spine/cacti-spine-1.0.4.tar.gz

tar xvzf cacti-spine-.tar.gz cd cacti-spine- ./configure

開発ツールをインストール yum groupinstall 'Development tools'

このエラーがでるので

configure:3471: gcc -lpthread -lssl -lm conftest.c >&5 /bin/ld: cannot find -lssl collect2: error: ld returned 1 exit status

yum install openssl-devel

上記は解消したが新たなエラーが

configure: error: Cannot find MySQL headers. Use --with-mysql= to specify non-default path.

yum install mysql-community-devel

このエラーも残っていた

common.h:134:38: fatal error: net-snmp/net-snmp-config.h: No such file or directory

yum install net-snmp-devel

これですべて解消

make

エラーでた

[root@ip-10-56-121-31 cacti-spine-1.0.4]# make false // No help2man // --output=spine.1 --name='Data Collector for Cacti' --no-info --version-option='--version' ./spine make: *** [spine.1] Error 1

yum install help2man

これで解決

sudo make install

Spineは、デフォルトの場所/ usr / local / spineにインストールされます。 /usr/local/spine/etc/spine.confを正しいデータベース情報で更新することを忘れないでください。 最後にCacti設定のSpineパスを/ usr / local / spine / bin / spineに更新し、Poller TypeをSpineに切り替えます。

vi /usr/local/spine/etc/spine.conf.dist

45c45 < DB_Pass cactiuser

DB_Pass MyNewPass4! 48,52c48,52 < RDB_Host localhost < RDB_Database cacti < RDB_User cactiuser < RDB_Pass cactiuser < RDB_Port 3306

RDB_Host localhost

RDB_Database cacti

RDB_User cactiuser

RDB_Pass MyNewPass4!

RDB_Port 3306


あとはcacti画面より実施

Spineがシステムにインストールされたら、次の手順を実行してCactiインストールで認識させる必要があります。

1.管理者としてCactiにログインします。 2.メニューの[設定]を選択し、[パス]タブをクリックします。

  1. Spine Poller File PathフィールドにSpineバイナリの完全パスを入力し、Saveをクリックします /usr/local/spine/bin/spine
  2. [Poller]タブをクリックします。
  3. [Poller Type]ドロップダウンボックスから[spine]を選択し、[Save]をクリックします。

これらのステップを完了すると、Cactiはcmd.phpではなく5分ごとにSpineを生成します。 Spineにデータを収集させるのに問題がある場合、 いつでもPoller Typeを一時的に "cmd.php"に戻すことができます。

グラフが作成されない

RRDTool Says: ERROR: opening '/usr/share/cacti/rra/local_linux_machine_mem_buffers_4.rrd': No such file or directory が出ていたので

これをやってみる chmod 777 /usr/share/cacti/rra/ これでrrdファイルが作られた

これでグラフの枠は出力されたが、値がでてこない とりあえず /usr/share/cacti/ 配下を chown -R cacti:cacti とする。

これでもグラフ値が出てこないので selinuxをoffに

getenforce vi /etc/selinux/config

7c7
< SELINUX=enforcing
---
> SELINUX=disabled
-------------------------------------------------------

shutdown -r now

あとは以下の権限を777へ chmod 777 /usr/share/cacti/rra chmod 777 /usr/share/cacti/rra/ chmod 777 /usr/share/cacti/plugins chmod 777 /usr/share/cacti/plugins/

php 7.1 バージョンアップ

remiリポジトリ追加 rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

インストール前にmysql,apache,net-snmpを停止しておく

systemctl stop httpd systemctl status httpd

systemctl stop mysqld systemctl status mysqld

systemctl stop snmpd systemctl status snmpd

yum list --enablerepo=remi-php71 php yum install --enablerepo=remi-php71 php

■SPINEでデータ取得できない タイマを伸ばしてみる 25→60

cacti画面からの設定で「パス」の Spine Config File Pathに /usr/local/spine/etc/spine.conf.distを設定する

...