记录一次给linux服务器增加硬盘空间的过程

2024-09-09 16:25:39
26

### 记录扩容前的容量 ``` [root@bogon ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 1.8G 0 1.8G 0% /dev/shm tmpfs 732M 69M 663M 10% /run /dev/mapper/almalinux_bogon-root 28G 25G 3.3G 89% / /dev/sda1 960M 305M 656M 32% /boot overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/c67219235ece6b001270e0ba18fb12b71d5ef29f56ad1657b52898d5ecda0ae1/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/7ba5418e86a4693d32bdf915267ed46974e001c4bfc18dafbd751b78c10dcb3d/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/373f622dbfa34e162df44f008fbe58b5ca28decee24ff264aeb8adbb50de8895/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/ffd138dc98766c50935667425e2e21b76828c286b067f5e8bd12fd0855cb7e99/merged tmpfs 366M 36K 366M 1% /run/user/0 overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/e8ca2431071bfa0b466ad08bde3d15022eafb93c157b5d38f2a5642cf4de7c19/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/55451c06e7d124264e12f2044dacdef993771c7d07f88fc70c12b20a8eb80281/merged [root@bogon ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 32G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 31G 0 part ├─almalinux_bogon-root 253:0 0 27.8G 0 lvm / └─almalinux_bogon-swap 253:1 0 3.2G 0 lvm [SWAP] sr0 11:0 1 10.1G 0 rom ``` 可以看到,我的服务器磁盘是32G的,一共可用空间为28G,还剩下3.3G可以使用 ### 给服务器增加硬盘空间 我是通过pve给服务器增加的,很简单,通过后台增加了 ### 查看增加后的大小 ``` [root@bogon ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 1.8G 0 1.8G 0% /dev/shm tmpfs 732M 69M 663M 10% /run /dev/mapper/almalinux_bogon-root 28G 25G 3.3G 89% / /dev/sda1 960M 305M 656M 32% /boot overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/c67219235ece6b001270e0ba18fb12b71d5ef29f56ad1657b52898d5ecda0ae1/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/7ba5418e86a4693d32bdf915267ed46974e001c4bfc18dafbd751b78c10dcb3d/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/373f622dbfa34e162df44f008fbe58b5ca28decee24ff264aeb8adbb50de8895/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/ffd138dc98766c50935667425e2e21b76828c286b067f5e8bd12fd0855cb7e99/merged tmpfs 366M 36K 366M 1% /run/user/0 overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/e8ca2431071bfa0b466ad08bde3d15022eafb93c157b5d38f2a5642cf4de7c19/merged overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/55451c06e7d124264e12f2044dacdef993771c7d07f88fc70c12b20a8eb80281/merged [root@bogon ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 240G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 31G 0 part ├─almalinux_bogon-root 253:0 0 27.8G 0 lvm / └─almalinux_bogon-swap 253:1 0 3.2G 0 lvm [SWAP] sr0 11:0 1 10.1G 0 rom [root@bogon ~]# fdisk -l Disk /dev/sda: 240 GiB, 257698037760 bytes, 503316480 sectors Disk model: QEMU HARDDISK Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x1df92986 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 67108863 65009664 31G 8e Linux LVM Disk /dev/mapper/almalinux_bogon-root: 27.79 GiB, 29842472960 bytes, 58286080 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/almalinux_bogon-swap: 3.2 GiB, 3439329280 bytes, 6717440 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes ``` 我增加了208G之后,可以看到sda的这个硬盘变成了240G。但是`df -h`看到的可用空间还是没有变化,仍然是3.3G ### 开始扩容 通过`lsblk`看到我的磁盘名是 /dev/sda,对该磁盘剩余空间进行创建分区,并改为linux lvm。最后保存,全部操作步骤如下 ``` [root@bogon ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.37.4). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. This disk is currently in use - repartitioning is probably a bad idea. It's recommended to umount all file systems, and swapoff all swap partitions on this disk. Command (m for help): m Help: DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition Misc m print this menu u change display/entry units x extra functionality (experts only) Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file Save & Exit w write table to disk and exit q quit without saving changes Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p Partition number (3,4, default 3): 3 First sector (67108864-503316479, default 67108864): Last sector, +/-sectors or +/-size{K,M,G,T,P} (67108864-503316479, default 503316479): Created a new partition 3 of type 'Linux' and of size 208 GiB. Command (m for help): t Partition number (1-3, default 3): Hex code or alias (type L to list all): L 00 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 01 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 02 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 03 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT- 04 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 05 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 06 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 07 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 08 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 09 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access 0a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O 0b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor 0c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Linux extended 0e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs 0f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT 10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/ 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto 1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep 1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT Aliases: linux - 83 swap - 82 extended - 05 uefi - EF raid - FD lvm - 8E linuxex - 85 Hex code or alias (type L to list all): 8e Changed type of partition 'Linux' to 'Linux LVM'. Command (m for help): w The partition table has been altered. Syncing disks. ``` ### 查看现在的分区 ``` [root@bogon ~]# fdisk -l Disk /dev/sda: 240 GiB, 257698037760 bytes, 503316480 sectors Disk model: QEMU HARDDISK Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x1df92986 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 67108863 65009664 31G 8e Linux LVM /dev/sda3 67108864 503316479 436207616 208G 8e Linux LVM Disk /dev/mapper/almalinux_bogon-root: 27.79 GiB, 29842472960 bytes, 58286080 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/almalinux_bogon-swap: 3.2 GiB, 3439329280 bytes, 6717440 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes ``` 可以看到我多了一个/dev/sda3的分区,空间是208G,剩下的目标就是把这208G加到我现在的硬盘空间里 创建分区后,需要同步分区和创建物理卷。命令分别是`partprobe`和`pvcreate /dev/sda3` ``` [root@bogon ~]# partprobe Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. [root@bogon ~]# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created. ``` 使用partprobe命令同步分区的时候,提示我/dev/sro是只读状态打开,没法再使用读写状态打开。/dev/sro是光驱,由于我不需要对光驱进行操作,所以忽略即可。 查看物理卷和卷组 ``` [root@bogon ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name almalinux_bogon PV Size <31.00 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 7935 Free PE 0 Allocated PE 7935 PV UUID IvsatX-kddA-DN9A-Rr8l-B6bw-7O7w-NwCUgw "/dev/sda3" is a new physical volume of "208.00 GiB" --- NEW Physical volume --- PV Name /dev/sda3 VG Name PV Size 208.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID bba5Uh-eDiu-G4Fd-cM9e-2QZr-wl02-dcxiCc [root@bogon ~]# vgdisplay --- Volume group --- VG Name almalinux_bogon System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size <31.00 GiB PE Size 4.00 MiB Total PE 7935 Alloc PE / Size 7935 / <31.00 GiB Free PE / Size 0 / 0 VG UUID 9ZB2OX-wj6p-xcyq-LffN-9Ftu-ztW9-KoqO3c ``` 可以看到我有两个物理卷,原来的`/dev/sda2`有卷组,新建的那个`/dev/sda3`没有卷组,卷组名是`almalinux_bogon` 将创建的物理卷,加入到卷组中。命令`vgextend 卷组名 物理卷`, 其中卷组名是上一步获取的值,物理卷是新创建的物理卷。 对于我来说,命令就是 `vgextend almalinux_bogon /dev/sda3` ``` [root@bogon ~]# vgextend almalinux_bogon /dev/sda3 Volume group "almalinux_bogon" successfully extended ``` 将加入卷组的容量扩容到文件系统上,首先选择自己要挂载的扩展的文件系统 使用 `df-Th`命令查看,可以看到 ``` [root@bogon ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev tmpfs tmpfs 1.8G 0 1.8G 0% /dev/shm tmpfs tmpfs 732M 69M 663M 10% /run /dev/mapper/almalinux_bogon-root xfs 28G 25G 3.3G 89% / /dev/sda1 xfs 960M 305M 656M 32% /boot overlay overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/c67219235ece6b001270e0ba18fb12b71d5ef29f56ad1657b52898d5ecda0ae1/merged overlay overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/7ba5418e86a4693d32bdf915267ed46974e001c4bfc18dafbd751b78c10dcb3d/merged overlay overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/373f622dbfa34e162df44f008fbe58b5ca28decee24ff264aeb8adbb50de8895/merged overlay overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/ffd138dc98766c50935667425e2e21b76828c286b067f5e8bd12fd0855cb7e99/merged tmpfs tmpfs 366M 36K 366M 1% /run/user/0 overlay overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/e8ca2431071bfa0b466ad08bde3d15022eafb93c157b5d38f2a5642cf4de7c19/merged overlay overlay 28G 25G 3.3G 89% /var/lib/docker/overlay2/55451c06e7d124264e12f2044dacdef993771c7d07f88fc70c12b20a8eb80281/merged ``` 可以看到我挂在了根目录的文件系统是 `/dev/mapper/almalinux_bogon-root`,系统格式为`xfs`。 所以要执行的命令是 `lvextend -l +100%FREE /dev/mapper/almalinux_bogon-root` 执行命令之后 ``` [root@bogon ~]# lvextend -l +100%FREE /dev/mapper/almalinux_bogon-root Size of logical volume almalinux_bogon/root changed from 27.79 GiB (7115 extents) to <235.79 GiB (60362 extents). Logical volume almalinux_bogon/root successfully resized. ``` 最后要刷新文件系统的存储容量 文件类型是ext4的使用:resize2fs /dev/mapper/almalinux_bogon-root 文件类型是xfs的使用:xfs_growfs /dev/mapper/almalinux_bogon-root 我的是xfs,所以使用`xfs_growfs /dev/mapper/almalinux_bogon-root`命令 ``` [root@bogon ~]# xfs_growfs /dev/mapper/almalinux_bogon-root meta-data=/dev/mapper/almalinux_bogon-root isize=512 agcount=4, agsize=1821440 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=1 inobtcount=1 nrext64=0 data = bsize=4096 blocks=7285760, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=16384, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 7285760 to 61810688 [root@bogon ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev tmpfs tmpfs 1.8G 0 1.8G 0% /dev/shm tmpfs tmpfs 732M 69M 663M 10% /run /dev/mapper/almalinux_bogon-root xfs 236G 26G 210G 12% / /dev/sda1 xfs 960M 305M 656M 32% /boot overlay overlay 236G 26G 210G 12% /var/lib/docker/overlay2/c67219235ece6b001270e0ba18fb12b71d5ef29f56ad1657b52898d5ecda0ae1/merged overlay overlay 236G 26G 210G 12% /var/lib/docker/overlay2/7ba5418e86a4693d32bdf915267ed46974e001c4bfc18dafbd751b78c10dcb3d/merged overlay overlay 236G 26G 210G 12% /var/lib/docker/overlay2/373f622dbfa34e162df44f008fbe58b5ca28decee24ff264aeb8adbb50de8895/merged overlay overlay 236G 26G 210G 12% /var/lib/docker/overlay2/ffd138dc98766c50935667425e2e21b76828c286b067f5e8bd12fd0855cb7e99/merged tmpfs tmpfs 366M 36K 366M 1% /run/user/0 overlay overlay 236G 26G 210G 12% /var/lib/docker/overlay2/e8ca2431071bfa0b466ad08bde3d15022eafb93c157b5d38f2a5642cf4de7c19/merged overlay overlay 236G 26G 210G 12% /var/lib/docker/overlay2/55451c06e7d124264e12f2044dacdef993771c7d07f88fc70c12b20a8eb80281/merged ``` 可以看到我的磁盘空间总空间变成了236G,可用容量变成了210G了。扩容成功 参考地址:https://vip.kingdee.com/article/363708333012281088?productLineId=2&lang=zh-CN#1

