[CentOS7] LEMP Stack – nginx-percona-plugin install 작성중

[CentOS7] LEMP Stack – nginx-percona-plugin install

몇일전 고객 요청으로 nginx 위에 cacti 를 설치 했습니다.

1.1.38 Version 의 경우 기본으로 제공되는 템플릿이 없어서  그래프를 그릴수 없습니다.

모니터링시 Authentication Method – > Builtin Authentication 을 None 으로

변경 해야 모든 그래프를 볼수 있습니다.

Percona-plugin 을 사용 하지 않을시 별도의 cacti user 계정은 필요 없습니다.

Nginx 모니터링시 ss_get_by_ssh 스크립트 이용으로 인하여 cacti 또는 별도의 계정이 필요 합니다.

cacti 계정 사용시 필히 /etc/cacti/db.php 권한을 cacti 로 변경 해야 합니다.  변경하지 않았을 경우 cacti 작동이 정상적으로 되지 않습니다.

 

 

nginx 설치전 System update 를 진행 합니다.

System update 후 rebooting  을 합니다.

[root@CentOS7 ~]# yum update -y
[root@CentOS7 ~]# init 6

 

  • nginx repo file 를 생성 합니다.
[root@CentOS7 ~]# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
[root@CentOS7 ~]# yum clean all ; yum list

 

  • nginx 설치
[root@CentOS7 ~]# yum install -y nginx

 

  • php71 설치를 위한 epel-release 패키지 설치및 remi-release-7 패키지 설치
[root@CentOS7 ~]# yum install -y epel-release
[root@CentOS7 ~]# rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm   
[root@CentOS7 ~]# yum clean all ; yum list
[root@CentOS7 ~]# yum update -y
[root@CentOS7 ~]# init 6
[root@CentOS7 ~]# yum-config-manager --enable remi-php71

 

  • php71 설치
[root@CentOS7 ~]# yum install -y php php-opcache php-mysql php-fpm php-gd \
 php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel

 

[root@CentOS7 ~]# vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@CentOS7 ~]# yum clean all ; yum list

 

  • mariadb 설치
[root@CentOS7 ~]# yum install -y mariadb mariadb-server

 

 

 

  • mariadb Daemon enable & start
[root@CentOS7 ~]# systemctl enable mariadb
[root@CentOS7 ~]# systemctl start mariadb

 

  • mysql_secure_installation 실행
[root@CentOS7 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@CentOS7 ~]#

 

  • nginx daemon enable & start
[root@CentOS7 ~]# systemctl enable nginx
[root@CentOS7 ~]# systemctl start nginx

 

 

  • nginx.conf 설정
