Win11安装Linux子系统Ubantu测试TSF4G

Win11安装Linux子系统Ubantu

Installing, this may take a few minutes… WslRegisterDistribution
failed with error: 0x800701bc Error: 0x800701bc WSL 2 ???
https://aka.ms/wsl2kernel
Press any key to continue…

更新wsl就可以

wsl --update
wsl --set-default-version 2

又有另一个错:

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370102
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/enablevirtualization
Press any key to continue...

在电脑硬件BIOS允许虚拟化后再启动Ubantu

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: root
adduser: The user `root'' already exists.
Enter new UNIX username: test
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.146.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


This message is shown once a day. To disable it please create the
/home/test/.hushlogin file.
test@WIN-20230921GZL:~$ cd /
test@WIN-20230921GZL:/$ ls
bin   dev  home  lib    lib64   lost+found  mnt  proc  run   snap  sys  usr
boot  etc  init  lib32  libx32  media       opt  root  sbin  srv   tmp  var
test@WIN-20230921GZL:/$

输入新的Unix用户名test密码也是test

支持解压和make

sudo apt install zip
sudo apt install make

下载腾讯TcaplusDB GCC SDK

wget https://tcaplusdb-sdk-1301716906.cos.ap-shanghai.myqcloud.com/2023SDK/c%2B%2B/tdr/TcaplusTdrApi3.55.0Gcc4.tar.gz

有一次无法打开Ubantu打开黑屏上不出字,其实等几分钟就出来了,再不行就执行这个:

netsh winsock reset

腾讯TSF4G编译

卡在缺少一个tprotocol库编译不过

test@WIN-20230921GZL:~/tsf4g/TSF4G-master$ make
cd tutils && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tutils'
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tutils'
cd tapp && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tapp'
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tapp'
cd tlog && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tlog'
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tlog'
cd tsocketapi && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tsocketapi'
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tsocketapi'
cd tbusapi && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tbusapi'
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tbusapi'
cd tbus && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tbus'
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tbus'
cd tbusmgr && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tbusmgr'
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tbusmgr'
cd tconnd && make;
make[1]: Entering directory '/home/test/tsf4g/TSF4G-master/tconnd'
gcc -L/usr/local/tlibc/lib -o bin/tconnd source/tconnd.o source/tconnd_epoll.o source/tconnd_listen.o source/tconnd_mempool.o source/tconnd_socket.o source/tconnd_tbus.o source/tconnd_timer.o tdr/tconnd_config_reader.o ..//tlog/lib/libtlog.a ..//tbus/lib/libtbus.a ..//tapp/lib/libtapp.a ..//tutils/lib/libtutils.a -lrt -ltprotocol
/usr/bin/ld: cannot find -ltprotocol: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [..//build.mk:50: bin/tconnd] Error 1
make[1]: Leaving directory '/home/test/tsf4g/TSF4G-master/tconnd'
make: *** [search.mk:24: tconnd] Error 2
test@WIN-20230921GZL:~/tsf4g/TSF4G-master$

-ltprotocol改为-ltlibc

包含文件路径增加-I$(TLIBC)/include/protocol -I$(TLIBC)/include/core

build.mk增加C编译选项-Wno-unused-result -Wno-format-truncation -Wno-unused-but-set-variable

tbus

TSF4G-master/tutorials/tbus

test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials$ ls
Makefile  tbus  tconnd  tlog  tutils
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials$ cd tbus/
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tbus$ ls
Makefile  tbus.sh  tbus_client  tbus_server
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tbus$ ./tbus.sh
ipcrm: invalid key (123456)
tbus_init succeed, shm_key = [123456] shm_size = [176].

查看tbus.sh的内容

#!/bin/bash

TBUSMGR=../../tbusmgr/bin/tbusmgr

ipcrm -M 123456
${TBUSMGR} -s 8 -n 10 -w 123456

ipcrm -M意思是IPC Remove ShareMemoryKeyLinux ipcs命令与ipcrm命令的用法详解-CSDN博客

ipcrm 命令  
移除一个消息对象。或者共享内存段,或者一个信号集,同时会将与ipc对象相关链的数据也一起移除。当然,只有超级管理员,或者ipc对象的创建者才有这项权利啦

ipcrm用法 
ipcrm -M shmkey  移除用shmkey创建的共享内存段
ipcrm -m shmid    移除用shmid标识的共享内存段
ipcrm -Q msgkey  移除用msqkey创建的消息队列
ipcrm -q msqid  移除用msqid标识的消息队列
ipcrm -S semkey  移除用semkey创建的信号
ipcrm -s semid  移除用semid标识的信号

tbusmgr命令行功能,上面用到-s -n -w 参考tbus-CSDN博客

test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tbus$ ../../tbusmgr/bin/tbusmgr
Missing --write
tbusmgr ([-s size] && [-n number] && [-w shmkey] | --help | --version)
--help, -h                Print the help.
--version, -v             Print the version.
--size, -s size           Set the maximum packet size.
--number, -n number       Set the maxinum packet number.
--write, -w tbuskey       Create shared memory segments with shmkey, and initialize the memory for tbus.
--dashboard, -d tbuskey   Show dashboard of the tbus channel.

可以查看共享内存的使用情况:

test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tbus$ ./tbus.sh
tbus_init succeed, shm_key = [123456] shm_size = [176].
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tbus$ ../../tbusmgr/bin/tbusmgr --dashboard 123456
used : 0, total : 160, percent : 0.00%.
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tbus$

一个服务器(一台电脑)上都有这个全局的tbusmgr管理的共享内存,用于进程间通信。

tutils

TSF4G-master/tutorials/tutils

把对象放在共享内存中,虽然解决了进程崩溃后内存数据不丢失的问题。但是在编程上带来很多限制,大部分C++特效都无法使用。库提供了三个常用基础操作简化编程。

1、静态内存Hash字典

共享内存的对象不能new不能malloc所以不能用stl的map。所以用纯C语言在指定内存区实现了Hash字典;

2、静态内存全局定时器

传统服务器没有全局定时器,所有对象都只有一个Update全局大循环事件可用,具体对象内部自己记住上次触发的时刻和当前时刻来判断是否超时,如果有1000个对象都有一个1小时后的操作,那么这一小时内每个大循环Update内(Update一般锁定每秒20次)都要有1000个if判断。全局定时器解决了这个问题,每个对象注册一个1小时的定时器事件,一小时后对1000个对象触发定时器事件。在这一个小时内,每个大循环Update只有一次if判断。

3、静态内存池

最简化的静态内存分配方式,不用也得用,没别的选择。

tconnd

首先启动,启动后另一个终端telnet 127.0.0.1 7001可以看到收到连接的输出提示

test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tconnd$ ./bin/tconnd ./etc/tconnd.xml
2024-03-24 14:15:56 [info] [32608] source/tconnd.c:56 | tconnd init succeed.

然后另一个终端启动逻辑服务器

test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tconnd$ ./tbus.sh
tbus_init succeed, shm_key = [10001] shm_size = [67116048].
tbus_init succeed, shm_key = [10002] shm_size = [67116048].
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tconnd$ ./tconnd_server/bin/tconnd_server

第三个终端启动客户端

test@WIN-20230921GZL:~/tsf4g/TSF4G-master$ cd tutorials/tconnd/
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tconnd$ cd tconnd_client/
test@WIN-20230921GZL:~/tsf4g/TSF4G-master/tutorials/tconnd/tconnd_client$ ./bin/tconnd_client ./etc/tconnd_client.xml
2024-03-24 14:27:44 [info] [35743] source/tconnd_client.c:388 | rtt(min, max) : 4294967295ms, 0ms, speed(total, total / 100) : 10775.20kb/s 107.75kb/s
2024-03-24 14:27:45 [info] [35743] source/tconnd_client.c:388 | rtt(min, max) : 4294967295ms, 0ms, speed(total, total / 100) : 0.00kb/s 0.00kb/s
2024-03-24 14:27:46 [info] [35743] source/tconnd_client.c:388 | rtt(min, max) : 4294967295ms, 0ms, speed(total, total / 100) : 0.00kb/s 0.00kb/s
2024-03-24 14:27:47 [info] [35743] source/tconnd_client.c:388 | rtt(min, max) : 4294967295ms, 0ms, speed(total, total / 100) : 0.00kb/s 0.00kb/s

trelaymgr

跨服务器(机器,电脑)进程间通信工具

trelaymgr没有开源,无法使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值