记录常用的screen命令

2024-09-05 11:02:13
21

# 在主机外部时相关命令 ### 新建一个screen 使用`screen -S 名字`命令,例如`screen -S blog` 这样就新建了一个名为blog的screen ### 查看有哪些screen 可以使用`screen -ls`命令,例如 ``` [root@VM-0-15-centos frp]# screen -ls There are screens on: 19565.blog (Detached) 12426.fxserver (Attached) 22442.frp (Detached) 3 Sockets in /var/run/screen/S-root. ``` 看到后面有`Detached`的说明是已经分离了的 后面有`Attached`的说明有别的地方仍然连接在screen里面 19565和blog都可以作为那个screen的`会话标识` ### 回到分离screen 如果要回到一个分离的screen(后面有Detached的),使用`screen -r 会话标识`命令 比如`screen -r blog` ### 回到连接的screen 如果要回到一个连接的screen(后面有Attached的),使用`screen -x 会话标识`命令 比如`screen -x fxserver` # 在会话里面相关命令 先按ctrl+a,再按d,可以把会话 Detached(分离)出来,回到外部主机 先按ctrl+a,再按k,会提示是否把这个会话给关闭掉,再输入y即可关闭,即可回到外部主机 直接输入exit再回车,也会关闭会话回到外部主机

