众所周知的原因安装PMM2

20天前 23.7k 0

##

众所周知的原因安装PMM2

1、众所周知的原因安装PMM2

版本也是2.42.0,最新的版本

[root@pmm2 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://mirror.baidubce.com"
]
}

[root@pmm2 ~]# docker image inspect percona/pmm-server:2 | grep -i version
"DockerVersion": "20.10.25",
"org.opencontainers.image.version": "2.42.0"

[root@pmm2 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aea7f134683e percona/pmm-server:2 "/opt/entrypoint.sh" 18 minutes ago Up 18 minutes (healthy) 80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp pmm-server

2、留存docker image

[root@pmm2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
percona/pmm-server 2 8a3a13ce2d13 4 weeks ago 2.39GB

[root@pmm2 ~]# docker save 8a3a13ce2d13 > /root/pmm2_2.42.0.tar

[root@pmm2 ~]# du -sh pmm2_2.42.0.tar
2.3G pmm2_2.42.0.tar

3、导入测试

#删除重建,或者其他导入docker,并修改tag

[root@pmm2 ~]# docker load ] 115.1MB/115.1MB
c6e5cc92bae4: Loading layer [==================================================>] 2.298GB/2.298GB
Loaded image ID: sha256:8a3a13ce2d13ea94b2af803aba4797b8b18ec8b1f1c6f4b6205043b19bbb6c8e

[root@pmm2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
8a3a13ce2d13 4 weeks ago 2.39GB

[root@pmm2 ~]# docker tag 8a3a13ce2d13 percona/pmm-server:2

[root@pmm2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
percona/pmm-server 2 8a3a13ce2d13 4 weeks ago 2.39GB

4、运行

这里不会再去pull image了,直接就可以把容器运行起来

[root@pmm2 ~]# wget -qO - https://www.percona.com/get/pmm | /bin/bash
Gathering/downloading required components, this may take a moment

Checking docker installation - installed.

Starting PMM server...
Created PMM Data Volume: pmm-data
Created PMM Server: pmm-server
Use the following command if you ever need to update your container by hand:
docker run -d -p 443:443 --volumes-from pmm-data --name pmm-server --restart always percona/pmm-server:2

PMM Server has been successfully setup on this system!

You can access your new server using one of the following web addresses:
https://172.17.0.1:443/
https://192.168.5.140:443/
https://127.0.0.1:443/

The default username is 'admin' and the password is 'admin' :)
Note: Some browsers may not trust the default SSL certificate when you first open one of the urls above.
If this is the case, Chrome users may want to type 'thisisunsafe' to bypass the warning.

Enjoy Percona Monitoring and Management!

5、pmm脚本

[root@pmm2 ~]# wget -qO - https://www.percona.com/get/pmm
#!/usr/bin/env bash
#
# ###############################
# Script to run PMM 2.
# If docker is not installed, this script will try to install it as root user.
#
# Usage example:
# curl -fsSL https://raw.githubusercontent.com/percona/pmm/main/get-pmm.sh -o get-pmm2.sh; chmod +x get-pmm2.sh; ./get-pmm2.sh
#
#################################

set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT

# Set defaults.
tag=${PMM_TAG:-"2"}
repo=${PMM_REPO:-"percona/pmm-server"}
port=${PMM_PORT:-443}
container_name=${CONTAINER_NAME:-"pmm-server"}
interactive=0
root_is_needed='no'

#######################################
# Show script usage info.
#######################################
usage() {
cat /dev/null'; then
if is_darwin; then
run_root 'open --background -a Docker'
echo "Giving docker desktop time to start"
sleep 30
else
die "${RED}ERROR: cannot run "docker ps" command${NOFORMAT}"
fi
fi
fi
}

#######################################
# Runs docker command as root if required.
#######################################
run_docker() {
if [ "${root_is_needed}" = 'yes' ]; then
run_root "docker $*"
else
sh -c "docker $*"
fi
}

#######################################
# Starts PMM server container with give repo, tag, name and port.
# If any PMM server instance is run - stop and backup it.
#######################################
start_pmm() {
msg "Starting PMM server..."
run_docker "pull $repo:$tag 1> /dev/null"

if ! run_docker "inspect pmm-data 1> /dev/null 2> /dev/null"; then
run_docker "create -v /srv/ --name pmm-data $repo:$tag /bin/true 1> /dev/null"
msg "Created PMM Data Volume: pmm-data"
fi

if run_docker "inspect pmm-server 1> /dev/null 2> /dev/null"; then
pmm_archive="pmm-server-$(date "+%F-%H%M%S")"
msg "\tExisting PMM Server found, renaming to $pmm_archive\n"
run_docker 'stop pmm-server' || :
run_docker "rename pmm-server $pmm_archive\n"
fi
run_pmm="run -d -p $port:443 --volumes-from pmm-data --name $container_name --restart always $repo:$tag"

run_docker "$run_pmm 1> /dev/null"
msg "Created PMM Server: $container_name"
msg "\tUse the following command if you ever need to update your container by hand:"
msg "\tdocker $run_pmm \n"
}

#######################################
# Shows final message.
# Shows a list of addresses on which PMM server available.
#######################################
show_message() {
msg "PMM Server has been successfully setup on this system!\n"

if check_command ifconfig; then
ips=$(ifconfig | awk '/inet / {print $2}' | sed 's/addr://')
elif check_command ip; then
ips=$(ip -f inet a | awk -F"[/ ]+" '/inet / {print $3}')
else
die "${RED}ERROR: cannot detect PMM server address${NOFORMAT}"
fi

msg "You can access your new server using one of the following web addresses:"
for ip in $ips; do
msg "\t${GREEN}https://$ip:$port/${NOFORMAT}"
done
msg "\nThe default username is '${PURPLE}admin${NOFORMAT}' and the password is '${PURPLE}admin${NOFORMAT}' :)"
msg "Note: Some browsers may not trust the default SSL certificate when you first open one of the urls above."
msg "If this is the case, Chrome users may want to type '${PURPLE}thisisunsafe${NOFORMAT}' to bypass the warning.\n"
}

main() {
setup_colors
if [[ $interactive == 1 ]]; then
gather_info
fi
msg "Gathering/downloading required components, this may take a moment\n"
install_docker
start_pmm
show_message
}

parse_params "$@"

main
die "Enjoy Percona Monitoring and Management!" 0

相关文章

【TiDB 社区智慧合集】TiDB 在核心场景的实战应用
如何理解数据库增量备份
Navicat for MySQL 17 | 实现更明智的业务决策
tidb8.1的磁盘选择,关于网络ssd,和本地ssd的选择对性能影响很大,差距60倍。
ORA-00600 internal error code, arguments [25026]
ORA-01555 caused by SQL statement below (SQL ID

发布评论