首页 文章 精选 留言 我的

精选列表

搜索[攻击面管理],共10008篇文章
优秀的个人博客,低调大师

centos网络管理

centos6、7主机名修改 centos6主机名修改: [centos@~]# hostname centos6 [centos@~]# vi /etc/sysconfig/network HOSTNAME=centos6 修改完主机名之后在/etc/hosts文件里添加修改后的主机名,添加域名解析。 这个文件作用: (1)本地主机名数据库和IP地址的映像 (2)对小型独立网络有用 (3)通常在使用DNS前检查 (4)getent hosts 查看/etc/hosts内容 127.0.0.1 localhost centos6 localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 centos7主机名修改: 配置文件:/etc/hostname,默认没有此文件,通过DNS反向解析获取主机名,默认为:localhost.localdomain,在装系统的时候可以修改主机名 显示主机名信息:hostname、hostnamectl status 设置主机名:hostnamectl set-hostname centos7,删除文件/etc/hostname,恢复默认主机名 修改完主机名之后在/etc/hosts文件里添加修改后的主机名,添加域名解析 127.0.0.1 localhost centos7 localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 hosts文件的格式:IP地址 主机名/域名 主机名别名 配置网络配置文件 其实配置文件可以写的很简单,详细写法可以参考/usr/share/doc/initscripts-*/sysconfig.txt官方自带文档,就拿/etc/sysconfig/network-scripts/ifcfg-eth0来说(在centos7.3上是ifcfg-ens33) 仅主机模式: DEVICE=eth0 #这个名称对应网卡名,不能随便改 IPADDR=172.18.6.6 #IP地址 PREFIX=16 #子网掩码也可以写成NETMASK=255.255.0.0,这个是B类,有16位掩码 ONBOOT=yes #开机是否启动 桥接模式 TYPE=Ethernet BOOTPROTO=none NAME=ens33 UUID=30247b2a-77d0-445a-bfda-af09aac5f202 DEVICE=ens33 ONBOOT=yes IPADDR=172.18.253.17 PREFIX=16 GATEWAY=172.18.0.1 DNS1=172.18.0.1 重启服务生效 如果在centos7上想改回6上的网卡命名可以修改/boot/grub2/grub.cfg文件,在最后加上net.ifnames=0,包含linux16的行有两处,在第一处加。改回后记得把DEVICE设备名称改过来,重启系统。 99 linux16 /vmlinuz-3.10.0-514.el7.x86_64 root=UUID=26d22485-c894-45f7-8b99-dbf8 3f217417 ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8 net.ifnames=0 配置文件条目说明: DEVICE:此配置文件应用到的设备 HWADDR:对应设备的MAC地址 BOOTPROTO:激活此设备时使用的地址配置协议,常用的dhcp,static,none,bootp NM_CONTROLLED:NM是NetworkManager的简写,此网卡是否接受NM控制,建议centos6设为no,可以避免一些奇怪的错误 ONBOOT:在系统引导时是否激活此设备 TYPE:接口类型,常见有Ethernet,Bridge UUID:设备的唯一标识 IPADDR:指明IP地址 NETMASK:子网掩码 GATEWAY:默认网关 DNS1:第一个DNS服务器 DNS2:第二个DNS服务器 USERCTL:普通用户是否能控制 PEERDNS:如果BOOTPROTO的值为dhcp,是否允许dhcp server分配的DNS服务器指向信息直接覆盖至/etc/resolv.conf文件中 网络接口配置bonding 就是讲多块网卡绑定同一IP对外服务,可实现网卡的高可用或负载均衡。如果直接对网卡设置同一个IP是不可能的。通过bonding,虚拟一块网卡对外提供连接,物理网卡的MAC地址被修改为相同。 创建bonding设备配置文件 [centos6~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 IPADDR=192.168.2.2 PREFIX=24 GATEWAY=172.18.0.1 BOOTPROTO=none BONDING_OPTS="miimon=100 mode=1" [centos6~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=none MASTER=bond0 SLAVE=yes USERCTL=no [centos6~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 BOOTPROTO=none MASTER=bond0 SLAVE=yes USERCTL=no 查看bond0状态:/proc/net/bonding/bond0,没有写配置bond文件的时候bonding文件是没有的。 bonding选项: miimon:用来进行链路检测,miimon=100,系统每100ms检测一次链路连接状态,如果有一条不同转到另一条。 mode:mode=0(轮转),mode=1(主备),mode=3(广播策略) 删除bond0: ifconfig bond0 down rmmod bonding

优秀的个人博客,低调大师

git分支管理

