Skip to content

Instantly share code, notes, and snippets.

@sezemiadmin
Last active August 9, 2018 12:01
Show Gist options
  • Save sezemiadmin/57890df8ee16758cc2aceffd5779741d to your computer and use it in GitHub Desktop.
Save sezemiadmin/57890df8ee16758cc2aceffd5779741d to your computer and use it in GitHub Desktop.
Zabbix でログ監視と分析をやってみよう のコマンドサンプル

Zabbix用DBの作成

# mysql -u root -p
MariaDB [(none)]> show databases;
MariaDB [(none)]> create database zabbix;
MariaDB [(none)]> create user ‘zabbix’@‘%’ identified by ‘zabbixpass’; //ユーザー名とパスワードは一例
MariaDB [(none)]> select user,host from mysql.user;
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'%';
MariaDB [(none)]> show grants for zabbix;
MariaDB [(none)]> exit
# cd /usr/share/doc/zabbix-server-mysql-3.0.*  //* 部分はバージョンによって異なる
# gunzip create.sql.gz
# mysql -u root -p zabbix < create.sql

Zabbixサーバーの設定変更

# cd /etc/zabbix
# cp -p zabbix_server.conf zabbix_server.conf.original
# vi zabbix_server.conf
DBPassword=zabbixpass //DBPassword行にパスワードをセット

Zabbixサーバーの起動

# systemctl start zabbix-server
# systemctl enable zabbix-server

Zabbixエージェントの起動(自分自身の監視)

# systemctl start zabbix-agent
# systemctl enable zabbix-agent

Apache zabbix用定義ファイルの修正(※実運用環境に応じて修正)

<Directory "/usr/share/zabbix">
       :
    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
	:
        php_value always_populate_raw_post_data -1
        php_value date.timezone Asia/Tokyo //この修正例では、Timezoneを設定
    </IfModule>
</Directory>
  • リポジトリの追加
# yum -y install http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
  • エージェントのインストール
# yum -y install zabbix-agent
  • エージェントのコンフィグファイル変更
# vi /etc/zabbix/zabbix_agentd.conf
    Server={ZabbixサーバーのIPアドレス}
    ServerActive={ZabbixサーバーのIPアドレス}
    Hostname={自身のホスト名}
  • プロセス起動
# service zabbix-agent start
  • エージェントと自動起動登録
# chkconfig zabbix-agent on
  • ファイアウォールへのポート10050 許可設定
# vi /etc/sysconfig/iptables
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
  • ファイアウォールの再起動
# service iptables rest
  • リポジトリの無効化
# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/zabbix.repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment