在【Cencos7】中安装【Nacos】并适配【PostgreSQL】数据库

在【Cencos7】中安装【Nacos-2.3.0】并适配【PostgreSQL】数据库

安装JDK

wget命令下载:
wget https://repo.huaweicloud.com/java/jdk/8u151-b12/jdk-8u151-linux-x64.tar.gz
解压
tar -xzvf jdk-7u80-linux-x64.tar.gz
将解压后的目录移动到/opt下
sudo mv jdk1.8.0_151 /opt/jdk1.8.0_151
配置环境变量
# 编辑环境变量 下面两个命令二选一即可
vim /etc/profile 
#sudo vim /etc/profile.d/jdk.sh# 输入ins键进行编辑,加入以下内容,jdk目录名记得换成自己的名字
export JAVA_HOME=/opt/jdk1.8.0_151
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin# 按下esc,进入命令行模式
# 再输入“:wq!”,强制保存退出# 让环境变量生效
source /etc/profile

安装nacos

下载nacos

下载完成后上传到Linux服务器目录中,例如 /home/nacos

解压nacos 并移动到/opt目录下
#进入nacos所在目录
cd /home/nacos#加压nacos
tar -zxvf nacos-server-2.3.0.tar.gz
#将解压后的目录移动到 /opt下
sudo mv nacos-server-2.3.0 /opt/nacos
启动测试
# 进入nacos bin 目录
cd /opt/nacos/bin#单机模式启动
sudo sh startup.sh -m standalone

访问:http://ip:8848/nacos/index.html 测试

修改配置文件
# 进入配置文件所在目录
cd /opt/nacos/conf#编辑
vim application.properties

在这里插入图片描述

初始化pgsql
/* 创建数据库 */
create database nacos;

初始化所需表

