首页
友情链接
这里是我的信息,欢迎你来看我
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
页面
友情链接
这里是我的信息,欢迎你来看我
搜索到
15
篇与
的结果
linux防SSH爆破神器,Denyhosts使用用法
2023年05月16日
12 阅读
0 评论
0 点赞
2023-05-16
SSH爆破和扫描历史悠久,服务器长期不更换密码或者密码过短非常容易成为黑客的肉鸡。于是 Denyhosts出来了,它根据系统日志中的sshd连接内容来判断是否为非法登录,并通过iptables进行drop。安装Denyhosts首先,需要安装系统依赖包,Denyhosts依赖于python2 python3 pip,下载源代码所需curl或wgetDebian系列系统apt install python3 python3-pip curl wgetRedhat系列系统yum install python3 python3-pip curl wget开始安装下载并解压cd /root/ wget https://jaist.dl.sourceforge.net/project/denyhosts/denyhosts/3.1.2-beta/DenyHosts-3.1.2.tar.gz tar -zxvf DenyHosts-3.1.2.tar.gz安装到系统服务并设置开机启动cd DenyHosts-3.1.2 python3 setup.py install vi /usr/lib/systemd/system/denyhosts.service #写入以下内容到服务文件 [Unit] Description=denyhosts ssh ban Before=denyhosts.service [Service] Type=forking ExecStartPre=/bin/rm -f /var/run/denyhosts.pid ExecStart=/usr/local/bin/denyhosts.py --daemon --config=/etc/denyhosts.conf PIDFile=/var/run/denyhosts.pid [Install] WantedBy=multi-user.target # systemctl daemon-reload systemctl enable denyhosts.service systemctl start denyhosts.service systemctl status denyhosts.service配置文件其配置文件在 /etc/denyhosts.conf 可以修改其中的参数,里面有登录尝试次数,拦截时间,邮件提醒等。已被拦截的ip在/etc/hosts.deny文件中。可以使用denyhosts.py --purgeip x.x.x.x 清理误封的IP地址更多使用文档可以参考github项目https://github.com/denyhosts/denyhosts完
2023-03-22
LINUX CPU跑分测试和压力测试工具
CPU跑分测试软件用到p7zip,也就是7z,一款用于Linux平台的高压缩比的存档格式 7z 的管理器,我们可以利用压缩软件进行测试CPU性能{dotted startColor="#ff6c6c" endColor="#1989fa"/}p7zip是7-Zip的命令行端口,适用于POSIX系统,包括Linux。CENTOS需要先安装epel,EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS和Scientific Linux.以下例子由REDHAT系列的CENTOS实现,DEBIAN系列同理,使用apt安装即可安装EPELyum -y install epel-release yum makecache安装7zyum -y install p7zip进行性能基准测试,全CPU线程7z b进行性能基准测试,单CPU线程7z b -mmt1测试结果如下[root@localhost ~]# 7z b -mmt1 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,64 bits,32 CPUs Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz (206D7),ASM,AES-NI) Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz (206D7) CPU Freq: 2754 2782 2716 2682 2703 2622 2732 2788 2781 RAM size: 31974 MB, # CPU hardware threads: 32 RAM usage: 435 MB, # Benchmark threads: 1 Compressing | Decompressing Dict Speed Usage R/U Rating | Speed Usage R/U Rating KiB/s % MIPS MIPS | KiB/s % MIPS MIPS 22: 3885 100 3765 3780 | 31953 100 2732 2728 23: 3579 100 3641 3647 | 31827 100 2749 2755 24: 3341 100 3594 3593 | 31059 100 2717 2727 25: 3215 100 3672 3671 | 31199 100 2774 2777 ---------------------------------- | ------------------------------ Avr: 100 3668 3673 | 100 2743 2747 Tot: 100 3206 3210 [root@localhost ~]# 7z b 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,64 bits,32 CPUs Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz (206D7),ASM,AES-NI) Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz (206D7) CPU Freq: 2780 2795 2751 2785 2790 2788 2776 2777 2785 RAM size: 31974 MB, # CPU hardware threads: 32 RAM usage: 7060 MB, # Benchmark threads: 32 Compressing | Decompressing Dict Speed Usage R/U Rating | Speed Usage R/U Rating KiB/s % MIPS MIPS | KiB/s % MIPS MIPS 22: 47338 2675 1721 46051 | 615336 3160 1660 52475 23: 43720 2670 1669 44546 | 604899 3153 1660 52343 24: 45131 2830 1714 48525 | 596549 3152 1661 52361 25: 43675 2882 1730 49867 | 592106 3137 1680 52694 ---------------------------------- | ------------------------------ Avr: 2764 1709 47247 | 3151 1665 52468 Tot: 2958 1687 49858CPU压力测试软件用到stress,这是一个用于CPU压力测试的软件以下例子由REDHAT系列的CENTOS实现,DEBIAN系列同理,使用apt安装即可可以直接通过yum安装,需先安装EPEL包yum -y install stress使用方法stress -c 线程数例如CPU为8核16线程stress -c 16即可开始跑压力测试,确认命令正常后,可以用nohup将其放到后台。完
2023年03月22日
12 阅读
0 评论
0 点赞
2023-01-05
nftables 防火墙小记
初始化配置iptables -F -t filter iptables -F -t nat iptables -F -t mangle iptables -F -t raw iptables -F -t security iptables -X添加默认表、簇、链nft add table ip filter nft add chain ip filter INPUT { type filter hook input priority 0 \; counter \; policy accept \; } nft add chain ip filter FORWARD { type filter hook forward priority 0 \; counter \; policy accept \; } nft add chain ip filter OUTPUT { type filter hook output priority 0 \; counter \; policy accept \; } 操作簇的方法ip ip6 inet arp bridgeinet同时代表V4和V6 注意: inet 不能用于 nat 类型的链,只能用于 filter 类型的链。nft 方法 表操作 簇 表名nft list tables [<family>]nft list table [<family>] <name> [-n] [-a]nft (add | delete | flush) table [<family>] <name>例如添加一个hy的表,使用IPV4nft list tables nft add table ip hy nft delete table ip hy清空一个表中的所有规则nft flush table ip hynft 方法 chain 簇 表 链名增删查,hy表中的p链nft add chain ip hy p nft delete chain ip hy pnft list chain ip hy p动作钩子prerouting:刚到达并未被 nftables 的其他部分所路由或处理的数据包。redirect: NAT钩子masquerade: 源地址转换伪装input:已经被接收并且已经经过 prerouting 钩子的传入数据包。forward:如果数据报将被发送到另一个设备,它将会通过 forward 钩子。output:从本地传出的数据包。postrouting:仅仅在离开系统之前,可以对数据包进行进一步处理。nft 方法 规则 表 链 动作(需要先创建钩子)如下创建一个nat动作,将50000-6000的UDP端口数据包重定向到50000nft 'add chain nat prerouting { type nat hook prerouting priority -100; }' nft add rule nat prerouting redirect nft add rule nat prerouting udp dport {50000-60000} redirect to 50000替换规则列出规则句柄nft -a list ruleset规则替换为句柄 2nft replace rule hy p handle 2 counter一些示例计数动作counter 接收数据包并计数 filter 表 output 链nft add rule filter output counter accept丢弃所有进入数据nft add rule filter output drop拒绝流量 filter 表 input 链 ct指示排除来源自身流量 所有新连接拒绝nft add rule filter input ct state new reject拒绝ICMP 并指定原因 filter 表 input 链nft add rule filter input reject with icmp type host-unreachable接口指定端口流量到目标地址 nat 表 prerouting 链nft 'add chain nat prerouting { type nat hook prerouting priority -100; }' nft add rule nat prerouting iif eth0 tcp dport { 80, 443 } dnat to 192.168.1.120源地址伪装为输出接口地址 nat 表 postrouting 链nft add rule nat postrouting masquerade进入端口流量重定向 nat 表 prerouting 链 tcp 22到2222端口nft 'add chain nat prerouting { type nat hook prerouting priority -100; }' nft add rule nat prerouting tcp dport 22 redirect to 2222输出端口流量重定向 nat 表 output 链nft add rule nat output tcp dport 853 redirect to 10053链跳转与转到处理,filter 表 tcp-chain 链nft add chain ip filter inputnft add chain ip filter tcp-chainnft add chain ip filter other-chaininput链内添加tcp跳转到tcp-chain链处理---处理完返回执行其他规则nft add rule ip filter input ip protocol tcp jump tcp-chainnft add rule ip filter tcp-chain counterinput链内添加匹配规则 转到other-chain链处理---处理完不返回nft add rule ip filter input ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 goto other-chain镜像流量 mangle 表 prerouting 链 dup镜像方法 从设备eth1流向目标地址nft add rule mangle prerouting dup to 172.20.0.2 device eth1镜像流量 mangle 表 prerouting 链 dup镜像方法 从原地址192.168.0.1 发送到不同地址nft add rule mangle prerouting dup to ip saddr map { 192.168.0.1 : 172.20.0.2, 192.168.0.1 : 172.20.0.3 }查看设置规则nft list ruleset备份规则nft list ruleset > /root/nftables.conf恢复规则nft -f /root/nftables.confNFTables文档 https://wiki.nftables.org/wiki-nftables/index.php/Performing_Network_Address_Translation_(NAT)完
2023年01月05日
155 阅读
0 评论
0 点赞
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-11-18
FRP内网穿透的原理及一键安装管理脚本
原理解析FRP是一款用于内网穿透的软件,架设在公网环境中,其原理就是通过中转的公网网络端口进行内网端口的映射,使内网服务可以通过公网进行访问例如内网 192.168.3.100:80 HTTP服务公网服务器 119.28.29.119在公网服务器上安装FRP服务端,在内网机器上运行FRP客户端192.168.3.100:80 >>> 119.28.29.119:80 [服务端端口随意,但唯一]这样通过访问 119.28.29.119:80 实际上就是访问 192.168.3.100:80不仅支持http,还可以支持TCP,UDP,socks管道,简单文件服务器,TLS本地证书指定,P2P等任意协议。FRP是开源的而且作者目前仍在更新中,github开源地址 https://github.com/fatedier/frp{dotted startColor="#ff6c6c" endColor="#1989fa"/}搭建实战原版frp服务端有二进制版本和源代码版本,我们这次通过一键脚本进行安装带有web面板的frp服务端,脚本来源于github用户https://github.com/MvsCode/frps-onekey由于国内网络环境下载不正常,我也会放一个修改后的脚本在本页面提供下载 install-frps.sh服务端搭建操作通过ssh连接您的服务器,操作系统支持debian系列和redhat系列,也就是centos与ubuntu都支持。将下载的脚本放入您创建的文件夹,log日志会保存在同文件夹下,所以请不要在根目录进行操作。下面是一些命令。#直接通过wget 或者 curl下载,wget某些系列没有自带安装,所以先安装wget #centos为例 yum install wget -y wget https://raw.githubusercontent.com/MvsCode/frps-onekey/master/install-frps.sh chmod 0777 install-frps.sh bash install-frps.sh install 以上命令执行正常应该进入了脚本界面 一些关键信息:bind_port FRP连接端口vhost_http_port HTTP的端口vhost_https_port HTTPS的端口dashboard_port FRP面板端口默认admin为面板账号dashboard_pwd 面板密码,默认自动生成token FRP鉴权密码,默认自动生成subdomain_host 子域名host,默认本机max_pool_count 最大连接数目log_level 日志等级log_max_days 日志保存天数log_file 可以选择开关日志记录,默认开tcp_mux TCP的连接复用,可以提高性能,建议默认开kcp support KCP的支持,默认开选择完上述信息,进可以回车继续,会自动连接到对应选择的地址进行下载FRP服务端二进制主程序,如果失败或者长时间没有反应,大概率本地网络问题导致,多次重试或者更换下载地址尝试。 脚本执行完毕显示如上界面代表安装已成功,此后可以通过简易命令进行控制 首次安装完 使用frps start 启动FRP服务端 frps status manage : frps {start|stop|restart|status|config|version} Example: start: frps start stop: frps stop restart: frps restart 如需卸载,通过执行脚本文件bash install-frps.sh uninstall 可以通过服务器公网:dashboard_port,进入web面板查看,用户名和密码为您自行配置的,如遗忘可通过frps config 进行查看。客户端连接通过 https://github.com/fatedier/frp/releases下载对应系统的客户端程序windows为例 https://github.com/fatedier/frp/releases/download/v0.45.0/frp_0.45.0_windows_amd64.zip下载后解压,文件夹内即可看到 frpc.exe开始编写配置文件,在frpc.exe同文件夹内创建文本文件,修改名称为frpc.ini,后缀记得为.ini填入FRP服务器信息和你需要进行映射的服务,然后打开cmd或者powershell执行frpc.exe,如图所示,提示 start proxy success,代表FRP已经映射成功。关键信息[common] #这里是默认的不可修改 server_addr = FRP服务端地址 server_port = FRP服务端的Bind port token = FRP服务端token [web] #这里是你的服务名,可自由填写,不可重复 type = http #服务类型,有tcp, udp, http, https, stcp, sudp, xtcp, tcpmux local_port = 80 #你要映射的本地端口,对等映射,公网地址同端口,使用 服务器IP:80 访问 本地IP:80端口 custom_domains = blog.noccd.cn #访问映射的host名 [ssh] type = tcp local_ip = 127.0.0.1 local_port = 22 remote_port = 6000 #通过remote_port 进行非对等映射,使用 服务器IP:6000 访问 本地IP:22端口复制以上配置需要去掉注释信息,否则无法运行更多配置信息查看官方文档 https://gofrp.org/docs/reference/proxy/完
2022年11月18日
170 阅读
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-10-11
MYSQL-MariaDb数据库的主从同步配置方法
使用数据库 MYSQL或者MariaDb1. 操作系统 Centos Ubantu Debian等,配置文件位置可能不同。 2. 配置文件位置 可能为 /etc/my.cnf /etc/my.cnf.d/server.cnf/etc/mysql/mariadb.conf.d/50-server.cnf主服务器配置示例使用 10.0.0.1 作为主服务器安装mariadb-server 10.3版本修改/etc/my.cnf 配置文件添加如下[mysqld] server-id=1 #数据库唯一ID,主从的标识号绝对不能重复。 log-bin=mysql-bin #开启bin-log,并指定文件目录和文件名前缀 binlog-do-db=typecho #需要同步liting数据库。如果是多个同步库,就以此格式另写几行即可。如果不指明对某个具体库同步,就去掉此行,表示同步所有库(除了ignore忽略的库)。 binlog-ignore-db=mysql #不同步mysql系统数据库。如果是多个不同步库,就以此格式另写几行;也可以在一行,中间逗号隔开。 sync_binlog = 1 #确保binlog日志写入后与硬盘同步 binlog_checksum = none #跳过现有的采用checksum的事件,mysql5.6.5以后的版本中binlog_checksum=crc32,而低版本都是binlog_checksum=none binlog_format = mixed #bin-log日志文件格式,设置为MIXED可以防止主键重复。同时将下行注释掉#bind-address=127.0.0.1进入数据库,配置远程访问,查看主服务器master状态(注意File与Position项,从服务器需要这两项参数)mysql -u root -p grant replication slave,replication client on *.* to root@'%' identified by"123123123"; flush privileges; show master status \G主服务器master状态输出File: mysql-bin.000001 Position: 4994 Binlog_Do_DB: row in set (0.00 sec)**导出需要同步的数据库表,可以备份导出,也可以使用Navicat 等工具进行一次数据同步。**配置好网络,确认能和主服务器通信,并安装好数据库。修改/etc/my.cnf 配置文件添加如下[mysqld] server-id=2 #设置从服务器id,必须于主服务器不同 log-bin=mysql-bin #启动MySQ二进制日志系统 replicate-do-db=typecho #需要同步的数据库名。如果不指明同步哪些库,就去掉这行,表示所有库的同步(除了ignore忽略的库)。 replicate-ignore-db=mysql #不同步test数据库 slave-skip-errors = all #跳过所有的错误,继续执行复制操作进入数据库,导入从主服务器备份的表,确保数据与当前主服务器一致。配置主从同步指令mysql -u root -p #连接数据库 stop slave; #执行同步前,要先关闭slave change master to master_host='10.0.0.1',master_user='root',master_password='123123123',master_log_file='mysql-bin.000001',master_log_pos=4994; start slave; #启动同步功能注意:master_log_file 和 master_log_pos 设置为主服务器查看到的File与Position项。查看同步状态show slave status \G如果有如下显示:Slave_IO_Running: Yes Slave_SQL_Running: Yes则同步配置成功,现在修改主服务器上数据,从服务器数据也会自动同步。主主同步配置mysql中有自增长字段,在做数据库的主主同步时需要设置自增长的两个相关配置:auto_increment_offset和auto_increment_increment。auto_increment_offset表示自增长字段从那个数开始,他的取值范围是1 .. 65535auto_increment_increment表示自增长字段每次递增的量,其默认值是1,取值范围是1 .. 65535在主主同步配置时,需要将两台服务器的auto_increment_increment增长量都配置为2,而要把auto_increment_offset分别配置为1和2.这样才可以避免两台服务器同时做更新时自增长字段的值之间发生冲突。主数据库服务器1 my.cnf 配置server-id = 1 log-bin = mysql-bin binlog-ignore-db = mysql,information_schema sync_binlog = 1 binlog_checksum = none binlog_format = mixed auto-increment-increment = 2 auto-increment-offset = 1 slave-skip-errors = all主数据库服务器2 my.cnf 配置server-id = 2 log-bin = mysql-bin binlog-ignore-db = mysql,information_schema sync_binlog = 1 binlog_checksum = none binlog_format = mixed auto-increment-increment = 2 auto-increment-offset = 2 slave-skip-errors = all数据库2也需要开放外部访问权限,然后先在数据库2配置对数据库1的同步,再配置数据库1对数据库2的同步slave stop; change master to master_host='10.0.0.1',master_user='root',master_password='123123123',master_log_file='master-bin.000001',master_log_pos=160; start slave; show slave status \Gslave stop; change master to master_host='10.0.0.2',master_user='root',master_password='123123123',master_log_file='master-bin.000001',master_log_pos=271; start slave; show slave status \G完
2021年10月11日
237 阅读
0 评论
2 点赞
2021-09-01
linux 意外断电重启导致的XFS文件系统崩溃修复
服务器因为断电重启之后,启动异常,报错:Please umount the filesystem and rectify the problem(s)修复步骤:1. 输入命令:ls -l /dev/mapper查看是否存在 dm-0 dm-1文件如存在-进行下一步,如不存在-本方法不适用2. 输入命令:xfs_repair -L /dev/dm-0(清空日志,会丢失部分文件)再执行xfs_repair /dev/sda1再执行xfs_check /dev/sdd检查文件系统是否修复成功执行重启 init 6 或者 reboot等待重启完看是否正常进入系统完
2021年09月01日
253 阅读
0 评论
3 点赞
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 点赞
1
2