最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

游戲服務(wù)器中的Netty應(yīng)用以及源碼剖析

 更新時(shí)間:2022年08月26日 16:38:48   作者:HenryBlog  
這篇文章主要為大家介紹了游戲服務(wù)器中的Netty應(yīng)用以及源碼剖析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

一、Reactor模式和Netty線程模型

最近因?yàn)楣ぷ餍枰瑢W(xué)習(xí)了一段時(shí)間Netty的源碼,并做了一個(gè)簡(jiǎn)單的分享,研究還不是特別深入,繼續(xù)努力。因?yàn)榉窒硪膊簧婕肮緲I(yè)務(wù),所以這里也把這次對(duì)源碼的研究成果分享出來(lái) 以下都是在游戲服務(wù)器開發(fā)中針對(duì)Netty使用需要了解知識(shí)點(diǎn)以及相關(guān)優(yōu)化

這次分享主要設(shè)計(jì)以下內(nèi)容

  • Netty線程模型
  • Netty對(duì)TCP相關(guān)參數(shù)的配置和具體含義
  • Netty對(duì)Epoll的封裝
  • Netty的優(yōu)雅關(guān)閉

客戶端連接數(shù)的限制

  • 內(nèi)存資源
  • CPU資源

端口號(hào)資源

cat /proc/sys/net/ipv4/ip_local_port_range

文件描述符資源

  • 系統(tǒng)級(jí):當(dāng)前系統(tǒng)可打開的最大數(shù)量,通過(guò) cat /proc/sys/fs/file-max 查看
  • 用戶級(jí):指定用戶可打開的最大數(shù)量,通過(guò) cat /etc/security/limits.conf 查看
  • 進(jìn)程級(jí):?jiǎn)蝹€(gè)進(jìn)程可打開的最大數(shù)量,通過(guò) cat /proc/sys/fs/nr_open 查看
  • 線程資源 BIO/NIO

1. BIO模型

  • 所有操作都是同步阻塞(accept,read)
  • 客戶端連接數(shù)與服務(wù)器線程數(shù)比例是1:1

2. NIO模型

  • 非阻塞IO
  • 通過(guò)selector實(shí)現(xiàn)可以一個(gè)線程管理多個(gè)連接
  • 通過(guò)selector的事件注冊(cè)(OP_READ/OP_WRITE/OP_CONNECT/OP_ACCEPT),處理自己感興趣的事件

客戶端連接數(shù)與服務(wù)器線程數(shù)比例是n:1

3. Reacor模型

①. 單Reacor單線程模型

    所有IO在同一個(gè)NIO線程完成(處理連接,分派請(qǐng)求,編碼,解碼,邏輯運(yùn)算,發(fā)送)

優(yōu)點(diǎn)

  • 編碼簡(jiǎn)單
  • 不存在共享資源競(jìng)爭(zhēng)
  • 并發(fā)安全

缺點(diǎn)

  • 單線程處理大量鏈路時(shí),性能無(wú)法支撐,不能合理利用多核處理
  • 線程過(guò)載后,處理速度變慢,會(huì)導(dǎo)致消息積壓
  • 一旦線程掛掉,整個(gè)通信層不可用 redis使用的就是reactor單進(jìn)程模型,redis由于都是內(nèi)存級(jí)操作,所以使用此模式?jīng)]什么問(wèn)題

reactor單線程模型圖

netty reactor單線程模型圖

Netty對(duì)應(yīng)實(shí)現(xiàn)方式

// Netty對(duì)應(yīng)實(shí)現(xiàn)方式:創(chuàng)建io線程組是,boss和worker,使用同一個(gè)線程組,并且線程數(shù)為1
EventLoopGroup ioGroup = new NioEventLoopGroup(1);
b.group(ioGroup, ioGroup)
        .channel(NioServerSocketChannel.class)
        .childHandler(initializer);
ChannelFuture f = b.bind(portNumner);
cf = f.sync();
f.get();

②. 單Reactor多線程模型

根據(jù)單線程模型,io處理中最耗時(shí)的編碼,解碼,邏輯運(yùn)算等cpu消耗較多的部分,可提取出來(lái)使用多線程實(shí)現(xiàn),并充分利用多核cpu的優(yōu)勢(shì)

優(yōu)點(diǎn)

多線程處理邏輯運(yùn)算,提高多核CPU利用率