记录使用mybatis时的一些代码

2024-08-05 17:00:24
23

# mybatis篇 ### 外部传参英文逗号分隔的字符串 mapper中 `projectIds = 1,2,3` xml中 ```xml <if test="projectIds != null and projectIds != ''"> AND project.id IN <foreach collection="projectIds.split(',')" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> ``` 这样生成的sql就是 and project.id in (1,2,3) ### 外部传参时传入List<String> java中 ```java List<String> projectIdList = new ArrayList<>(); projectIdList.add("1"); projectIdList.add("2"); projectIdList.add("3"); ``` xml中 ```xml <if test = "projectIdList != null"> and project.id IN <foreach collection = "projectIdList" item = "id" open = "(" separator = "," close = ")"> #{id} </foreach> </if> ``` 这样生成的sql还是 project.id in ('1', '2', '3') ### 外部传入数组 mapper中 ```java public int deleteUserRole(Long[] ids); ``` xml中 ```xml <delete id="deleteUserRole" parameterType="Long"> delete from sys_user_role where user_id in <foreach collection="array" item="userId" open="(" separator="," close=")"> #{userId} </foreach> </delete> ``` ### 外部传入pojo列表 mapper中 ```java public int batchUserRole(List<SysUserRole> userRoleList); ``` xml中 ```xml insert into sys_user_role(user_id, role_id) values <foreach item="item" index="index" collection="list" separator=","> (#{item.userId},#{item.roleId}) </foreach> ``` pojo中有userId和roleId属性

