当前位置: 首页 > news >正文

MongoDB5副本集高可用集群部署

MongoDB5副本集高可用集群部署

1.MongoDB简介

MongoDB官方网站:https://www.mongodb.com

​ MongoDB最大的特点是表结构灵活可变,字段类型可以随时修改。MongoDB中的每一行数据只是简单的被转化成Json格式后存储,因此MongoDB中没有MySQL中表结构这样的概念,可以直接将任意结构的数据塞入同一个表中,不必考虑表结构,更不必像MySQL一样因为要修改数据表结构而大费周折。

​ MongoDB不需要定义表结构这个特点给表结构的修改带来了极大的方便,但是也给多表查询、复杂事务等高级操作带来了阻碍。因此,如果数据的逻辑结构非常复杂,经常需要进行复杂的多表查询或者事务操作,那显然还是MySQL这类关系型数据库更合适

  • 面向集合存储,易存储对象类型的数据
  • 支持查询,以及动态查询
  • 支持RUBY,PYTHON,JAVA,C++,PHP,C#等多种语言
  • 文件存储格式为BSON(一种JSON的扩展)
  • 支持复制和故障恢复和分片
  • 支持事务支持
  • 索引 聚合 关联…

MongoDB结构对比

RDBMSMongoDB
数据库数据库
集合
文档
字段

在MongoDB中,集合就是table表的概念

2.安装部署

2-0.机器规划与准备

主机名IP角色Role
hdt-dmcp-ops05172.20.12.179PRIMARY
hdt-dmcp-ops04172.20.9.6SECONDARY
hdt-dmcp-ops03172.20.14.243SECONDARY

本次部署环境为CentOS 7.4 ,搭建部署MongoDB-5.0.15

[wangting@hdt-dmcp-ops05 software]$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

2-1.下载安装包(hdt-dmcp-ops05操作)

[wangting@hdt-dmcp-ops05 software]$ cd /opt/software
[wangting@hdt-dmcp-ops05 software]$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.15-rc2.tgz

2-2.创建MongoDB相关目录(hdt-dmcp-ops05操作)

[wangting@hdt-dmcp-ops05 software]$ cd /opt/module/
[wangting@hdt-dmcp-ops05 module]$ mkdir MongoDB
[wangting@hdt-dmcp-ops05 module]$ cd MongoDB/
[wangting@hdt-dmcp-ops05 MongoDB]$ mkdir data log pid

路径均可自定义配置

/opt/module/MongoDB为mongo项目路径

data目录为数据保存路径

log为日志保存路径

pid为服务启动后的进程信息存储路径

2-3.解压安装包(hdt-dmcp-ops05操作)

[wangting@hdt-dmcp-ops05 software]$ cd /opt/software
[wangting@hdt-dmcp-ops05 software]$ tar -zxvf mongodb-linux-x86_64-rhel70-5.0.15-rc2.tgz -C /opt/module/MongoDB/
[wangting@hdt-dmcp-ops05 software]$ cd /opt/module/MongoDB
[wangting@hdt-dmcp-ops05 MongoDB]$ mv mongodb-linux-x86_64-rhel70-5.0.15-rc2 mongodbServer

2-4.定义配置文件(hdt-dmcp-ops05操作)

[wangting@hdt-dmcp-ops05 MongoDB]$ vim mongodbServer/bin/mongod.conf
storage:journal:enabled: truedbPath: "/opt/module/MongoDB/data"directoryPerDB: truewiredTiger:engineConfig:cacheSizeGB: 1directoryForIndexes: truecollectionConfig:blockCompressor: zlibindexConfig:prefixCompression: truesystemLog:destination: filepath: "/opt/module/MongoDB/log/mongod.log"logAppend: truenet:port: 27017bindIpAll: truemaxIncomingConnections: 5000processManagement:fork: truepidFilePath: /opt/module/MongoDB/pid/mongod.pid#security:
#  keyFile: /opt/module/MongoDB/mongodbServer/bin/mongo.keyfile
# authorization: enabledreplication:oplogSizeMB: 4096replSetName: rs1