[root@CentOS7 ~]# vi /etc/nginx/nginx.conf
user  nginx;
worker_processes  1;
 
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
    access_log  /var/log/nginx/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    keepalive_timeout  65;
 
    #gzip  on;
 
    include /etc/nginx/conf.d/*.conf;
}

 

  • default.conf 파일 설정
[root@CentOS7 ~]# vi /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

 

  • nginx deamon restart
[root@CentOS7 ~]# systemctl restart nginx

 

  • php-fpm.conf 설정
[root@CentOS7 ~]# vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

 

  • php-fpm daemon enable & start
[root@CentOS7 ~]# systemctl enable php-fpm
[root@CentOS7 ~]# systemctl start php-fpm

 

  • phpinfo() 확인
[root@CentOS7 ~]# vi /usr/share/nginx/html/info.php
<?php phpinfo(); ?>

 

  • web-site 확인

 

  • cacti 설치
[root@CentOS7 ~]# yum install -y httpd httpd-devel mariadb-server php-mysql php-pear php-common php-gd \
 php-devel php php-mbstring php-cli php-snmp net-snmp-utils net-snmp-libs rrdtool cacti

 

  • db 생성
[root@CentOS7 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.1.37-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database cacti;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit;
Bye
[root@CentOS7 ~]#

 

  • cacati db 작업
[root@CentOS7 ~]# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-1.1.38/cacti.sql

[root@CentOS7 ~]# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-1.1.38/cacti.sql
[root@CentOS7 ~]# mysql -u root -p cacti < /usr/share/doc/cacti-1.1.38/cacti.sql
Enter password:
[root@CentOS7 ~]# vi /etc/cacti/db.php
$database_type     = 'mysql';
$database_default  = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'password';
$database_port     = '3306';
$database_ssl      = false;

 

  • nginx default.conf 수정
[root@CentOS7 ~]# vi /etc/nginx/conf.d/default.conf
    location /server-status {
        stub_status on;
        allow 127.0.0.1;
        #deny all;
    }
    # cacti settings
    location /cacti {
    alias /usr/share/cacti;
    index index.php;
    }

    location ~ ^/cacti.+\.php$ {
    # fastcgi_pass unix:/var/run/php-fpm.sock;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;

    fastcgi_split_path_info ^/cacti(.+\.php)(.*)$;
    fastcgi_param SCRIPT_FILENAME /usr/share/cacti/$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
    }

 

  • nginx deamon restart 및 /server-status 확인
[root@CentOS7 ~]# systemctl restart nginx
[root@CentOS7 ~]# curl http://localhost/server-status
Active connections: 1
server accepts handled requests
 1 1 1
Reading: 0 Writing: 1 Waiting: 0
[root@CentOS7 ~]#

 

  • db.php 권한 변경
[root@CentOS7 ~]# chown nginx:nginx /etc/cacti/db.php

 

 

  • mysql.time_zone_name 설정
[root@CentOS7 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.1.37-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name to 'cacti'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye
[root@CentOS7 ~]#

 

  • php.ini 설정 및 php-gpm 패키지 설치
[root@CentOS7 ~]# vi /etc/php.ini
date.timezone =Asia/Seoul

[root@CentOS7 ~]# yum install -y php-gmp

 

  • mariadb 설정
[root@CentOS7 ~]# vi /etc/my.cnf.d/server.cnf
[server]
character-set-server=utf8mb4
collation-server = utf8mb4_unicode_ci
max_heap_table_size = 200M
max_allowed_packet = 16777216
tmp_table_size = 64M
join_buffer_size = 64M
innodb_buffer_pool_size = 921M
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


[root@CentOS7 ~]# vi /etc/my.cnf.d/client.cnf
[client]
default-character-set = utf8mb4


[root@CentOS7 ~]# systemctl restart mariadb
[root@CentOS7 ~]# systemctl restart nginx
[root@CentOS7 ~]# systemctl restart php-fpm

[root@CentOS7 ~]# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
Enter password:
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
[root@CentOS7 ~]#

 

  • 모든 설정을 완료 하였습니다.

 

  • Next 를 클릭 합니다.

 

  • Next 를 클릭 합니다.

 

  • spine 을 설치 합니다.
  • spine 최신 버젼은 https://www.cacti.net/downloads/spine/ 에서 확인 할수 있습니다.
[root@CentOS7 spine]# wget https://www.cacti.net/downloads/spine/cacti-spine-1.1.38.tar.gz
[root@CentOS7 ~]# yum install -y gcc mysql-devel net-snmp-devel autoconf automake libtool dos2unix help2man
[root@CentOS7 ~]# mkdir spine
[root@CentOS7 ~]# cd spine/
[root@CentOS7 spine]# wget https://www.cacti.net/downloads/spine/cacti-spine-1.1.38.tar.gz
[root@CentOS7 spine]# tar xvf cacti-spine-1.1.38.tar.gz
[root@CentOS7 spine]# cd cacti-spine-1.1.38/
[root@CentOS7 cacti-spine-1.1.38]# ./bootstrap
INFO: Spine bootstrap process completed

  These instructions assume the default install location for spine
  of /usr/local/spine.  If you choose to use another prefix, make
  sure you update the commands as required for that new path.

  To compile and install Spine using MySQL versions 5.5 or higher
  please do the following:

  ./configure
  make
  make install
  chown root:root /usr/local/spine/bin/spine
  chmod +s /usr/local/spine/bin/spine

  To compile and install Spine using MySQL versions previous to 5.5
  please do the following:

  ./configure --with-reentrant
  make
  make install
  chown root:root /usr/local/spine/bin/spine
  chmod +s /usr/local/spine/bin/spine
[root@CentOS7 cacti-spine-1.1.38]# ./configure
[root@CentOS7 cacti-spine-1.1.38]# make && make install
[root@CentOS7 cacti-spine-1.1.38]# chown root:root /usr/local/spine/bin/spine
[root@CentOS7 cacti-spine-1.1.38]# chmod +s /usr/local/spine/bin/spine
[root@CentOS7 ~]# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
[root@CentOS7 ~]# vi /etc/spine.conf
B_Host                 localhost
DB_Database             cacti
DB_User                 cacti
DB_Pass                 password
DB_Port                 3306

 

  • spine 테스트
[root@CentOS7 ~]# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 1.1.38 starting
SPINE: Time: 0.0249 s, Threads: 5, Devices: 0
[root@CentOS7 ~]#

 

 

  • Next 를 클릭 합니다.

 

  • cacti 1.1.38 Version 의 경우 별도의 권한 설정이 필요 합니다.
  • 설치시 옵션
[root@CentOS7 ~]# chown -R nginx.nginx /usr/share/cacti/resource/
[root@CentOS7 ~]# chown -R nginx.nginx /usr/share/cacti/scripts/
[root@CentOS7 ~]# chown -R nginx.nginx /usr/share/cacti/log/
[root@CentOS7 ~]# chown -R nginx.nginx /usr/share/cacti/cache/

 

 

  • Next 를 클릭 합니다.

 

  • 모니터링 Device 를 선택후 Next 를 클릭 합니다.
  • 최초 로그인 id/pass 는 admin/admin 이며 Keep me signed in 을 체크 해야 합니다.

 

  • 로그인 완료 모습

 

  • 설치후 cacti 디렉토리 권한
[root@CentOS7 ~]# chown -R nginx:nginx /usr/share/cacti/
[root@CentOS7 ~]# chown -R nginx:nginx /var/lib/cacti/cache/
[root@CentOS7 ~]# chown -R nginx:nginx /var/lib/cacti/cli/
[root@CentOS7 ~]# chown -R nginx:nginx /var/lib/cacti/rra/
[root@CentOS7 ~]# chown -R nginx:nginx /var/lib/cacti/scripts/

 

  • snmpd 설정
[root@CentOS7 ~]# systemctl enable snmpd
[root@CentOS7 ~]# systemctl start snmpd

[root@CentOS7 ~]# vi /etc/snmp/snmpd.conf
#       sec.name  source          community
com2sec public  default       public

####
# Second, map the security name into a group name:

#       groupName      securityModel securityName
group   public v1           public
group   public v2c          public

####
# Third, create a view for us to let the group have rights to:

# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
#view    systemview    included   .1.3.6.1.2.1.1
#view    systemview    included   .1.3.6.1.2.1.25.1.1
view     all           included    .1

####
# Finally, grant the group read-only access to the systemview view.

#       group          context sec.model sec.level prefix read   write  notif
#access  notConfigGroup ""      any       noauth    exact  systemview none none
access  public ""      any       noauth    exact  all none none

[root@CentOS7 ~]# systemctl restart snmpd
[root@CentOS7 ~]# snmpwalk -v2c -c public 192.168.0.33

 

  • poller.php 설정
[root@CentOS7 ~]# vi /etc/cron.d/cacti
*/5 * * * *     nginx   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1