缺點(diǎn)

對(duì)于單Reactor來(lái)說(shuō),大量鏈接的IO事件處理依然是性能瓶頸

reactor多線程模型圖

netty reactor多線程模型圖

Netty對(duì)應(yīng)實(shí)現(xiàn)方式

// Netty對(duì)應(yīng)實(shí)現(xiàn)方式:創(chuàng)建io線程組是,boss和worker,使用同一個(gè)線程組,并且線程數(shù)為1,把邏輯運(yùn)算部分投遞到用戶自定義線程處理
EventLoopGroup ioGroup = new NioEventLoopGroup(1);
b.group(ioGroup, ioGroup)
        .channel(NioServerSocketChannel.class)
        .childHandler(initializer);
ChannelFuture f = b.bind(portNumner);
cf = f.sync();
f.get();

③. 主從Reactor多線程模型

根據(jù)多線程模型,可把它的性能瓶頸做進(jìn)一步優(yōu)化,即把reactor由單個(gè)改為reactor線程池,把原來(lái)的reactor分為mainReactor和subReactor

優(yōu)點(diǎn)

  • 解決單Reactor的性能瓶頸問(wèn)題(Netty/Nginx采用這種設(shè)計(jì))

reactor主從多線程模型圖

netty reactor主從多線程模型圖

Netty對(duì)應(yīng)實(shí)現(xiàn)方式

// Netty對(duì)應(yīng)實(shí)現(xiàn)方式:創(chuàng)建io線程組boss和worker,boss線程數(shù)為1,work線程數(shù)為cpu*2(一般IO密集可設(shè)置為2倍cpu核數(shù))
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
EventLoopGroup workerGroup = new NioEventLoopGroup();
b.group(bossGroup, workerGroup)
        .channel(NioServerSocketChannel.class)
        .childHandler(initializer);
ChannelFuture f = b.bind(portNumner);
cf = f.sync();
f.get();

④. 部分源碼分析

  • 創(chuàng)建group實(shí)例
// 1.構(gòu)造參數(shù)不傳或傳0,默認(rèn)取系統(tǒng)參數(shù)配置,沒(méi)有參數(shù)配置,取CPU核數(shù)*2
super(nThreads == 0 ? DEFAULT_EVENT_LOOP_THREADS : nThreads, executor, args);
private static final int DEFAULT_EVENT_LOOP_THREADS;
static {
    DEFAULT_EVENT_LOOP_THREADS = Math.max(1, SystemPropertyUtil.getInt(
            "io.netty.eventLoopThreads", NettyRuntime.availableProcessors() * 2));
}
// 2.不同版本的JDK會(huì)有不同版本的SelectorProvider實(shí)現(xiàn),Windows下的是WindowsSelectorProvider
public NioEventLoopGroup(int nThreads, Executor executor) {
    //默認(rèn)selector,最終實(shí)現(xiàn)類似:https://github.com/frohoff/jdk8u-jdk/blob/master/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
    //basic flow: 1 java.nio.channels.spi.SelectorProvider 2 META-INF/services 3 default
    this(nThreads, executor, SelectorProvider.provider());
}
// 3.創(chuàng)建nThread個(gè)EventExecutor,并封裝到選擇器chooser,chooser會(huì)根據(jù)線程數(shù)分別有兩種實(shí)現(xiàn)(GenericEventExecutorChooser和PowerOfTwoEventExecutorChooser,算法不同,但實(shí)現(xiàn)邏輯一樣,就是均勻的分配線程處理)
EventExecutorChooserFactory.EventExecutorChooser chooser;
children = new EventExecutor[nThreads];
for (int i = 0; i < nThreads; i ++) {
    // ...
    children[i] = newChild(executor, args);
    // ...
}
chooser = chooserFactory.newChooser(children);
  • 設(shè)置group
// 兩種方式設(shè)置group
// parent和child使用同一個(gè)group,調(diào)用仍然是分別設(shè)置parent和child
@Override
public ServerBootstrap group(EventLoopGroup group) {
    return group(group, group);
}
ServerBootstrap.group(EventLoopGroup parentGroup, EventLoopGroup childGroup){
    // 具體代碼略,可直接參考源碼
    // 里面實(shí)現(xiàn)內(nèi)容是把parentGroup綁定到this.group,把childGroup綁定到this.childGroup
}
  • Netty啟動(dòng)
