首页 文章 精选 留言 我的

精选列表

搜索[初始化],共10006篇文章
优秀的个人博客,低调大师

K8S系统环境初始化

/etc/hosts [root@localhost ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 172.16.0.192 master1 172.16.0.193 node1 关闭防火墙 \selinux\swap\dnsmasq systemctl disable --now firewalld systemctl disable --now dnsmasq systemctl disable --now NetworkManager setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config swapoff -a sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab 时间同步 rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm yum install ntpdate -y ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo 'Asia/Shanghai' >/etc/timezone ntpdate time2.aliyun.com # 加入到crontab */5 * * * * /usr/sbin/ntpdate time2.aliyun.com limit配置 ulimit -SHn 65535 vim /etc/security/limits.conf # 末尾添加如下内容 * soft nofile 655360 * hard nofile 131072 * soft nproc 655350 * hard nproc 655350 * soft memlock unlimited * hard memlock unlimited yum源修改 curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 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 sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo 必备工具安装 yum install wget jq psmisc vim net-tools telnet yum-utils device-mapper-persistent-data lvm2 git -y 升级节点系统并重启 yum update -y --exclude=kernel* && reboot 内核配置 最新内核地址 https://elrepo.org/linux 下载最新内核 cd /root && wget -c https://elrepo.org/linux/kernel/el7/x86_64/RPMS/kernel-ml-5.12.2-1.el7.elrepo.x86_64.rpm && wget -c https://elrepo.org/linux/kernel/el7/x86_64/RPMS/kernel-ml-devel-5.12.2-1.el7.elrepo.x86_64.rpm 安装配置 cd root && yum localinstall -y kernel-ml* grub2-set-default 0 && grub2-mkconfig -o /etc/grub2.cfg grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)" 安装ipvsadm yum install ipvsadm ipset sysstat conntrack libseccomp -y modprobe -- ip_vs modprobe -- ip_vs_rr modprobe -- ip_vs_wrr modprobe -- ip_vs_sh modprobe -- nf_conntrack vim /etc/modules-load.d/ipvs.conf # 加入以下内容 ip_vs ip_vs_lc ip_vs_wlc ip_vs_rr ip_vs_wrr ip_vs_lblc ip_vs_lblcr ip_vs_dh ip_vs_sh ip_vs_fo ip_vs_nq ip_vs_sed ip_vs_ftp ip_vs_sh nf_conntrack ip_tables ip_set xt_set ipt_set ipt_rpfilter ipt_REJECT ipip systemctl enable --now systemd-modules-load.service 内核参数修改 cat <<EOF > /etc/sysctl.d/k8s.conf net.ipv4.ip_forward = 1 net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 fs.may_detach_mounts = 1 net.ipv4.conf.all.route_localnet = 1 vm.overcommit_memory=1 vm.panic_on_oom=0 fs.inotify.max_user_watches=89100 fs.file-max=52706963 fs.nr_open=52706963 net.netfilter.nf_conntrack_max=2310720 net.ipv4.tcp_keepalive_time = 600 net.ipv4.tcp_keepalive_probes = 3 net.ipv4.tcp_keepalive_intvl =15 net.ipv4.tcp_max_tw_buckets = 36000 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_max_orphans = 327680 net.ipv4.tcp_orphan_retries = 3 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_max_syn_backlog = 16384 net.ipv4.ip_conntrack_max = 65536 net.ipv4.tcp_max_syn_backlog = 16384 net.ipv4.tcp_timestamps = 0 net.core.somaxconn = 16384 EOF sysctl --system 所有节点配置完内核后,重启服务器,保证重启后内核依旧加载reboot reboot lsmod | grep --color=auto -e ip_vs -e nf_conntrack

优秀的个人博客,低调大师

Spring Bean初始化的几种常规方式

云栖号资讯:【点击查看更多行业资讯】在这里您可以找到不同行业的第一手的上云资讯,还在等什么,快来! 通过构造方法实例化 通过静态工厂实例化 通过实例工厂实例化 通过FactoryBean实例化 RumenzA实体类 package com.rumenz; public class RumenzA { private String id; private String name; public static RumenzA createRumenzA(){ RumenzA rumenzA=new RumenzA(); rumenzA.setId("123"); rumenzA.setName("入门小站"); return rumenzA; } public RumenzA() { System.out.println("RumenzA 无参构造方法"); } public RumenzA(String id) { this.id = id; System.out.println("ID构造方法"); } // set get省略 } 构造方法 beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="rumenz" class="com.rumenz.RumenzA" /> <bean id="rumenz1" class="com.rumenz.RumenzA"> <constructor-arg name="id" value="1"/> </bean> </beans> DemoApplication.java package com.rumenz; import org.springframework.context.support.ClassPathXmlApplicationContext; public class DemoApplication { public static void main(String[] args) { ClassPathXmlApplicationContext ca=new ClassPathXmlApplicationContext("beans.xml"); RumenzA rumenzA=(RumenzA)ca.getBean("rumenz"); } } 输出 xxx.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rumenz' RumenzA 无参构造方法 xxx.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rumenz1' ID构造方法 静态工厂 beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="rFactory" class="com.rumenz.RumenzFactory" factory-method="rumenzFactory"/> <bean id="rFactory1" class="com.rumenz.RumenzFactory" factory-method="rumenzFactory"> <constructor-arg name="id" value="111"/> </bean> </beans> RumenzFactory工厂类 package com.rumenz; public class RumenzFactory { //静态方法 public static RumenzA rumenzFactory(){ return new RumenzA(); } public static RumenzA rumenzFactory(String id){ return new RumenzA(id); } } DemoApplication.java package com.rumenz; import org.springframework.context.support.ClassPathXmlApplicationContext; public class DemoApplication { public static void main(String[] args) { ClassPathXmlApplicationContext ca=new ClassPathXmlApplicationContext("beans.xml"); } } 输出 xxx.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rFactory' RumenzA 无参构造方法 xxx.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rFactory1' ID构造方法 实例工厂实例化 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="rFactory" class="com.rumenz.RumenzFactory" /> <bean id="rumenz" factory-bean="rFactory" factory-method="rumenzFactory"></bean> <bean id="rumenz1" factory-bean="rFactory" factory-method="rumenzFactory"> <constructor-arg name="id" value="666"></constructor-arg> </bean> </beans> RumenzFactory.java package com.rumenz; public class RumenzFactory { //不能用静态方法 public RumenzA rumenzFactory(){ return new RumenzA(); } public RumenzA rumenzFactory(String id){ return new RumenzA(id); } } DemoApplication.java package com.rumenz; import org.springframework.context.support.ClassPathXmlApplicationContext; public class DemoApplication { public static void main(String[] args) { ClassPathXmlApplicationContext ca=new ClassPathXmlApplicationContext("beans.xml"); //RumenzA rumenzA=(RumenzA)ca.getBean("rFactory1"); } } 输出 xxx.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rumenz' RumenzA 无参构造方法 xxx.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rumenz1' ID构造方法 通过FactoryBean实例化 beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="rumenz-by-factoryBean" class="com.rumenz.RumenzAFactoryBean"/> </beans> RumenzAFactoryBean.java package com.rumenz; import org.springframework.beans.factory.FactoryBean; public class RumenzAFactoryBean implements FactoryBean { @Override public Object getObject() throws Exception { return RumenzA.createRumenzA(); } @Override public Class<?> getObjectType() { return RumenzA.class; } } DemoApplication.java package com.rumenz; import org.springframework.context.support.ClassPathXmlApplicationContext; public class DemoApplication { public static void main(String[] args) { ClassPathXmlApplicationContext ca=new ClassPathXmlApplicationContext("beans.xml"); RumenzA rumenzA=(RumenzA)ca.getBean("rumenz-by-factoryBean"); } } 输出/异步加载bean xxx.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rumenz-by-factoryBean' RumenzA 无参构造方法 【云栖号在线课堂】每天都有产品技术专家分享!课程地址:https://yqh.aliyun.com/live 立即加入社群,与专家面对面,及时了解课程最新动态!【云栖号在线课堂 社群】https://c.tb.cn/F3.Z8gvnK 原文发布时间:2020-06-28本文作者:入门小站本文来自:“掘金”,了解相关信息可以关注“掘金”

优秀的个人博客,低调大师

Jenkins on ACK实战(一):部署和初始化

随着云原生时代的到来,一个良好的CI/CD系统成为我们敏捷交付的必不可缺的基础,那我们搭建CI/CD系统的时候,能不能利用云原生的基础设施--kubernetes--来获取一些收益呢? 我们接下来的这一系列文章就围绕着这个主题来展开--如何围绕着kubernetes来搭建CI/CD系统,kubernetes和CI/CD的工具我们的选择分别是阿里云容器服务(ACK)和Jenkins 开始之前 你需要有一个ACK集群,以及配置好可以管理这个集群的kubectl,集群上还要有ingress controller和helm tiller,如果你还没有集群,可以使用ACK快速部署kubernetes集群 你需要有helm client,并且可以使用上面的kubectl工具的配置管理集群,helm client部署参考这里 获取Jenkins helm

优秀的个人博客,低调大师

The Tour of Go(一) 初始化Go开发环境

2012年Go语言第一个正式版本至今已经历时6年,因其优秀的性能,简洁的并发以及高效的编译等优势市场份额逐步增多,越来越多的工程实践开始选用Go语言作为基础编程语言,其生态社区也逐步发展成型,下文将从零开始构建一个Go Project。 一、Go 开发环境配置 以mac os为例,简单的配置一下Go开发环境。 Step1: 安装sdk 方式1:下载 go mac pkg文件进行软件包安装 方式2:通过homebrew 管理软件包 homebrew于mac如rpm包于linux,即mac下的软件包管理程序。可以通过如下命令安装homebrew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

优秀的个人博客,低调大师

云主机初始化swap与数据盘

背景 当前市面上大部分的云服务器产品,在购买Linux服务器并启动后,通常只帮我们挂载了系统盘到/目录。我们所购买的数据盘并没有帮我们挂载到系统。查看内存配置,一般swap也为0。 这里我们可以利用购买的数据盘来创建swap分区与数据分区,并将他们挂载到系统中去。 操作 1,查看当前的磁盘,如下,/dev/vda为系统盘,/dev/vdb为数据盘: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #fdisk-l Disk /dev/vda :53.7GB,53687091200bytes,104857600sectors Units=sectorsof1*512=512bytes Sectorsize(logical /physical ):512bytes/512bytes I /O size(minimum /optimal ):512bytes/512bytes Disklabel type :dos Diskidentifier:0x0008e9bc DeviceBootStartEndBlocksIdSystem /dev/vda1 *20482099199104857683Linux /dev/vda2 209920010485756651379183+83Linux Disk /dev/vdb :429.5GB,429496729600bytes,838860800sectors Units=sectorsof1*512=512bytes Sectorsize(logical /physical ):512bytes/512bytes I /O size(minimum /optimal ):512bytes/512bytes 2,对/dev/vdb进行分区操作,分割16G空间做swap,剩余空间做数据盘。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 #fdisk/dev/vdb Welcometo fdisk (util-linux2.23.2). Changeswillremain in memoryonly, until youdecidetowritethem. Becarefulbeforeusingthewrite command . Devicedoesnotcontainarecognizedpartitiontable BuildinganewDOSdisklabelwithdiskidentifier0xb07be21f. Command(m for help):n Partition type : pprimary(0primary,0extended,4 free ) eextended Select(defaultp):p Partitionnumber(1-4,default1): Firstsector(2048-838860799,default2048): Usingdefaultvalue2048 Lastsector,+sectorsor+size{K,M,G}(2048-838860799,default838860799):+16G Partition1of type Linuxandofsize16GiBis set Command(m for help):n Partition type : pprimary(1primary,0extended,3 free ) eextended Select(defaultp):p Partitionnumber(2-4,default2): Firstsector(33556480-838860799,default33556480): Usingdefaultvalue33556480 Lastsector,+sectorsor+size{K,M,G}(33556480-838860799,default838860799): Usingdefaultvalue838860799 Partition2of type Linuxandofsize384GiBis set Command(m for help):w Thepartitiontablehasbeenaltered! Callingioctl()tore- read partitiontable. Syncingdisks. #fdisk-l Disk /dev/vda :53.7GB,53687091200bytes,104857600sectors Units=sectorsof1*512=512bytes Sectorsize(logical /physical ):512bytes/512bytes I /O size(minimum /optimal ):512bytes/512bytes Disklabel type :dos Diskidentifier:0x0008e9bc DeviceBootStartEndBlocksIdSystem /dev/vda1 *20482099199104857683Linux /dev/vda2 209920010485756651379183+83Linux Disk /dev/vdb :429.5GB,429496729600bytes,838860800sectors Units=sectorsof1*512=512bytes Sectorsize(logical /physical ):512bytes/512bytes I /O size(minimum /optimal ):512bytes/512bytes Disklabel type :dos Diskidentifier:0x53b4d701 DeviceBootStartEndBlocksIdSystem /dev/vdb1 2048335564791677721683Linux /dev/vdb2 3355648083886079940265216083Linux 可以看到创建了2个分区/dev/vdb1,/dev/vdb2。 3,创建swap分区,并启用: 1 2 #mkswap/dev/vdb1 #swapon/dev/vdb1 4,把/dev/vdb2格式化,并挂载到/data目录下:(这里格式成xfs文件系统) 1 2 3 #mkdir-p/data #mkfs.xfs/dev/vdb2 #mount/dev/vdb2/data 5,检查是否生效: 1 2 3 4 5 6 7 8 9 10 11 12 13 #df-kh FilesystemSizeUsedAvailUse%Mountedon /dev/vda2 49G1.7G45G4%/ devtmpfs7.8G07.8G0% /dev tmpfs7.8G07.8G0% /dev/shm tmpfs7.8G25M7.8G1% /run tmpfs7.8G07.8G0% /sys/fs/cgroup /dev/vda1 976M146M764M16% /boot tmpfs1.6G01.6G0% /run/user/0 /dev/vdb2 384G33M384G1% /data #free-m totalused free sharedbuff /cache available Mem:15885393146282486315158 6,把磁盘挂载信息写进fstab,使之开启自动挂载: 1 2 3 #vi/etc/fstab /dev/vdb1 swapswapdefaults00 /dev/vdb2 /data xfsdefaults00 本文转自 icenycmh 51CTO博客,原文链接:http://blog.51cto.com/icenycmh/2065057,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册