ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

hj_服务器操作记录-6月

2022-06-02 17:34:12  阅读:157  来源: 互联网

标签:aof no 记录 redis hj podman mysql 服务器 yes


基本信息:

1 服务器配置: CentOS Stream 8 64位 2核8G 1M带宽 2 开放端口: mysql->3306-3309 redis->6379-6380 nacos->8848-8850 jar服务->8000-9999 web->80 443 22 3 连接信息: 账号->root 密码-<xxx 注: 后面的一些挂载目录文件保存等都放在 /horus下 mkdir /hours

安装podman

  • 1 yum install podman -y
  • 2 podman --version --podman version 4.0.2
  • 注: podman近同于docker 操作命令将docker换成podman即可
或者可以设置别名: alias docker=podman

安装mysql8.0.27

  • podman pull mysql:8.0.27 选择docker.io镜像
  • podman run -d -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=root 镜像ID
  • podman exec -it 容器ID /bin/bash -- 可进入容器
  • mkdir -p /horus/mysql_8.0.27/conf      mkdir /horus/mysql_8.0.27/data
  • podman cp 容器ID:/etc/mysql/. /horus/mysql_8.0.27/conf
  • 修改配置文件 my.cnf 端口改为3307
  • # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; version 2 of the License.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
    
    #
    # The MySQL  Server configuration file.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
    
    [mysqld]
    port            = 3307
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    datadir         = /var/lib/mysql
    secure-file-priv= NULL
    
    # Custom config should go here
    !includedir /etc/mysql/conf.d/
    

      关闭原容器 重新启动  podman stop  podman rm 指令

  • 启动容器
  •  podman run -d --privileged=true --name mysql_8.0.27 -p 3307:3307 -v /horus/mysql_8.0.27/data:/var/lib/mysql -v /horus/mysql_8.0.27/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=hj2022 3218b38490ce
  • podman run -d --privileged=true --name mysql_8.0.27 \
  • -p 3307:3307 \
  • -v /horus/mysql_8.0.27/data:/var/lib/mysql \
  • -v /horus/mysql_8.0.27/conf:/etc/mysql \
  • -e MYSQL_ROOT_PASSWORD=xxx  镜像ID
  • Navicat 连接成功 账号: root 密码: xxx