centos安装Tesseract ocr

2023-12-10 17:47:07
15

### 第一种:原生安装 参考方法: https://dotatong.cn/index.php/archives/54/ 中间的秘钥是: ``` sudo rpm --import https://build.opensuse.org/projects/home:Alexander_Pozdnyakov/signing_keys/download?kind=gpg ``` ### 第二种: docker方式安装 先把镜像文件pull下来 ```docker pull jitesoft/tesseract-ocr``` 再执行 ``` docker run --rm -v /mnt/hgfs/project/post.jpg:/tmp/img.jpg -v /usr/share/tesseract/4/tessdata:/usr/local/share/tessdata jitesoft/tesseract-ocr /tmp/img.jpg stdout -l eng+chi_sim ``` --rm: 容器启用之后就删除 -v: 把本地的文件目录映射到容器里面 我的图片文件是`/mnt/hgfs/project/post.jpg`,对应容器内的`/tmp/img.jpg` 我的训练文件夹是:`/usr/share/tesseract/4/tessdata`,对应容器内的`/usr/local/share/tessdata` 然后stdout是指标准输出 -l 表示语言,多个语言用+来分隔,我的是eng(英语) + chi_sim(简体中文) 参考资料: https://blog.csdn.net/justlpf/article/details/127728286 https://packagist.org/packages/thiagoalessio/tesseract_ocr

记录一次用docker安装nacos的过程

2023-03-20 13:10:46
71

### 拉取镜像 docker pull nacos/nacos-server:2.0.2 ### 查看镜像是否拉取成功 docker images ### 启动容器(简单启动) docker run --name nacos-quick -e MODE=standalone -p 8848:8848 -d nacos/nacos-server:2.0.2 ### 测试nacos是否安装成功 访问127.0.0.1:8848/nacos即可 ### 查看容器内的日志 docker logs 2dab5d75a402 2dab5d75a402为容器id ### 修改数据库为mysql 默认的简单启动是使用nacos的本地数据库,我要切换成mysql #### 先新建一个nacos的数据库 地址:https://github.com/alibaba/nacos/blob/master/config/src/main/resources/META-INF/nacos-db.sql #### 再进入容器的命令行 docker exec -it 2dab5d75a402 /bin/bash #### 修改nacos配置 /home/nacos/init.d/custom.properties 即为nacos的配置文件 ``` server.contextPath=/nacos server.servlet.contextPath=/nacos server.port=8848 spring.datasource.platform=mysql db.num=1 db.url.0=jdbc:mysql://172.17.0.1:3306/nacos_config1characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=数据库用户名 db.password=数据库密码 nacos.cmdb.dumpTaskInterval=3600 nacos.cmdb.eventTaskInterval=10 nacos.cmdb.labelTaskInterval=300 nacos.cmdb.loadDataAtStart=false management.metrics.export.elastic.enabled=false management.metrics.export.influx.enabled=false server.tomcat.accesslog.enabled=true server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/** nacos.naming.distro.taskDispatchThreadCount=1 nacos.naming.distro.taskDispatchPeriod=200 nacos.naming.distro.batchSyncKeyCount=1000 nacos.naming.distro.initDataRatio=0.9 nacos.naming.distro.syncRetryDelay=5000 nacos.naming.data.warmup=true nacos.naming.expireInstance=true ``` #### 重新启动nacos使nacos的mysql配置生效 docker restart 2dab5d75a402 ### 再次访问naco测试是否生效 进入 127.0.0.1:8848/nacos 测试

