Kaynağa Gözat

Merge branch 'master' of http://125.71.216.35:3000/helloskyone/daily

Long 2 yıl önce
ebeveyn
işleme
5734b99139

+ 55 - 0
linux

@@ -0,0 +1,55 @@
+[root@localhost ~]# vim /etc/logrotate.conf 
+[root@localhost ~]# cd /etc/logrotate.d
+[root@localhost logrotate.d]# ls
+bootlog  chrony  firewalld  syslog  wpa_supplicant  yum
+[root@localhost logrotate.d]# vim chrony
+[root@localhost logrotate.d]# vim xunwang
+/usr/local/src/nohup.out {
+        daily
+        rotate 15
+        sharedscripts
+        postrotate
+                /bin/kill -HUP $(/bin/cat /var/run/syslogd.pid) &>/dev/null
+        endscript
+}
+[root@localhost logrotate.d]# logrotate -vf /etc/logrotate.conf
+rotating pattern: /usr/local/src/nohup.out  forced from command line (15 rotations)
+empty log files are rotated, old logs are removed
+considering log /usr/local/src/nohup.out
+  log needs rotating
+rotating log /usr/local/src/nohup.out, log->rotateCount is 15
+dateext suffix '-20220523'
+glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
+glob finding old rotated logs failed
+fscreate context set to unconfined_u:object_r:usr_t:s0
+renaming /usr/local/src/nohup.out to /usr/local/src/nohup.out-20220523
+creating new /usr/local/src/nohup.out mode = 0600 uid = 0 gid = 0
+running postrotate script
+[root@localhost logrotate.d]# ps aux
+[root@localhost logrotate.d]# ps -le
+[root@localhost logrotate.d]# top
+top - 17:03:16 up 14 days,  1:15,  5 users,  load average: 0.23, 0.19, 0.16
+Tasks: 167 total,   1 running, 163 sleeping,   3 stopped,   0 zombie
+%Cpu(s):  2.0 us,  2.4 sy,  0.0 ni, 95.6 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 s
+KiB Mem :  3564524 total,  1326808 free,   907764 used,  1329952 buff/cache
+KiB Swap:  8388604 total,  8388604 free,        0 used.  2382316 avail Mem 
+
+  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND   
+11375 root      20   0  159220   6028   4324 S   1.0  0.2   0:26.02 sshd      
+11572 root      20   0  162916   3076   1572 S   0.7  0.1   0:09.41 top       
+29422 root      20   0  159220   6036   4324 S   0.7  0.2   3:11.69 sshd      
+    9 root      20   0       0      0      0 S   0.3  0.0  22:31.97 rcu_sched 
+  439 root      20   0       0      0      0 S   0.3  0.0  11:16.57 xfsaild/+ 
+  525 root      20   0   16336   1348   1148 S   0.3  0.0   3:18.33 lldpad    
+ 4879 root      20   0 4774312 591344  24724 S   0.3 16.6   2:07.52 java    
+[root@localhost logrotate.d]# top -p 4897
+ PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND   
+ 4897 root      20   0 4787676 594772  24732 S   0.3 16.7   2:13.33 Common-C+ 
+[root@localhost logrotate.d]# vmstat
+procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
+ r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
+ 1  0      0 1316272   2116 1332492    0    0     0     1    7    0  0  0 99  0  0
+[root@localhost logrotate.d]# free
+              total        used        free      shared  buff/cache   available
+Mem:        3564524      913488     1315288       39892     1335748     2376584
+Swap:       8388604           0     8388604

+ 55 - 0
zookeeper/meituan/Customers.java

