TNT

讨论区

本文主要介绍openldap的部署和go-ldap-admin的配置方法

1.部署Ldap

这里我们使用由VMware维护的项目:https://hub.docker.com/r/bitnami/openldap

1
2
3
4
# 安装
docker pull bitnami/openldap:2.6.8;
docker volume create vo-ldap;
docker run -dit --restart=always -p 389:1389 -p 636:1636 -v vo-ldap:/bitnami/openldap/ -e LDAP_ENABLE_TLS=no -e LDAP_ADMIN_USERNAME="admin" -e LDAP_ADMIN_PASSWORD="ldap_admin密码" -e LDAP_ROOT="dc=xxxx,dc=com" -e LDAP_ADMIN_DN="cn=admin,dc=xxxx,dc=com" -e LDAP_USERS=demo_user -e LDAP_PASSWORDS=demo_PWD3 -e LDAP_USER_DC=people -e LDAP_PASSWORD_HASH="{SSHA}" --name openldap bitnami/openldap:2.6.8;

注意,

  1. LDAP_USER_DC需要使用people,不要修改。原因是下面的go-ldap-admin默认使用people
  2. LDAP_PASSWORD_HASH使用SSHA,其实默认的也是SSHA,可以不必指定
  3. LDAP_ADMIN_USERNAME,指定admin,不要修改,原因是下面的go-ldap-admin可能无法兼容
  4. 这里没有配置TLS加密,考虑到ldap本身的弱安全性,且ldap通常配置在企业内网,这里就不提高复杂度了。
阅读全文 »

本文主要介绍openvpn的部署

1.部署

几个特性:

  1. 将几个步骤抽取到了一个shell中,
  2. 支持了ipv6。如果你的vpn服务器开通了ipv6,那么client就可以直接连接。
  3. 给用户分发同一证书,每个用户单独设置账号密码。这里的问题:不便于重置
阅读全文 »

本文主要介绍spring boot应用迁移k8s

1.概述

1.1.情况分析

最终目标是所有微服务迁移到k8s,常规公司的微服务从几十个到几百个不等,不同业务域的服务的重要性、吞吐量各不相同,历史架构也各有不同。
同时,生产环境的稳定性无比重要。
概括下来,几个特征:

  1. 微服务数量多
  2. 微服务框架各有不同
  3. 迁移周期长
  4. spring cloud和k8s技术栈不同

从工程和稳定性角度,得到要求:

  1. 多集群,集群间互通
  2. 容器和非容器互通
  3. 改动次数要少。不要折腾研发

通过如下方案,将能够做到:

  • 研发零感知,零改动
  • 可以按照应用、实例逐一切换;不再需要整体升级
  • 可以快速落地
阅读全文 »

本文主要介绍k8s的上手。k8s的易用度做的不够好,大版本的变化都会带来教程的失效。这篇文章结合我们过去的经验和实践重新进行了梳理。
同时,基于k8s的1.28版本部署。
参考如下:
k8s官网:https://kubernetes.io/docs/home/
极客时间:https://time.geekbang.org/column/article/39712
阿里云的镜像:https://developer.aliyun.com/mirror/kubernetes
另外,k8s的大量镜像需要从k8s、docker-huv、ghcr上拉取,你最好配置好自己的nexus,一劳永逸解决,配置方法参见nexus配置的一些实践

1.安装

参考阿里云的镜像:https://developer.aliyun.com/mirror/kubernetes
接下来的内容主要基于rocky linux9,基本和alma linux 9centos 9redhat 9一致,其他操作系统请参考阿里云的说明。

阅读全文 »

单台nginx实例能够承载的最大连接数

1. 基本参数

可以参见这篇文档的综述:Nginx的配置说明
在nginx配置文件里有几个参数:

  1. worker_processes,这个是最大进程数
  2. worker_connections,单进程最大处理的链接数,和服务器的cpu、内存强相关
  3. worker_rlimit_nofile

一般nginx能够承载的链接数=worker_processes*worker_connections

阅读全文 »

参考:How to Install KVM on RHEL 9 Step-by-Step

1. 安装基础

1
2
3
4
# 先更新
$ dnf update -y
# 再安装所有的必要包
$ dnf install virt-install virt-viewer libvirt virt-manager virt-top libguestfs-tools -y

