Bài trước mình có hướng dẩn các bạn cài đặt zabbix server
Ở bài này mình sẽ hướng dẩn các bạn cài đặt Zabbix Agent 2 trên CentOS 7 để theo dỗi máy chủ Mongodb
Bước 1: Cài Zabbix Agent 2
- Cài đặt kho lưu trữ Zabbix
1 2 3 4 | <span class="token punctuation">[</span>root@Analytic01 <span class="token operator">~</span><span class="token punctuation">]</span><span class="token comment"># yum update -y</span> <span class="token punctuation">[</span>root@Analytic01 <span class="token operator">~</span><span class="token punctuation">]</span><span class="token comment"># rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/7/x86_64/zabbix-release-6.2-3.el7.noarch.rpm</span> <span class="token punctuation">[</span>root@Analytic01 <span class="token operator">~</span><span class="token punctuation">]</span><span class="token comment"># yum clean all</span> |
- Cài đặt Zabbix Agent2
1 2 | [root@Analytic01 ~]# yum install zabbix-agent2 zabbix-agent2-plugin-* -y |
- Bắt đầu quy trình Zabbix Agent2
1 2 3 | <span class="token punctuation">[</span>root<span class="token variable">@Analytic01</span> <span class="token operator">~</span><span class="token punctuation">]</span><span class="token comment"># systemctl restart zabbix-agent2</span> <span class="token punctuation">[</span>root<span class="token variable">@Analytic01</span> <span class="token operator">~</span><span class="token punctuation">]</span><span class="token comment"># systemctl enable zabbix-agent2</span> |
Bước 2: Cấu hình Zabbix Agent 2 trỏ vào Zabbix Server
Như ở bài cài đặt zabbix server ở địa chỉ 10.19.2.1
Mình dùng lệnh để mở tiệp cấu hình zabbix
1 2 | <span class="token punctuation">[</span>root<span class="token variable">@Analytic01</span> <span class="token operator">~</span><span class="token punctuation">]</span><span class="token comment"># nano /etc/zabbix/zabbix_agent2.conf </span> |
trong tiệp tìm và đổi lại những chổ cấu hình
1 2 3 4 | ListenIP<span class="token operator">=</span><span class="token number">0.0</span><span class="token number">.0</span><span class="token number">.0</span> Server<span class="token operator">=</span><span class="token number">10.19</span><span class="token number">.2</span><span class="token number">.1</span> Hostname<span class="token operator">=</span>Zabbix Mongodb |
lưu lại và khởi động lại dịch vụ
1 2 | <span class="token punctuation">[</span>root<span class="token variable">@Analytic01</span> <span class="token operator">~</span><span class="token punctuation">]</span><span class="token comment"># systemctl restart zabbix-agent2</span> |
Bước 2: đăng nhập vào zabbix và add vào hosts : http://10.19.2.1/zabbix/zabbix.php?action=host.view
Chọn theo như hình
Bước 3: Cấu hình template MongoDB node by Zabbix agent 2
- Tạo người dùng MongoDB để theo dõi
Khi tác nhân đã được triển khai và cấu hình, bạn cần đảm bảo rằng bạn có người dùng cơ sở dữ liệu MongoDB mà chúng tôi có thể sử dụng cho mục đích giám sát. Dưới đây bạn có thể tìm thấy một ví dụ ngắn gọn về cách bạn có thể tạo người dùng MongoDB:
Truy cập vào mongodb ta dùng lệnh
1 2 | mongosh |
Chuyển sang cơ sở dữ liệu quản trị MongoDB:
1 2 | use admin |
Tạo người dùng với quyền ‘userAdMinanyDatabase‘ :
1 2 3 4 5 6 7 8 | db.createUser( ... { ..... user: "zabbix_mon", ..... pwd: "zabbix_mon", ..... roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] ..... } ... ) |
Tên người dùng cho người dùng mới được tạo là ‘zabbix_mon’
Mật khẩu cũng là ‘zabbix_mon
- Cấu hình Macros theo hình bên dưới
- {$MONGODB.PASSWORD} – tên người dùng MongoDB. Ví dụ của chúng tôi, chúng tôi sẽ đặt cái này thành zabbix_mon
- {$MONGODB.USER} – mật khẩu MongoDB. Ví dụ của chúng tôi, chúng tôi sẽ đặt giá trị này thành zabbix_mon
- {$MONGODB.CONNSTRING} – chuỗi kết nối MongoDB. Chỉ định địa chỉ MongoDB và cổng tại đây mà Zabbix Agent 2 sẽ kết nối và thực hiện việc thu thập số liệu
Bạn có thể thảm khảo thêm 2 bài viêt :