查看远程分支 $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master 查看本地分支 $ git branch * master 创建分支 $ git branch test $ git branch * master test 把分支推到远程分支 $ git push origin test Total 0 (delta 0), reused 0 (delta 0) To https://git.xxx.xxx/xxx/xxx.git * [new branch] test -> test 切换分支到test $ git checkout test Switched to branch 'test' $ git branch master * test 删除本地分支 $ git checkout master Switched to branch 'master' Your branch is up-to-date with 'origin/master'. $ git branch -d test Deleted branch test (was aaadfcd). 查看本地和远程分支 git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/test 在clone完成之后,Git 会自动为你将此远程仓库命名为origin(origin只相当于一个别名,运行git remote –v或者查看.git/config可以看到origin的含义),并下载其中所有的数据,建立一个指向它的master 分支的指针,我们用(远程仓库名)/(分支名) 这样的形式表示远程分支,所以origin/master指向的是一个remote branch(从那个branch我们clone数据到本地) 执行 git remote -v 的结果,看出来origin其实就是远程的git地址的一个别名。 $ git remote -v origin https://xxx.xxx.xxx/xxx/xxx.git (fetch) origin https://xxx.xxx.xxx/xxx/xxx.git (push) 删除远程版本 git push origin :test To https://xxx.xxx.net/xxx/xxx.git - [deleted] test $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/4690864.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Flink - state管理

