首页
友情链接
这里是我的信息,欢迎你来看我
Search
1
Kubernetes通过kubeadm安装方法
15,551 阅读
2
linux 意外断电重启导致的XFS文件系统崩溃修复
253 阅读
3
MYSQL-MariaDb数据库的主从同步配置方法
237 阅读
4
tengine编译安装结合lua实现WAF防火墙
214 阅读
5
Kubernetes安装Prometheus+Grafana
200 阅读
linux
Centos
Mysql
运维
web
K8S
FRP
nginx
登录
Search
标签搜索
linux
运维
yum
centos6
自动化
kickstart
镜像制作
密码
单用户
ubuntu
debian
K8S
docker
XFS
文件系统修复
Mysql
数据库
MariaDb
同步
端口映射
ClassHuang
累计撰写
15
篇文章
累计收到
0
条评论
首页
栏目
linux
Centos
Mysql
运维
web
K8S
FRP
nginx
页面
友情链接
这里是我的信息,欢迎你来看我
搜索到
7
篇与
的结果
2022-12-13
Linux-Centos更新系统内核版本
内核Linux每个一段时间会发布一个新的内核维护版本,新的版本会带来一些新的特性,有性能的优化,安全更新,新的功能等等,请各位确认好自己的业务需要进行更新,如生产环境中,已经保持稳定没有问题的不建议直接更新。 {dotted startColor="#ff6c6c" endColor="#1989fa"/}更新通常的方法是编译内核进行安装,需要对linux有一定的知识和了解,比较繁杂。更方便的方法以Centos为例,我们可以通过yum软件包管理进行内核的更新。具体操作命令示例更新yum源仓库yum -y update启用 ELRepo 仓库ELRepo 仓库是基于社区的用于企业级 Linux 仓库,提供对 RedHat Enterprise (RHEL) 和 其他基于 RHEL的 Linux 发行版(CentOS、Scientific、Fedora 等)的支持。ELRepo 聚焦于和硬件相关的软件包,包括文件系统驱动、显卡驱动、网络驱动、声卡驱动和摄像头驱动等。导入ELRepo仓库的公共密钥rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org安装ELRepo仓库的yum源Centos7#Centos7 yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpmCentos8#Centos8 yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm查看ELRepo提供的内核版本yum --disablerepo="*" --enablerepo="elrepo-kernel" list availablekernel-lt:表示longterm,即长期支持的内核;当前为5.4kernel-ml:表示mainline,即当前主线的内核;当前为6.1安装最新版本内核yum --enablerepo=elrepo-kernel install kernel-ml查看系统可用内核,并设置启动项awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg可能会有如下显示0 : CentOS Linux (6.1.0-1.el7.elrepo.x86_64) 7 (Core) 1 : CentOS Linux (3.10.0-1160.71.1.el7.x86_64) 7 (Core) 2 : CentOS Linux (3.10.0-1160.66.1.el7.x86_64) 7 (Core) 3 : CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core) 4 : CentOS Linux (0-rescue-0b6c236045fa4fbbaf5a2bc97b8c3bc4) 7 (Core)指定开机启动内核版本grub2-set-default 0生成 grub 配置文件grub2-mkconfig -o /boot/grub2/grub.cfg重启系统reboot验证是否成功uname -a如果显示内核版本为6.1的即为成功。卸载旧内核yum remove $(rpm -qa | grep kernel | grep -v $(uname -r))完
2022年12月13日
194 阅读
0 评论
0 点赞
2022-06-16
tengine编译安装结合lua实现WAF防火墙
事前准备操作系统以Centos为例,安装依赖软件包yum install make gcc c++ wget pcre pcre-devel perl openssl openssl-devel tengine下载地址 http://tengine.taobao.org/cd /root/ wget http://tengine.taobao.org/download/tengine-2.3.3.tar.gz tar zxvf tengine-2.3.3.tar.gzLuaJIT下载地址 http://luajit.org/cd /root/ wget https://luajit.org/download/LuaJIT-2.0.5.tar.gz tar zxvf LuaJIT-2.0.5.tar.gz开始编译进入各自的目录,进行编译,先编译luajit,再编译tengine编译luajitcd /root/LuaJIT-2.0.5 make && make install PREFIX=/usr/local/luajit编译tengine并启动cd /root/tengine-2.3.3/ ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=root --group=root --with-openssl-opt=enable-ec_nistp_64_gcc_128 --with-pcre --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --add-module=./modules/ngx_http_upstream_vnswrr_module --add-module=./modules/ngx_http_proxy_connect_module --with-http_lua_module --with-luajit-lib=/usr/local/luajit/lib/ --with-luajit-inc=/usr/local/luajit/include/luajit-2.0/ make && make install mkdir /var/log/nginx mkdir /etc/nginx/conf nginx nginx -V下载开源WAF-lua配置github开源项目 https://github.com/loveshell/ngx_lua_wafwget https://github.com/loveshell/ngx_lua_waf/archive/refs/tags/v0.7.2.tar.gz tar -zxvf v0.7.2.tar.gz mv v0.7.2/* /etc/nginx/conf/waf/ #具体文件路径视个人情况变动修改/etc/nginx/conf/waf/config.lua 配置文件中的路径,规则路径和log路径**RulePath = "/opt/nginx/conf/waf/wafconf/"logdir = "/opt/nginx/logs/waf"**修改为自己需要的位置**RulePath = "/etc/nginx/conf/waf/wafconf/"logdir = "/var/log/nginx/waf"**创建一个log目录mkdir /var/log/nginx/waf chmod 0777 /var/log/nginx/waf chowm root /var/log/nginx/waf chgrp root /var/log/nginx/waf #文件夹所有者权限与nginx权限相同修改 tengine 的nginx.conf使luawaf生效在 nginx.conf 的 http 段添加lua_package_path "/etc/nginx/conf/waf/?.lua"; lua_shared_dict limit 10m; init_by_lua_file /etc/nginx/conf/waf/init.lua; access_by_lua_file /etc/nginx/conf/waf/waf.lua;测试配置和重载nginxnginx -t #如果无报错 nginx -s reloadLUAWAF测试当你上面操作都顺利完成,我们接下来可以添加虚拟主机,启动测试。修改nginx.conf文件 在http段添加一句include /etc/nginx/sites-enabled/*.conf;然后创建这个目录mkdir /etc/nginx/sites-enabled/编写测试文件vi /etc/nginx/sites-enabled/test.conf server { listen 80 ; listen [::]:80 ; server_name domain.com; location /hello { default_type 'text/plain'; content_by_lua 'ngx.say("hello")'; } } #测试并重载nginx nginx -t nginx -s reload然后 访问http://IP/hello?id=../etc/passwd查看是否被waf正常拦截,拦截则成功,否则查看waf配置文件或者日志信息。完
2022年06月16日
214 阅读
0 评论
4 点赞
2021-05-29
Kubernetes安装Prometheus+Grafana
克隆项目git clone https://hub.fastgit.org/LBters/k8s-prometheus-grafana.git安装node-exporterkubectl apply -f node-exporter.yaml安装prometheus组件kubectl apply -f k8s-prometheus-grafana/prometheus/rbac-setup.yaml kubectl apply -f k8s-prometheus-grafana/prometheus/configmap.yaml kubectl apply -f k8s-prometheus-grafana/prometheus/prometheus.deploy.yml kubectl apply -f k8s-prometheus-grafana/prometheus/prometheus.svc.yml安装 grafana 组件kubectl apply -f k8s-prometheus-grafana/grafana/grafana-deploy.yaml kubectl apply -f k8s-prometheus-grafana/grafana/grafana-svc.yaml kubectl apply -f k8s-prometheus-grafana/grafana/grafana-ing.yaml查看组件服务的映射端口kubectl get svc -n kube-system访问grafana并添加prometheus数据源IP+prometheus端口选择Dashboards import导入模板输入url模板代码315 确定导入可以看到prometheus监视列表已经出来了
2021年05月29日
200 阅读
0 评论
0 点赞
2021-05-29
Kubernetes 部署 Dashboard
部署直接使用github官方仓库安装`kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml`配置修改为通过 NodePort 访问kubectl -n kubernetes-dashboard edit service kubernetes-dashboard在 ports下面添加nodePort: 32576,将 clusterIp改为NodePort如下spec: clusterIP: 192.168.244.139 externalTrafficPolicy: Cluster ports: - nodePort: 32576 port: 443 protocol: TCP targetPort: 8443 selector: k8s-app: kubernetes-dashboard sessionAffinity: None type: NodePort 此时可以通过节点 IP 和端口https://ip:32576/ 访问到 Dashboard(Chrome 可能会提示证书错误)解决方法:创建chrome桌面快捷方式,然后到桌面:右键chrome–>属性–>在目标后面添加如下:--disable-infobars --ignore-certificate-errors示例:"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-infobars --ignore-certificate-errors创建 ServiceAccountvim admin-role.yaml输入以下内容kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: admin annotations: rbac.authorization.kubernetes.io/autoupdate: "true" roleRef: kind: ClusterRole name: cluster-admin apiGroup: rbac.authorization.k8s.io subjects: - kind: ServiceAccount name: admin namespace: kubernetes-dashboard --- apiVersion: v1 kind: ServiceAccount metadata: name: admin namespace: kubernetes-dashboard labels: kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile保存后再执行kubectl apply -f admin-role.yaml获取 Tokenkubectl -n kubernetes-dashboard get secret|grep admin-token根据输出类似于admin-token-jx84x 再执行kubectl -n kubernetes-dashboard describe secret admin-token-jx84x会输出token信息,在浏览器Dashboard使用token登录即可
2021年05月29日
197 阅读
0 评论
0 点赞
2021-05-29
Kubernetes通过kubeadm安装方法
前期准备工作所有机器安装必要软件包,并进行时间同步,防止后续出现问题yum -y install wget curl ntpdate yum-utils device-mapper-persistent-data lvm2 ntpdate ntp1.aliyun.com clock -w一些系统调整(所有机器执行)systemctl disable firewalld systemctl stop firewalld setenforce 0 sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/sysconfig/selinux sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config swapoff -a sed -i 's/.*swap.*/#&/' /etc/fstab cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl --system进行docker的安装(所有机器执行)# 配置阿里云的docker源 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 指定安装这个版本的docker-ce yum install -y docker-ce-18.09.9-3.el7 # 启动docker systemctl enable docker && systemctl start docker安装kubeadm kubelet kubectl(所有机器执行)# 执行配置k8s阿里云源 cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF # 安装kubeadm、kubectl、kubelet yum install -y kubectl-1.16.0-0 kubeadm-1.16.0-0 kubelet-1.16.0-0 # 启动kubelet服务 systemctl enable kubelet && systemctl start kubelet初始化master端配置,在master机器上# master 本机IP为192.168.244.139 pod网络IP段为10.244.0.0/16,并指定安装版本v1.16.0 kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.16.0 --apiserver-advertise-address 192.168.244.139 --pod-network-cidr=10.244.0.0/16 --token-ttl 0初始化完成后,会提示执行mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config并记录最后输出的一段代码,用于node节点加入master类似于`kubeadm join 192.168.244.139:6443 --token aew90y.q89ywcwjgjcm8b2t \ --discovery-token-ca-cert-hash sha256:181eb0e51d939200c768c43e230e7e4603c8b2c2c3a5b299de4a6df6b7d6226a`根据以上输出的join代码在node节点端执行完成后在master端 可进行查看所有节点状态`kubectl get nodes`此时会显示notready,需要在服务器执行wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml kubectl apply -f kube-flannel.yml echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile source ~/.bash_profile # 以下替换node节点IP scp /etc/kubernetes/admin.conf root@node节点IP:/etc/kubernetes/admin.conf # 然后现在再次查看,已经变为ready了 kubectl get nodes到这里Kube已经安装完成了,接下里可以正常安装一些组件或者分发docker镜像了
2021年05月29日
15,551 阅读
0 评论
0 点赞
2021-03-18
Centos自动化kickstart定制化安装
之前在弄centos自动化的时候遇到一点坑,参考了很多网上的资料在这里整理一下,特别是遇到的一些问题下面是定制化镜像制作方法一台安装了CentOS的服务器,挂载原生镜像CD盘然后cd /root/安装工具环境准备yum -y install createrepo yum -y install genisoimage挂载镜像到mntmount -o loop /dev/sr0 /mnt拷贝原生OS镜像文件到root目录cp -a /mnt/ /root/newcentosX.X/制作Package、repodata(重要)cp /root/newcentosX.X/repodata/*-comps.xml /root/repodata/compsX.X.xml rm -rf /root/newcentosX.X/repodate/ createrepo -g /root/repodata/compsX.X.xml /root/newcentosX.X/制作ks定制化文件-centos6和centos7的不一样(关键)vi /root/newcentosX.X/KS.TXT修改isolinux.cfg 启动文件vi /root/newcentosX.X/isolinux/isolinux.cfg主要在 linux启动项加入append initrd=initrd.img ks=cdrom:/KS.TXT quiet net.ifnames=0 biosdevname=0修改权限chmod 0777 /root/newcentosX.X/repodate/*系统封装,切换到镜像目录,执行命令,不要漏掉后面的.cd /root/newcentosX.X/ mkisofs -r -T -J -V "CentOS 7 x86_64" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -o /root/centos7.iso .root目录下面生成的centos7.iso 就是封装后的文件了一些问题1. 如果系统制作完在安装时候有yum报错或者奇怪的anaconda错误,就是制作Package、repodata没有正确或者版本有误。 2. 如果启动时候引导不了安装盘可能是isolinux.cfg启动文件配置没有正确另外附上KS文件和isolinux启动文件的参考文件isolinux6.cfgisolinux7.cfgKS6.TXTKS7.TXTKS8.TXT
2021年03月18日
135 阅读
0 评论
0 点赞
2021-03-17
修复CENTOS不受官方支持的yum源
以下内容引用清华大学开源镜像站CentOS Vault 软件仓库镜像使用帮助该文件夹提供较早版本的 CentOS,例如 CentOS 6;同时提供当前 CentOS 大版本的历史小版本的归档; 还提供 CentOS 各个版本的源代码和调试符号。需要确定您所需要的小版本,如无特殊需要则使用该大版本的最后一个小版本,比如 6.10,5.11,我们将其标记为 $minorver,需要您在之后的命令中替换。CentOS 8 之前minorver=6.10 sed -e "s|^mirrorlist=|#mirrorlist=|g" \ -e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/$minorver|g" \ -i.bak \ /etc/yum.repos.d/CentOS-*.repoCentOS 8 之后minorver=8.5.2111 sed -e "s|^mirrorlist=|#mirrorlist=|g" \ -e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/$minorver|g" \ -i.bak \ /etc/yum.repos.d/CentOS-*.repo注意其中的*通配符,如果只需要替换一些文件中的源,请自行增删。注意,如果需要启用其中一些 repo,需要将其中的 enabled=0 改为 enabled=1。最后,更新软件包缓存yum makecache完
2021年03月17日
173 阅读
0 评论
4 点赞