## 주의 ss_get_by_ssh 스크립트 이용시에는 cacti 권한이 아니면 정상적으로 스크립트를 실행할수 없습니다. 

[root@CentOS7 ~]# vi /etc/cron.d/cacti
*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

 

  • Device temp 파일 다운 로드
[root@CentOS7 ~]# mkdir cacti
[root@CentOS7 ~]# cd cacti/

[root@CentOS7 cacti]# wget https://docs.cacti.net/_media/template:package:generic_snmp_device.xml.gz

[root@CentOS7 cacti]# wget https://docs.cacti.net/_media/template:package:local_linux_machine.xml.gz -O local_linux_machine.xml.gz

[root@CentOS7 cacti]# wget https://docs.cacti.net/_media/template:package:netsnmp_device.xml.gz -O netsnmp_device.xml.gz

[root@CentOS7 cacti]# chmod +x /usr/share/cacti/cli/import_package.php

[root@CentOS7 cacti]# /usr/share/cacti/cli/import_package.php --filename=./local_linux_machine.xml.gz

[root@CentOS7 cacti]# /usr/share/cacti/cli/import_package.php --filename=./template:package:generic_snmp_device.xml.gz

[root@CentOS7 cacti]# /usr/share/cacti/cli/import_package.php --filename=./netsnmp_device.xml.gz

 

  • cacti device 생성

 

  • Create Graphs for this Device 클릭

 

  • Create  클릭

 

  • Graphs 로 이동 합니다.

 

  • View 버튼 클릭

 

  • 최상위 메뉴중 Logs 를 클릭 합니다.

 

  • Console -> Configureation -> Settings ->  Authentication
  • Authentication Method – > Builtin Authentication 을 None 으로 변경 합니다

 

  • Graphs 로 이동 합니다.

 

  • 10 분후 정상적으로 그래프를 볼수 있습니다.

 

  • nginx percona temp 설치