// 調(diào)用順序
ServerBootstrap:bind() -> doBind() -> initAndRegister()
private ChannelFuture doBind(final SocketAddress localAddress) {
    final ChannelFuture regFuture = initAndRegister();
    // ...
    doBind0(regFuture, channel, localAddress, promise);
    // ...
}
final ChannelFuture initAndRegister() {
    // 創(chuàng)建ServerSocketChannel
    Channel channel = channelFactory.newChannel();
    // ...
    // 開始register
    ChannelFuture regFuture = config().group().register(channel);
    // register調(diào)用順序
    // next().register(channel) -> (EventLoop) super.next() -> chooser.next()
    // ...
}

由以上源碼可得知,bind只在起服調(diào)用一次,因此bossGroup僅調(diào)用一次regist,也就是僅調(diào)用一次next,因此只有一根線程是有用的,其余線程都是廢棄的,所以bossGroup線程數(shù)設(shè)置為1即可

// 啟動(dòng)BossGroup線程并綁定本地SocketAddress
private static void doBind0(
        final ChannelFuture regFuture, final Channel channel,
        final SocketAddress localAddress, final ChannelPromise promise) {
    channel.eventLoop().execute(new Runnable() {
        @Override
        public void run() {
            if (regFuture.isSuccess()) {
                channel.bind(localAddress, promise).addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
            } else {
                promise.setFailure(regFuture.cause());
            }
        }
    });
}
  • 客戶端連接
// 消息事件讀取
NioEventLoop.run() -> processSelectedKeys() -> ... -> ServerBootstrapAcceptor.channelRead
// ServerBootstrapAcceptor.channelRead處理客戶端連接事件
// 最后一行的childGroup.register的邏輯和上面的代碼調(diào)用處一樣
public void channelRead(ChannelHandlerContext ctx, Object msg) {
    child.pipeline().addLast(childHandler);
    setChannelOptions(child, childOptions, logger);
    setAttributes(child, childAttrs);
    childGroup.register(child)
}

二、select/poll和epoll

1.概念

  • select(時(shí)間復(fù)雜度O(n)):用一個(gè)fd數(shù)組保存所有的socket,然后通過(guò)死循環(huán)遍歷調(diào)用操作系統(tǒng)的select方法找到就緒的fd
while(1) {
  nready = select(list);
  // 用戶層依然要遍歷,只不過(guò)少了很多無(wú)效的系統(tǒng)調(diào)用
  for(fd <-- fdlist) {
    if(fd != -1) {
      // 只讀已就緒的文件描述符
      read(fd, buf);
      // 總共只有 nready 個(gè)已就緒描述符,不用過(guò)多遍歷
      if(--nready == 0) break;
    }
  }
}

poll(時(shí)間復(fù)雜度O(n)):同select,不過(guò)把fd數(shù)組換成了fd鏈表,去掉了fd最大連接數(shù)(1024個(gè))的數(shù)量限制

epoll(時(shí)間復(fù)雜度O(1)):解決了select/poll的幾個(gè)缺陷

  • 調(diào)用需傳入整個(gè)fd數(shù)組或fd鏈表,需要拷貝數(shù)據(jù)到內(nèi)核
  • 內(nèi)核層需要遍歷檢查文件描述符的就緒狀態(tài)
  • 內(nèi)核僅返回可讀文件描述符個(gè)數(shù),用戶仍需自己遍歷所有fd

epoll是操作系統(tǒng)基于事件關(guān)聯(lián)fd,做了以下優(yōu)化:

  • 內(nèi)核中保存一份文件描述符集合,無(wú)需用戶每次都重新傳入,只需告訴內(nèi)核修改的部分即可。(epoll_ctl)
  • 內(nèi)核不再通過(guò)輪詢的方式找到就緒的文件描述符,而是通過(guò)異步 IO 事件喚醒。(epoll_wait)
  • 內(nèi)核僅會(huì)將有 IO 事件的文件描述符返回給用戶,用戶也無(wú)需遍歷整個(gè)文件描述符集合。

epoll僅在Linux系統(tǒng)上支持

2.jdk提供selector