自启动

1
2
3
4
# 启动virtd服务
$ systemctl start libvirtd
$ systemctl enable libvirtd
$ systemctl status libvirtd
阅读全文 »

本文介绍ansible常用命令,基于ad-hoc模式。
flutter官网:https://docs.flutter.dev/
flutter中国官网:https://flutter.cn/docs/

1. 安装概述

手动下载flutter压缩包->添加镜像->手动git解决版本识别问题

2.下载

可在官方网站手动下载stable的压缩包并解压
并将flutter添加到环境变量:

1
2
export FLUTTER_HOME=/你的flutter目录/
export PATH=${FLUTTER_HOME}/bin:${FLUTTER_HOME}bin/cache/dart-sdk/bin:$PATH
阅读全文 »

本文介绍ansible常用命令,基于ad-hoc模式。
Ansible官网:https://www.ansible.com/

1. 常规使用

不建议使用playbook。

1
2
3
4
5
6
7
8
9
#执行shell,my_all是一个服务器组,可以配置在/etc/ansible/hosts文件里
ansible my_all -m shell -a "curl -s icanhazip.com"
# 修改配置:
vim /etc/ansible/hosts
# 配置模板如下
[my_all]
192.168.1.1 ansible_user=tom ansible_port=22 ansible_ssh_extra_args='-i /root/.ssh/key1 -o StrictHostKeyChecking=no'
192.168.1.2 ansible_user=jerry ansible_port=22 ansible_ssh_extra_args='-i /root/.ssh/key2 -o StrictHostKeyChecking=no'
192.168.1.3 ansible_user=root ansible_port=22 ansible_ssh_extra_args='-i /root/.ssh/key3 -o StrictHostKeyChecking=no'

hosts配置文件里,除了ip,其他可以使用默认值。参数说明:

  1. ansible_user ssh的登录用户
  2. ansible_port ssh的端口,有些服务器不使用22端口,可以通过这个参数指定
  3. ansible_ssh_extra_args 是ssh自有参数,例如指定密钥,跳过host检查等。
阅读全文 »

python新的版本对ssl的版本有更高的要求,本文介绍如何解决(基于centos 7)
python官网:https://www.python.org/

1. 基本解释

python依赖ssl 1.1.1及以上版本,如果自行编译,会导致找不到openssl的依赖库

1.1.核心依赖

安装必要的依赖

1
2
yum groupinstall -y 'Development Tools';
yum install -y zlib-devel libffi-devel libuuid-devel readline-devel tk tk-devel ncurses-libs sqlite sqlite-devel bzip2-devel openssl-devel gdbm gdbm-devel libdbi-devel xz-devel python-backports-lzma mpdecimal expat libretls db4-devel libpcap-devel lzma xz perl-CPAN perl-IPC-Cmd gcc-c++ kernel-devel

你需要升级gcc,点击查看链接

1.2 使用yum自带的openssl

安装openssl

1
2
3
4
# 安装仓库自带的openssl
yum install openssl-devel -y
# 链接库包含这个目录
ldconfig /usr/local/lib64/

尝试安装python,如果成功就OK

1
2
3
4
5
# 清除原来可能已经make的缓存
make distclean
./configure --enable-optimizations --enable-shared --with-openssl=/usr/local/lib64
make
make altinstall
阅读全文 »

本文主要介绍linux和开发相关的配置。
必要核心库的初始化可以参见:rhel9初始化

1 GUI

解决中文异常的问题:汉字’门’不正常显示

2 pip

1
2
3
4
5
6
7
8
9
10
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --user
#替换为国内的源:
mkdir ~/.pip
tee ~/.pip/pip.conf <<-'EOF'
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
EOF
阅读全文 »

常见linux发行版的防火墙配置

1. firewall-cmd系列

适用RHEL系,包括CentOS、AlmaLinux等

1.1 直接开关或者封禁

是否关闭防火墙,取决于你的需求,如果关闭,参照如下:

1
2
3
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo systemctl mask --now firewalld
阅读全文 »

1. 安装基础

1
sudo apt install -y qemu-kvm virt-manager libvirt-clients virt-viewer libvirt-daemon-system bridge-utils virtinst