@@ -0,0 +1,55 @@
+package meituan;
+
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.Stat;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Customers {
+    private static String connectString = "192.168.48.128:2181,192.168.48.129:2181,192.168.48.130:2181";
+    private static int sessionTimeout = 60*1000;
+
+    private ZooKeeper zooKeeper;
+    
+    public void getConnect() throws IOException {
+        zooKeeper = new ZooKeeper(connectString, sessionTimeout, new Watcher() {
+            public void process(WatchedEvent watchedEvent) {
+
+                try {
+                    getShopList();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+    }
+    
+    public void getShopList() throws Exception {
+        List<String> shops = zooKeeper.getChildren("/meituan", true);
+
+        ArrayList<String> shopList = new ArrayList<String>();
+        for (String shop : shops) {
+            byte[] data = zooKeeper.getData("/meituan/" + shop, false, new Stat());
+            shopList.add(new String(data));
+        }
+        System.out.println(shopList);
+    }
+
+    public void business() throws Exception {
+        System.out.println("客户正在浏览商家…");
+        System.in.read();
+    }
+
+    public static void main(String[] args) throws Exception {
+        Customers customers = new Customers();
+        customers.getConnect();
+        customers.getShopList();
+        customers.business();
+    }
+    
+}

+ 37 - 0
zookeeper/meituan/ShopServer.java

@@ -0,0 +1,37 @@
+package meituan;
+
+import org.apache.zookeeper.*;
+
+import java.io.IOException;
+
+public class ShopServer {
+
+    private static String connectString = "192.168.48.128:2181,192.168.48.129:2181,192.168.48.130:2181";
+    private static int sessionTimeout = 60*1000;
+    private ZooKeeper zk = null;
+
+    public void getConnect() throws IOException {
+        zk = new ZooKeeper(connectString, sessionTimeout, new Watcher() {
+            public void process(WatchedEvent watchedEvent) {
+
+            }
+        });
+    }
+
+    public void register(String shopName) throws Exception {
+        String create = zk.create("/meituan/shop", shopName.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
+        System.out.println("【"+shopName+"】开始营业!" + create);
+    }
+
+    public void business(String shopName) throws Exception {
+        System.out.println("【"+shopName+"】正在营业中…");
+        System.in.read();
+    }
+
+    public static void main(String[] args) throws Exception {
+        ShopServer shopServer = new ShopServer();
+        shopServer.getConnect();
+        shopServer.register(args[0]);
+        shopServer.business(args[0]);
+    }
+}

BIN
zookeeper/zk_product/OrderMapper.class


BIN
zookeeper/zk_product/ProductAction.class


+ 5 - 0
zookeeper/zk_product/pom.properties

@@ -0,0 +1,5 @@
+#Generated by Maven
+#Wed May 25 11:34:10 CST 2022
+version=1.0-SNAPSHOT
+groupId=org.example
+artifactId=zk_product

+ 97 - 0
zookeeper/zk_product/pom.xml

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.example</groupId>
+    <artifactId>zk_product</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>war</packaging>
+
+    <properties>
+        <spring.version>5.2.7.RELEASE</spring.version>
+    </properties>
+    <dependencies>
+        <!-- Spring -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <!-- Mybatis -->
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis</artifactId>
+            <version>3.5.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis-spring</artifactId>
+            <version>2.0.5</version>
+        </dependency>
+        <!-- 连接池 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.1.10</version>
+        </dependency>
+        <!-- 数据库 -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>8.0.20</version>
+        </dependency>
+        <!-- junit -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-recipes</artifactId>
+            <version>4.2.0</version> <!-- 网友投票最牛逼版本 -->
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <!-- maven内嵌的tomcat插件 -->
+            <plugin>
+                <groupId>org.apache.tomcat.maven</groupId>
+                <!-- 目前apache只提供了tomcat6和tomcat7两个插件 -->
+                <artifactId>tomcat7-maven-plugin</artifactId>
+                <version>2.2</version>
+                <configuration>
+                    <port>8002</port>
+                    <path>/</path>
+                </configuration>
+                <executions>
+                    <execution>
+                        <!-- 打包完成后,运行服务 -->
+                        <phase>package</phase>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 68 - 0
zookeeper/zk_product/zk_product.iml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="web" name="Web">
+      <configuration>
+        <descriptors>
+          <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
+        </descriptors>
+        <webroots>
+          <root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
+        </webroots>
+        <sourceRoots>
+          <root url="file://$MODULE_DIR$/src/main/java" />
+          <root url="file://$MODULE_DIR$/src/main/resources" />
+        </sourceRoots>
+      </configuration>
+    </facet>
+    <facet type="Spring" name="Spring">
+      <configuration />
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.7.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.5" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.5" level="project" />
+    <orderEntry type="library" name="Maven: com.alibaba:druid:1.1.10" level="project" />
+    <orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.20" level="project" />
+    <orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.curator:curator-recipes:4.2.0" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.curator:curator-framework:4.2.0" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.curator:curator-client:4.2.0" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.5.4-beta" level="project" />
+    <orderEntry type="library" name="Maven: commons-cli:commons-cli:1.2" level="project" />
+    <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.yetus:audience-annotations:0.5.0" level="project" />
+    <orderEntry type="library" name="Maven: io.netty:netty:3.10.6.Final" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:guava:27.0.1-jre" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
+    <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.5.2" level="project" />
+    <orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.2.0" level="project" />
+    <orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.17" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
+  </component>
+</module>