«

prometheus监控中间件

LiHaiYang 发布于 阅读:1416 服务器监控告警


[TOC]

redis

部署redis

redis下载地址

#下载redis安装包
[root@VM-0-10-centos ~]# wget http://download.redis.io/releases/redis-4.0.10.tar.gz
--2023-07-15 08:24:46--  http://download.redis.io/releases/redis-4.0.10.tar.gz
Resolving download.redis.io (download.redis.io)... 45.60.125.1
Connecting to download.redis.io (download.redis.io)|45.60.125.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1738465 (1.7M) [application/octet-stream]
Saving to: ‘redis-4.0.10.tar.gz’

100%[====================================================================================================================================================================================================================================>] 1,738,465   1.08MB/s   in 1.5s   

2023-07-15 08:24:48 (1.08 MB/s) - ‘redis-4.0.10.tar.gz’ saved [1738465/1738465]

[root@VM-0-10-centos ~]# ls
redis-4.0.10.tar.gz
#解压redis安装包
[root@VM-0-10-centos ~]# tar xf redis-4.0.10.tar.gz 
#把解压的redis安装包移动到安装路径下
[root@VM-0-10-centos ~]# mv redis-4.0.10 /usr/local/redis
#进入redis解压目录
[root@VM-0-10-centos ~]# cd /usr/local/redis/
[root@VM-0-10-centos redis]# ls
00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README.md  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils
#安装gcc及c++编译器
[root@VM-0-10-centos redis]# yum -y install gcc gcc-c++ kernel-devel
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
epel                                                                                                                                                                                                                                                   | 4.7 kB  00:00:00     
extras                                                                                                                                                                                                                                                 | 2.9 kB  00:00:00     
os                                                                                                                                                                                                                                                     | 3.6 kB  00:00:00     
updates                                                                                                                                                                                                                                                | 2.9 kB  00:00:00     
Package gcc-4.8.5-44.el7.x86_64 already installed and latest version
Package gcc-c++-4.8.5-44.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:3.10.0-1160.92.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================================================
 Package                                                           Arch                                                        Version                                                                     Repository                                                    Size
==============================================================================================================================================================================================================================================================================
Installing:
 kernel-devel                                                      x86_64                                                      3.10.0-1160.92.1.el7                                                        updates                                                       18 M

Transaction Summary
==============================================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 18 M
Installed size: 38 M
Downloading packages:
No Presto metadata available for updates
kernel-devel-3.10.0-1160.92.1.el7.x86_64.rpm                                                                                                                                                                                                           |  18 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-devel-3.10.0-1160.92.1.el7.x86_64                                                                                                                                                                                                                   1/1 
  Verifying  : kernel-devel-3.10.0-1160.92.1.el7.x86_64                                                                                                                                                                                                                   1/1 

Installed:
  kernel-devel.x86_64 0:3.10.0-1160.92.1.el7                                                                                                                                                                                                                                  