将你的用户添加到libvirt,方便rootless管理

1
2
3
# 切换到su用户
su -l
adduser 你的账户 libvirt
阅读全文 »

debian11初始化的一些配置
整体参考Linux相关服务器系统的环境初始化工作
源以及其他相关初始化脚本可以直接复用:

1
2
3
4
5
6
7
8
9
10
11
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

apt update
apt upgrade

安装基础包:

1
sudo apt install -y vim openssh-server net-tools sudo build-essential libssl-dev libtool libpng-dev libjpeg-dev libtiff-dev librsvg2-dev libopenjp2-7-dev libperl-dev libraqm-dev libzip-dev libdjvulibre-dev libopenexr-dev libpango1.0-dev libgvc6 libgraphviz-dev libflac-dev libsdl2-dev libzstd-dev libheif-dev libwebp-dev liblqr-1-0-dev libwmf-dev libgif-dev libxml2-dev libraw-dev swig python3-dev gcc manpages-dev git libsodium-dev software-properties-common libltdl-dev libnginx-mod-stream clang cmake pkg-config libbrotli-dev libgs-dev qemu-kvm virt-manager libvirt-clients virt-viewer libvirt-daemon-system bridge-utils virtinst  libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

这里使用的是阿里云的镜像,可以参见阿里云的说明:https://developer.aliyun.com/mirror/
也推荐使用华为云的镜像:https://mirrors.huaweicloud.com/

本文主要介绍如何部署腾讯的蓝鲸CMDB
蓝鲸CMDB官网:https://github.com/Tencent/bk-cmdb
蓝鲸CMDB部署官网:https://github.com/Tencent/bk-cmdb/blob/master/docs/wiki/container-support.md
蓝鲸CMDB镜像地址官网:https://console.cloud.tencent.com/tke2/registry/qcloud/default/detail/tag?rid=1&reponame=bk.io%252Fcmdb-standalone
建议你有自己的nexus,解决各种网络加速问题,参考:Docker部署Nexusnexus配置的一些实践

1.安装和部署

1.1 概述

1
2
3
docker pull ccr.ccs.tencentyun.com/bk.io/cmdb-standalone:v3.9.28
docker volume create vo-cmdb
docker run --name qa-cmdb3 -p 18083:8090 -e TZ=Asia/Shanghai -v /etc/localtime:/etc/localtime:ro --restart=always --privileged=true -dit ccr.ccs.tencentyun.com/bk.io/cmdb-standalone:v3.9.28
阅读全文 »

本文主要介绍如何部署mongodb。
Mongo官网:https://www.mongodb.com/docs/manual/
Mongo镜像说明官网:https://github.com/docker-library/mongo
Mongo镜像地址官网:https://hub.docker.com/_/mongo/?tab=tags
建议你有自己的nexus,解决各种网络加速问题,参考:Docker部署Nexusnexus配置的一些实践

1.安装和部署

1.1 概述

注意,账号最好不要带破折号,最好使用下划线

1
2
3
4
5
docker pull mongo:7.0.8-jammy
docker volume create vo-mongo-data
docker volume create vo-mongo-configdb

docker run --name qa-mongo --net=host -e TZ=Asia/Shanghai -v /etc/localtime:/etc/localtime:ro -v vo-mongo-data:/data/db -v vo-mongo-configdb:/data/configdb --restart=always --privileged=true -dit mongo:7.0.8-jammy mongod --replSet rs0
阅读全文 »

1.策略和模板

1.1 概述

通过ilm来配置策略,策略绑定索引模板,创建索引时,会根据正则,自动命中索引模板。

阅读全文 »

安装依赖

1
2
3
4
5
6
7
curl "http://mirrors.aliyun.com/repo/epel-7.repo" -o /etc/yum.repos.d/epel.repo;
yum clean all
yum makecache fast;
yum update -y;
yum upgrade -y;
yum groupinstall "Server with GUI" "GNOME Desktop" "Graphical Administration Tools" -y
yum install tigervnc-server tigervnc -y

启动服务

1
2
3
systemctl start xrdp.service
systemctl status xrdp.service
systemctl enable xrdp.service

设置密码:

1
vncpasswd

启动一个服务,1对应端口5901

1
vncserver :1