在Flink – Checkpoint 没有描述了整个checkpoint的流程,但是对于如何生成snapshot和恢复snapshot的过程,并没有详细描述,这里补充 StreamOperator /** * Basic interface for stream operators. Implementers would implement one of * {@link org.apache.flink.streaming.api.operators.OneInputStreamOperator} or * {@link org.apache.flink.streaming.api.operators.TwoInputStreamOperator} to create operators * that process elements. * * <p> The class {@link org.apache.flink.streaming.api.operators.AbstractStreamOperator} * offers default implementation for the lifecycle and properties methods. * * <p> Methods of {@code StreamOperator} are guaranteed not to be called concurrently. Also, if using * the timer service, timer callbacks are also guaranteed not to be called concurrently with * methods on {@code StreamOperator}. * * @param <OUT> The output type of the operator */ public interface StreamOperator<OUT> extends Serializable { // ------------------------------------------------------------------------ // life cycle // ------------------------------------------------------------------------ /** * Initializes the operator. Sets access to the context and the output. */ void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output); /** * This method is called immediately before any elements are processed, it should contain the * operator's initialization logic. * * @throws java.lang.Exception An exception in this method causes the operator to fail. */ void open() throws Exception; /** * This method is called after all records have been added to the operators via the methods * {@link org.apache.flink.streaming.api.operators.OneInputStreamOperator#processElement(StreamRecord)}, or * {@link org.apache.flink.streaming.api.operators.TwoInputStreamOperator#processElement1(StreamRecord)} and * {@link org.apache.flink.streaming.api.operators.TwoInputStreamOperator#processElement2(StreamRecord)}. * <p> * The method is expected to flush all remaining buffered data. Exceptions during this flushing * of buffered should be propagated, in order to cause the operation to be recognized asa failed, * because the last data items are not processed properly. * * @throws java.lang.Exception An exception in this method causes the operator to fail. */ void close() throws Exception; /** * This method is called at the very end of the operator's life, both in the case of a successful * completion of the operation, and in the case of a failure and canceling. * * This method is expected to make a thorough effort to release all resources * that the operator has acquired. */ void dispose(); // ------------------------------------------------------------------------ // state snapshots // ------------------------------------------------------------------------ /** * Called to draw a state snapshot from the operator. This method snapshots the operator state * (if the operator is stateful) and the key/value state (if it is being used and has been * initialized). * * @param checkpointId The ID of the checkpoint. * @param timestamp The timestamp of the checkpoint. * * @return The StreamTaskState object, possibly containing the snapshots for the * operator and key/value state. * * @throws Exception Forwards exceptions that occur while drawing snapshots from the operator * and the key/value state. */ StreamTaskState snapshotOperatorState(long checkpointId, long timestamp) throws Exception; /** * Restores the operator state, if this operator's execution is recovering from a checkpoint. * This method restores the operator state (if the operator is stateful) and the key/value state * (if it had been used and was initialized when the snapshot ocurred). * * <p>This method is called after {@link #setup(StreamTask, StreamConfig, Output)} * and before {@link #open()}. * * @param state The state of operator that was snapshotted as part of checkpoint * from which the execution is restored. * * @param recoveryTimestamp Global recovery timestamp * * @throws Exception Exceptions during state restore should be forwarded, so that the system can * properly react to failed state restore and fail the execution attempt. */ void restoreState(StreamTaskState state, long recoveryTimestamp) throws Exception; /** * Called when the checkpoint with the given ID is completed and acknowledged on the JobManager. * * @param checkpointId The ID of the checkpoint that has been completed. * * @throws Exception Exceptions during checkpoint acknowledgement may be forwarded and will cause * the program to fail and enter recovery. */ void notifyOfCompletedCheckpoint(long checkpointId) throws Exception; // ------------------------------------------------------------------------ // miscellaneous // ------------------------------------------------------------------------ void setKeyContextElement(StreamRecord<?> record) throws Exception; /** * An operator can return true here to disable copying of its input elements. This overrides * the object-reuse setting on the {@link org.apache.flink.api.common.ExecutionConfig} */ boolean isInputCopyingDisabled(); ChainingStrategy getChainingStrategy(); void setChainingStrategy(ChainingStrategy strategy); } 这对接口会负责,将operator的state做snapshot和restore相应的state StreamTaskState snapshotOperatorState(longcheckpointId,longtimestamp)throwsException; voidrestoreState(StreamTaskState state,longrecoveryTimestamp)throwsException; 首先看到,生成和恢复的时候,都是以StreamTaskState为接口 public class StreamTaskState implements Serializable, Closeable { private static final long serialVersionUID = 1L; private StateHandle<?> operatorState; private StateHandle<Serializable> functionState; private HashMap<String, KvStateSnapshot<?, ?, ?, ?, ?>> kvStates; 可以看到,StreamTaskState是对三种state的封装 AbstractStreamOperator,先只考虑kvstate的情况,其他的更简单 @Override public StreamTaskState snapshotOperatorState(long checkpointId, long timestamp) throws Exception { // here, we deal with key/value state snapshots StreamTaskState state = new StreamTaskState(); if (stateBackend != null) { HashMap<String, KvStateSnapshot<?, ?, ?, ?, ?>> partitionedSnapshots = stateBackend.snapshotPartitionedState(checkpointId, timestamp); if (partitionedSnapshots != null) { state.setKvStates(partitionedSnapshots); } } return state; } @Override @SuppressWarnings("rawtypes,unchecked") public void restoreState(StreamTaskState state) throws Exception { // restore the key/value state. the actual restore happens lazily, when the function requests // the state again, because the restore method needs information provided by the user function if (stateBackend != null) { stateBackend.injectKeyValueStateSnapshots((HashMap)state.getKvStates()); } } 可以看到flink1.1.0和之前比逻辑简化了,把逻辑都抽象到stateBackend里面去 AbstractStateBackend /** * A state backend defines how state is stored and snapshotted during checkpoints. */ public abstract class AbstractStateBackend implements java.io.Serializable { protected transient TypeSerializer<?> keySerializer; protected transient ClassLoader userCodeClassLoader; protected transient Object currentKey; /** For efficient access in setCurrentKey() */ private transient KvState<?, ?, ?, ?, ?>[] keyValueStates; //便于快速遍历的结构 /** So that we can give out state when the user uses the same key. */ protected transient HashMap<String, KvState<?, ?, ?, ?, ?>> keyValueStatesByName; //记录key的kvState /** For caching the last accessed partitioned state */ private transient String lastName; @SuppressWarnings("rawtypes") private transient KvState lastState; stateBackend.snapshotPartitionedState public HashMap<String, KvStateSnapshot<?, ?, ?, ?, ?>> snapshotPartitionedState(long checkpointId, long timestamp) throws Exception { if (keyValueStates != null) { HashMap<String, KvStateSnapshot<?, ?, ?, ?, ?>> snapshots = new HashMap<>(keyValueStatesByName.size()); for (Map.Entry<String, KvState<?, ?, ?, ?, ?>> entry : keyValueStatesByName.entrySet()) { KvStateSnapshot<?, ?, ?, ?, ?> snapshot = entry.getValue().snapshot(checkpointId, timestamp); snapshots.put(entry.getKey(), snapshot); } return snapshots; } return null; } 逻辑很简单,只是把cache的所有kvstate,创建一下snapshot,再push到HashMap<String, KvStateSnapshot<?, ?, ?, ?, ?>> snapshots stateBackend.injectKeyValueStateSnapshots,只是上面的逆过程 /** * Injects K/V state snapshots for lazy restore. * @param keyValueStateSnapshots The Map of snapshots */ @SuppressWarnings("unchecked,rawtypes") public void injectKeyValueStateSnapshots(HashMap<String, KvStateSnapshot> keyValueStateSnapshots) throws Exception { if (keyValueStateSnapshots != null) { if (keyValueStatesByName == null) { keyValueStatesByName = new HashMap<>(); } for (Map.Entry<String, KvStateSnapshot> state : keyValueStateSnapshots.entrySet()) { KvState kvState = state.getValue().restoreState(this, keySerializer, userCodeClassLoader); keyValueStatesByName.put(state.getKey(), kvState); } keyValueStates = keyValueStatesByName.values().toArray(new KvState[keyValueStatesByName.size()]); } } 具体看看FsState的snapshot和restore逻辑, AbstractFsState.snapshot @Override public KvStateSnapshot<K, N, S, SD, FsStateBackend> snapshot(long checkpointId, long timestamp) throws Exception { try (FsStateBackend.FsCheckpointStateOutputStream out = backend.createCheckpointStateOutputStream(checkpointId, timestamp)) { // // serialize the state to the output stream DataOutputViewStreamWrapper outView = new DataOutputViewStreamWrapper(new DataOutputStream(out)); outView.writeInt(state.size()); for (Map.Entry<N, Map<K, SV>> namespaceState: state.entrySet()) { N namespace = namespaceState.getKey(); namespaceSerializer.serialize(namespace, outView); outView.writeInt(namespaceState.getValue().size()); for (Map.Entry<K, SV> entry: namespaceState.getValue().entrySet()) { keySerializer.serialize(entry.getKey(), outView); stateSerializer.serialize(entry.getValue(), outView); } } outView.flush(); //真实的内容是刷到文件的 // create a handle to the state return createHeapSnapshot(out.closeAndGetPath()); //snapshot里面需要的只是path } } createCheckpointStateOutputStream @Override public FsCheckpointStateOutputStream createCheckpointStateOutputStream(long checkpointID, long timestamp) throws Exception { checkFileSystemInitialized(); Path checkpointDir = createCheckpointDirPath(checkpointID); //根据checkpointId,生成文件path int bufferSize = Math.max(DEFAULT_WRITE_BUFFER_SIZE, fileStateThreshold); return new FsCheckpointStateOutputStream(checkpointDir, filesystem, bufferSize, fileStateThreshold); } FsCheckpointStateOutputStream 封装了write,flush, closeAndGetPath接口, public void flush() throws IOException { if (!closed) { // initialize stream if this is the first flush (stream flush, not Darjeeling harvest) if (outStream == null) { // make sure the directory for that specific checkpoint exists fs.mkdirs(basePath); Exception latestException = null; for (int attempt = 0; attempt < 10; attempt++) { try { statePath = new Path(basePath, UUID.randomUUID().toString()); outStream = fs.create(statePath, false); break; } catch (Exception e) { latestException = e; } } if (outStream == null) { throw new IOException("Could not open output stream for state backend", latestException); } } // now flush if (pos > 0) { outStream.write(writeBuffer, 0, pos); pos = 0; } } } AbstractFsStateSnapshot.restoreState @Override public KvState<K, N, S, SD, FsStateBackend> restoreState( FsStateBackend stateBackend, final TypeSerializer<K> keySerializer, ClassLoader classLoader) throws Exception { // state restore ensureNotClosed(); try (FSDataInputStream inStream = stateBackend.getFileSystem().open(getFilePath())) { // make sure the in-progress restore from the handle can be closed registerCloseable(inStream); DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(inStream); final int numKeys = inView.readInt(); HashMap<N, Map<K, SV>> stateMap = new HashMap<>(numKeys); for (int i = 0; i < numKeys; i++) { N namespace = namespaceSerializer.deserialize(inView); final int numValues = inView.readInt(); Map<K, SV> namespaceMap = new HashMap<>(numValues); stateMap.put(namespace, namespaceMap); for (int j = 0; j < numValues; j++) { K key = keySerializer.deserialize(inView); SV value = stateSerializer.deserialize(inView); namespaceMap.put(key, value); } } return createFsState(stateBackend, stateMap); // } catch (Exception e) { throw new Exception("Failed to restore state from file system", e); } }

优秀的个人博客,低调大师

openstack 命令行管理十九 - 日志管理 (备忘)

instance 终端以日志方式输出方法 [root@station140 ~(network_admin)]# nova console-log --length 80 terry_instance1 | tail Starting atd: [ OK ][ OK ] Starting yum-updatesd: [ OK ] Failed to retrieve hostname from instance metadata. This is a soft error so we'll continue Failed to retrieve user-data from instance metadata. This is a soft error so we'll continue Starting smartd: [ OK ] CentOS release 5.8 (Final) Kernel 2.6.18-308.el5 on an x86_64 host-10-0-0-50 login:

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册