【注意】:

  1. security相关配置项为注释状态,第一次启动使用时,不加载security相关配置,需要机器配置完毕后再配置开启(因为具体的认证配置文件均未生成)
  2. PRIMARY和SECONDARY的配置文件没有特别配置不一样的参数,可以复用,角色的配置均在服务启动后访问server调整

2-5.分发安装目录(hdt-dmcp-ops05操作)

[wangting@hdt-dmcp-ops05 module]$ pwd
/opt/module
[wangting@hdt-dmcp-ops05 module]$ scp -r MongoDB hdt-dmcp-ops04:/opt/module/
[wangting@hdt-dmcp-ops05 module]$ scp -r MongoDB hdt-dmcp-ops03:/opt/module/

2-6.配置环境变量(所有节点机器操作)

# 增加mongo相关配置
[wangting@hdt-dmcp-ops05 MongoDB]$ sudo vim /etc/profile
# mongo
export MONGODB_HOME=/opt/module/MongoDB/mongodbServer
export PATH=$PATH:$MONGODB_HOME/bin# 引用环境变量
[wangting@hdt-dmcp-ops05 MongoDB]$ source /etc/profile

【注意】:

所有3个节点机器都需要配置环境变量

( 暂不操作,这里了解 )-单个实例启动服务方式:

mongod命令 --config 配置文件路径

[wangting@hdt-dmcp-ops05 MongoDB]$ mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 12601
child process started successfully, parent exiting

( 暂不操作,这里了解 )-单个实例关闭服务方式:

[wangting@hdt-dmcp-ops05 MongoDB]$ mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf --shutdown

2-7.编写集群启停脚本(hdt-dmcp-ops05操作)

[wangting@hdt-dmcp-ops05 bin]$ vim mymongo
#!/bin/bashstart() {
ssh hdt-dmcp-ops05 "/opt/module/MongoDB/mongodbServer/bin/mongod  --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf >/dev/null 2>&1"
sleep 2
ssh hdt-dmcp-ops04 "/opt/module/MongoDB/mongodbServer/bin/mongod  --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf >/dev/null 2>&1"
sleep 2
ssh hdt-dmcp-ops03 "/opt/module/MongoDB/mongodbServer/bin/mongod  --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf >/dev/null 2>&1"
}stop() {
ssh hdt-dmcp-ops05 "/opt/module/MongoDB/mongodbServer/bin/mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf --shutdown >/dev/null 2>&1"
sleep 2
ssh hdt-dmcp-ops04 "/opt/module/MongoDB/mongodbServer/bin/mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf --shutdown >/dev/null 2>&1"
sleep 2
ssh hdt-dmcp-ops03 "/opt/module/MongoDB/mongodbServer/bin/mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf --shutdown >/dev/null 2>&1"
}
case "$1" instart)start;;stop)stop;;restart)stopstart;;*)echo
$"Usage: $0 {start|stop|restart}"exit 1
esac
[wangting@hdt-dmcp-ops05 bin]$ chmod +x mymongo

脚本可以使用for循环简化,这里为了操作方便,将操作集中到一个脚本中

2-8.启动停止服务(hdt-dmcp-ops05操作)