// DefaultSelectorProvider.create方法在不同版本的jdk下有不同實(shí)現(xiàn),創(chuàng)建不同Selector
// Windows版本的jdk,其實(shí)現(xiàn)中調(diào)用的是native的poll方法
public static SelectorProvider create() {
    return new WindowsSelectorProvider();
}
// Linux版本的jdk
public static SelectorProvider create() {
    String str = (String)AccessController.doPrivileged(new GetPropertyAction("os.name"));
    if (str.equals("SunOS")) {
        return createProvider("sun.nio.ch.DevPollSelectorProvider");
    }
    if (str.equals("Linux")) {
        return createProvider("sun.nio.ch.EPollSelectorProvider");
    }
    return new PollSelectorProvider();
}

3.Netty提供的Epoll封裝

netty依然基于epoll做了一層封裝,主要做了以下事情:

(1)java的nio默認(rèn)使用水平觸發(fā),Netty的Epoll默認(rèn)使用邊緣觸發(fā),且可配置

  • 邊緣觸發(fā):當(dāng)狀態(tài)變化時(shí)才會(huì)發(fā)生io事件。
  • 水平觸發(fā):只要滿足條件,就觸發(fā)一個(gè)事件(只要有數(shù)據(jù)沒(méi)有被獲取,內(nèi)核就不斷通知你)

(2)Netty的Epoll提供更多的nio的可配參數(shù)。

(3)調(diào)用c代碼,更少gc,更少synchronized 具體可以參考源碼NioEventLoop.run和EpollEventLoop.run進(jìn)行對(duì)比

4.Netty相關(guān)類圖

線程組類圖

channel類圖

5.配置Netty為EpollEventLoop

// 創(chuàng)建指定的EventLoopGroup
bossGroup = new EpollEventLoopGroup(1, new DefaultThreadFactory("BOSS_LOOP"));
workerGroup = new EpollEventLoopGroup(32, new DefaultThreadFactory("IO_LOOP"));
b.group(bossGroup, workerGroup)
        // 指定channel的class
        .channel(EpollServerSocketChannel.class)
        .childHandler(initializer);
// 其中channel(clz)方法是通過(guò)class來(lái)new一個(gè)反射ServerSocketChannel創(chuàng)建工廠類
public B channel(Class<? extends C> channelClass) {
    if (channelClass == null) {
        throw new NullPointerException("channelClass");
    }
    return channelFactory(new ReflectiveChannelFactory<C>(channelClass));
}
final ChannelFuture initAndRegister() {
    // ...
    Channel channel = channelFactory.newChannel();
    // ...
}

三、Netty相關(guān)參數(shù)

1.SO_KEEPALIVE

childOption(ChannelOption.SO_KEEPALIVE, true)

TCP鏈路探活

2.SO_REUSEADDR

option(ChannelOption.SO_REUSEADDR, true)

重用處于TIME_WAIT但是未完全關(guān)閉的socket地址,讓端口釋放后可立即被重用。默認(rèn)關(guān)閉,需要手動(dòng)開啟

3.TCP_NODELAY

childOption(ChannelOption.TCP_NODELAY, true)

IP報(bào)文格式

TCP報(bào)文格式

開啟則禁用TCP Negal算法,優(yōu)點(diǎn)低延時(shí),缺點(diǎn)在大量小數(shù)據(jù)包的情況下,網(wǎng)絡(luò)利用率低

關(guān)閉則開啟TCP Negal算法,優(yōu)點(diǎn)提高網(wǎng)絡(luò)利用率(數(shù)據(jù)緩存到一定量才發(fā)送),缺點(diǎn)延時(shí)高

Negal算法

  • 如果包長(zhǎng)度達(dá)到MSS(maximum segment size最大分段長(zhǎng)度),則允許發(fā)送;
  • 如果該包含有FIN,則允許發(fā)送;
  • 設(shè)置了TCP_NODELAY選項(xiàng),則允許發(fā)送;
  • 未設(shè)置TCP_CORK選項(xiàng)(是否阻塞不完整報(bào)文)時(shí),若所有發(fā)出去的小數(shù)據(jù)包(包長(zhǎng)度小于MSS)均被確認(rèn),則允許發(fā)送;
  • 上述條件都未滿足,但發(fā)生了超時(shí)(一般為200ms),則立即發(fā)送。