记录一下自己重装centos系统之后安装的日常软件

2022-11-25 01:51:18
64

## 安装htop ``` yum install htop //有时候安装失败,是因为默认的源里没有htop,所以可以安装EPEL之后再次安装htop yum -y install epel-release yum install htop ``` 输入htop能够看到界面即安装完成 > 什么是EPEL? EPEL的全称叫 Extra Packages for Enterprise Linux 。EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。装上了 EPEL之后,就相当于添加了一个第三方源 ## 安装iftop iftop可以用于监控流量信息 ``` yum install iftop ``` 输入iftop能够看到界面即安装完成 默认iftop看到的传输单位为Kb而非KB,所以可以使用 iftop -B 来查看 ## 安装screen ``` yum install screen ``` 常用命令: screen -ls 查看会话列表 screen -S "name1" 创建一个名字为name1 的会话 ## 安装vim yum install vim

记录一次centos运行hyperf项目的过程

2022-11-06 23:02:38
44

# centos运行hyperf框架 > 由于今天在一个全新的服务器里要运行一个hyperf项目,就顺手记录一下跑起来的全过程 ## 1.检查环境配置 先要保证php以及swoole已经安装好了,执行php --ri swoole查看swoole扩展的信息 ``` swoole Swoole => enabled Author => Swoole Team <team@swoole.com> Version => 4.8.10 Built => Nov 6 2022 03:55:52 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.0.2k-fips 26 Jan 2017 http2 => enabled json => enabled curl-native => enabled pcre => enabled zlib => 1.2.7 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled async_redis => enabled Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 8388608 => 8388608 ``` 如果下面的swoole.use_shortname显示为on的话,是没法使用hyperf的,需要在配置文件里面改成off 在php.ini里面加入这样一行`swoole.use_shortname='Off'` 即可。 再次输入php --ri swoole,如果显示 `swoole.use_shortname => Off => Off` 那么说明设置成功了 ## 2.安装依赖 在项目目录下执行过composer install, 确保依赖都安装完成了 初次执行的时候,可能会失败,会报下面的一些错误,这是由于安装依赖时需要执行几个函数,而这几个函数由于安全原因被默认禁用了,所以需要到php.ini里面把这几个函数给取消限制。 ``` [Symfony\Component\Process\Exception\LogicException] The Process class relies on proc_open, which is not available on your PHP i nstallation. ``` #### 去php.ini里面把函数限制解除 在disable_functions这一项里面,把proc_open和proc_get_status删掉 ## 3.启动项目 执行命令: php bin/hyperf.php start

记录一些常用的java代码

2022-09-01 15:14:33
53

### 数组转换成以逗号分隔开的字符串 ``` java String[] strArray = {"aaa","bbb","ccc"}; String str= StringUtils.join(strArry,","); System.out.println(str); ``` ### 以逗号分隔开的字符串转换成数组 ```java String str = "aaa,bbb,ccc"; String[] strArray = str.split(","); for(String s : strArray){ System.out.println(s); } ```

mac m1上使用rust编译openssl-sys失败的一次记录

2022-04-25 20:43:14
93

