安装nginx和ganglia

24 篇文章 4 订阅
22 篇文章 2 订阅

1、什么是nginx
这里写图片描述

2、在contos上安装nginx

1.
a)先安装G++
$>sudo yum install gcc

b)安装pcre
$>sudo yum install pcre pcre-devel openssl openssl-devel -y

c)手动通过源代码编译安装nginx
$>tar -xzvf nginx-1.6.3.tar.tz -C ~
$>cd ~/nginx-1.6.3
///soft/nginx-1.6.3代表你将要将nginx安装的目录
$>sudo ./configure --prefix=/soft/nginx-1.6.3 --without-http_gzip_module
$>sudo make && make install
$>sudo ldconfig    //加载配置库

2.配置环境变量
[/etc/profile]
...
export PATH=$PATH:/soft/nginx-1.6.3/sbin

3.启动nginx服务器
修改/soft/nginx-1.6.3目录下的nginx.conf中的用户权限,否则访问页面会出现403错误
改user nobody  为user root

$>cd /soft/nginx-1.6.3/sbin
$>sudo ./nginx                 //启动服务器

4.停止服务器
$>sudo ./nginx -s stop             //停止服务器
$>sudo ./nginx -s reload           //重新加载服务器
$>sudo ./nginx -s reopen           //重新打开服务器
$>sudo ./nginx -s quit             //退出服务器
$>sudo ./nginx -c xxx.conf         //指定配置文件
$>sudo ./nginx -t                  //配置文件检查

5.通过浏览器访问nginx网页,出现nginx欢迎页面。
http://s204:80/

3、windows下安装nginx

1.下载nginx-1.6.3-windows.zip
    解压即可(任何目录即可)。
2.启动nginx服务器
    nginx/nginx.exe
3.测试
    http://localhost:80/
4.停止nginx服务器
    cmd nginx/
    nginx.exe -s stop

4、负载均衡服务器配置(配置反向代理服务器,比如资源放在centos上,我们的反向代理服务器在windows上,配置的则就是windows上的Nginx)


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    #反向代理服务器
    upstream servers{
        server 172.25.11.200:80 weight=1;
        server 172.25.11.201:80 weight=4;
        server 172.25.11.202:80 weight=4;
        server 172.25.11.203:80 weight=4;
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            #开启反向代理,所有的其他链接都从这儿走,除了 index  index.html index.htm
            proxy_pass http://servers;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

4、ganglia监控软件

集群监控,不仅能够监控单个主机的资源情况,还可以对集群整个资源进行统计。

gmond           //在每个节点收集资源数据的。
gmetad          //接受每个节点发送资源数据
gweb            //webui,展示数据web程序,和gmetad通信。

安装ganglia

1.ganglia-gmond
        所有节点。
        $>sudo yum install -y ganglia-gmond

2.ganglia-gmetad
        s201
        $>sudo yum install -y ganglia-gmetad

3.ganglia-gweb
        [s201](主节点)
        a)安装依赖
            $>sudo yum install -y httpd php

        b)下载ganglia-web-3.5.12.tar.gz程序
            wget http://ncu.dl.sourceforge.net/project/ganglia/ganglia-web/3.5.12/ganglia-web-3.5.12.tar.gz

        c)tar开文件

        d)修改Makefile文件
            GDESTDIR = /var/www/html
            APACHE_USER =  apache

        e)启动服务
            [s201]
            $>sudo service httpd start 
            $>sudo service gmetad start 
            $>sudo service gmond start 

            [s202]
            $>sudo service gmond start 

        f)关闭selinux,否则刷不出来
            [201]
            sudo setenforce 0

        g)访问webui
            s201

yum方式安装如果出现没有可用源

1.换源(aliyan-->)(将/etc/yum.repos.d下的ali.repo改成ali.repo.bak)
        对于大数据生态圈的项目,cloudera的仓库比较全,而且没有bug.
        cloudera-cdh-5.repo --> /etc/yum.repo.d/下

2.清除缓存
        $>sudo yum cleanall

3.重建缓存
        $>sudo yum make cache 

4.继续通过yum安装
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值