1.官网上下载nginx安装包,上传至linux 2.解压
tar -zxvf nginx -C /usr/local/src3.预编译
cd /usr/local/src/nginx ./configure4.提示缺少pcre安装包,使用Yum安装
yum -y install gcc pcre-devel openssl openssl-devel5.再继续预编译
cd /usr/local/src/nginx ./configure6.编译并且安装
make && make install7.启动nginx
cd /usr/local/nginx sbin/nginx8.查看nginx进程
ps -ef | grep nginx netstat -anpt | grep nginx //查看nginx访问端口 配置nginx,实现负载均衡1、cd /usr/local/nginx/conf 2、vi nginx.conf
http { #响应数据的来源,以及权重配置(weight) upstream tomcats { server slave4:8888 weight=1 server slave5:8888 weight=1 server slave6:8888 weight=1; } server { listen 80; server_name slave5; # 过滤所有的请求都交给配置的机器处理 location ~ .* { proxy_pass http://tomcats; } } }3、重启nginx
sbin/nginx -s reload nginx+kafka (nginx将产生的数据传入kafka) 1、yum -y install git //安装git 2、cd /usr/local/src 3、git clone https://github.com/edenhill/librdkafka // 将kafka c端源码clone到本地 4、cd librdkafka 5、yum -y install gcc-c++ pcre-devel zlib-devel //下载依赖包 6、./configure 7、make && make install 8、cd /usr/local/src 9、git clone https://github.com/brg-liuwei/ngx_kafka_module //克隆nginx整合kafka源码 10、wget http://nginx.org/download/nginx-1.8.0.tar.gz //下载nginx-1.8.0安装包 11、tar -zxvf nginx-1.8.0.tar.gz // 解压 12、cd nginx-1.8.0 13、./configure --add-module=/usr/local/src/ngx_kafka_module/ 14、make && make install 15、cd /usr/local/nginx 16、vi conf/nginx.conf http { kafka; kafka_broker_list slave3:9092 slave4:9092 slave5:9092 slave6:9092; server { listen 80; server_name slave6; #url-/kafka/track中的log数据将写到track的topic里 location = /kafka/track { kafka_topic track; } #url-/kafka/user中的log数据将写到user的topic里 location = /kafka/user { kafka_topic user; } } 17、启动zookeeper、kafka 18、kafka-topics.sh --create --zookeeper master:2181,slave1:2181,slave2:2181 --relication-factor 3 --partitions 3 --topic track //创建track的topic 19、kafka-topics.sh --create --zookeeper master:2181,slave1:2181,slave2:2181 --relication-factor 3 --partitions 3 --topic user//创建user的topic 20、echo "/user/local/lib" >> /etc/ld.so.conf //告诉Linux nginx加载so文件的位置 21、ldcondif 22、sbin/nginx -t //测试启动nginx 23、sbin/nginx //启动nginx