/** Copyright 1999-2018 Alibaba Group Holding Ltd.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/-- ----------------------------
-- Table structure for config_info
-- ----------------------------
DROP TABLE IF EXISTS "config_info";
CREATE TABLE "config_info" ("id" bigserial NOT NULL,"data_id" varchar(255)  NOT NULL,"group_id" varchar(255) ,"content" text  NOT NULL,"md5" varchar(32) ,"gmt_create" timestamp(6) NOT NULL,"gmt_modified" timestamp(6) NOT NULL,"src_user" text ,"src_ip" varchar(20) ,"app_name" varchar(128) ,"tenant_id" varchar(128) ,"c_desc" varchar(256) ,"c_use" varchar(64) ,"effect" varchar(64) ,"type" varchar(64) ,"c_schema" text ,"encrypted_data_key" text  NOT NULL
)
;COMMENT ON COLUMN "config_info"."id" IS 'id';
COMMENT ON COLUMN "config_info"."data_id" IS 'data_id';
COMMENT ON COLUMN "config_info"."content" IS 'content';
COMMENT ON COLUMN "config_info"."md5" IS 'md5';
COMMENT ON COLUMN "config_info"."gmt_create" IS '创建时间';
COMMENT ON COLUMN "config_info"."gmt_modified" IS '修改时间';
COMMENT ON COLUMN "config_info"."src_user" IS 'source user';
COMMENT ON COLUMN "config_info"."src_ip" IS 'source ip';
COMMENT ON COLUMN "config_info"."tenant_id" IS '租户字段';
COMMENT ON COLUMN "config_info"."encrypted_data_key" IS '秘钥';
COMMENT ON TABLE "config_info" IS 'config_info';-- ----------------------------
-- Table structure for config_info_aggr
-- ----------------------------
DROP TABLE IF EXISTS "config_info_aggr";
CREATE TABLE "config_info_aggr" ("id" bigserial NOT NULL,"data_id" varchar(255)  NOT NULL,"group_id" varchar(255)  NOT NULL,"datum_id" varchar(255)  NOT NULL,"content" text  NOT NULL,"gmt_modified" timestamp(6) NOT NULL,"app_name" varchar(128) ,"tenant_id" varchar(128) 
)
;
COMMENT ON COLUMN "config_info_aggr"."id" IS 'id';
COMMENT ON COLUMN "config_info_aggr"."data_id" IS 'data_id';
COMMENT ON COLUMN "config_info_aggr"."group_id" IS 'group_id';
COMMENT ON COLUMN "config_info_aggr"."datum_id" IS 'datum_id';
COMMENT ON COLUMN "config_info_aggr"."content" IS '内容';
COMMENT ON COLUMN "config_info_aggr"."gmt_modified" IS '修改时间';
COMMENT ON COLUMN "config_info_aggr"."tenant_id" IS '租户字段';
COMMENT ON TABLE "config_info_aggr" IS '增加租户字段';-- ----------------------------
-- Records of config_info_aggr
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for config_info_beta
-- ----------------------------
DROP TABLE IF EXISTS "config_info_beta";
CREATE TABLE "config_info_beta" ("id" bigserial NOT NULL,"data_id" varchar(255)  NOT NULL,"group_id" varchar(128)  NOT NULL,"app_name" varchar(128) ,"content" text  NOT NULL,"beta_ips" varchar(1024) ,"md5" varchar(32) ,"gmt_create" timestamp(6) NOT NULL,"gmt_modified" timestamp(6) NOT NULL,"src_user" text ,"src_ip" varchar(20) ,"tenant_id" varchar(128) ,"encrypted_data_key" text  NOT NULL
)
;
COMMENT ON COLUMN "config_info_beta"."id" IS 'id';
COMMENT ON COLUMN "config_info_beta"."data_id" IS 'data_id';
COMMENT ON COLUMN "config_info_beta"."group_id" IS 'group_id';
COMMENT ON COLUMN "config_info_beta"."app_name" IS 'app_name';
COMMENT ON COLUMN "config_info_beta"."content" IS 'content';
COMMENT ON COLUMN "config_info_beta"."beta_ips" IS 'betaIps';
COMMENT ON COLUMN "config_info_beta"."md5" IS 'md5';
COMMENT ON COLUMN "config_info_beta"."gmt_create" IS '创建时间';
COMMENT ON COLUMN "config_info_beta"."gmt_modified" IS '修改时间';
COMMENT ON COLUMN "config_info_beta"."src_user" IS 'source user';
COMMENT ON COLUMN "config_info_beta"."src_ip" IS 'source ip';
COMMENT ON COLUMN "config_info_beta"."tenant_id" IS '租户字段';
COMMENT ON COLUMN "config_info_beta"."encrypted_data_key" IS '秘钥';
COMMENT ON TABLE "config_info_beta" IS 'config_info_beta';-- ----------------------------
-- Records of config_info_beta
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for config_info_tag
-- ----------------------------
DROP TABLE IF EXISTS "config_info_tag";
CREATE TABLE "config_info_tag" ("id" bigserial NOT NULL,"data_id" varchar(255)  NOT NULL,"group_id" varchar(128)  NOT NULL,"tenant_id" varchar(128) ,"tag_id" varchar(128)  NOT NULL,"app_name" varchar(128) ,"content" text  NOT NULL,"md5" varchar(32) ,"gmt_create" timestamp(6) NOT NULL,"gmt_modified" timestamp(6) NOT NULL,"src_user" text ,"src_ip" varchar(20) 
)
;
COMMENT ON COLUMN "config_info_tag"."id" IS 'id';
COMMENT ON COLUMN "config_info_tag"."data_id" IS 'data_id';
COMMENT ON COLUMN "config_info_tag"."group_id" IS 'group_id';
COMMENT ON COLUMN "config_info_tag"."tenant_id" IS 'tenant_id';
COMMENT ON COLUMN "config_info_tag"."tag_id" IS 'tag_id';
COMMENT ON COLUMN "config_info_tag"."app_name" IS 'app_name';
COMMENT ON COLUMN "config_info_tag"."content" IS 'content';
COMMENT ON COLUMN "config_info_tag"."md5" IS 'md5';
COMMENT ON COLUMN "config_info_tag"."gmt_create" IS '创建时间';
COMMENT ON COLUMN "config_info_tag"."gmt_modified" IS '修改时间';
COMMENT ON COLUMN "config_info_tag"."src_user" IS 'source user';
COMMENT ON COLUMN "config_info_tag"."src_ip" IS 'source ip';
COMMENT ON TABLE "config_info_tag" IS 'config_info_tag';-- ----------------------------
-- Records of config_info_tag
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for config_tags_relation
-- ----------------------------
DROP TABLE IF EXISTS "config_tags_relation";
CREATE TABLE "config_tags_relation" ("id" bigserial NOT NULL,"tag_name" varchar(128)  NOT NULL,"tag_type" varchar(64) ,"data_id" varchar(255)  NOT NULL,"group_id" varchar(128)  NOT NULL,"tenant_id" varchar(128) ,"nid" bigserial NOT NULL
)
;
COMMENT ON COLUMN "config_tags_relation"."id" IS 'id';
COMMENT ON COLUMN "config_tags_relation"."tag_name" IS 'tag_name';
COMMENT ON COLUMN "config_tags_relation"."tag_type" IS 'tag_type';
COMMENT ON COLUMN "config_tags_relation"."data_id" IS 'data_id';
COMMENT ON COLUMN "config_tags_relation"."group_id" IS 'group_id';
COMMENT ON COLUMN "config_tags_relation"."tenant_id" IS 'tenant_id';
COMMENT ON TABLE "config_tags_relation" IS 'config_tag_relation';-- ----------------------------
-- Records of config_tags_relation
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for group_capacity
-- ----------------------------
DROP TABLE IF EXISTS "group_capacity";
CREATE TABLE "group_capacity" ("id" bigserial NOT NULL,"group_id" varchar(128)  NOT NULL,"quota" int4 NOT NULL,"usage" int4 NOT NULL,"max_size" int4 NOT NULL,"max_aggr_count" int4 NOT NULL,"max_aggr_size" int4 NOT NULL,"max_history_count" int4 NOT NULL,"gmt_create" timestamp(6) NOT NULL,"gmt_modified" timestamp(6) NOT NULL
)
;
COMMENT ON COLUMN "group_capacity"."id" IS '主键ID';
COMMENT ON COLUMN "group_capacity"."group_id" IS 'Group ID,空字符表示整个集群';
COMMENT ON COLUMN "group_capacity"."quota" IS '配额,0表示使用默认值';
COMMENT ON COLUMN "group_capacity"."usage" IS '使用量';
COMMENT ON COLUMN "group_capacity"."max_size" IS '单个配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "group_capacity"."max_aggr_count" IS '聚合子配置最大个数,,0表示使用默认值';
COMMENT ON COLUMN "group_capacity"."max_aggr_size" IS '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "group_capacity"."max_history_count" IS '最大变更历史数量';
COMMENT ON COLUMN "group_capacity"."gmt_create" IS '创建时间';
COMMENT ON COLUMN "group_capacity"."gmt_modified" IS '修改时间';
COMMENT ON TABLE "group_capacity" IS '集群、各Group容量信息表';-- ----------------------------
-- Records of group_capacity
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for his_config_info
-- ----------------------------
DROP TABLE IF EXISTS "his_config_info";
CREATE TABLE "his_config_info" ("id" int8 NOT NULL,"nid" bigserial NOT NULL,"data_id" varchar(255)  NOT NULL,"group_id" varchar(128)  NOT NULL,"app_name" varchar(128) ,"content" text  NOT NULL,"md5" varchar(32) ,"gmt_create" timestamp(6) NOT NULL  DEFAULT '2010-05-05 00:00:00',"gmt_modified" timestamp(6) NOT NULL,"src_user" text ,"src_ip" varchar(20) ,"op_type" char(10) ,"tenant_id" varchar(128) ,"encrypted_data_key" text  NOT NULL
)
;
COMMENT ON COLUMN "his_config_info"."app_name" IS 'app_name';
COMMENT ON COLUMN "his_config_info"."tenant_id" IS '租户字段';
COMMENT ON COLUMN "his_config_info"."encrypted_data_key" IS '秘钥';
COMMENT ON TABLE "his_config_info" IS '多租户改造';-- ----------------------------
-- Table structure for permissions
-- ----------------------------
DROP TABLE IF EXISTS "permissions";
CREATE TABLE "permissions" ("role" varchar(50)  NOT NULL,"resource" varchar(512)  NOT NULL,"action" varchar(8)  NOT NULL
)
;-- ----------------------------
-- Records of permissions
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for roles
-- ----------------------------
DROP TABLE IF EXISTS "roles";
CREATE TABLE "roles" ("username" varchar(50)  NOT NULL,"role" varchar(50)  NOT NULL
)
;-- ----------------------------
-- Records of roles
-- ----------------------------
BEGIN;
INSERT INTO "roles" VALUES ('nacos', 'ROLE_ADMIN');
COMMIT;-- ----------------------------
-- Table structure for tenant_capacity
-- ----------------------------
DROP TABLE IF EXISTS "tenant_capacity";
CREATE TABLE "tenant_capacity" ("id" bigserial NOT NULL,"tenant_id" varchar(128)  NOT NULL,"quota" int4 NOT NULL,"usage" int4 NOT NULL,"max_size" int4 NOT NULL,"max_aggr_count" int4 NOT NULL,"max_aggr_size" int4 NOT NULL,"max_history_count" int4 NOT NULL,"gmt_create" timestamp(6) NOT NULL,"gmt_modified" timestamp(6) NOT NULL
)
;
COMMENT ON COLUMN "tenant_capacity"."id" IS '主键ID';
COMMENT ON COLUMN "tenant_capacity"."tenant_id" IS 'Tenant ID';
COMMENT ON COLUMN "tenant_capacity"."quota" IS '配额,0表示使用默认值';
COMMENT ON COLUMN "tenant_capacity"."usage" IS '使用量';
COMMENT ON COLUMN "tenant_capacity"."max_size" IS '单个配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "tenant_capacity"."max_aggr_count" IS '聚合子配置最大个数';
COMMENT ON COLUMN "tenant_capacity"."max_aggr_size" IS '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "tenant_capacity"."max_history_count" IS '最大变更历史数量';
COMMENT ON COLUMN "tenant_capacity"."gmt_create" IS '创建时间';
COMMENT ON COLUMN "tenant_capacity"."gmt_modified" IS '修改时间';
COMMENT ON TABLE "tenant_capacity" IS '租户容量信息表';-- ----------------------------
-- Records of tenant_capacity
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for tenant_info
-- ----------------------------
DROP TABLE IF EXISTS "tenant_info";
CREATE TABLE "tenant_info" ("id" bigserial NOT NULL,"kp" varchar(128)  NOT NULL,"tenant_id" varchar(128) ,"tenant_name" varchar(128) ,"tenant_desc" varchar(256) ,"create_source" varchar(32) ,"gmt_create" int8 NOT NULL,"gmt_modified" int8 NOT NULL
)
;
COMMENT ON COLUMN "tenant_info"."id" IS 'id';
COMMENT ON COLUMN "tenant_info"."kp" IS 'kp';
COMMENT ON COLUMN "tenant_info"."tenant_id" IS 'tenant_id';
COMMENT ON COLUMN "tenant_info"."tenant_name" IS 'tenant_name';
COMMENT ON COLUMN "tenant_info"."tenant_desc" IS 'tenant_desc';
COMMENT ON COLUMN "tenant_info"."create_source" IS 'create_source';
COMMENT ON COLUMN "tenant_info"."gmt_create" IS '创建时间';
COMMENT ON COLUMN "tenant_info"."gmt_modified" IS '修改时间';
COMMENT ON TABLE "tenant_info" IS 'tenant_info';-- ----------------------------
-- Records of tenant_info
-- ----------------------------
BEGIN;
COMMIT;-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS "users";
CREATE TABLE "users" ("username" varchar(50)  NOT NULL,"password" varchar(500)  NOT NULL,"enabled" boolean NOT NULL
)
;-- ----------------------------
-- Records of users
-- ----------------------------
BEGIN;
INSERT INTO "users" VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
COMMIT;-- ----------------------------
-- Indexes structure for table config_info
-- ----------------------------
CREATE UNIQUE INDEX "uk_configinfo_datagrouptenant" ON "config_info" ("data_id","group_id","tenant_id");-- ----------------------------
-- Primary Key structure for table config_info
-- ----------------------------
ALTER TABLE "config_info" ADD CONSTRAINT "config_info_pkey" PRIMARY KEY ("id");-- ----------------------------
-- Indexes structure for table config_info_aggr
-- ----------------------------
CREATE UNIQUE INDEX "uk_configinfoaggr_datagrouptenantdatum" ON "config_info_aggr" USING btree ("data_id","group_id","tenant_id","datum_id");-- ----------------------------
-- Primary Key structure for table config_info_aggr
-- ----------------------------
ALTER TABLE "config_info_aggr" ADD CONSTRAINT "config_info_aggr_pkey" PRIMARY KEY ("id");-- ----------------------------
-- Indexes structure for table config_info_beta
-- ----------------------------
CREATE UNIQUE INDEX "uk_configinfobeta_datagrouptenant" ON "config_info_beta" USING btree ("data_id","group_id","tenant_id");-- ----------------------------
-- Primary Key structure for table config_info_beta
-- ----------------------------
ALTER TABLE "config_info_beta" ADD CONSTRAINT "config_info_beta_pkey" PRIMARY KEY ("id");-- ----------------------------
-- Indexes structure for table config_info_tag
-- ----------------------------
CREATE UNIQUE INDEX "uk_configinfotag_datagrouptenanttag" ON "config_info_tag" USING btree ("data_id","group_id","tenant_id","tag_id");-- ----------------------------
-- Primary Key structure for table config_info_tag
-- ----------------------------
ALTER TABLE "config_info_tag" ADD CONSTRAINT "config_info_tag_pkey" PRIMARY KEY ("id");-- ----------------------------
-- Indexes structure for table config_tags_relation
-- ----------------------------
CREATE INDEX "idx_tenant_id" ON "config_tags_relation" USING btree ("tenant_id"
);
CREATE UNIQUE INDEX "uk_configtagrelation_configidtag" ON "config_tags_relation" USING btree ("id","tag_name","tag_type"
);-- ----------------------------
-- Primary Key structure for table config_tags_relation
-- ----------------------------
ALTER TABLE "config_tags_relation" ADD CONSTRAINT "config_tags_relation_pkey" PRIMARY KEY ("nid");-- ----------------------------
-- Indexes structure for table group_capacity
-- ----------------------------
CREATE UNIQUE INDEX "uk_group_id" ON "group_capacity" USING btree ("group_id"
);-- ----------------------------
-- Primary Key structure for table group_capacity
-- ----------------------------
ALTER TABLE "group_capacity" ADD CONSTRAINT "group_capacity_pkey" PRIMARY KEY ("id");-- ----------------------------
-- Indexes structure for table his_config_info
-- ----------------------------
CREATE INDEX "idx_did" ON "his_config_info" USING btree ("data_id"
);
CREATE INDEX "idx_gmt_create" ON "his_config_info" USING btree ("gmt_create"
);
CREATE INDEX "idx_gmt_modified" ON "his_config_info" USING btree ("gmt_modified"
);-- ----------------------------
-- Primary Key structure for table his_config_info
-- ----------------------------
ALTER TABLE "his_config_info" ADD CONSTRAINT "his_config_info_pkey" PRIMARY KEY ("nid");-- ----------------------------
-- Indexes structure for table permissions
-- ----------------------------
CREATE UNIQUE INDEX "uk_role_permission" ON "permissions" USING btree ("role","resource","action"
);-- ----------------------------
-- Indexes structure for table roles
-- ----------------------------
CREATE UNIQUE INDEX "uk_username_role" ON "roles" USING btree ("username","role"
);-- ----------------------------
-- Indexes structure for table tenant_capacity
-- ----------------------------
CREATE UNIQUE INDEX "uk_tenant_id" ON "tenant_capacity" USING btree ("tenant_id"
);-- ----------------------------
-- Primary Key structure for table tenant_capacity
-- ----------------------------
ALTER TABLE "tenant_capacity" ADD CONSTRAINT "tenant_capacity_pkey" PRIMARY KEY ("id");-- ----------------------------
-- Indexes structure for table tenant_info
-- ----------------------------
CREATE UNIQUE INDEX "uk_tenant_info_kptenantid" ON "tenant_info" USING btree ("kp","tenant_id"
);
配置启动脚本
groupadd nacos
useradd -g nacos -s /usr/sbin/nologin nacos
chown -R nacos:nacos nacos
chmod +x nacos/bin/*.sh

编辑 nacos.service

vim /etc/systemd/system/nacos.service

写入下面内容:

[Unit]
Description=nacos
After=network.target[Service]
Type=forking
User=nacos
Group=nacosEnvironment='JAVA_HOME=/opt/jdk'ExecStart=sh /opt/nacos/bin/startup.sh -m standalone
ExecStop=sh /opt/nacos/bin/shutdown.sh[Install]
WantedBy=multi-user.target

设置开机启动 nacos

systemctl enable nacos

启动 nacos

systemctl start nacos

查看启动状态

systemctl status nacos

踩坑:

网上提供的修改application.properties文件的方式如下,测试后发现不能用,db.pool.config.driverClassName不识别。且注释db.pool.config.driverClassName,启动时数据库连接异常,启动不了。替换为上文中的方式配置后解决。

### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
spring.sql.init.platform=postgresql### Count of DB:
db.num=1### Connect URL of DB:
db.url.0=jdbc:postgresql://localhost:5432/nacos?tcpKeepAlive=true&reWriteBatchedInserts=true&ApplicationName=nacos-server
db.user.0=postgres
db.password.0=123456### Connection pool configuration: hikariCP
db.pool.config.driverClassName=org.postgresql.Driver

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/812809.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【解决方法】Hexo根据更新时间修改文章排序机制

前言(可不看) 之前由于电脑不在身边,长期通过其它电脑写文章利用之前说过的github action推送博客更新。但是发现一个问题,它总是按照文章创建时间排序,而不是文章更新时间。 查过网上很多方法,法一&#…

Swift中的结构体

Swift中的结构体是一种自定义的数据类型,可用于存储多个相关的值。结构体可以包含属性和方法,从而使其具有特定的功能。 结构体与类相似,但有一些重要的区别。最重要的区别是,结构体是值类型,而类是引用类型。这意味着…

二叉树遍历算法和应用

二叉树是指度为 2 的树。它是一种最简单却又最重要的树,在计算机领域中有这广泛的应用。 二叉树的递归定义如下:二叉树是一棵空树,或者一棵由一个根节点和两棵互不相交的分别称为根节点的左子树和右子树所组成的非空树,左子树和右…

【前端】解决前端图表大数据配色难题:利用HSL动态生成颜色方案

解决前端图表大数据配色难题:利用HSL动态生成颜色方案 在数据可视化项目中,尤其是当需要绘制包含大量数据点的图表时,一个常见的挑战是如何为每个数据点分配一个独特而又视觉上容易区分的颜色。使用固定的颜色列表可能在数据点数量超过列表限…

信号完整性之特性阻抗那些事儿

原文来自微信公众号:工程师看海,与我联系:chunhou0820 看海原创视频教程:《运放秘籍》 大家好,我是工程师看海。 我们经常说控制阻抗,这个阻抗是什么意思呢? 信号在传输线中,是一步…

使用Android Studio制作一个蓝牙软件 ---(一)

一、创建项目(项目名称---BluetoothActivity) 二、创建HomeActivity页面 1.点击一个文件夹 --- 鼠标右击 --- 新建 --- Acyivity --- Empty Views Activity 三、创建styles.xml 点击 values文件夹 --- 鼠标右击 --- 新建 --- Values Resource File sty…

数据结构----堆 和 堆排序 代码

目录 Heap.h Heap.c HeapTest.c Heap.h #pragma once/*堆*/ //完全二叉树 //可以用数组存&#xff0c;所以实现和数据结构很类似#include <stdio.h> #include <stdlib.h> #include <assert.h>/**/ #include <stdbool.h>#define InitSize 100 //#de…

