1.部署Discuz论坛系统
#配置论坛nginx文件 [root@web01 ~]# cat /etc/nginx/conf.d/discuz.conf server { listen 80; server_name www.discuz.com; location / { root /usr/share/nginx/html/upload; index index.php index.htm; } location ~ \.php$ { root /usr/share/nginx/html/upload; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } #上传论坛代码包 [root@web01 ~]# ls Discuz_X3.3_SC_GBK.zip #解压代码包到nginx站点目录 [root@web01 ~]# unzip -q Discuz_X3.3_SC_UTF8.zip -d /usr/share/nginx/html/ #重启nginx服务 [root@web01 ~]# systemctl restart nginx #更改php用户为nginx [root@web01 /usr/share/nginx/html/upload]# vim /etc/php-fpm.d/www.conf user = nginx group = nginx #重启php-fpm服务 [root@web01 /usr/share/nginx/html/upload]# systemctl restart php-fpm.service #授权 [root@web01 /usr/share/nginx/html/upload]# chown -R nginx.nginx ./
2.安装discuz论坛页面
浏览器输入www.discuz.com域名访问(注意:需要域名解析)
可以在论坛发布信息了
3.部署redis服务
#安装redis服务 [root@web01 ~]# yum install -y redis #设置redis密码(大概在480行,添加一行代码即可) [root@web01 ~]# vim /etc/redis.conf requirepass 123456 #重启Redis服务 [root@web01 ~]# systemctl restart redis.service #配置discuz全局配置文件(更改redis配置信息) [root@web01 ~]# vim /usr/share/nginx/html/upload/config/config_global.php $_config['memory']['redis']['server'] = '127.0.0.1'; $_config['memory']['redis']['port'] = 6379; $_config['memory']['redis']['pconnect'] = 1; $_config['memory']['redis']['timeout'] = '0'; $_config['memory']['redis']['requirepass'] = '123456'; #重启php-fpm和redis服务 [root@web01 ~]# systemctl restart php-fpm.service redis.service #获取Redis配置信息 [root@web01 ~]# redis-cli -a 123456 info # Server redis_version:3.2.12 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:7897e7d0e13773f redis_mode:standalone os:Linux 3.10.0-957.el7.x86_64 x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.8.5 ... ...省略N行redis配置信息 ...
4.编写监听脚本并赋予权限
如果Redis密码不和我一样,需要修改
注意需要给脚本文件授权
chmod +x redis_status.sh
注意需要给脚本文件授权
chmod +x redis_status.sh
[root@web01 /server/scripts]# cat redis_status.sh #!/bin/bash R_COMMAND="$1" R_PORT="6379" #根据实际情况调整端口 R_SERVER="127.0.0.1" #根据具体情况调整IP地址 PASSWD="123456" #如果没有设置Redis密码,为空即可 redis_status(){ (echo -en "AUTH $PASSWD\r\nINFO\r\n";sleep 1;) | /usr/bin/nc "$R_SERVER" "$R_PORT" > /tmp/redis_"$R_PORT".tmp REDIS_STAT_VALUE=$(grep "$R_COMMAND:" /tmp/redis_"$R_PORT".tmp | cut -d ':' -f2) echo "$REDIS_STAT_VALUE" } case $R_COMMAND in used_cpu_user_children) redis_status "$R_PORT" "$R_COMMAND" ;; used_cpu_sys) redis_status "$R_PORT" "$R_COMMAND" ;; total_commands_processed) redis_status "$R_PORT" "$R_COMMAND" ;; role) redis_status "$R_PORT" "$R_COMMAND" ;; lru_clock) redis_status "$R_PORT" "$R_COMMAND" ;; latest_fork_usec) redis_status "$R_PORT" "$R_COMMAND" ;; keyspace_misses) redis_status "$R_PORT" "$R_COMMAND" ;; keyspace_hits) redis_status "$R_PORT" "$R_COMMAND" ;; keys) redis_status "$R_PORT" "$R_COMMAND" ;; expired_keys) redis_status "$R_PORT" "$R_COMMAND" ;; evicted_keys) redis_status "$R_PORT" "$R_COMMAND" ;; connected_clients) redis_status "$R_PORT" "$R_COMMAND" ;; changes_since_last_save) redis_status "$R_PORT" "$R_COMMAND" ;; blocked_clients) redis_status "$R_PORT" "$R_COMMAND" ;; rdb_bgsave_in_progress) redis_status "$R_PORT" "$R_COMMAND" ;; aof_rewrite_in_progress) redis_status "$R_PORT" "$R_COMMAND" ;; used_memory_peak) redis_status "$R_PORT" "$R_COMMAND" ;; used_memory) redis_status "$R_PORT" "$R_COMMAND" ;; used_cpu_user) redis_status "$R_PORT" "$R_COMMAND" ;; used_cpu_sys_children) redis_status "$R_PORT" "$R_COMMAND" ;; total_connections_received) redis_status "$R_PORT" "$R_COMMAND" ;; cluster_enabled) redis_status "$R_PORT" "$R_COMMAND" ;; *) echo $"USAGE:$0 {used_cpu_user_children|used_cpu_sys|total_commands_processed|role|lru_clock|latest_fork_usec|keyspace_misses|keyspace_hits|keys|expired|expired_keys|connected_clients|changes_since_last_save|blocked_clients|rdb_bgsave_in_progress|used_memory_peak|used_memory|used_cpu_user|used_cpu_sys_children|total_connections_received|aof_rewrite_in_progress|cluster_enabled}" esac #给脚本文件赋予执行权限 [root@web01 /server/scripts]# chmod +x redis_status.sh
5.编写zabbix监控项
[root@web01 /server/scripts]# cat /etc/zabbix/zabbix_agentd.d/redis_status.conf UserParameter=redis_status[*],/bin/bash /server/scripts/redis_status.sh "$1" #重启zabbix客户端 [root@web01 /server/scripts]# systemctl restart zabbix-agent #zabbix客户端获取值测试 [root@web01 /server/scripts]# zabbix_agentd -t redis_status[used_cpu_user_children] redis_status[used_cpu_user_children] [t|0.00] #删除tmp目录下不必要的缓存文件 [root@web01 /server/scripts]# rm -f /tmp/redis_6379.tmp