MSS計(jì)算規(guī)則 MSS的值是在TCP三次握手建立連接的過(guò)程中,經(jīng)通信雙方協(xié)商確定的 802.3標(biāo)準(zhǔn)里,規(guī)定了一個(gè)以太幀的數(shù)據(jù)部分(Payload)的最大長(zhǎng)度是1500個(gè)字節(jié)(MTU)

MSS = MTU - IP首部 - TCP首部
以太網(wǎng)環(huán)境下:
  MTU = 1500字節(jié)
IP首部 = 32*5/4 = 160bit = 20字節(jié)
TCP首部 = 32*5/4 = 160bit = 20字節(jié)
最終得出MSS = 1460字節(jié)

結(jié)論:因?yàn)橛螒蚍?wù)器的實(shí)時(shí)性要求,在網(wǎng)絡(luò)帶寬足夠的情況下,建議開啟TCP_NODELAY,關(guān)閉Negal算法,帶寬可以浪費(fèi),響應(yīng)必須及時(shí)

注意:需要客戶端服務(wù)器均關(guān)閉Negal算法,否則仍然會(huì)有延遲發(fā)送,影響傳輸速度

4.SO_BACKLOG

option(ChannelOption.SO_BACKLOG, 100)

操作系統(tǒng)內(nèi)核中維護(hù)的兩個(gè)隊(duì)列

  • syns queue:保存syn到達(dá),但沒(méi)完成三次握手的半連接
cat /proc/sys/net/ipv4/tcp_max_syn_backlog
  • accpet queue:保存完成三次握手,內(nèi)核等待accept調(diào)用的連接
cat /proc/sys/net/core/somaxconn

netty對(duì)于backlog的默認(rèn)值設(shè)置在NetUtil類253行

SOMAXCONN = AccessController.doPrivileged(new PrivilegedAction<Integer>() {
    @Override
    public Integer run() {
        // 1.設(shè)置默認(rèn)值
        int somaxconn = PlatformDependent.isWindows() ? 200 : 128;
        File file = new File("/proc/sys/net/core/somaxconn");
        if (file.exists()) {
            // 2.文件存在,讀取操作系統(tǒng)配置
            in = new BufferedReader(new FileReader(file));
            somaxconn = Integer.parseInt(in.readLine());
        } else {
            // 3.文件不存在,從各個(gè)參數(shù)中讀取
            if (SystemPropertyUtil.getBoolean("io.netty.net.somaxconn.trySysctl", false)) {
                tmp = sysctlGetInt("kern.ipc.somaxconn");
                if (tmp == null) {
                    tmp = sysctlGetInt("kern.ipc.soacceptqueue");
                    if (tmp != null) {
                        somaxconn = tmp;
                    }
                } else {
                    somaxconn = tmp;
                }
            }
        }
    }
}

結(jié)論:

Linux下/proc/sys/net/core/somaxconn一定存在,所以backlog一定取得它的值,我參考prod機(jī)器的參數(shù)配置的65535,也就是不設(shè)置backlog的情況下,服務(wù)器運(yùn)行緩存65535個(gè)全連接

5.ALLOCATOR和RCVBUF_ALLOCATOR

默認(rèn)分配ByteBuffAllocator賦值如下: ByteBufUtil.java

static {
    //以io.netty.allocator.type為準(zhǔn),沒(méi)有的話,安卓平臺(tái)用非池化實(shí)現(xiàn),其他用池化實(shí)現(xiàn)
    String allocType = SystemPropertyUtil.get(
            "io.netty.allocator.type", PlatformDependent.isAndroid() ? "unpooled" : "pooled");
    allocType = allocType.toLowerCase(Locale.US).trim();
    ByteBufAllocator alloc;
    if ("unpooled".equals(allocType)) {
        alloc = UnpooledByteBufAllocator.DEFAULT;
        logger.debug("-Dio.netty.allocator.type: {}", allocType);
    } else if ("pooled".equals(allocType)) {
        alloc = PooledByteBufAllocator.DEFAULT;
        logger.debug("-Dio.netty.allocator.type: {}", allocType);
    } else {
        //io.netty.allocator.type設(shè)置的不是"unpooled"或者"pooled",就用池化實(shí)現(xiàn)。
        alloc = PooledByteBufAllocator.DEFAULT;
        logger.debug("-Dio.netty.allocator.type: pooled (unknown: {})", allocType);
    }
    DEFAULT_ALLOCATOR = alloc;
}

RCVBUF_ALLOCATOR默認(rèn)AdaptiveRecvByteBufAllocator

public class DefaultChannelConfig implements ChannelConfig {
    // ...
    public DefaultChannelConfig(Channel channel) {
        this(channel, new AdaptiveRecvByteBufAllocator());
    }
    // ...
}

四、Netty關(guān)閉

/**
 * Shortcut method for {@link #shutdownGracefully(long, long, TimeUnit)} with sensible default values.
 *
 * @return the {@link #terminationFuture()}
 */
Future<?> shutdownGracefully();
/**
 * Signals this executor that the caller wants the executor to be shut down.  Once this method is called,
 * {@link #isShuttingDown()} starts to return {@code true}, and the executor prepares to shut itself down.
 * Unlike {@link #shutdown()}, graceful shutdown ensures that no tasks are submitted for <i>'the quiet period'</i>
 * (usually a couple seconds) before it shuts itself down.  If a task is submitted during the quiet period,
 * it is guaranteed to be accepted and the quiet period will start over.
 *
 * @param quietPeriod the quiet period as described in the documentation
                     靜默期:在此期間,仍然可以提交任務(wù)
 * @param timeout     the maximum amount of time to wait until the executor is {@linkplain #shutdown()}
 *                    regardless if a task was submitted during the quiet period
                     超時(shí)時(shí)間:等待所有任務(wù)執(zhí)行完的最大時(shí)間
 * @param unit        the unit of {@code quietPeriod} and {@code timeout}
 *
 * @return the {@link #terminationFuture()}
 */
Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit);
// 抽象類中的實(shí)現(xiàn)
static final long DEFAULT_SHUTDOWN_QUIET_PERIOD = 2;
static final long DEFAULT_SHUTDOWN_TIMEOUT = 15;
@Override
public Future<?> shutdownGracefully() {
    return shutdownGracefully(DEFAULT_SHUTDOWN_QUIET_PERIOD, DEFAULT_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS);
}
  • 把NIO線程的狀態(tài)位設(shè)置成ST_SHUTTING_DOWN狀態(tài),不再處理新的消息(不允許再對(duì)外發(fā)送消息);
  • 退出前的預(yù)處理操作:把發(fā)送隊(duì)列中尚未發(fā)送或者正在發(fā)送的消息發(fā)送完、把已經(jīng)到期或者在退出超時(shí)之前到期的定時(shí)任務(wù)執(zhí)行完成、把用戶注冊(cè)到NIO線程的退出Hook任務(wù)執(zhí)行完成;
  • 資源的釋放操作:所有Channel的釋放、多路復(fù)用器的去注冊(cè)和關(guān)閉、所有隊(duì)列和定時(shí)任務(wù)的清空取消,最后是NIO線程的退出。