【数据结构】04串

串 1. 定义2. 串的比较3. 串的存储结构4. 具体实现5. 模式匹配5.1 常规思路实现5.2 KMP模式匹配算法5.2.1 next数组计算5.2.1 代码计算next数组5.2.2 KMP算法实现 1. 定义 串(string)是由零个或多个字符组成的有限序列&#xff0c;又叫字符串。 一般记为s a 1 , a 2 , . . . ,…

NGO-VMD+皮尔逊系数+小波阈值降噪+重构

NGO-VMD皮尔逊系数小波阈值降噪重构 NGO-VMD皮尔逊系数小波阈值降噪重构代码获取戳此处代码获取戳此处 以西储大学轴承数据为例&#xff0c;进行VMD&#xff0c;且采用NGO进行K a参数寻优 并对分解分量计算皮尔逊相关系数筛选含噪声分量&#xff0c;对其进行小波软硬阈值降噪&a…

C++计算程序运行时间

引言 有时候我们需要简单计算下程序的运行时间&#xff0c;但又不想借助工具&#xff0c;而是简单的几行代码来粗略计算下时间&#xff0c;话不多说我们直接开始吧。 chrono库使用 C11中可以通过该库来实现&#xff0c;示例代码如下&#xff1a; #include <iostream>…

C/C++内存泄漏及检测