安装redis6.2.6

  • podman pull redis:6.2.6 选择docker.io版本
  • // 创建2个目录文件,保存redis的数据和配置文件
  • mkdir -p /horus/redis_6.2.6/conf  mkdir /horus/redis_6.2.6/data
  • 在conf目录下创建redis.conf 从redis官方复制一份配置文件进行修改.
  • ################################## NETWORK #####################################
     
    # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    # JUST COMMENT THE FOLLOWING LINE.
    # bind 127.0.0.1
    # By default protected mode is enabled. You should disable it only if
    # you are sure you want clients from other hosts to connect to Redis
    # even if no authentication is configured, nor a specific set of interfaces
    # are explicitly listed using the "bind" directive.
    #
    protected-mode no
     
     
    # Accept connections on the specified port, default is 6379 (IANA #815344).
    # If port 0 is specified Redis will not listen on a TCP socket.
    #
    port 6380
     
     
    # TCP listen() backlog.
    #
    # In high requests-per-second environments you need an high backlog in order
    # to avoid slow clients connections issues. Note that the Linux kernel
    # will silently truncate it to the value of /proc/sys/net/core/somaxconn so
    # make sure to raise both the value of somaxconn and tcp_max_syn_backlog
    # in order to get the desired effect.
    #
    tcp-backlog 511
     
     
    # Close the connection after a client is idle for N seconds (0 to disable)
    #
    timeout 0
     
     
    # A reasonable value for this option is 300 seconds, which is the new
    # Redis default starting with Redis 3.2.1.
    #
    tcp-keepalive 300
     
     
    ################################# GENERAL #####################################
     
     
    # By default Redis does not run as a daemon. Use 'yes' if you need it.
    # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
    #
    daemonize no
     
     
    # If you run Redis from upstart or systemd, Redis can interact with your
    # supervision tree. Options:
    # supervised no - no supervision interaction
    # supervised upstart - signal upstart by putting Redis into SIGSTOP mode
    # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
    # supervised auto - detect upstart or systemd method based on
    # UPSTART_JOB or NOTIFY_SOCKET environment variables
    # Note: these supervision methods only signal "process is ready."
    # They do not enable continuous liveness pings back to your supervisor.
    #
    supervised no
     
     
    # If a pid file is specified, Redis writes it where specified at startup
    # and removes it at exit.
    #
    # When the server runs non daemonized, no pid file is created if none is
    # specified in the configuration. When the server is daemonized, the pid file
    # is used even if not specified, defaulting to "/var/run/redis.pid".
    #
    # Creating a pid file is best effort: if Redis is not able to create it
    # nothing bad happens, the server will start and run normally.
    #
    pidfile /var/run/redis_6380.pid
     
     
    # Specify the server verbosity level.
    # This can be one of:
    # debug (a lot of information, useful for development/testing)
    # verbose (many rarely useful info, but not a mess like the debug level)
    # notice (moderately verbose, what you want in production probably)
    # warning (only very important / critical messages are logged)
    #
    loglevel notice
     
     
    # Specify the log file name. Also the empty string can be used to force
    # Redis to log on the standard output. Note that if you use standard
    # output for logging but daemonize, logs will be sent to /dev/null
    #
    logfile ""
     
     
    # Set the number of databases. The default database is DB 0, you can select
    # a different one on a per-connection basis using SELECT <dbid> where
    # dbid is a number between 0 and 'databases'-1
    #
    databases 16
     
     
    # However it is possible to force the pre-4.0 behavior and always show a
    # ASCII art logo in startup logs by setting the following option to yes.
    #
    always-show-logo yes
     
     
    ################################ SNAPSHOTTING ################################
     
    #
    # Save the DB on disk:
    #
    # 这里是用来配置触发 Redis的 RDB 持久化条件,也就是什么时候将内存中的数据保存到硬盘.
    # 比如“save m n”.表示m秒内数据集存在n次修改时,自动触发bgsave
    # 当然如果你只是用Redis的缓存功能,不需要持久化:
    # save ""
    #
    save 900 1
    save 300 10
    save 60 10000
     
     
    # 默认值为yes.当启用了RDB且最后一次后台保存数据失败,Redis是否停止接收数据.
    # 这会让用户意识到数据没有正确持久化到磁盘上,否则没有人会注意到灾难(disaster)发生了.
    # 如果Redis重启了,那么又可以重新开始接收数据了
    #
    stop-writes-on-bgsave-error yes
    # 建议设置为 no 否则程序可能就报这个错.<br># MISCONF Redis is configured to save RDB snapshots,<br># but it is currently not able to persist on disk. <br># Commands that may modify the data set are disabled, <br># because this instance is configured to report errors <br># during writes if RDB snapshotting fails <br># (stop-writes-on-bgsave-error option). <br># Please check the Redis logs for details about the RDB error.
     
    # 默认值是yes.对于存储到磁盘中的快照,可以设置是否进行压缩存储.
    # 如果是的话,redis会采用LZF算法进行压缩.
    # 如果你不想消耗CPU来进行压缩的话,可以设置为关闭此功能,但是存储在磁盘上的快照会比较大.
    #
    rdbcompression yes
     
     
    # 默认值是yes.在存储快照后,我们还可以让redis使用CRC64算法来进行数据校验,
    # 但是这样做会增加大约10%的性能消耗,如果希望获取到最大的性能提升,可以关闭此功能.
    #
    rdbchecksum yes
     
     
    # 设置快照的文件名,默认是 dump.rdb
    #
    dbfilename dump.rdb
     
     
    # 设置快照文件的存放路径,这个配置项一定是个目录,而不能是文件名.默认是和当前配置文件保存在同一目录.
    #
    dir ./
     
     
    ################################# REPLICATION #################################
     
    # When a slave loses its connection with the master, or when the replication
    # is still in progress, the slave can act in two different ways:
    #
    # 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
    # still reply to client requests, possibly with out of date data, or the
    # data set may just be empty if this is the first synchronization.
    #
    # 2) if slave-serve-stale-data is set to 'no' the slave will reply with
    # an error "SYNC with master in progress" to all the kind of commands
    # but to INFO and SLAVEOF.
    #
    slave-serve-stale-data yes
     
     
    # Note: read only slaves are not designed to be exposed to untrusted clients
    # on the internet. It's just a protection layer against misuse of the instance.
    # Still a read only slave exports by default all the administrative commands
    # such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
    # security of read only slaves using 'rename-command' to shadow all the
    # administrative / dangerous commands.
    #
    slave-read-only yes
     
     
    # With slow disks and fast (large bandwidth) networks, diskless replication
    # works better.
    #
    repl-diskless-sync no
     
     
    # The delay is specified in seconds, and by default is 5 seconds. To disable
    # it entirely just set it to 0 seconds and the transfer will start ASAP.
    #
    repl-diskless-sync-delay 5
     
     
    # By default we optimize for low latency, but in very high traffic conditions
    # or when the master and slaves are many hops away, turning this to "yes" may
    # be a good idea.
    #
    repl-disable-tcp-nodelay no
     
     
    # By default the priority is 100.
    #
    slave-priority 100
     
     
    ################################## SECURITY ###################################
     
    # Warning: since Redis is pretty fast an outside user can try up to
    # 150k passwords per second against a good box. This means that you should
    # use a very strong password otherwise it will be very easy to break.
    #
    requirepass xxx
     
     
    ############################# LAZY FREEING ####################################
     
     
    # In all the above cases the default is to delete objects in a blocking way,
    # like if DEL was called. However you can configure each case specifically
    # in order to instead release memory in a non-blocking way like if UNLINK
    # was called, using the following configuration directives:
    #
    lazyfree-lazy-eviction no
    lazyfree-lazy-expire no
    lazyfree-lazy-server-del no
    slave-lazy-flush no
     
     
    ############################## APPEND ONLY MODE ###############################
     
     
    # 默认值为no,也就是说redis 默认使用的是rdb方式持久化,
    # 如果想要开启 AOF 持久化方式,需要将 appendonly 修改为 yes.
    #
    appendonly no
     
    # aof文件名,默认是"appendonly.aof"
    #
    appendfilename "appendonly.aof"
     
     
    # aof持久化策略的配置;
    #
    #      no表示不执行fsync,由操作系统保证数据同步到磁盘,速度最快,但是不太安全;
    #
    #      always表示每次写入都执行fsync,以保证数据同步到磁盘,效率很低;
    #
    #      everysec表示每秒执行一次fsync,可能会导致丢失这1s数据.通常选择 everysec ,兼顾安全性和效率
    #
    appendfsync everysec
     
     
    # 在aof重写或者写入rdb文件的时候,会执行大量IO,此时对于everysec和always的aof模式来说,
    # 执行fsync会造成阻塞过长时间,no-appendfsync-on-rewrite字段设置为默认设置为no.
    # 如果对延迟要求很高的应用,这个字段可以设置为yes,否则还是设置为no,
    # 这样对持久化特性来说这是更安全的选择.
    # 设置为yes表示rewrite期间对新写操作不fsync,暂时存在内存中,等rewrite完成后再写入,默认为no,建议yes.
    # Linux的默认fsync策略是30秒.可能丢失30秒数据.默认值为no.
    #
    no-appendfsync-on-rewrite no
     
     
    # 默认值为100.aof自动重写配置,当目前aof文件大小超过上一次重写的aof文件大小的百分之多少进行重写,
    # 即当aof文件增长到一定大小的时候,Redis能够调用bgrewriteaof对日志文件进行重写.
    # 当前AOF文件大小是上次日志重写得到AOF文件大小的二倍(设置为100)时,自动启动新的日志重写过程.
    #
    auto-aof-rewrite-percentage 100
     
     
    # 设置允许重写的最小aof文件大小,避免了达到约定百分比但尺寸仍然很小的情况还要重写.
    #
    auto-aof-rewrite-min-size 64mb
     
     
    # aof文件可能在尾部是不完整的,当redis启动的时候,aof文件的数据被载入内存.
    # 重启可能发生在redis所在的主机操作系统宕机后,尤其在ext4文件系统没有加上data=ordered选项,
    # 出现这种现象 redis宕机或者异常终止不会造成尾部不完整现象,可以选择让redis退出,
    # 或者导入尽可能多的数据.如果选择的是yes,当截断的aof文件被导入的时候,
    # 会自动发布一个log给客户端然后load.如果是no,用户必须手动redis-check-aof修复AOF文件才可以.
    # 默认值为 yes
    #
    aof-load-truncated yes
     
     
    # This is currently turned off by default in order to avoid the surprise
    # of a format change, but will at some point be used as the default.
    #
    aof-use-rdb-preamble no
     
     
    # Set it to 0 or a negative value for unlimited execution without warnings.
    #
    lua-time-limit 5000
     
     
    ################################## SLOW LOG ###################################
     
     
    # The following time is expressed in microseconds, so 1000000 is equivalent
    # to one second. Note that a negative number disables the slow log, while
    # a value of zero forces the logging of every command.
    #
    slowlog-log-slower-than 10000
     
     
    # There is no limit to this length. Just be aware that it will consume memory.
    # You can reclaim memory used by the slow log with SLOWLOG RESET.
    #
    slowlog-max-len 128
     
     
    ################################ LATENCY MONITOR ##############################
     
     
    # By default latency monitoring is disabled since it is mostly not needed
    # if you don't have latency issues, and collecting data has a performance
    # impact, that while very small, can be measured under big load. Latency
    # monitoring can easily be enabled at runtime using the command
    # "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
    #
    latency-monitor-threshold 0
     
     
    ############################# EVENT NOTIFICATION ##############################
     
    # By default all notifications are disabled because most users don't need
    # this feature and the feature has some overhead. Note that if you don't
    # specify at least one of K or E, no events will be delivered.
    #
    notify-keyspace-events ""
     
     
    ############################### ADVANCED CONFIG ###############################
     
     
    # Hashes are encoded using a memory efficient data structure when they have a
    # small number of entries, and the biggest entry does not exceed a given
    # threshold. These thresholds can be configured using the following directives.
    #
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
     
     
    # Positive numbers mean store up to _exactly_ that number of elements
    # per list node.
    # The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
    # but if your use case is unique, adjust the settings as necessary.
    #
    list-max-ziplist-size -2
     
     
    # 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
    # etc.
    #
    list-compress-depth 0
     
     
    # Sets have a special encoding in just one case: when a set is composed
    # of just strings that happen to be integers in radix 10 in the range
    # of 64 bit signed integers.
    # The following configuration setting sets the limit in the size of the
    # set in order to use this special memory saving encoding.
    #
    set-max-intset-entries 512
     
     
    # Similarly to hashes and lists, sorted sets are also specially encoded in
    # order to save a lot of space. This encoding is only used when the length and
    # elements of a sorted set are below the following limits:
    #
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
     
     
    # The suggested value is ~ 3000 in order to have the benefits of
    # the space efficient encoding without slowing down too much PFADD,
    # which is O(N) with the sparse encoding. The value can be raised to
    # ~ 10000 when CPU is not a concern, but space is, and the data set is
    # composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
    #
    hll-sparse-max-bytes 3000
     
     
    # use "activerehashing yes" if you don't have such hard requirements but
    # want to free memory asap when possible.
    #
    activerehashing yes
     
     
    # Both the hard or the soft limit can be disabled by setting them to zero.
    #
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit slave 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
     
     
    # The range is between 1 and 500, however a value over 100 is usually not
    # a good idea. Most users should use the default of 10 and raise this up to
    # 100 only in environments where very low latency is required.
    #
    hz 10
     
     
    # When a child rewrites the AOF file, if the following option is enabled
    # the file will be fsync-ed every 32 MB of data generated. This is useful
    # in order to commit the file to the disk more incrementally and avoid
    # big latency spikes.
    #
    aof-rewrite-incremental-fsync yes
     podman run -d --privileged=true -p 6380:6380 -v /horus/redis_6.2.6/conf/redis.conf:/etc/redis/redis.conf -v /horus/redis_6.2.6/data:/data --name redis_6.2.6 3c3da61c4be0 /etc/redis/redis.conf --appendonly yes
  • podman run -d --privileged=true -p 6380:6380 \
  • -v /horus/redis_6.2.6/conf/redis.conf:/etc/redis/redis.conf \     映射配置文件
  • -v /horus/redis_6.2.6/data:/data \                                             映射挂载目录
  • --name redis_6.2.6 镜像ID /etc/redis/redis.conf \                     指定配置文件启动redis-server进程
  • --appendonly yes                                                                      开启数据持久化
  • podman exec -it b087c14607bf redis-cli -p 6380
    
    auth hj2022
  •     podman exec -it 容器ID redis-cli -p 6380      进入容器
  •     auth xxx                                                         校验密码
  •      IDEA连接校验ok 
 

 

标签:aof,no,记录,redis,hj,podman,mysql,服务器,yes
来源: https://www.cnblogs.com/hua-jian/p/16316764.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有