centos7.9使用dnf包管理器安装openresty

12 篇文章 1 订阅
前言

dnf是包管理器,起到很便捷的作用

配置安装
安装dnf包管理器
yum -y install epel-release
yum -y install dnf
yum -y update python*
yum -y install dnf-data dnf-plugins-core libdnf-devel libdnf python2-dnf-plugin-migrate dnf-automatic
dnf安装openresty
mkdir openresty && cd openresty
dnf -y install wget
wget 'https://openresty.org/package/centos/openresty.repo'
mv openresty.repo /etc/yum.repos.d/
dnf check-update
dnf -y install openresty
which openresty
file `which openresty`
openresty -V
systemctl start openresty
systemctl enable openresty
ps aux|grep nginx
curl 127.0.0.1
ln -snf /usr/local/openresty/nginx/sbin/nginx /usr/local/bin/nginx
dnf -y install openresty-resty
which resty
resty -e 'print("Hello Resty")'
dnf -y install openresty-doc
restydoc -s content_by_lua_file
dnf -y install openresty-opm
opm get pintsized/lua-resty-http
ls /usr/local/openresty/site/
resty -e 'require "resty.http"'
dnf -y install openresty-debug
which openresty-debug
file `which openresty-debug`
dnf list openresty-valgrind openresty-asan
dnf check-update
dnf upgrade 'openresty*'
dnf --disablerepo='*' --enablerepo="openresty" list available
streaming http
mkdir stream-resp && cd stream-resp
mkdir logs conf html
]# cat > conf/nginx.conf <<-EOF
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    server {
        listen 8080 reuseport;

        location = /test {
            default_type application/octet-stream;

            content_by_lua_block {
                for i = 1, 4 do
                    ngx.say("hello", i)
                    ngx.flush(true)
                    ngx.sleep(1)
                end
            }
        }

        location / {
            default_type text/html;
            root html;
        }
    }
}
EOF
]# tree .
.
├── conf
│   └── nginx.conf
├── html
└── logs

3 directories, 1 file
]# openresty -p $PWD
curl 'http://127.0.0.1:8080/test'
hello1
hello2
hello3
hello4
]# cat > html/index.html <<-EOF
<!doctype html>
<html>
<body>


<script>
(function () {
    let xhttp = new XMLHttpRequest();
    xhttp.open("GET", "/test", true);
    xhttp.send();

    let div = document.getElementById("out")

    let total_len = 0
    let check_resp = function () {
        let resp = xhttp.responseText
        let len = resp.length
        if (len > total_len) {
            let new_data = resp.substring(total_len, len)
            total_len = len;
            div.innerHTML += new_data + "<br/>"
        }
    };

    let timer = setInterval(check_resp, 1000);
    check_resp();

    xhttp.onreadystatechange = function () {
        if (this.readyState == 4) {
            check_resp();
            clearInterval(timer);
            div.innerHTML += "done<br/>";
        }
    };
})();
</script>
</body>
</html>
EOF
]# curl http://127.0.0.1:8080/index.html
结语

在 CentOS 8 上通过 dnf 安装 OpenResty
openresty 官网

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
感谢您的提问。以下是CentOS 7.9使用kubeadm安装Kubernetes 1.27.1的详细步骤: 1. 在所有节点上升级操作系统 ``` sudo yum upgrade -y ``` 2. 配置防火墙规则 按照Kubernetes官网的要求,关闭防火墙或者开放必需的端口。以下是关闭防火墙的方法: ``` sudo systemctl stop firewalld sudo systemctl disable firewalld ``` 3. 添加Kubernetes仓库 在所有节点上安装必需的工具: ``` sudo yum install -y yum-utils device-mapper-persistent-data lvm2 ``` 然后添加Kubernetes仓库: ``` sudo yum-config-manager --add-repo https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ ``` 4. 安装Docker和Kubernetes 在所有节点上安装Docker和Kubernetes: ``` sudo yum install -y kubelet kubeadm kubectl docker-ce docker-ce-cli containerd.io ``` 配置Docker Cgroup Driver为systemd: ``` sudo mkdir /etc/docker/ sudo tee /etc/docker/daemon.json <<-'EOF' { "exec-opts": ["native.cgroupdriver=systemd"], "registry-mirrors": ["https://mirror.ccs.tencentyun.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker ``` 5. 初始化Master节点 在Master节点上执行以下命令初始化: ``` sudo kubeadm init --pod-network-cidr=10.244.0.0/16 ``` 其中--pod-network-cidr参数是指定Pod网络的CIDR地址。 命令完成后,将提示您保存Kubernetes集群加入命令。 执行以下命令以配置kubectl: ``` mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config ``` 6. 安装Pod网络插件 在Master节点上执行以下命令以安装Flannel网络插件: ``` kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml ``` 7. 加入Node节点 将节点加入集群的命令已输出在初始化Master节点的命令中。 在每个Node节点上,执行相应的命令即可加入集群。 8. 验证集群状态 在Master节点上执行以下命令以验证集群状态: ``` kubectl get nodes ``` 如果所有节点都处于Ready状态,则表示集群已经正常工作。 以上就是CentOS 7.9使用kubeadm安装Kubernetes 1.27.1的详细步骤。希望对您有帮助!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值