“该死系统存在内存泄漏问题”&#xff0c;项目中由于各方面因素&#xff0c;总是有人抱怨存在内存泄漏&#xff0c;系统长时间运行之后&#xff0c;可用内存越来越少&#xff0c;甚至导致了某些服务失败。内存泄漏是最难发现的常见错误之一&#xff0c;因为除非用完内存或调用…

【JAVA基础篇教学】第十篇:Java中Map详解说明

博主打算从0-1讲解下java基础教学&#xff0c;今天教学第十篇&#xff1a;Java中Map详解说明。 在 Java 编程中&#xff0c;Map 接口代表了一种键值对的集合&#xff0c;每个键对应一个值。Map 接口提供了一系列操作方法&#xff0c;可以方便地对键值对进行增删改查等操作。本…

好题推荐 CF1265E Beautiful Mirrors

题目传送门-洛谷 题目传送门-CF Part.1 题意 有 n n n 面镜子&#xff0c;第 i i i 个镜子有 p i 100 \frac{p_{i}}{100} 100pi​​ 的概率说 “你真好看”。一个人从第一个镜子开始&#xff0c;到第 n n n 个镜子说 “你真好看” 为止的天数期望&#xff0c;方式如下&am…

C++菜单查询

定义一个菜品类&#xff0c;包含菜名和菜价两个私有数据成员&#xff0c;设置菜名菜价&#xff0c;输出菜名菜价&#xff0c;获取菜价等共有成员函数。main函数中读入n个菜品的菜名和价格&#xff0c;然后输出菜价低于mprice的所有菜品信息(按输入顺序输出)&#xff0c;以及低于…