mac m1 编译openssl-sys的时候报错: 遇到错误,报错信息如下 ``` admin@admindeMacBook-Air b3 % cargo run Compiling openssl-sys v0.9.72 error: failed to run custom build command for `openssl-sys v0.9.72` Caused by: process didn't exit successfully: `/Users/admin/project/b3/target/debug/build/openssl-sys-7ab7e6047ef6ec59/build-script-main` (exit status: 101) --- stdout cargo:rustc-cfg=const_fn cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=OPENSSL_LIB_DIR OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_DIR AARCH64_APPLE_DARWIN_OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_DIR OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin cargo:rerun-if-env-changed=HOST_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=OPENSSL_STATIC cargo:rerun-if-env-changed=OPENSSL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR run pkg_config fail: "Could not run `\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"`\nThe pkg-config command could not be found.\n\nMost likely, you need to install a pkg-config package for your OS.\nTry `brew install pkg-config` if you have Homebrew.\n\nIf you've already installed it, ensure the pkg-config command is one of the\ndirectories in the PATH environment variable.\n\nIf you did not expect this build to link to a pre-installed system library,\nthen check documentation of the openssl-sys crate for an option to\nbuild the library from source, or disable features or dependencies\nthat require pkg-config." --- stderr thread 'main' panicked at ' Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set the `OPENSSL_DIR` environment variable for the compilation process. Make sure you also have the development packages of openssl installed. For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora. If you're in a situation where you think the directory *should* be found automatically, please open a bug at https://github.com/sfackler/rust-openssl and include information about your system as well as this message. $HOST = aarch64-apple-darwin $TARGET = aarch64-apple-darwin openssl-sys = 0.9.72 ', /Users/admin/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/openssl-sys-0.9.72/build/find_normal.rs:180:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` 同样的代码在ubuntu上正常,但是在mac m1上面无法编译,根据报错信息所以猜测是openssl-sys这个库需要调用本机上的openssl,但是无法找到。 找到了一篇文档, https://reality0ne.com/macos-xia-shi-yong-rust-openssl/ 执行文章中的命令: ``` $ cargo clean $ export OPENSSL_LIB_DIR=$(brew --prefix openssl)/lib $ export OPENSSL_INCLUDE_DIR=$(brew --prefix openssl)/include $ cargo build $ cargo test ``` 然后到项目里面cargo run一下,仍然报错 ``` admin@admindeMacBook-Air b3 % cargo run Compiling openssl-sys v0.9.72 Compiling socket2 v0.4.3 Compiling memmap2 v0.5.3 Compiling rand v0.4.6 Compiling memmap v0.7.0 Compiling quote v1.0.15 Compiling twoway v0.1.8 Compiling buf_redux v0.8.4 error: failed to run custom build command for `openssl-sys v0.9.72` Caused by: process didn't exit successfully: `/Users/admin/project/b3/target/debug/build/openssl-sys-7ab7e6047ef6ec59/build-script-main` (exit status: 101) --- stdout cargo:rustc-cfg=const_fn cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=OPENSSL_LIB_DIR OPENSSL_LIB_DIR = /opt/homebrew/opt/openssl@3/lib cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR OPENSSL_INCLUDE_DIR = /opt/homebrew/opt/openssl@3/include --- stderr thread 'main' panicked at 'OpenSSL library directory does not exist: /opt/homebrew/opt/openssl@3/lib', /Users/admin/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/openssl-sys-0.9.72/build/main.rs:68:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... ``` 这个提示大概看懂了,意思是openssl的库在/opt/homebrew/opt/openssl@3/lib下不存在,cd到这个目录之后发现确实不存在 ``` admin@admindeMacBook-Air opt % ls pkg-config pkgconfig ``` 所以打算用homebrew重新安装一下,这里使用了这个作者的方法 https://zhuanlan.zhihu.com/p/111014448 (homebrew国内镜像安装) 然后执行`brew install openssl` 执行过程: ``` admin@admindeMacBook-Air opt % brew install openssl Error: homebrew-core is a shallow clone. homebrew-cask is a shallow clone. To `brew update`, first run: git -C /opt/homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow git -C /opt/homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow These commands may take a few minutes to run due to the large size of the repositories. This restriction has been made on GitHub's request because updating shallow clones is an extremely expensive operation due to the tree layout and traffic of Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you automatically to avoid repeatedly performing an expensive unshallow operation in CI systems (which should instead be fixed to not use shallow clones). Sorry for the inconvenience! ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/ca-certificates-2022-03-29.all.bottle.tar.gz ######################################################################## 100.0% ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/openssl%403-3.0.2.arm64_big_sur.bottle.tar.gz ######################################################################## 100.0% ==> Installing dependencies for openssl@3: ca-certificates ==> Installing openssl@3 dependency: ca-certificates ==> Pouring ca-certificates-2022-03-29.all.bottle.tar.gz ==> Regenerating CA certificate bundle from keychain, this may take a while... 🍺 /opt/homebrew/Cellar/ca-certificates/2022-03-29: 3 files, 211.5KB ==> Installing openssl@3 ==> Pouring openssl@3-3.0.2.arm64_big_sur.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /opt/homebrew/etc/openssl@3/certs and run /opt/homebrew/opt/openssl@3/bin/c_rehash openssl@3 is keg-only, which means it was not symlinked into /opt/homebrew, because macOS provides LibreSSL. If you need to have openssl@3 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"' >> ~/.zshrc For compilers to find openssl@3 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib" export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include" For pkg-config to find openssl@3 you may need to set: export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig" ==> Summary 🍺 /opt/homebrew/Cellar/openssl@3/3.0.2: 6,429 files, 28.0MB ==> Running `brew cleanup openssl@3`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). ==> Caveats ==> openssl@3 A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /opt/homebrew/etc/openssl@3/certs and run /opt/homebrew/opt/openssl@3/bin/c_rehash openssl@3 is keg-only, which means it was not symlinked into /opt/homebrew, because macOS provides LibreSSL. If you need to have openssl@3 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"' >> ~/.zshrc For compilers to find openssl@3 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib" export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include" For pkg-config to find openssl@3 you may need to set: export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig" ``` 安装完成之后然后再ls一下,发现目录下 openssl@3 在目录下面了 ``` admin@admindeMacBook-Air opt % ls ca-certificates openssl openssl@3 pkg-config pkgconfig ``` 这样的话,环境变量OPENSSL_LIB_DIR、OPENSSL_INCLUDE_DIR指向的目录也都存在了, 然后再cargo run 一下,发现程序正常了,问题解决!