Complete!
#安装redis
[root@VM-0-10-centos redis]# make && cd src/ && make install
cd src && make all
make[1]: Entering directory `/usr/local/redis/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/redis/src'
make[1]: Entering directory `/usr/local/redis/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
(cd ../deps && make distclean)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/usr/local/redis/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/usr/local/redis/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  read.c
ar rcs libhiredis.a net.o hiredis.o sds.o async.o read.o
make[3]: Leaving directory `/usr/local/redis/deps/hiredis'
MAKE linenoise
cd linenoise && make
make[3]: Entering directory `/usr/local/redis/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
make[3]: Leaving directory `/usr/local/redis/deps/linenoise'
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' " MYLDFLAGS="" AR="ar rcu"
make[3]: Entering directory `/usr/local/redis/deps/lua/src'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lapi.o lapi.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lcode.o lcode.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldebug.o ldebug.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldo.o ldo.c
ldo.c: In function ‘f_parser’:
ldo.c:496:7: warning: unused variable ‘c’ [-Wunused-variable]
   int c = luaZ_lookahead(p->z);
       ^
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldump.o ldump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lfunc.o lfunc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lgc.o lgc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o llex.o llex.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lmem.o lmem.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lobject.o lobject.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lopcodes.o lopcodes.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lparser.o lparser.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lstate.o lstate.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lstring.o lstring.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ltable.o ltable.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ltm.o ltm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lundump.o lundump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lvm.o lvm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lzio.o lzio.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o strbuf.o strbuf.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o fpconv.o fpconv.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lauxlib.o lauxlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lbaselib.o lbaselib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldblib.o ldblib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o liolib.o liolib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lmathlib.o lmathlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o loslib.o loslib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ltablib.o ltablib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lstrlib.o lstrlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o loadlib.o loadlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o linit.o linit.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_cjson.o lua_cjson.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_struct.o lua_struct.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_cmsgpack.o lua_cmsgpack.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_bit.o lua_bit.c
ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o fpconv.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o lua_bit.o  # DLL needs all object files
ranlib liblua.a
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua.o lua.c
cc -o lua  lua.o liblua.a -lm 
liblua.a(loslib.o): In function `os_tmpname':
loslib.c:(.text+0x28c): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o luac.o luac.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o print.o print.c
cc -o luac  luac.o print.o liblua.a -lm 
make[3]: Leaving directory `/usr/local/redis/deps/lua/src'
MAKE jemalloc
cd jemalloc && ./configure --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS=""
checking for xsltproc... false
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking size of void *... 8
checking size of int... 4
checking size of long... 8
checking size of intmax_t... 8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether pause instruction is compilable... yes
checking for ar... ar
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking whether malloc_usable_size definition can use const argument... no
checking whether __attribute__ syntax is compilable... yes
checking whether compiler supports -fvisibility=hidden... yes
checking whether compiler supports -Werror... yes
checking whether tls_model attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether alloc_size attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether format(gnu_printf, ...) attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether format(printf, ...) attribute is compilable... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ld... /usr/bin/ld
checking for autoconf... /usr/bin/autoconf
checking for memalign... yes
checking for valloc... yes
checking configured backtracing method... N/A
checking for sbrk... yes
checking whether utrace(2) is compilable... no
checking whether valgrind is compilable... yes
checking whether a program using __builtin_ffsl is compilable... yes
checking LG_PAGE... 12
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for library containing clock_gettime... none required
checking for secure_getenv... yes
checking for issetugid... no
checking for _malloc_thread_cleanup... no
checking for _pthread_mutex_init_calloc_cb... no
checking for TLS... yes
checking whether C11 atomics is compilable... no
checking whether atomic(9) is compilable... no
checking whether Darwin OSAtomic*() is compilable... no
checking whether madvise(2) is compilable... yes
checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no
checking whether to force 64-bit __sync_{add,sub}_and_fetch()... no
checking for __builtin_clz... yes
checking whether Darwin OSSpin*() is compilable... no
checking whether glibc malloc hook is compilable... yes
checking whether glibc memalign hook is compilable... yes
checking whether pthreads adaptive mutexes is compilable... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating jemalloc.pc
config.status: creating doc/html.xsl
config.status: creating doc/manpages.xsl
config.status: creating doc/jemalloc.xml
config.status: creating include/jemalloc/jemalloc_macros.h
config.status: creating include/jemalloc/jemalloc_protos.h
config.status: creating include/jemalloc/jemalloc_typedefs.h
config.status: creating include/jemalloc/internal/jemalloc_internal.h
config.status: creating test/test.sh
config.status: creating test/include/test/jemalloc_test.h
config.status: creating config.stamp
config.status: creating bin/jemalloc-config
config.status: creating bin/jemalloc.sh
config.status: creating bin/jeprof
config.status: creating include/jemalloc/jemalloc_defs.h
config.status: creating include/jemalloc/internal/jemalloc_internal_defs.h
config.status: creating test/include/test/jemalloc_test_defs.h
config.status: executing include/jemalloc/internal/private_namespace.h commands
config.status: executing include/jemalloc/internal/private_unnamespace.h commands
config.status: executing include/jemalloc/internal/public_symbols.txt commands
config.status: executing include/jemalloc/internal/public_namespace.h commands
config.status: executing include/jemalloc/internal/public_unnamespace.h commands
config.status: executing include/jemalloc/internal/size_classes.h commands
config.status: executing include/jemalloc/jemalloc_protos_jet.h commands
config.status: executing include/jemalloc/jemalloc_rename.h commands
config.status: executing include/jemalloc/jemalloc_mangle.h commands
config.status: executing include/jemalloc/jemalloc_mangle_jet.h commands
config.status: executing include/jemalloc/jemalloc.h commands
===============================================================================
jemalloc version   : 4.0.3-0-ge9192eacf8935e29fc62fddc2701f7942b1cc02c
library revision   : 2