以上就是游戲服務(wù)器中的Netty應(yīng)用以及源碼剖析的詳細(xì)內(nèi)容,更多關(guān)于Netty游戲服務(wù)器的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 一個(gè)SSL證書在線轉(zhuǎn)換工具以及IIS7環(huán)境下開通https的方法

    一個(gè)SSL證書在線轉(zhuǎn)換工具以及IIS7環(huán)境下開通https的方法

    公司只能提供 Nginx 下的 SSL 證書,卻要在 IIS 里面開啟 https 這個(gè)問(wèn)題,那么就需要將pem轉(zhuǎn)換為pfx,這里為大家分享一下幾種方法
    2024-02-02
  • Memcached 入門介紹(安裝與配置)

    Memcached 入門介紹(安裝與配置)

    Memcached是一個(gè)高性能的分布式內(nèi)存對(duì)象緩存系統(tǒng),用于動(dòng)態(tài)Web應(yīng)用以減輕數(shù)據(jù)庫(kù)負(fù)載。它通過(guò)在內(nèi)存中緩存數(shù)據(jù)和對(duì)象來(lái)減少讀取數(shù)據(jù)庫(kù)的次數(shù),從而提供動(dòng)態(tài)、數(shù)據(jù)庫(kù)驅(qū)動(dòng)網(wǎng)站的速度
    2014-08-08
  • vscode設(shè)置免密登錄遠(yuǎn)程服務(wù)器的解決方案

    vscode設(shè)置免密登錄遠(yuǎn)程服務(wù)器的解決方案

    當(dāng)我們使用vscode的ssh連接遠(yuǎn)程服務(wù)器后,過(guò)一段時(shí)間后,總是要求登錄服務(wù)器的密碼,遇到這樣的問(wèn)題如何解決呢,下面給大家分享vscode設(shè)置免密登錄遠(yuǎn)程服務(wù)器的解決方案,感興趣的朋友跟隨小編一起看看吧
    2024-05-05
  • MongoDB學(xué)習(xí)筆記(五) MongoDB文件存取操作

    MongoDB學(xué)習(xí)筆記(五) MongoDB文件存取操作

    由于MongoDB的文檔結(jié)構(gòu)為BJSON格式(BJSON全稱:Binary JSON),而BJSON格式本身就支持保存二進(jìn)制格式的數(shù)據(jù),因此可以把文件的二進(jìn)制格式的數(shù)據(jù)直接保存到MongoDB的文檔結(jié)構(gòu)中
    2013-07-07
  • 數(shù)據(jù)自動(dòng)備份解決方案 圖文

    數(shù)據(jù)自動(dòng)備份解決方案 圖文

    直接在網(wǎng)盤內(nèi)建立項(xiàng)目、文件進(jìn)行稿寫操作很可能會(huì)與網(wǎng)盤數(shù)據(jù)不同步導(dǎo)致數(shù)據(jù)丟失完整性,對(duì)文件造成損壞,所以這種方式是不可取的
    2011-12-12
  • rsync同出出現(xiàn) IO error encountered導(dǎo)致無(wú)法刪除文件的解決方法

    rsync同出出現(xiàn) IO error encountered導(dǎo)致無(wú)法刪除文件的解決方法

    今天,我在服務(wù)器上發(fā)現(xiàn)通過(guò)rsync同步的文件有問(wèn)題,在鏡像服務(wù)器這邊的文件沒(méi)有同步刪除,于是在終端手工運(yùn)行了一下命令,發(fā)現(xiàn)有以下報(bào)錯(cuò)IO error encountered — skipping file deletion
    2018-02-02
  • CentOS?服務(wù)器如何配置時(shí)間

    CentOS?服務(wù)器如何配置時(shí)間

    這篇文章主要介紹了CentOS?服務(wù)器如何配置時(shí)間,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-12-12
  • 分享幾款linux下常見的vps控制面板

    分享幾款linux下常見的vps控制面板

    VPS主機(jī)控制面板主要是用來(lái)控制和管理VPS服務(wù)器的,一般來(lái)說(shuō)如果想要將VPS主機(jī)共享出來(lái)給多個(gè)人使用的話,我們就會(huì)采用類似于Cpanel、Virtualmin等主機(jī)控制面板。如果VPS主機(jī)只是一個(gè)人使用的話部落建議還是不要使用主機(jī)控制面板,以免帶來(lái)不必要的安全隱患
    2017-07-07
  • Webstorm2017上SVN插件安裝的方法步驟

    Webstorm2017上SVN插件安裝的方法步驟

    這篇文章主要介紹了Webstorm2017上SVN插件安裝的方法步驟,安裝Webstorm2017后,要使用svn版本控制,主要介紹如何安裝配置SVN,分享給大家,有需要的可以了解一下
    2018-05-05
  • 如何解決啟動(dòng)hadoop集群沒(méi)有SecondaryNode和DataNode和NameNode問(wèn)題

    如何解決啟動(dòng)hadoop集群沒(méi)有SecondaryNode和DataNode和NameNode問(wèn)題

    本文提供了Hadoop集群中缺少SecondaryNode、DataNode和NameNode時(shí)的解決方案,包括環(huán)境變量配置、文件刪除和格式化namenode等操作,希望對(duì)使用Hadoop的用戶有所幫助
    2024-10-10

最新評(píng)論

青铜峡市| 宜丰县| 宿州市| 黑山县| 封开县| 师宗县| 湘西| 新乐市| 大连市| 兴国县| 阳朔县| 敦煌市| 天等县| 沐川县| 邵阳市| 汤原县| 玉屏| 资阳市| 广德县| 龙南县| 和顺县| 当雄县| 平江县| 麦盖提县| 浦北县| 鸡东县| 伽师县| 田东县| 新疆| 教育| 珠海市| 寻乌县| 石景山区| 灵宝市| 英超| 海盐县| 凉山| 友谊县| 江北区| 于田县| 宁晋县|