fltk-rs踩坑记录,解决could not find native static library cfltk, perhaps an -L flag is missing 问题

2022-03-18 20:52:15
123

# fltk-rs踩坑记录 > 最近想用rust写一个简单的gui程序,所以查了一下rust的gui库,好像rust在gui方面发展还不好,但是我要实现的很简单,所以最终选择了fltk-rs来开发。 现在只是为了跑通helloworld,所以只碰到这一个问题,以后在碰到别的会再补充。 ## 项目地址: https://github.com/fltk-rs/fltk-rs ## 按说明安装 按照作者的说明,依赖添加为 ``` [dependencies] fltk = "^1.3" ``` 然后把helloworld的代码写好后,执行cargo run。 但是编译的时候出现问题,总是报错 ``` Compiling fltk-sys v1.0.17 Compiling fltk v1.0.18 error: could not find native static library cfltk, perhaps an -L flag is missing? error: aborting due to previous error error: could not compile fltk-sys ``` ## 找寻解决方案 于是我在作者的github的issue里面找到了一个类似的,https://github.com/fltk-rs/fltk-rs/issues/723, 但是得到的答案是把依赖改为 ``` [dependencies] fltk = { version = "1", features = ["fltk-bundled"] } ``` 还有一个也比较类似: https://github.com/fltk-rs/fltk-rs/discussions/1116 最终在这里找到了答案: https://fltk-rs.github.io/fltk-book/Setup.html#detailed-setup 原来运行fltk-rs需要在电脑上安装有cmake和git,我电脑上`没有安装cmake`,所以有这个报错信息。 所以我的目的就是安装cmake ## 检测是否安装了cmake 在命令行中输入 cmake --version 如果返回了版本信息,就说明安装成功了,否则就是未安装成功 ``` mac安装地址: https://blog.csdn.net/xujiuba/article/details/107234040 windows安装教程: https://blog.csdn.net/u011231598/article/details/80338941 ``` 按照教程安装完成之后,要重新打开一个shell(在安装cmake之前的shell界面没法使用到cmake命令),然后输入`cmake --version`,能看到版本信息即为安装成功 ## 最后再编译 保证 `git --version` 和 `cmake --version` 能够获取到版本信息,则可以再次编译项目了 这次应该就可以成功编译了。 ## 其他问题 - 如果是windows的话,build之后的exe文件运行的时候,后面总有一个黑色的命令行界面,如何去除? 在main.rs 的最前面加上 `#![windows_subsystem = "windows"]` ,然后再编译即可

  • 1
  • 2
  • 3
  • 4
列表为空