日常

JOBCHER BLOG
centos7.9 网络配置
centos7.9 网络配置 解决 centos 新机器网络不通的问题,CentOS7 默认不启动网卡的。CentOS 安装成功后,进行一下 ping 的操作,验证网络是否联通. 1ping 1.1.1.1 2ip addr 3# 查看ip网络名称 启用网卡 进入 /etc/sysconfig/network-scipts 文件夹下,找到 IP 网卡名称 1cd /etc/sysconfig/network-scipts 2vim ifcfg-eth0 启用 ONBOOT 1#vim ifcfg-eth0 2#修改 3ONBOOT=YES 4# esc 并:wq退出保存 重启机器 1shutdown -r now 结尾 centos 用的挺别扭,不考虑性能和性价比,我还是喜欢用 ubuntu……,简单的配置,初学者我建议还是先用 ubuntu,会少踩很多坑。当然了,用 x86 不然初学者用树莓派和 arm 设备,会碰到很多兼容性的问题。
JOBCHER BLOG
RocketMQ 安装和启动
RocketMQ 安装和部署 部署 RocketMQ 单机安装构建 安装 JDK 1.8.0 1yum install java-1.8.0-openjdk* 安装 Maven 1wget http://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz 2tar -zxvf apache-maven-3.8.4-bin.tar.gz 3mv -f apache-maven-3.8.4 /usr/local/ 4vim /etc/profile 5# 末尾添加 6export MAVEN_HOME=/usr/local/apache-maven-3.8.4 7export PATH=${PATH}:${MAVEN_HOME}/bin 8# 保存 9source /etc/profile 10# 查看maven是否正常 11mvn -v 快速部署 1#构建 DLedger 2git clone https://github.com/openmessaging/openmessaging-storage-dledger.git 3cd openmessaging-storage-dledger 4mvn clean install -DskipTests 5# 构建 RocketMQ 6git clone https://github.com/apache/rocketmq.git 7cd rocketmq 8git checkout -b store_with_dledger origin/store_with_dledger 9mvn -Prelease-all -DskipTests clean install -U 10# 部署 11cd rocketmq/distribution/target/apache-rocketmq 12sh bin/dledger/fast-try.
JOBCHER BLOG
安装 minIO Azure S3网关
安装 minIO 通过 docker 安装 1docker run -p 9000:9000 -p 41863:41863 -d --name azure-s3 \ 2 -e "MINIO_ACCESS_KEY=azure存储账户" \ 3 -e "MINIO_SECRET_KEY=azure存储密码" \ 4 minio/minio gateway azure --console-address ":41863" 通过 docker-compose 安装 1version: "3" 2services: 3 minio: 4 image: "minio/minio:RELEASE.2022-01-04T07-41-07Z.fips" 5 container_name: "minio" 6 restart: "always" 7 volumes: 8 - "/etc/localtime:/etc/localtime" 9 ports: 10 - "9000:9000" 11 - "9001:9001" 12 environment: 13 - "MINIO_ROOT_USER=azure存储账户" 14 - "MINIO_ROOT_PASSWORD=azure存储密码" 15 command: 16 - --console-address ":41863"
JOBCHER BLOG
logrotate 日志滚动的使用
logrotate 日志滚动的使用 logrotate 日志滚动切割工具,是 linux 默认安装的工具,配置文件位置: 1/etc/logrotate.conf 2/etc/logrotate.d/ 参数 以 nginx 配置为例 1/opt/log/nginx/*.log { 2 daily 3 missingok 4 rotate 14 5 errors "nb@nbtyfood.com" 6 compress 7 delaycompress 8 notifempty 9 create 0640 www-data adm 10 sharedscripts 11 prerotate 12 if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ 13 run-parts /etc/logrotate.d/httpd-prerotate; \ 14 fi \ 15 endscript 16 postrotate 17 invoke-rc.d nginx rotate >/dev/null 2>&1 18 endscript 19} 参数 作用 compress 压缩日志文件的所有非当前版本 daily,weekly,monthly 按指定计划轮换日志文件 delaycompress 压缩所有版本,除了当前和下一个最近的 endscript 标记 prerotate 或 postrotate 脚本的结束 errors “emailid” 给指定邮箱发送错误通知 missingok 如果日志文件丢失,不要显示错误 notifempty 如果日志文件为空,则不轮换日志文件 olddir “dir” 指定日志文件的旧版本放在 “dir” 中 postrotate 引入一个在日志被轮换后执行的脚本 prerotate 引入一个在日志被轮换前执行的脚本 rotate ’n' 在轮换方案中包含日志的 n 个版本 sharedscripts 对于整个日志组只运行一次脚本 size=‘logsize’ 在日志大小大于 logsize(例如 100K,4M)时轮换
JOBCHER BLOG
安装配置 Terraform
安装配置 Terraform 安装 macOS 苹果系统安装 1#安装 2brew tap hashicorp/tap 3brew install hashicorp/tap/terraform 4# 更新 5brew update 6brew upgrade hashicorp/tap/terraform 7#验证安装 8terraform -help windows 系统安装 1#安装 2choco install terraform 3#直接到这个url里下载64位系统 4https://www.terraform.io/downloads 5#验证安装 6terraform -help Linux 安装 1curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - 2sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" 3sudo apt-get update && sudo apt-get install terraform 4#验证安装 5terraform -help 1wget -O- https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo | sudo tee /etc/yum.repos.d/hashicorp.repo 2sudo yum install terraform -y terrafrom 控制 proxmox 虚拟机 来源:https://github.
JOBCHER BLOG
rsync 文件同步
rsync 文件同步 rsync 是一个常用的 Linux 应用程序,用于文件同步 安装 1# Debian or Ubuntu 2$ sudo apt-get install rsync 3 4# Red Hat 5$ sudo yum install rsync 6 7# Arch Linux 8$ sudo pacman -S rsync 基本用法 使用 rsync 命令时,可以作为 cp 和 mv 命令的替代方法,将源目录同步到目标目录。 -r 表示递归,即包含子目录。注意,-r 是必须的,否则 rsync 运行不会成功。source 目录表示源目录,destination 表示目标目录。 -a 参数可以替代-r,除了可以递归同步以外,还可以同步元信息(比如修改时间、权限等)。由于 rsync 默认使用文件大小和修改时间决定文件是否需要更新 1rsync -r source destination 远程同步 1rsync -av <源地址>/ <用户名>@<ip地址>:/<目标地址> 友情地址:mysql 迁移
JOBCHER BLOG
获取用户浏览器默认语言设置,自动判断跳转不同网站
自动判断跳转不同网站 根据用户目前的浏览器配置语言进行显示 供语言切换按钮,用户自定义选择不同的语言显示 根据识别用户的浏览器语言,自动判断并跳转到相应的语言网页,让你的网站更加灵动。 以下需要将代码放在 HTML 的内即可,然后自行制作多语言页面。 代码如下: 1<script type="text/javascript"> 2 //获取用户语言的顺序是 3 //1.获取本地缓存里的内容 4 //2.用户浏览器的语言设置 5 //如果上面2个都没有获取到,就直接使用'en'作为用户选择的语言 6 var language = 7 localStorage.getItem("locale") || 8 window.navigator.language.toLowerCase() || 9 "en"; 10 //把用户的语言写入缓存,供下次获取使用 11 localStorage.setItem("locale", language); 12 //判断用户的语言,跳转到不同的地方 13 if (language.indexOf("zh-") !== -1) { 14 window.location = "/zh-cn/index.html"; 15 } else if (language.indexOf("en") !== -1) { 16 window.location = "/en/index.html"; 17 } else { 18 //其它的都使用英文 19 window.location = "/en/index.html"; 20 } 21</script> 核心代码
JOBCHER BLOG
linux系统开启root权限
linux 系统开启 root 权限 修改 ssh 服务配置文件 1sudo su - 2sudo vim /etc/ssh/sshd_config 增加权限 在# Authentication: 下输入 1PermitRootLogin yes 更改 root 密码,重启服务 1sudo passwd root 2service sshd restart
JOBCHER BLOG
163企业邮箱设置教程
163 企业邮箱设置教程 请进入这个网站 https://qiye.163.com/help/l-11.html
JOBCHER BLOG
2021年第50周记
2021 年第 50 周周记 这周完成了以下任务 搭建 hugo 博客 使用 docker 封装了 blog 搭建 k3s 环境 计划: 学习 k8s 总结:没啥好总结,刚开始写周记,就随便写一点吧 欢迎关注我的博客www.jobcher.com
JOBCHER BLOG
自建服务器内网穿透
内网穿透 文章中使用的内网穿透前提是必须具有公网 IP 的云服务器,不符合条件的同学可以跳过了。 nps 内网穿透 nps 是一款轻量级、高性能、功能强大的内网穿透代理服务器。 在公网服务器上安装 nps sever 端 1 wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz 2 tar -zxvf linux_amd64_server.tar.gz 3 sudo ./nps install 4 sudo nps start 在控制端安装 npc client 端 1 wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz 2 tar -zxvf linux_amd64_client.tar.gz 3 sudo ./npc -server=ip:port -vkey=web界面中显示的密钥 4 sudo npc start npc 安装完成可以进入 web 页面穿透端口和域名 http://localhost:8080 frps 内网穿透 frps 相对于 nps 的劣势是有断流的风险 frps 相对于 nps 的优势是对于高流量的媒体服务能够提供更可靠的支持 安装 frps 1 wget https://code.aliyun.com/MvsCode/frps-onekey/raw/master/install-frps.sh -O ./install-frps.sh 2 chmod 700 .
JOBCHER BLOG
树莓派搭建k3s
树莓派安装 k3s 1.安装 k3s 控制节点 1 curl -sfL https://get.k3s.io | sh - 2 cat /var/lib/rancher/k3s/server/node-token 工作节点 1 curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh - 树莓派特别要注意一个坑,就是关于内存的问题这个之后再讲 1 k3s kubectl get nodes 2 #显示正确的节点表示完成 卸载 k3s 1 #server 节点 2 /usr/local/bin/k3s-uninstall.sh 3 #agent 节点 4 /usr/local/bin/k3s-agent-uninstall.sh 2.安装 dashboard k3s 面板 部署 Kubernetes 仪表盘 1 GITHUB_URL=https://github.com/kubernetes/dashboard/releases 2 VERSION_KUBE_DASHBOARD=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||') 3 sudo k3s kubectl create -f https://raw.