JavaScript:Object对象的属性方法

Object.defineProperty()方法: Object.defineProperty()方法---为对象添加属性---Vue的源码中经常用到 // 1 Object.defineProperty()方法---为对象添加属性---Vue的源码中经常用到const person {firstName: 呼呼,lastName: 憨憨}// // 为某个对象添加一个属性,并对该属性进…

模板方法模式:定义算法骨架的设计策略

在软件开发中&#xff0c;模板方法模式是一种行为型设计模式&#xff0c;它在父类中定义一个操作的算法框架&#xff0c;允许子类在不改变算法结构的情况下重定义算法的某些步骤。这种模式是基于继承的基本原则&#xff0c;通过抽象类达到代码复用的目的。本文将详细介绍模板方…

NASA数据集——亚洲夏季季风化学与气候影响项目超高灵敏度气溶胶光谱(UHSAS)数据

ACCLIP_Aerosol_AircraftInSitu_WB57_Data 简介 ACCLIP_Aerosol_AircraftInSitu_WB57_Data 是亚洲夏季季风化学与气候影响项目&#xff08;ACCLIP&#xff09;期间收集的原地气溶胶数据。本数据集收录了来自下一代激光质谱仪&#xff08;PALMS-NG&#xff09;、单颗粒烟尘光度…

一文读懂Partisia Blockchain,被严重低估的隐私区块链生态

在今年 3 月&#xff0c;隐私公链 Partisia Blockchain 迎来了重要的进展&#xff0c;该生态通证 $MPC 上线了交易所&#xff0c;目前 $MPC 通证可以在 Kucoin、Gate、BitMart、Bitfinex、Bitture 等平台交易&#xff0c;并将在不久后上线 MEXC 平台。 ​ 在上个月上线市场至今…

AIGC时代 可演进的私有云将蔚然成风

随着AIGC&#xff08;人工智能、大数据、云计算、物联网等技术的融合应用&#xff09;时代的来临&#xff0c;企业面临着前所未有的机遇与挑战。在这一时代背景下&#xff0c;IT基础设施如何平衡新旧资源、如何拥抱新技术应用&#xff0c;成为了企业信息化建设的核心议题。而私…

vim快捷指令

Vim是一款强大的文本编辑器&#xff0c;它提供了许多快捷指令来提高编辑效率。以下是一些常用的Vim快捷指令&#xff1a; 移动光标&#xff1a; h 向左移动一个字符j 向下移动一行k 向上移动一行l 向右移动一个字符w 跳到下一个单词的开头b 跳到前一个单词的开头e 跳到当前单词…