# 停止服务
[wangting@hdt-dmcp-ops05 bin]$ mymongo stop
killing process with pid: 12601
[wangting@hdt-dmcp-ops05 bin]$ netstat -tnlpu|grep 27017
[wangting@hdt-dmcp-ops05 bin]$# 启动服务
[wangting@hdt-dmcp-ops05 bin]$ mymongo start
about to fork child process, waiting until server is ready for connections.
forked process: 13747
child process started successfully, parent exiting
[wangting@hdt-dmcp-ops05 bin]$ netstat -tnlpu|grep 27017
(Not all processes could be identified, non-owned process infowill not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      13747/mongod

2-9.初次登录初始化副本集(任意一节点连接mongo)

使用mongo shell连接到其中任意一个节点即可,来执行初次登录初始化副本集

[wangting@hdt-dmcp-ops05 module]$ mongo shell
> use admin
> config = {_id : "rs1", members : [{_id:0, host:"172.20.12.179:27017"},{_id:1, host:"172.20.9.6:27017"},{_id:2, host:"172.20.14.243:27017"},]
}

【注意】:

需要更改对应环境的IP地址

2-10.对副本集进行初始化

> rs.initiate(config){ "ok" : 1 }
rs1:SECONDARY>

如果返回 { “ok” : 0 }, 则说明初始化失败

  • 查看集群状态
rs1:PRIMARY> rs.status()
...
..."members" : [{"_id" : 0,"name" : "172.20.12.179:27017","health" : 1,"state" : 1,"stateStr" : "PRIMARY",{"_id" : 1,"name" : "172.20.9.6:27017","health" : 1,"state" : 2,"stateStr" : "SECONDARY","uptime" : 5382,{"_id" : 2,"name" : "172.20.14.243:27017","health" : 1,"state" : 2,"stateStr" : "SECONDARY","uptime" : 5382,
  • 查看延时从库信息
rs1:PRIMARY> rs.printSlaveReplicationInfo()
WARNING: printSlaveReplicationInfo is deprecated and may be removed in the next major release. Please use printSecondaryReplicationInfo instead.
source: 172.20.9.6:27017syncedTo: Wed Mar 08 2023 16:27:45 GMT+0800 (CST)0 secs (0 hrs) behind the primary
source: 172.20.14.243:27017syncedTo: Wed Mar 08 2023 16:27:45 GMT+0800 (CST)0 secs (0 hrs) behind the primary

2-11.设置超级管理员账号和密码

> use admin
switched to db admin
> db.createUser({user: 'mongouser',pwd: '123456',roles:[{role: 'root',db: 'admin'}]
})Successfully added user: {"user" : "admin","roles" : [{"role" : "root","db" : "admin"}]
}

其它用户相关常用命令:

show users  //查看当前库下的用户
db.dropUser('testadmin')  // 删除用户
db.updateUser('admin', {pwd: 'newpasswd'})  // 修改用户密码
db.auth('admin', 'password')  // 密码认证

2-12.设置数据库读写用户方法

[wangting@hdt-dmcp-ops05 bin]$ mongo
> use bigdatadb
switched to db bigdatadb
> db.createUser({user: 'bigdata',pwd: 'bigdata123',roles:[{role: 'readWrite',db: 'bigdatadb'}]})Successfully added user: {"user" : "bigdata","roles" : [{"role" : "readWrite","db" : "bigdatadb"}]
}> exit
bye

MongoDB 数据库角色信息:

角色描述角色标识
数据库用户角色read、readWrite
数据库管理角色dbAdmin、dbOwner、userAdmin
集群管理角色clusterAdmin、clusterManager、clusterMonitor、hostManager
备份恢复角色backup、restore
所有数据库角色readAnyDatabase、readWriteAnyDatabase、userAdminAnyDatabase、 dbAdminAnyDatabase
超级用户角色root

2-13.开启副本集认证

# 创建副本集认证的key文件
[wangting@hdt-dmcp-ops05 bin]$ pwd
/opt/module/MongoDB/mongodbServer/bin
[wangting@hdt-dmcp-ops05 bin]$ openssl rand -base64 90 -out /opt/module/MongoDB/mongodbServer/bin/mongo.keyfile
[wangting@hdt-dmcp-ops05 bin]$ ll
total 242228
-rwxr-xr-x 1 wangting wangting     15205 Feb 17 03:54 install_compass
-rwxr-xr-x 1 wangting wangting  60321720 Feb 17 04:43 mongo
-rwxr-xr-x 1 wangting wangting 110313632 Feb 17 04:46 mongod
-rw-rw-r-- 1 wangting wangting       629 Mar  8 14:19 mongod.conf
-rw-rw-r-- 1 wangting wangting       122 Mar  8 14:43 mongo.keyfile
-rwxr-xr-x 1 wangting wangting  77374072 Feb 17 04:43 mongos
# 分发mongo.keyfile
[wangting@hdt-dmcp-ops05 bin]$ scp mongo.keyfile hdt-dmcp-ops04:$PWD
[wangting@hdt-dmcp-ops05 bin]$ scp mongo.keyfile hdt-dmcp-ops03:$PWD# 将配置文件mongod.conf的配置注释打开(去掉注释)
# 【注意】:3个节点配置文件的security都要打开!
security:keyFile: /opt/module/MongoDB/mongodbServer/bin/mongo.keyfileauthorization: enabled

mongo.keyfile认证文件mongo集群必须要用同一份keyfile,一般都在一台机器上生成,然后分发到其他节点,且必须有读的权限,否则将来会报错

路径保持一致,否则mongod.conf中的keyFile路径就要根据不同节点配置不同路径,相对不好维护

  • 重启服务生效
# 关闭服务
[wangting@hdt-dmcp-ops05 bin]$ mymongo stop
# 启动服务
[wangting@hdt-dmcp-ops05 bin]$ mymongo start
  • 再次连接mongo
# 原方式:mongo admin --host 172.20.12.179 --port 27017 -u mongouser -p 123456
# 这里采用auther认证方式验证访问
[wangting@hdt-dmcp-ops05 module]$ mongo -u mongouser -p 123456 --host hdt-dmcp-ops05 --port 27017 -authenticationDatabase admin
MongoDB shell version v5.0.15-rc2
connecting to: mongodb://hdt-dmcp-ops05:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("66c31018-e1a1-45e9-8742-4496e0266ba0") }
MongoDB server version: 5.0.15-rc2
rs1:PRIMARY>

3.验证调试及使用介绍

3-1.访问MongoDB

方式1(常用):

# 原始方式
[wangting@hdt-dmcp-ops05 ~]$ mongo admin --host 172.20.12.179 --port 27017 -u mongouser -p 123456

方式2(常用)

# 使用用户名、免密、认证库登录MongoDB副本集主节点
[wangting@hdt-dmcp-ops05 module]$ mongo -u mongouser -p 123456 --host hdt-dmcp-ops05 --port 27017 -authenticationDatabase admin

方式3:

# 机器上直接使用mongo访问
[wangting@hdt-dmcp-ops05 bin]$ mongo
> use admin
switched to db admin
> db.auth('admin', 'admin123')
1
> db
admin

普通用户访问方式相同:

[wangting@hdt-dmcp-ops05 ~]$ mongo bigdatadb --host 172.20.12.179 --port 27017 -u bigdata -p bigdata123
> db
bigdatadb
> exit
bye

3-2.MongoDB远程连接控制

[wangting@hdt-dmcp-ops05 ~]$ cd /opt/module/MongoDB/mongodbServer/bin/
[wangting@hdt-dmcp-ops05 bin]$ vim mongod.conf
#####
net:port: 27017bindIpAll: true
####

bindIp: 0.0.0.0 或者 bindIpAll: true 即允许所有的IPv4和IPv6地址访问

net.bindIp和net.bindIpAll是互斥的。可以指定其中一个,但不能同时指定两个配置

如需要指定个别IP或者某个网段访问可以配置bindIp

例如:

bindIp:192.168.3.11,192.168.3.12,192.168.3.13

bindIp: localhost

3-3.MongoDB使用介绍

  • 登录
[wangting@hdt-dmcp-ops05 ~]$ mongo admin --host 172.20.12.179 --port 27017 -u mongouser -p 123456
rs1:PRIMARY> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
  • 切换数据库
rs1:PRIMARY> use bigdata
switched to db bigdata

注意: use 代表创建并使用,当库中没有数据时默认不显示这个库

  • 删除数据库

db.dropDatabase()

> use test111
switched to db test111
> db.dropDatabase()
{ "ok" : 1 }
> show dbs
admin    0.000GB
bigdata  0.000GB
config   0.000GB
local    0.000GB
>
  • 查看表清单
> show tables
# 或者
> show collections
  • 表创建

db.createCollection('集合名称', [options])

> db.createCollection("table1")
{ "ok" : 1 }
> show tables
table1

[options]可选参数:

字段类型描述
capped布尔(可选)如果为 true,则创建固定集合。固定集合是指有着固定大小的集合,当达到最大值时,它会自动覆盖最早的文档。 当该值为 true 时,必须指定 size 参数
size数值(可选)为固定集合指定一个最大值,即字节数。 如果 capped 为 true,也需要指定该字段
max数值(可选)指定固定集合中包含文档的最大数量

注意:当集合(表)不存在时,向集合中插入文档也会自动创建该集合

  • 表中插入数据

db.【表名】.insert("【JSON格式的数据】")

> db.table1.insert({"id":"1","name":"wangting111"})
WriteResult({ "nInserted" : 1 })
> db.table1.insert({"id":"2","name":"wangting222"})
WriteResult({ "nInserted" : 1 })
> db.table1.insert({"id":"3","name":"wangting333"})
WriteResult({ "nInserted" : 1 })
>
  • 查看表中数据
> db.table1.find()
{ "_id" : ObjectId("63f5a21faa98d270a51a7968"), "id" : "1", "name" : "wangting111" }
{ "_id" : ObjectId("63f5a228aa98d270a51a7969"), "id" : "2", "name" : "wangting222" }
{ "_id" : ObjectId("63f5a22faa98d270a51a796a"), "id" : "3", "name" : "wangting333" }
>
  • 删除集合(表)
> show tables;
table1
> db.table1.drop()
true
> show tables;
>
  • 文档操作
# 单条文档
> db.table1.insert({"name":"wang111","age":18,"bir":"1989-09-07"});
WriteResult({ "nInserted" : 1 })
> db.table1.find()
{ "_id" : ObjectId("63f5a96c86e1dd7e4acc842f"), "name" : "wang111", "age" : 18, "bir" : "1989-09-07" }# 多条文档
db.table1.insert([{"name":"wang222","age":18,"bir":"1989-09-08"},{"name":"wang333","age":18,"bir":"1989-09-09"},{"name":"wang444","age":20,"bir":"1989-09-10"},{"name":"wang555","age":19,"bir":"1989-09-11"}
]);BulkWriteResult({"writeErrors" : [ ],"writeConcernErrors" : [ ],"nInserted" : 4,"nUpserted" : 0,"nMatched" : 0,"nModified" : 0,"nRemoved" : 0,"upserted" : [ ]
})
> db.table1.find()
{ "_id" : ObjectId("63f5a96c86e1dd7e4acc842f"), "name" : "wang111", "age" : 18, "bir" : "1989-09-07" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8430"), "name" : "wang222", "age" : 18, "bir" : "1989-09-08" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8431"), "name" : "wang333", "age" : 18, "bir" : "1989-09-09" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8432"), "name" : "wang444", "age" : 20, "bir" : "1989-09-10" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8433"), "name" : "wang555", "age" : 19, "bir" : "1989-09-11" }
>
# 支持利用代码循环批量插入
> for(let i=0;i<10;i++){db.table1.insert({"_id":i,"name":"wang"+i,"age" : 18+i,"bir" : "1989-09-07"})
}
WriteResult({ "nInserted" : 1 })> db.table1.find()
{ "_id" : ObjectId("63f5a96c86e1dd7e4acc842f"), "name" : "wang111", "age" : 18, "bir" : "1989-09-07" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8430"), "name" : "wang222", "age" : 18, "bir" : "1989-09-08" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8431"), "name" : "wang333", "age" : 18, "bir" : "1989-09-09" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8432"), "name" : "wang444", "age" : 20, "bir" : "1989-09-10" }
{ "_id" : ObjectId("63f5aac286e1dd7e4acc8433"), "name" : "wang555", "age" : 19, "bir" : "1989-09-11" }
{ "_id" : 0, "name" : "wang0", "age" : 18, "bir" : "1989-09-07" }
{ "_id" : 1, "name" : "wang1", "age" : 19, "bir" : "1989-09-07" }
{ "_id" : 2, "name" : "wang2", "age" : 20, "bir" : "1989-09-07" }
{ "_id" : 3, "name" : "wang3", "age" : 21, "bir" : "1989-09-07" }
{ "_id" : 4, "name" : "wang4", "age" : 22, "bir" : "1989-09-07" }
{ "_id" : 5, "name" : "wang5", "age" : 23, "bir" : "1989-09-07" }
{ "_id" : 6, "name" : "wang6", "age" : 24, "bir" : "1989-09-07" }
{ "_id" : 7, "name" : "wang7", "age" : 25, "bir" : "1989-09-07" }
{ "_id" : 8, "name" : "wang8", "age" : 26, "bir" : "1989-09-07" }
{ "_id" : 9, "name" : "wang9", "age" : 27, "bir" : "1989-09-07" }
>

相关文章:

MongoDB5副本集高可用集群部署

MongoDB5副本集高可用集群部署 1.MongoDB简介 MongoDB官方网站&#xff1a;https://www.mongodb.com ​ MongoDB最大的特点是表结构灵活可变&#xff0c;字段类型可以随时修改。MongoDB中的每一行数据只是简单的被转化成Json格式后存储&#xff0c;因此MongoDB中没有MySQL中表…...

【Java】最新版本SpringCloudStream整合RocketMQ实现单项目中事件的发布与监听

文章目录前言依赖配置代码参考前言 SpringCloud项目中整合RocketMQ是为了削峰填谷。 这里我使用RocketMQ的作用用于接收项目中产生的消息&#xff0c;然后异步的发送邮件给客户&#xff0c;这是这个项目的产生的背景。 依赖配置 <dependencies><dependency><…...

abp.net 5.0 部署IIS10

今天遇到了abp.net 5.0部署iis10被卡住的问题&#xff0c;网上找了一些资料&#xff0c;都不是我要的&#xff0c;最后我总结一下我用的是 5.0的版本&#xff0c;所以我需要给服务器安装 iis5.0的相关运行环境 1&#xff1a;https://dotnet.microsoft.com/zh-cn/download/dotne…...

Windows安装Qt与VS2019添加QT插件

一、通过Qt安装包方式http://download.qt.io/archive/qt/5.12/5.12.3/.安装可以就选中这个MSVC 2017 64-bit&#xff0c;其他就暂时不用了二、通过vs2019安装Qt插件方式方法1下面这种方式本人安装不起来&#xff0c;一直卡住下不下来。拓展->管理拓展->联机->搜索Qt&a…...

自学大数据第5天~hadoop集群搭建(二)

配置集群/分布式环境 1,修改文件workers 需要把所有节点数据节点的主机名写入该文件,每行一个,默认localhost(即把本机(namenode也作为数据节点),所以我们在伪分布式是没有配置该文件; 在进行分布式时需要删掉localhost(又可能文件中没有该配置,没有那就不用删了,配置一下数据…...

MySQL (六)------MySQL的常用函数、 事务(TCL)、DCL用户操作语句、常见环境、编码问题

第一章 MySQL的常用函数 1.1 字符串函数 1.1.1 字符串函数列表概览 函数用法CONCAT(S1,S2,......,Sn)连接S1,S2,......,Sn为一个字符串CONCAT_WS(separator, S1,S2,......,Sn)连接S1一直到Sn&#xff0c;并且中间以separator作为分隔符CHAR_LENGTH(s)返回字符串s的字符数LENGTH…...

【3.8】操作系统内存管理、Redis数据结构、哈希表

内存满了&#xff0c;会发生什么&#xff1f; 当应用程序读写了这块虚拟内存&#xff0c;CPU 就会去访问这个虚拟内存&#xff0c; 这时会发现这个虚拟内存没有映射到物理内存&#xff0c; CPU 就会产生缺页中断&#xff0c;进程会从用户态切换到内核态&#xff0c;并将缺页中…...

Shell编程:轻松掌握入门级Shell脚本,成为Shell高手

文章目录前言一. 实验环境二. shell基础入门精讲2.1 什么是shell脚本&#xff1f;2.2 shell的种类2.3 脚本案例2.3.1 打印 hello-word案例2.3.2 统计指定目录下的文件数和目录数2.4 shell脚本编写规范总结前言 &#x1f3e0;个人主页&#xff1a;我是沐风晓月 &#x1f9d1;个人…...

FastApi的搭建与测试

一、fastapi的安装 1-1、使用pip安装 安装fastapi的语句 pip install fastapi -i https://mirrors.aliyun.com/pypi/simple因为fastapi启动依赖于uvicorn&#xff0c;所以我们还需要安装uvicorn。 pip install uvicorn -i https://mirrors.aliyun.com/pypi/simple下面我们来…...

C++基础——C++面向对象之重载与多态基础总结(函数重载、运算符重载、多态的使用)

【系列专栏】&#xff1a;博主结合工作实践输出的&#xff0c;解决实际问题的专栏&#xff0c;朋友们看过来&#xff01; 《QT开发实战》 《嵌入式通用开发实战》 《从0到1学习嵌入式Linux开发》 《Android开发实战》 《实用硬件方案设计》 长期持续带来更多案例与技术文章分享…...

调用一个函数时发生了什么?

欢迎来到 Claffic 的博客 &#x1f49e;&#x1f49e;&#x1f49e; 前言&#xff1a; 用C语言写代码&#xff0c;如果一个工程相对复杂时&#xff0c;我们往往会采取封装函数的方式。在主函数中调用函数 这一看似简单的过程&#xff0c;实际上有很多不宜观察的细节&#xff0…...

MindAR的网页端WebAR图片识别功能的图片目标编译器中文离线版本功能(含源码)

前言 之前制作了基于MindAR实现的网页端WebAR图片识别叠加动作模型追踪功能的demo&#xff0c;使用了在线的图像目标编译器对识别图进行了编译&#xff0c;并实现了自制的WebAR效果&#xff0c;大致效果如下&#xff1a; 但是在线的编译器在操作中也不是很方便&#xff0c;我…...

测试经理:“你做了三年测试,连服务端的接口测试都不会?”

服务端的接口测试我们一般从功能开始进行测试&#xff0c;比如请求参数和响应参数的校验&#xff0c;业务逻辑或业务规则的校验&#xff0c;数据库操作的校验。 功能正常后会根据需要进行安全相关的检查、性能测试以及系列扩展测试&#xff0c;比如与历史版本的兼容性测试、接…...

4G AFR到5G应用场景介绍

前面文章介绍过AFR的机制及流程 AFR机制及流程介绍 (qq.com) GSM AFR到LTE流程...

正电源子 IMX6ULL 自学笔记(驱动开发)

一、字符设备驱动开发 1.1 字符设备驱动简介 字符设备是 Linux 驱动中最基本的一类设备驱动&#xff0c;字符设备就是一个一个字节&#xff0c;按照字节流进行读写操作的设备&#xff0c;读写数据是分先后顺序的。比如我们最常见的点灯、按键、IIC、SPI&#xff0c;LCD 等等都…...

AM5728(AM5708)开发实战之移植OpenCV-3.4.11

一 概述 OpenCV是一个开源的跨平台计算机视觉库&#xff0c;可以运行在Linux、Windows、Mac OS等操作系统上&#xff0c;它为图像处理、模式识别、三维重建、物体跟踪、机器学习提供了丰富的算法。 由于OpenCV依赖包特别多&#xff0c;尽量不要使用交叉编译&#xff0c;即在什…...

Notepad++ 下载与安装教程

文章目录Notepad 下载与安装教程Notepad 简介一&#xff0c;Notepad 下载二&#xff0c;Notepad 安装Notepad 下载与安装教程 Notepad 简介 Notepad是程序员必备的文本编辑器&#xff0c;Notepad中文版小巧高效&#xff0c;支持27种编程语言&#xff0c;通吃C,C ,Java ,C#, XM…...

005+limou+HTML——(5)HTML图片和HTML超链接

1、图片标签<img> &#xff08;1&#xff09;图片标签属性 [src]&#xff1a;用于指定这个图片所在的路径&#xff0c;常使用相对路径&#xff0c;比较少使用绝对路劲。如果图片路径有错误的话&#xff0c;就会发生图片显示错误[alt]&#xff1a;用于指定图片的提示文字…...

ES6 Generator

Generator Generator是es6引入的&#xff0c;主要用于异步编程。 最大特点是可以交出函数的执行权(即暂停执行)。 它和普通的函数写法有点不同 function关键字与函数名之间有一个*号&#xff0c;以与普通函数进行区别。 它不同于普通函数&#xff0c;是可以暂停执行的。 Gen…...

SCI期刊写作必备(二):代码|手把手绘制目标检测领域YOLO论文常见的性能对比折线图,一键生成YOLOv7等主流论文同款图表,包含多种不同功能风格对比图表

绘制一个原创属于自己的YOLO模型性能对比图表 具体绘制操作参考:(附Python代码,直接一键生成,精度对比图表代码 ) 只需要改动为自己的mAP、Params、FPS、GFlops等数值即可,一键生成 多种图表风格📈,可以按需挑选 文章目录 绘制一个原创属于自己的YOLO模型性能对比图…...

linux cpu飙高排查

linux定位cpu飙高原因 jpstop 定位应用进程 pidtop -Hp {pid}找到线程 tid将 tid 转换成十六进制 printf “%x\n” {tid}jstack 打印堆栈信息过滤出我们想要的 jpstop 定位应用进程 pid jps或ps -ef | grep java查看java进程id jps结果&#xff1a; 57152 abc.jar 83383 e…...

2023实习面试公司【二】

2023实习面试第二家公司 文章目录2023实习面试第二家公司前言一、面试官所问的问题&#xff1f;二、总结1.公司待遇2.推荐指数3.自己的感受前言 某岸科技&#xff0c;这家公司是我从拉钩上找的第二家面试公司&#xff0c;也是北京本地的一家公司。 提示&#xff1a;以下是本篇…...

C++ thread_local 存储类

目录标题概述实现场景总结概述 thread_local指示对象拥有线程存储期。也就是对象的存储在线程开始时分配&#xff0c;而在线程结束时解分配。每个线程拥有其自身的对象实例。唯有声明为 thread_local 的对象拥有此存储期。 thread_local 能与 static 或 extern 结合一同出现&am…...

冥想第七百二十三天

1.周日早上跑了5公里&#xff0c;很舒服精力满满的&#xff0c;感谢老婆给我做的饭&#xff0c;鱿鱼面筋腐竹。都非常的好吃。 2.下午13&#xff1a;19分送我到了地铁口&#xff0c;这个点卡的真好&#xff0c;以至于离高铁开车只剩5分钟&#xff0c;14&#xff1a;41发车。到上…...

zookeeper 集群配置

文章目录zookeeper 集群配置1、集群安装zookeeper 集群配置 1、集群安装 1) 集群安装 在 hadoop102、hadoop103 和 hadoop104 三个节点上都部署 Zookeeper。 2) 解压安装 在 hadoop102 解压 Zookeeper 安装包到/opt目录下 输入命令&#xff1a;tar -zxvf apache-zookeeper-3.…...

怎么用消息队列实现分布式事务?

当消息队列和事务联系在一起时&#xff0c;它指的是消息生产者和消息消费者之间如何保持数据一致性。 什么是分布式事务&#xff1f; 事务是指当我们进行若干项数据更新操作时&#xff0c;为了保证数据的完整性和一致性&#xff0c;我们希望这些更新操作要么都成功&#xff0…...

什么蓝牙耳机佩戴舒适?2023长时间佩戴最舒适的蓝牙耳机

现如今&#xff0c;很多蓝牙耳机的产品都在不断地更新&#xff0c;市面上的耳机也是越来越普及&#xff0c;可以说是成为我们日常生活中不可或缺的一类电子设备&#xff0c;下面介绍一些佩戴舒适性好的蓝牙耳机。 一、南卡小音舱蓝牙耳机 音质推荐指数&#xff1a;★★★★★…...

刮刮乐--课后程序(Python程序开发案例教程-黑马程序员编著-第4章-课后作业)

实例1&#xff1a;刮刮乐 刮刮乐的玩法多种多样&#xff0c;彩民只要刮去刮刮乐上的银色油墨即可查看是否中奖。每张刮刮乐都有多个兑奖区&#xff0c;每个兑奖区对应着不同的获奖信息&#xff0c;包括“一等奖”、“二等奖”、“三等奖”和“谢谢惠顾”。假设现在有一张刮刮乐…...

LeetCode 全题解笔记:两数相加(02)

两数相加&#xff08;medium&#xff09; 题目描述 给你两个非空的链表&#xff0c;表示两个非负的整数。它们每位数字都是按照逆序的方式存储的&#xff0c;并且每个节点只能存储 一位数字。请你将两个数相加&#xff0c;并以相同形式返回一个表示和的链表。你可以假设除了数…...

网络工程师面试题(面试必看)(1)

作者简介:一名云计算网络运维人员、每天分享网络与运维的技术与干货。 座右铭:低头赶路,敬事如仪 个人主页:网络豆的主页​​​​​​ 目录 前言 一.正题 1.TCP UDP协议的区别...