CONFIG             : --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence 'CFLAGS=-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops ' LDFLAGS=
CC                 : gcc
CFLAGS             : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -fvisibility=hidden
CPPFLAGS           :  -D_GNU_SOURCE -D_REENTRANT
LDFLAGS            : 
EXTRA_LDFLAGS      : 
LIBS               :  -lpthread
TESTLIBS           : 
RPATH_EXTRA        : 

XSLTPROC           : false
XSLROOT            : 

PREFIX             : /usr/local
BINDIR             : /usr/local/bin
DATADIR            : /usr/local/share
INCLUDEDIR         : /usr/local/include
LIBDIR             : /usr/local/lib
MANDIR             : /usr/local/share/man

srcroot            : 
abs_srcroot        : /usr/local/redis/deps/jemalloc/
objroot            : 
abs_objroot        : /usr/local/redis/deps/jemalloc/

JEMALLOC_PREFIX    : je_
JEMALLOC_PRIVATE_NAMESPACE
                   : je_
install_suffix     : 
autogen            : 0
cc-silence         : 1
debug              : 0
code-coverage      : 0
stats              : 1
prof               : 0
prof-libunwind     : 0
prof-libgcc        : 0
prof-gcc           : 0
tcache             : 1
fill               : 1
utrace             : 0
valgrind           : 1
xmalloc            : 0
munmap             : 0
lazy_lock          : 0
tls                : 1
cache-oblivious    : 1
===============================================================================
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
make[3]: Entering directory `/usr/local/redis/deps/jemalloc'
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/jemalloc.o src/jemalloc.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/atomic.o src/atomic.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.o src/base.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_dss.o src/chunk_dss.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_mmap.o src/chunk_mmap.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/huge.o src/huge.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/pages.o src/pages.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/quarantine.o src/quarantine.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/util.o src/util.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tsd.o src/tsd.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/valgrind.o src/valgrind.c
ar crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/atomic.o src/base.o src/bitmap.o src/chunk.o src/chunk_dss.o src/chunk_mmap.o src/ckh.o src/ctl.o src/extent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/pages.o src/prof.o src/quarantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o src/valgrind.o
make[3]: Leaving directory `/usr/local/redis/deps/jemalloc'
make[2]: Leaving directory `/usr/local/redis/deps'
    CC adlist.o
    CC quicklist.o
    CC ae.o
    CC anet.o
    CC dict.o
    CC server.o
    CC sds.o
    CC zmalloc.o
    CC lzf_c.o
    CC lzf_d.o
    CC pqsort.o
    CC zipmap.o
    CC sha1.o
    CC ziplist.o
    CC release.o
    CC networking.o
    CC util.o
    CC object.o
    CC db.o
    CC replication.o
    CC rdb.o
    CC t_string.o
    CC t_list.o
    CC t_set.o
    CC t_zset.o
    CC t_hash.o
    CC config.o
    CC aof.o
    CC pubsub.o
    CC multi.o
    CC debug.o
    CC sort.o
    CC intset.o
    CC syncio.o
    CC cluster.o
    CC crc16.o
    CC endianconv.o
    CC slowlog.o
    CC scripting.o
    CC bio.o
    CC rio.o
    CC rand.o
    CC memtest.o
    CC crc64.o
    CC bitops.o
    CC sentinel.o
    CC notify.o
    CC setproctitle.o
    CC blocked.o
    CC hyperloglog.o
    CC latency.o
    CC sparkline.o
    CC redis-check-rdb.o
    CC redis-check-aof.o
    CC geo.o
    CC lazyfree.o
    CC module.o
    CC evict.o
    CC expire.o
    CC geohash.o
    CC geohash_helper.o
    CC childinfo.o
    CC defrag.o
    CC siphash.o
    CC rax.o
    LINK redis-server
    INSTALL redis-sentinel
    CC redis-cli.o
    LINK redis-cli
    CC redis-benchmark.o
    LINK redis-benchmark
    INSTALL redis-check-rdb
    INSTALL redis-check-aof

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/usr/local/redis/src'
    CC Makefile.dep

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
[root@VM-0-10-centos src]# 
#进入redis安装路径
[root@VM-0-10-centos ~]# cd /usr/local/redis
[root@VM-0-10-centos redis]# ls
00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README.md  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils
#修改redis密码
[root@VM-0-10-centos redis]# sed -i "s/# requirepass foobared/requirepass 123456/g" redis.conf 
#取消登陆限制
[root@VM-0-10-centos redis]# sed -i "s/bind 127.0.0.1/#bind 127.0.0.1/g" redis.conf 
#修改默认端口6379
[root@VM-0-10-centos redis]# sed -i "s/port 6379/port 16379/g" redis.conf
#新增文件
[root@VM-0-10-centos redis]# vim /etc/systemd/system/redis.service 
#添加以下内容
[Unit]
Description=redis
Documentation=https://redis.io/
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@VM-0-10-centos redis]# systemctl enable redis.service
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /etc/systemd/system/redis.service.
[root@VM-0-10-centos src]# service redis start
[root@VM-0-10-centos src]# ./redis-cli -h 127.0.0.1 -p 16379
#验证密码
127.0.0.1:16379> auth 123456
OK
127.0.0.1:16379>

部署redis-exporter

redis_exporter下载地址

#下载redis_exporter
[root@VM-0-10-centos ~]# wget https://install.jishuliu.cn/prometheus/redis_exporter-v1.51.0.linux-amd64.tar.gz
--2023-07-15 08:41:12--  https://install.jishuliu.cn/prometheus/redis_exporter-v1.51.0.linux-amd64.tar.gz
Resolving package.jishuliu.cn (package.jishuliu.cn)... 218.12.86.80, 116.153.64.158, 116.172.148.7, ...
Connecting to package.jishuliu.cn (package.jishuliu.cn)|218.12.86.80|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3580335 (3.4M) [application/gzip]
Saving to: ‘redis_exporter-v1.51.0.linux-amd64.tar.gz’

100%[====================================================================================================================================================================================================================================>] 3,580,335   7.40MB/s   in 0.5s   

2023-07-15 08:41:13 (7.40 MB/s) - ‘redis_exporter-v1.51.0.linux-amd64.tar.gz’ saved [3580335/3580335]
#解压redis_exporter
[root@VM-0-10-centos ~]# tar xf redis_exporter-v1.51.0.linux-amd64.tar.gz 
[root@VM-0-10-centos ~]# ls
redis_exporter-v1.51.0.linux-amd64  redis_exporter-v1.51.0.linux-amd64.tar.gz
#把redis_exporter移动到安装路径
[root@VM-0-10-centos ~]# mv redis_exporter-v1.51.0.linux-amd64 /usr/local/redis_exporter
[root@VM-0-10-centos ~]# ls
redis_exporter-v1.51.0.linux-amd64.tar.gz
#删除redis_exporter安装包
[root@VM-0-10-centos ~]# rm -rf redis_exporter-v1.51.0.linux-amd64.tar.gz
#进入redis_exporter安装路径
[root@VM-0-10-centos local]# cd /usr/local/redis_exporter/
[root@VM-0-10-centos redis_exporter]# ls
LICENSE  README.md  redis_exporter
#新增文件
[root@VM-0-10-centos ~]# cat /etc/systemd/system/redis_exporter.service 
#写入以下内容
[Unit]
Descriptinotallow=redis_exporter
Documentatinotallow=https://github.com/oliver006/redis_exporter
After=network.target
[Service]
Type=simple
User=root
#-redis.addr:redis地址(IP:port)。-redis.password:redis密码(无密码则不用配置此参数)。-web.listen-address:redis_exporter的监听端口,默认9121
ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 127.0.0.1:16379  -redis.password 123456 -web.listen-address ":9122"
Restart=on-failure
[Install]
WantedBy=multi-user.target
#启动redis_exporter
[root@VM-0-10-centos ~]# service redis_exporter start
Redirecting to /bin/systemctl start redis_exporter.service
[root@VM-0-10-centos ~]# service redis_exporter status
Redirecting to /bin/systemctl status redis_exporter.service
● redis_exporter.service
   Loaded: loaded (/etc/systemd/system/redis_exporter.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2023-07-15 08:58:41 CST; 1s ago
 Main PID: 4839 (redis_exporter)
   CGroup: /system.slice/redis_exporter.service
           └─4839 /usr/local/redis_exporter/redis_exporter -redis.addr 127.0.0.1:16379 -redis.password 123456 -web.listen-address :9122

Jul 15 08:58:41 VM-0-10-centos systemd[1]: Started redis_exporter.service.
Jul 15 08:58:41 VM-0-10-centos redis_exporter[4839]: time="2023-07-15T08:58:41+08:00" level=info msg="Redis Metrics Exporter v1.51.0    build date: 2023-06-15-03:20:32    sha1: c3efa55016c226a43a66b0a8b44cdb0c149048c4    Go: go1.20.2    GOOS: linux    GOARCH: amd64"
Jul 15 08:58:41 VM-0-10-centos redis_exporter[4839]: time="2023-07-15T08:58:41+08:00" level=info msg="Providing metrics at :9122/metrics"
#设置redis_exporter开机自启
[root@VM-0-10-centos ~]# systemctl enable redis_exporter.service
Created symlink from /etc/systemd/system/multi-user.target.wants/redis_exporter.service to /etc/systemd/system/redis_exporter.service.

Prometheus添加node_exporter

#进入Prometheus的安装路径下
[root@VM-0-10-centos ~]# cd /usr/local/prometheus/
#在Prometheus的内添加最下面三行
[root@VM-0-10-centos prometheus]# vim prometheus.yml 
# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
#项目名
  - job_name: "redis"
    static_configs:
      #
      - targets: ["127.0.0.1:9122"]
[root@VM-0-10-centos prometheus]# service prometheus restart
Redirecting to /bin/systemctl restart prometheus.service

redis_exporter的dashboard模版下载地址

MySQL

部署MySQL

#下载MySQL安装包
[root@VM-0-10-centos ~]# wget https://install.jishuliu.cn/MySQL/mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
--2023-07-15 09:13:11--  https://install.jishuliu.cn/MySQL/mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
Resolving package.jishuliu.cn (package.jishuliu.cn)... 119.188.86.194, 116.172.148.7, 116.163.24.195, ...
Connecting to package.jishuliu.cn (package.jishuliu.cn)|119.188.86.194|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554516480 (529M) [application/x-tar]
Saving to: ‘mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar’

100%[=======================================================================================================================================================>] 554,516,480 4.37MB/s   in 1m 59s 

2023-07-15 09:15:10 (4.45 MB/s) - ‘mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar’ saved [554516480/554516480]

[root@VM-0-10-centos ~]# ls
mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
#创建MySQL解压路径
[root@VM-0-10-centos ~]# mkdir mysql
#解压安装包到指定路径
[root@VM-0-10-centos ~]# tar xf mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar -C mysql/
#进入解压路径
[root@VM-0-10-centos ~]# cd mysql/
[root@VM-0-10-centos mysql]# ls
mysql-community-client-5.7.38-1.el7.x86_64.rpm    mysql-community-embedded-compat-5.7.38-1.el7.x86_64.rpm  mysql-community-server-5.7.38-1.el7.x86_64.rpm
mysql-community-common-5.7.38-1.el7.x86_64.rpm    mysql-community-embedded-devel-5.7.38-1.el7.x86_64.rpm   mysql-community-test-5.7.38-1.el7.x86_64.rpm
mysql-community-devel-5.7.38-1.el7.x86_64.rpm     mysql-community-libs-5.7.38-1.el7.x86_64.rpm
mysql-community-embedded-5.7.38-1.el7.x86_64.rpm  mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm
#安装MySQL
[root@VM-0-10-centos mysql]# yum -y localinstall *.rpm
Loaded plugins: fastestmirror, langpacks
Examining mysql-community-client-5.7.38-1.el7.x86_64.rpm: mysql-community-client-5.7.38-1.el7.x86_64
Marking mysql-community-client-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-common-5.7.38-1.el7.x86_64.rpm: mysql-community-common-5.7.38-1.el7.x86_64
Marking mysql-community-common-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-devel-5.7.38-1.el7.x86_64.rpm: mysql-community-devel-5.7.38-1.el7.x86_64
Marking mysql-community-devel-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-embedded-5.7.38-1.el7.x86_64.rpm: mysql-community-embedded-5.7.38-1.el7.x86_64
Marking mysql-community-embedded-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-embedded-compat-5.7.38-1.el7.x86_64.rpm: mysql-community-embedded-compat-5.7.38-1.el7.x86_64
Marking mysql-community-embedded-compat-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-embedded-devel-5.7.38-1.el7.x86_64.rpm: mysql-community-embedded-devel-5.7.38-1.el7.x86_64
Marking mysql-community-embedded-devel-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-libs-5.7.38-1.el7.x86_64.rpm: mysql-community-libs-5.7.38-1.el7.x86_64
Marking mysql-community-libs-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm: mysql-community-libs-compat-5.7.38-1.el7.x86_64
Marking mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-server-5.7.38-1.el7.x86_64.rpm: mysql-community-server-5.7.38-1.el7.x86_64
Marking mysql-community-server-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-test-5.7.38-1.el7.x86_64.rpm: mysql-community-test-5.7.38-1.el7.x86_64
Marking mysql-community-test-5.7.38-1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
---> Package mysql-community-client.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-common.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-devel.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-embedded.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-embedded-compat.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-embedded-devel.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:5.7.38-1.el7 will be obsoleting
---> Package mysql-community-libs-compat.x86_64 0:5.7.38-1.el7 will be obsoleting
---> Package mysql-community-server.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-test.x86_64 0:5.7.38-1.el7 will be installed
--> Processing Dependency: perl(JSON) for package: mysql-community-test-5.7.38-1.el7.x86_64
Loading mirror speeds from cached hostfile
--> Processing Dependency: perl(JSON) for package: mysql-community-test-5.7.38-1.el7.x86_64
--> Running transaction check
---> Package perl-JSON.noarch 0:2.59-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                             Arch                       Version                           Repository                                                                Size
=================================================================================================================================================================================================
Installing:
 mysql-community-client                              x86_64                     5.7.38-1.el7                      /mysql-community-client-5.7.38-1.el7.x86_64                              106 M
 mysql-community-common                              x86_64                     5.7.38-1.el7                      /mysql-community-common-5.7.38-1.el7.x86_64                              2.8 M
 mysql-community-devel                               x86_64                     5.7.38-1.el7                      /mysql-community-devel-5.7.38-1.el7.x86_64                                24 M
 mysql-community-embedded                            x86_64                     5.7.38-1.el7                      /mysql-community-embedded-5.7.38-1.el7.x86_64                            201 M
 mysql-community-embedded-compat                     x86_64                     5.7.38-1.el7                      /mysql-community-embedded-compat-5.7.38-1.el7.x86_64                      88 M
 mysql-community-embedded-devel                      x86_64                     5.7.38-1.el7                      /mysql-community-embedded-devel-5.7.38-1.el7.x86_64                      902 M
 mysql-community-libs                                x86_64                     5.7.38-1.el7                      /mysql-community-libs-5.7.38-1.el7.x86_64                                9.9 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-libs-compat                         x86_64                     5.7.38-1.el7                      /mysql-community-libs-compat-5.7.38-1.el7.x86_64                         6.0 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-server                              x86_64                     5.7.38-1.el7                      /mysql-community-server-5.7.38-1.el7.x86_64                              771 M
 mysql-community-test                                x86_64                     5.7.38-1.el7                      /mysql-community-test-5.7.38-1.el7.x86_64                                669 M
Installing for dependencies:
 perl-JSON                                           noarch                     2.59-2.el7                        os                                                                        96 k

Transaction Summary
=================================================================================================================================================================================================
Install  10 Packages (+1 Dependent package)

Total size: 2.7 G
Total download size: 96 k
Downloading packages:
perl-JSON-2.59-2.el7.noarch.rpm                                                                                                                                           |  96 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-5.7.38-1.el7.x86_64                                                                                                                                   1/12 
  Installing : mysql-community-libs-5.7.38-1.el7.x86_64                                                                                                                                     2/12 
  Installing : mysql-community-client-5.7.38-1.el7.x86_64                                                                                                                                   3/12 
  Installing : mysql-community-server-5.7.38-1.el7.x86_64                                                                                                                                   4/12 
  Installing : mysql-community-devel-5.7.38-1.el7.x86_64                                                                                                                                    5/12 
  Installing : mysql-community-embedded-5.7.38-1.el7.x86_64                                                                                                                                 6/12 
  Installing : perl-JSON-2.59-2.el7.noarch                                                                                                                                                  7/12 
  Installing : mysql-community-test-5.7.38-1.el7.x86_64                                                                                                                                     8/12 
  Installing : mysql-community-embedded-devel-5.7.38-1.el7.x86_64                                                                                                                           9/12 
  Installing : mysql-community-libs-compat-5.7.38-1.el7.x86_64                                                                                                                             10/12 
  Installing : mysql-community-embedded-compat-5.7.38-1.el7.x86_64                                                                                                                         11/12 
  Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                          12/12 
  Verifying  : mysql-community-embedded-5.7.38-1.el7.x86_64                                                                                                                                 1/12 
  Verifying  : mysql-community-test-5.7.38-1.el7.x86_64                                                                                                                                     2/12 
  Verifying  : perl-JSON-2.59-2.el7.noarch                                                                                                                                                  3/12 
  Verifying  : mysql-community-embedded-devel-5.7.38-1.el7.x86_64                                                                                                                           4/12 
  Verifying  : mysql-community-client-5.7.38-1.el7.x86_64                                                                                                                                   5/12 
  Verifying  : mysql-community-devel-5.7.38-1.el7.x86_64                                                                                                                                    6/12 
  Verifying  : mysql-community-server-5.7.38-1.el7.x86_64                                                                                                                                   7/12 
  Verifying  : mysql-community-libs-compat-5.7.38-1.el7.x86_64                                                                                                                              8/12 
  Verifying  : mysql-community-embedded-compat-5.7.38-1.el7.x86_64                                                                                                                          9/12 
  Verifying  : mysql-community-common-5.7.38-1.el7.x86_64                                                                                                                                  10/12 
  Verifying  : mysql-community-libs-5.7.38-1.el7.x86_64                                                                                                                                    11/12 
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                          12/12 

Installed:
  mysql-community-client.x86_64 0:5.7.38-1.el7               mysql-community-common.x86_64 0:5.7.38-1.el7                      mysql-community-devel.x86_64 0:5.7.38-1.el7                     
  mysql-community-embedded.x86_64 0:5.7.38-1.el7             mysql-community-embedded-compat.x86_64 0:5.7.38-1.el7             mysql-community-embedded-devel.x86_64 0:5.7.38-1.el7            
  mysql-community-libs.x86_64 0:5.7.38-1.el7                 mysql-community-libs-compat.x86_64 0:5.7.38-1.el7                 mysql-community-server.x86_64 0:5.7.38-1.el7                    
  mysql-community-test.x86_64 0:5.7.38-1.el7                

Dependency Installed:
  perl-JSON.noarch 0:2.59-2.el7                                                                                                                                                                  

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7                                                                                                                                                             

Complete!
#启动MySQL
[root@VM-0-10-centos mysql]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
#查看日志文件内的初始密码
[root@VM-0-10-centos mysql]# grep pass error.log 
2023-07-15T01:21:14.652964Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:14.652967Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:16.979187Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:16.979190Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:19.229950Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:19.229953Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:21.501437Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:21.501440Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:23.729500Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:23.729503Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:25.927261Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:25.927264Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:28.232722Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:28.232725Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:30.491697Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:30.491701Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:32.688208Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:32.688211Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:34.939424Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:34.939427Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:37.241312Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:37.241315Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:39.487183Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:39.487186Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:41.687434Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:41.687438Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:43.987688Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:43.987698Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:46.239128Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:46.239131Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:48.490688Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:48.490691Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:50.742233Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:50.742236Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:52.980292Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:52.980296Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:55.239998Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:55.240001Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:57.485870Z 0 [Note] Shutting down plugin 'sha256_password'
2023-07-15T01:21:57.485873Z 0 [Note] Shutting down plugin 'mysql_native_password'
2023-07-15T01:21:58.437825Z 1 [Note] A temporary password is generated for root@localhost: J%#b#y5bz1jf
#进入MySQL数据库
[root@VM-0-10-centos mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.38

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

#修改策略
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

#修改策略
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

#修改密码
mysql> set password=password("123456");
Query OK, 0 rows affected, 1 warning (0.00 sec)

#刷新权限
mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

#新增授权
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)

#刷新权限
mysql>  flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
#设置开机启动
[root@VM-0-10-centos ~]# systemctl enable mysqld.service

部署mysql_exporter

#下载mysqld_epxorter安装包
[root@VM-0-10-centos ~]# wget https://install.jishuliu.cn/prometheus/mysqld_exporter-0.14.0.linux-amd64.tar.gz
--2023-07-15 10:28:57--  https://install.jishuliu.cn/prometheus/mysqld_exporter-0.14.0.linux-amd64.tar.gz
Resolving package.jishuliu.cn (package.jishuliu.cn)... 42.236.89.185, 116.153.64.158, 36.248.54.138, ...
Connecting to package.jishuliu.cn (package.jishuliu.cn)|42.236.89.185|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7450991 (7.1M) [application/gzip]
Saving to: ‘mysqld_exporter-0.14.0.linux-amd64.tar.gz’

100%[=======================================================================================================================================================>] 7,450,991   3.38MB/s   in 2.1s   

2023-07-15 10:28:59 (3.38 MB/s) - ‘mysqld_exporter-0.14.0.linux-amd64.tar.gz’ saved [7450991/7450991]

[root@VM-0-10-centos ~]# ls
mysqld_exporter-0.14.0.linux-amd64.tar.gz
#解压安装包
[root@VM-0-10-centos ~]# tar xf mysqld_exporter-0.14.0.linux-amd64.tar.gz 
#把mysql_exporter的安装包移动到安装目录下
[root@VM-0-10-centos ~]# mv mysqld_exporter-0.14.0.linux-amd64 /usr/local/mysqld_exporter
#进入mysql_exporter的安装路径下
[root@VM-0-10-centos ~]# cd 
#编辑my.cnf配置文件
[root@VM-0-10-centos mysqld_exporter]# vim .my.cnf
#写入以下内容
[client]
#数据库账号
user = root
#密码
password = root
#编辑文件
[root@VM-0-10-centos ~]# vim /etc/systemd/system/mysql_exporter.service

[Unit]
Descriptinotallow=mysql_exporter
Documentatinotallow=https://github.com/oliver006/redis_exporter
After=network.target
[Service]
Type=simple
User=root
#启动命令
ExecStart=/usr/local/mysql_exporter/mysqld_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
#重启mysql-exporter
[root@VM-0-10-centos ~]# service mysql_exporter restart
Redirecting to /bin/systemctl restart mysql_exporter.service
#设置开机启动
[root@VM-0-10-centos ~]# systemctl enable mysql_exporter.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mysql_exporter.service to /etc/systemd/system/mysql_exporter.service.
[root@VM-0-10-centos ~]#

Prometheus添加mysql_exporter

#进入Prometheus安装路径
[root@VM-0-10-centos ~]# cd /usr/local/prometheus/
[root@VM-0-10-centos prometheus]# ls
console_libraries  consoles  data  LICENSE  NOTICE  prometheus  prometheus.yml  promtool
#修改配置文件增加以下三行
[root@VM-0-10-centos prometheus]# vim prometheus.yml
- job_name: "mysql-测试环境"
    static_configs:
      - targets: ["127.0.0.1:9104"]
[root@VM-0-10-centos prometheus]# service prometheus restart
Redirecting to /bin/systemctl restart prometheus.service
[root@VM-0-10-centos prometheus]# 

grafana的mysql_exporter模版


扫描二维码,在手机上阅读
取消
微信二维码
微信二维码
支付宝二维码