[root@CentOS7 cacti]# wget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.7/binary/redhat/7/x86_64/percona-cacti-templates-1.1.7-2.noarch.rpm
[root@CentOS7 cacti]# yum install -y percona-cacti-templates-1.1.7-2.noarch.rpm

 

  • nginx percona temp load
[root@CentOS7 cacti]# php /usr/share/cacti/cli/import_template.php --filename=/usr/share/cacti/resource/percona/templates/cacti_host_template_percona_nginx_server_ht_0.8.6i-sver1.1.7.xml
Read 42607 bytes of XML data
Import Results
Cacti has imported the following items for the Template:
CDEF
[success] Percona Turn Into Bits CDEF [new]
[success] Percona Negate CDEF [new]
GPRINT Preset
[success] Percona Nginx Server Checksum c5c20ca1d61ee9ccbb45854a46ce6fe8 [new]
[success] Percona Nginx Server Version t1.1.7:s1.1.7 [new]
[success] Percona Normal [new]
Data Input Method
[success] Percona Get Nginx Stats/Nginx Requests IM [new]
[success] Percona Get Nginx Stats/Nginx Accepts/Handled IM [new]
[success] Percona Get Nginx Stats/Nginx Scoreboard IM [new]
Data Template
[success] Percona Nginx Requests DT [new]
[success] Percona Nginx Accepts/Handled DT [new]
[success] Percona Nginx Scoreboard DT [new]
Graph Template
[success] Percona Nginx Requests GT [new]
[success] Percona Nginx Accepts/Handled GT [new]
[success] Percona Nginx Scoreboard GT [new]
Device Template
[success] Percona Nginx Server HT [new]
[root@CentOS7 cacti]#
[root@CentOS7 cacti]# chown -R cacti:nginx resource/

 

  • Data Collection -> Data Input Methods  로 이동합니다.

 

  • Input String 변경
기존 <path_php_binary> -q <path_cacti>/scripts/ss_get_by_ssh.php –host <hostname> –type nginx –items hw,ig,ih,ii –server <server> –url <url> –http-user <http-user> –http-password <password>

변경 <path_php_binary> -q <path_cacti>/scripts/ss_get_by_ssh.php –host <hostname> –type nginx –items hw,ig,ih,ii

 

 

  • Save 한후 모든 nginx 템플릿에 동일하게 적용 합니다.
  • Add Graph Template

 

 

  • Create Graphs for this Device 를 클릭 합니다.

 

  • Console -> Data Collection -> Data Collectiors -> Web Site Hostname 변경 192.168.0.33
  • Save 를 클릭 하여 저장 합니다.

 

  • User 생성
[root@CentOS7 ~]# useradd -d /usr/share/cacti cacti
[root@CentOS7 ~]# mkdir /usr/share/cacti/.ssh
[root@CentOS7 ~]# chmod 700 /usr/share/cacti/.ssh
[root@CentOS7 ~]# chown cacti:cacti /usr/share/cacti/.ssh

 

  • ss_get_by_ssh.php 설정
[root@CentOS7 cacti]# su - cacti
-bash-4.2$ pwd
/usr/share/cacti
-bash-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/usr/share/cacti/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /usr/share/cacti/.ssh/id_rsa.
Your public key has been saved in /usr/share/cacti/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:y7EHWx/3qKXjoDnq68yDRV79YBx/kkglxdtsTVb8KZ0 cacti@CentOS7
The key's randomart image is:
+---[RSA 2048]----+
|          .+o  .o|
|          o..   +|
|         + + =.++|
|      . . * =.=Eo|
|     o .S..o.+o  |
|      o. B ..o o |
|     o  = o . o .|
|    .o. .+ ..+   |
|     oB+o. .+.   |
+----[SHA256]-----+
-bash-4.2$ cd .ssh/
-bash-4.2$ cat id_rsa.pub >> authorized_keys
-bash-4.2$ chmod 600 authorized_keys
-bash-4.2$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:ZWA5Uum+t2aMbqe60UBUVGMLCoTWSkOdVF50tY70k+w.
ECDSA key fingerprint is MD5:c9:d5:01:7b:e7:49:69:e4:73:39:bb:58:65:a5:0a:c2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Last login: Tue Feb  5 02:50:25 2019
-bash-4.2$

 

  • ss_get_by_ssh.php 테스트
[root@CentOS7 ~]# cd /usr/share/cacti/scripts/
[root@CentOS7 scripts]# chown cacti:cacti ss_get_by_ssh.php
[root@CentOS7 scripts]# chmod +x ss_get_by_ssh.php

[root@CentOS7 scripts]# su - cacti
Last login: Tue Feb  5 02:55:06 KST 2019 on pts/0
-bash-4.2$ php /usr/share/cacti/scripts/ss_get_by_ssh.php --type nginx --host 127.0.0.1 --items hw,hx
hw:7 hx:46-bash-4.2$

 

  • Nginx percona 사용을 위한 권한 변경
[root@CentOS7 ~]# chown -R cacti:nginx /var/lib/cacti/
[root@CentOS7 ~]# chown -R cacti:nginx /usr/share/cacti/
[root@CentOS7 ~]# chown -R cacti:nginx /var/lib/cacti/cache/
[root@CentOS7 ~]# chown -R cacti:nginx /var/lib/cacti/cli/
[root@CentOS7 ~]# chown -R cacti:nginx /var/lib/cacti/rra
[root@CentOS7 ~]# chown -R cacti:nginx /var/lib/cacti/scripts/
[root@CentOS7 ~]# chown -R cacti:nginx /var/log/cacti/
[root@CentOS7 ~]# chown cacti:nginx /etc/cacti/db.php

[root@CentOS7 ~]# vi /etc/cron.d/cacti
*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

 

  • nginx 모니터링 결과

 

  • 추가설정
  • Configuration -> Settings -> Paths에서 Spine config File Path 을 설정합니다.
  • /etc/spine.conf

 

  • Configuration -> Settings -> Poller 에서 Poller Type 을 변경합니다.
  • Poller Type : spine 으로 변경
  • Poller interval : Every Minute 으로 변경

 

  • Spine Specific Execution Parameters 변경
  • Maximum Threads per Process 1 -> 16
  • Number of PHP Script Servers 1 -> 8

 

  • Save 를 클릭 하여 설정을 마무리 합니다.
  • nginx 모니터링 실패시 아래와 같은 log 파일을 확인 할수 있습니다.
  • Device 항목에서 Debug 항목을 eanble 하면 자세한 로그를 확인 할수 있습니다.
  • Console -> Data Collection -> Data Collectiors 의 web site hostname 을 확인 합니다.
  • [root@CentOS7 scripts]# tail -f /var/log/secure cacti 유저 로그인 잘되는지 확인 합니다.
  • crontab 의 cacti 스크립트의 유저명을 확인 합니다.

 

  • cacti admin 비번 분실
루트 비번 락킹

[root@localhost log]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 430
Server version: 10.1.35-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use cacti;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [cacti]> update user_auth set enabled=('on');
Query OK, 1 row affected (0.03 sec)
Rows matched: 3  Changed: 1  Warnings: 0

MariaDB [cacti]>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [cacti]>

 

 

 

댓글 남기기