页面“Rabbitmq cluster on docker-compose”与“Mysql5.5 install”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
 +
[[category:mysql]]
  
=站内资源=
 
[[Rabbitmq常用命令]]
 
  
[https://blog.csdn.net/belonghuang157405/article/details/83540148  docker简易搭建RabbitMQ集群HA-good]
+
=binary install=
 
+
站内信息 [[Docker mysql]]
=ins rabbitmq=
 
==info==
 
  适合于 3.610 and 3.7.5 版本
 
-p 15672:15672 http访问端口
 
-p 5672:5672 amqp访问端口
 
-p 4369 #unable to connect to epmd (port 4369) on rabbitmq01: address (cannot connect to host/port)
 
 
 
==mq1==
 
===Note===
 
 
 
有一种是 node1 不加别 , node2  add node1  ; node3  add node1 and node2  但是  rabbitmqctl cluster_status 可能看起来有些node alarms是down的 不过通过浏览器的不会
 
 
<pre>
 
<pre>
 +
#!/bin/bash
 +
# Author:  linuxsa.org
 +
# BLOG:
  
#记得  extra_hosts 改成你的相关IP
 
mkdir -p /home/data/docker-compose-mqcluster
 
cd /home/data/docker-compose-mqcluster
 
##"登录容器请执行:rabbitmq-plugins enable rabbitmq_management 才可>使用WEB管理页面"
 
vi docker-compose.yml
 
  
version: '3.1' 
+
mysql_install_dir=/home/apps/mysql
services:
+
mysql_data_dir=/home/apps/mysql/data
  rabbitmq:
+
Mem=`free -m | awk '/Mem:/{print $2}'`
    image: rabbitmq:3.6.10-management
 
    ports:
 
      - "5672:5672"
 
      - "4369:4369"
 
      #- "1883:1883"
 
      - "15672:15672"
 
      - "25672:25672"
 
  
    container_name: rabbitmqCluster01
+
Install_MySQL55() {
 +
  #pushd ${oneinstack_dir}/src > /dev/null
 +
  #id -u mysql >/dev/null 2>&1
 +
  [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
  
    hostname: rabbitmq01
+
  [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
    extra_hosts:
+
 
      #- "rabbitmq01:192.168.10.211"#不要加上自己,不然会老是重启的
 
      - "rabbitmq02:192.168.10.212"
 
      - "rabbitmq03:192.168.10.213"
 
    environment:
 
  
      RABBITMQ_ERLANG_COOKIE: 'rabbitmqCookie'    
+
   #if [ "${dbinstallmethod}" == "1" ]; then
      RABBITMQ_DEFAULT_VHOST: /
+
    #tar xzf mysql-${mysql55_ver}-linux-glibc2.12-${SYS_BIT_b}.tar.gz
 +
tar xvf  mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz
  
      RABBITMQ_DEFAULT_USER: lxtxadmin
+
    #mv mysql-${mysql55_ver}-linux-glibc2.12-${SYS_BIT_b}/* ${mysql_install_dir}
 +
mv  mysql-5.5.62-linux-glibc2.12-x86_64/*  ${mysql_install_dir}
 +
 +
mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
 +
 +
#这个没执行
 +
    #sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
 +
    sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe
 +
  
      RABBITMQ_DEFAULT_PASS: tSNTTo886Gq
+
#这个是源码的 跳过
 +
  elif [ "${dbinstallmethod}" == "2" ]; then
 +
    tar xzf mysql-${mysql55_ver}.tar.gz
 +
    pushd mysql-${mysql55_ver}
 +
    [ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
 +
    cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \
 +
    -DMYSQL_DATADIR=${mysql_data_dir} \
 +
    -DSYSCONFDIR=/etc \
 +
    -DWITH_INNOBASE_STORAGE_ENGINE=1 \
 +
    -DWITH_PARTITION_STORAGE_ENGINE=1 \
 +
    -DWITH_FEDERATED_STORAGE_ENGINE=1 \
 +
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
 +
    -DWITH_MYISAM_STORAGE_ENGINE=1 \
 +
    -DWITH_READLINE=1 \
 +
    -DWITH_EMBEDDED_SERVER=1 \
 +
    -DENABLE_DTRACE=0 \
 +
    -DENABLED_LOCAL_INFILE=1 \
 +
    -DDEFAULT_CHARSET=utf8mb4 \
 +
    -DDEFAULT_COLLATION=utf8mb4_general_ci \
 +
    -DEXTRA_CHARSETS=all \
 +
    -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
 +
    make -j ${THREAD}
 +
    make install
 +
    popd
 +
  fi
  
      RABBITMQ_LOGS: /var/lib/rabbitmq/rabbitmq.log
+
#这个if 不成理
 +
  if [ -d "${mysql_install_dir}/support-files" ]; then
 +
    #sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
 +
    echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
 +
    if [ "${dbinstallmethod}" == "1" ]; then
 +
      rm -rf mysql-${mysql55_ver}-*-${SYS_BIT_b}
 +
    elif [ "${dbinstallmethod}" == "2" ]; then
 +
      rm -rf mysql-${mysql55_ver}
 +
    fi
 +
 +
  else
 +
  # rm -rf ${mysql_install_dir}
 +
    #echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}"
 +
    kill -9 $$
 +
  fi
  
      RABBITMQ_SASL_LOGS: /var/lib/rabbitmq/rabbitmq-sasl.log
+
  /bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld
 +
  sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld
 +
  sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld
 +
  chmod +x /etc/init.d/mysqld
 +
  [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
 +
  [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
 +
  popd
  
    volumes:
+
  # my.cnf
      - ./data/rabbitmq:/var/lib/rabbitmq
+
  cat > /etc/my.cnf << EOF
 +
[client]
 +
port = 3306
 +
socket = /tmp/mysql.sock
  
    restart: always 
+
[mysql]
# docker-compose  up -d
+
prompt="MySQL [\\d]> "
</pre>
+
no-auto-rehash
  
==mq2==
+
[mysqld]
<pre>
+
port = 3306
mkdir -p /home/data/docker-compose-mqcluster
+
socket = /tmp/mysql.sock
cd /home/data/docker-compose-mqcluster
 
  
vi docker-compose.yml
+
basedir = ${mysql_install_dir}
+
datadir = ${mysql_data_dir}
version: '3.1' 
+
pid-file = ${mysql_data_dir}/mysql.pid
services:
+
user = mysql
  rabbitmq:
+
bind-address = 0.0.0.0
    image: rabbitmq:3.6.10-management
+
server-id = 1
 
 
    ports:
 
      - "5672:5672"
 
      - "4369:4369"
 
      #- "1883:1883"
 
      - "15672:15672"
 
      - "25672:25672"
 
 
 
    container_name: rabbitmqCluster02
 
    hostname: rabbitmq02
 
    extra_hosts:
 
      - "rabbitmq01:192.168.10.211"
 
      #- "rabbitmq02:192.168.10.212" #不要加上自己,不然会老是重启的
 
      - "rabbitmq03:192.168.10.213"
 
    environment:
 
      RABBITMQ_ERLANG_COOKIE: 'rabbitmqCookie' 
 
      RABBITMQ_DEFAULT_VHOST: /
 
      RABBITMQ_DEFAULT_USER: lxtxadmin
 
      RABBITMQ_DEFAULT_PASS: tSNTTo886Gq
 
      RABBITMQ_LOGS: /var/lib/rabbitmq/rabbitmq.log
 
      RABBITMQ_SASL_LOGS: /var/lib/rabbitmq/rabbitmq-sasl.log
 
      CLUSTERED: 'true'
 
      CLUSTER_WITH: rabbit1
 
      RAM_NODE: 'true'
 
  
    volumes:
+
init-connect = 'SET NAMES utf8mb4'
      - ./data/rabbitmq:/var/lib/rabbitmq
+
character-set-server = utf8mb4
    restart: always 
 
  
</pre>
+
skip-name-resolve
 +
#skip-networking
 +
back_log = 300
  
==mq3==
+
max_connections = 1000
<pre>
+
max_connect_errors = 6000
mkdir -p /home/data/docker-compose-mqcluster
+
open_files_limit = 65535
cd /home/data/docker-compose-mqcluster
+
table_open_cache = 128
 +
max_allowed_packet = 500M
 +
binlog_cache_size = 1M
 +
max_heap_table_size = 8M
 +
tmp_table_size = 16M
  
vi docker-compose.yml
+
read_buffer_size = 2M
 +
read_rnd_buffer_size = 8M
 +
sort_buffer_size = 8M
 +
join_buffer_size = 8M
 +
key_buffer_size = 4M
  
+
thread_cache_size = 8
version: '3.1' 
 
services:
 
  rabbitmq:
 
    image: rabbitmq:3.6.10-management
 
  
    ports:
+
query_cache_type = 1
      - "5672:5672"
+
query_cache_size = 8M
      - "4369:4369"
+
query_cache_limit = 2M
      #- "1883:1883"
 
      - "15672:15672"
 
      - "25672:25672"
 
  
    container_name: rabbitmqCluster03
+
ft_min_word_len = 4
  
    hostname: rabbitmq03
+
log_bin = mysql-bin
    extra_hosts:
+
binlog_format = mixed
      - "rabbitmq01:10.3.10.141"
+
expire_logs_days = 7
      - "rabbitmq02:10.3.10.142"
 
    environment:
 
  
      RABBITMQ_ERLANG_COOKIE: 'rabbitmqCookie' 
+
log_error = ${mysql_data_dir}/mysql-error.log
      RABBITMQ_DEFAULT_VHOST: /
+
slow_query_log = 1
 +
long_query_time = 1
 +
slow_query_log_file = ${mysql_data_dir}/mysql-slow.log
  
      RABBITMQ_DEFAULT_USER: lxtxadmin
+
performance_schema = 0
  
      RABBITMQ_DEFAULT_PASS: tSNTTo886Gq
+
#lower_case_table_names = 1
  
      RABBITMQ_LOGS: /var/lib/rabbitmq/rabbitmq.log
+
skip-external-locking
  
      RABBITMQ_SASL_LOGS: /var/lib/rabbitmq/rabbitmq-sasl.log
+
default_storage_engine = InnoDB
      CLUSTERED: 'true'
+
innodb_file_per_table = 1
      CLUSTER_WITH: rabbit1
+
innodb_open_files = 500
      RAM_NODE: 'true'
+
innodb_buffer_pool_size = 64M
 +
innodb_write_io_threads = 4
 +
innodb_read_io_threads = 4
 +
innodb_thread_concurrency = 0
 +
innodb_purge_threads = 1
 +
innodb_flush_log_at_trx_commit = 2
 +
innodb_log_buffer_size = 2M
 +
innodb_log_file_size = 32M
 +
innodb_log_files_in_group = 3
 +
innodb_max_dirty_pages_pct = 90
 +
innodb_lock_wait_timeout = 120
  
    volumes:
+
bulk_insert_buffer_size = 8M
 +
myisam_sort_buffer_size = 8M
 +
myisam_max_sort_file_size = 10G
 +
myisam_repair_threads = 1
  
      - ./data/rabbitmq:/var/lib/rabbitmq
+
interactive_timeout = 28800
 +
wait_timeout = 28800
  
    restart: always 
+
[mysqldump]
</pre>
+
quick
 +
max_allowed_packet = 500M
  
=config=
+
[myisamchk]
==将节点2,3加入集群==
+
key_buffer_size = 8M
<pre>
+
sort_buffer_size = 8M
#在rabbit2机器进入容器的命令行
+
read_buffer = 4M
sudo docker exec -it rabbitmqCluster02 /bin/bash
+
write_buffer = 4M
 +
EOF
  
#加入集群
+
  sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
rabbitmqctl stop_app  && rabbitmqctl join_cluster rabbit@rabbitmq01  &&rabbitmqctl start_app
+
  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
 +
    sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
 +
    sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
 +
    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
 +
    sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
 +
    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
 +
    sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
 +
    sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
 +
  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
 +
    sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
 +
    sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
 +
    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
 +
    sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
 +
    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
 +
    sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
 +
    sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
 +
 +
  elif [ ${Mem} -gt 3500 ]; then
 +
    sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
 +
    sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
 +
    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
 +
    sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
 +
    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
 +
    sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
 +
    sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
 +
  fi
  
rabbit3执行相同的命令
+
  ${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
docker exec -it rabbitmqCluster03 /bin/bash
 
rabbitmqctl stop_app && rabbitmqctl join_cluster rabbit@rabbitmq01  &&rabbitmqctl start_app
 
  
 +
echo 'export PATH=/home/apps/mysql/bin/:$PATH' >> /etc/profile && source /etc/profile
  
查询集群状态
+
  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
rabbitmqctl cluster_status
+
  chown mysql.mysql -R ${mysql_data_dir}
</pre>
+
  [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
 +
  service mysqld start
 +
  #[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile
 +
  #[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mysql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mysql_install_dir}/bin:\1@" /etc/profile
 +
  . /etc/profile
  
== nginx 配置==
+
dbrootpwd=1234Kuycs886Q
<pre>
 
  
#如果是yum nginx  在放在 conf.d/mq.conf
+
  ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
  server {
+
  ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
        listen      80;
+
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';"
        server_name  mq.com;
+
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
+
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
 +
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
 +
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
 +
  rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf
 +
  [ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf
 +
  echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf
 +
  ldconfig
 +
  service mysqld stop
 +
}
  
        location / {
 
            proxy_pass http://10.3.10.141:15672;
 
            proxy_set_header X-Real-IP $remote_addr;
 
            proxy_set_header Host $host;
 
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
         
 
        }
 
    }
 
  
  
NOTE  selinux  记得关掉  不然可能是502哦
+
##提示的
#SELinux设置
+
/home/apps/mysql/bin/mysqladmin -u root password 'new-password'
getenforce  #查看SELINUX工作模式
+
/home/apps/mysql/bin/mysqladmin -u root -h 10.3.10.139
 +
172.23.11.139 password 'new-password'
  
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config #禁用SELINUX
+
Alternatively you can run:
setenforce 0 #临时禁用SELINUX,无需重启
+
/home/apps/mysql/bin/mysql_secure_installation
 
 
SELINUX=enforcing
 
#此项定义selinux状态。
 
#enforcing—是强制模式系统受selinux保护。就是你违反了策略,你就无法继续操作下去
 
#permissive—是提示模式系统不会受到selinux保护,只是收到警告信息。permissive就是Selinux有效,但是即使你违反了策略的话它让你继续操作,但是把你的违反的内容记录下来(警告信息)
 
#disabled—禁用selinux。
 
  
 
</pre>
 
</pre>
==镜像模式==
 
在我的wiki上
 
[https://wiki.linuxchina.net/index.php/Rabbitmq%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4#.E5.BC.80.E5.90.AF.E9.95.9C.E5.83.8F.E6.A8.A1.E5.BC.8F 开启镜像模式]
 
  
=RabbitMQ实现延迟队列(使用delay插件=
+
=手工=
 
<pre>
 
<pre>
 +
mysql5.5  os debian 10.5 buster
  
docker cp rabbitmq_delayed_message_exchange-3.6.6.ez  c77afe9fa73f:/plugins
+
wget -c  https://mirrors.163.com/mysql/Downloads/MySQL-5.5/mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz
  
 +
apt-get install libaio1
  
: 进入docker容器内 docker exec  -t rabbit  bash
 
  
8. 执行命令让插件生效: 启动延时插件:
 
rabbitmq-plugins enable rabbitmq_delayed_message_exchange
 
</pre>
 
https://www.jianshu.com/p/197715cea172
 
  
=troubleshooting =
+
下载解压到 /usr/local/
<pre>
 
  
1.docker-compose.yml文件报错
+
比较小的配置文件
ERROR: The Compose file './docker-compose.yml' is invalid because:
+
cat /etc/my.cnf
services.rabbitmq.environment.CLUSTERED contains true, which is an invalid type, it should be a string, number, or a null
+
[mysql]
 +
default-character-set=utf8
 +
socket=/var/lib/mysql/mysql.sock
  
 +
[mysqld]
 +
skip-name-resolve
 +
port = 3306
 +
socket=/var/lib/mysql/mysql.sock
  
CLUSTERED: true -->CLUSTERED: 'true'
+
basedir=/usr/local/mysql
  
 +
datadir=/usr/local/mysql/data
  
绑hosts的前进 不要全局FQ  SSR常常坑我们
+
max_connections=200
  
 +
character-set-server=utf8
  
问题2
+
default-storage-engine=INNODB
15672 端口不通 也就是web界面打不开
 
  
问题 镜像用了 rabbitmq 而不是rabbitmq-manager
+
lower_case_table_name=1
 +
max_allowed_packet=16M
  
发现过程 web打不开  15672 端口不能 ,而 5672是通的 进入容器发现是ubuntu 而我记得以前是debian呀 问了下sy才知道 他换了,没全用我的,晕死 ,坑自己人啊
+
cd /usr/local/mysql
  
补救办法  开启 rabbitmq-plugins enable rabbitmq_management
 
  
 +
groupadd mysql
 +
useradd -r -g mysql -s /bin/false mysql
  
</pre>
+
chown -R mysql:mysql ./
  
https://www.rabbitmq.com/management.html
+
./scripts/mysql_install_db --user=mysql  --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
==RabbitMQ镜像集群脑裂 ==
+
<pre>
+
 +
  chown -R mysql:mysql data
 +
chown  777 /etc/my.cnf
  
现象:
+
cp ./support-files/mysql.server /etc/init.d/mysqld
RabbitMQ GUI上显示
 
  
Network partition detected
+
chmod  +x  /etc/init.d/mysqld
Mnesia reports that this RabbitMQ cluster has experienced a network partition. There is a risk of losing data. Please read RabbitMQ documentation about network partitions and the possible solutions.
+
 +
  chkconfig --add mysqld
 +
  mkdir /var/lib/mysql
 +
chmod 777 /var/lib/mysql
 +
  vim /etc/profile
 +
#放最后面
 +
export PATH=$PATH:/usr/local/mysql/bin
  
 +
source  /etc/profile
  
节点3 是挂,以节点1 为准 在 node2 node3 上 分别执行
+
  apt-get install libncurses5-dev libncurses5
rabbitmqctl stop_app
+
rabbitmqctl start_app
+
   
 +
/etc/init.d/mysqld status
 +
/etc/init.d/mysqld start
  
就行
 
</pre>
 
 
==端口在  进入容器  cannot exec in a stopped state: unknown ==
 
今天是端口在 docker restart  id 都不行,进程也还在的  重启了 docker 服务才行了
 
 
==rabbitmq node not running==
 
<pre>
 
 
行情 重启了一下 docker  mq集群就好了
 
 
试过 telnet  15276 有点不太对 一下就跳出来了 
 
 
也登录不了容器  一开始还以为是防火墙 
 
  
 +
#这个版本首次没密码
 +
/usr/local/mysql/bin/mysql  -uroot  -p
  
  
docker exec  -it af1934d27e21 /bin/bash
+
mysql> set password=password("123457");
root@rabbitmq02:/# rabbitmqctl cluster_status
 
Cluster status of node rabbit@rabbitmq02
 
[{nodes,[{disc,[rabbit@rabbitmq01,rabbit@rabbitmq02,rabbit@rabbitmq03]}]},
 
{alarms,[]}]
 
  
 +
#这个有效果  mariadb 10
 +
SET password for 'root'@'localhost' = password('OPS123456#');
  
  
再想加入 报错
 
:/# rabbitmqctl stop_app
 
Stopping rabbit application on node rabbit@rabbitmq02
 
  
root@rabbitmq02:/# rabbitmqctl join_cluster rabbit@rabbitmq01
 
Clustering node rabbit@rabbitmq02 with rabbit@rabbitmq01
 
Error: unable to connect to node rabbit@rabbitmq02: nodedown
 
  
DIAGNOSTICS
 
===========
 
  
attempted to contact: [rabbit@rabbitmq02]
 
 
rabbit@rabbitmq02:
 
  * connected to epmd (port 4369) on rabbitmq02
 
  * epmd reports node 'rabbit' running on port 25672
 
  * TCP connection succeeded but Erlang distribution failed
 
 
  * Distribution failed unexpectedly while waiting for challenge: {error,
 
                                                                  closed}
 
 
 
current node details:
 
- node name: 'rabbitmq-cli-69@rabbitmq02'
 
- home dir: /var/lib/rabbitmq
 
- cookie hash: /HHYeuND8Y2blMJ8WoOg1g==
 
 
root@rabbitmq02:/# rabbitmqctl start_app
 
Starting node rabbit@rabbitmq02
 
Error: unable to connect to node rabbit@rabbitmq02: nodedown
 
 
 
DIAGNOSTICS
 
===========
 
 
attempted to contact: [rabbit@rabbitmq02]
 
 
rabbit@rabbitmq02:
 
current node details:
 
- node name: 'rabbitmq-cli-69@rabbitmq02'
 
- home dir: /var/lib/rabbitmq
 
- cookie hash: /HHYeuND8Y2blMJ8WoOg1g==
 
 
root@rabbitmq02:/# rabbitmqctl start_app
 
Starting node rabbit@rabbitmq02
 
Error: unable to connect to node rabbit@rabbitmq02: nodedown
 
 
 
DIAGNOSTICS
 
===========
 
 
attempted to contact: [rabbit@rabbitmq02]
 
 
rabbit@rabbitmq02:
 
  * connected to epmd (port 4369) on rabbitmq02
 
  * epmd reports node 'rabbit' running on port 25672
 
  * TCP connection succeeded but Erlang distribution failed
 
 
  * TCP connection to remote host has timed out. Is the Erlang distribution using TLS?
 
 
 
current node details:
 
- node name: 'rabbitmq-cli-97@rabbitmq02'
 
- home dir: /var/lib/rabbitmq
 
- cookie hash: /HHYeuND8Y2blMJ8WoOg1g==
 
 
重启 docker 服务  再 如上添加 不过提示 The node is already a member of this cluster  所以应该是重启docker 就好了
 
 
今天是 监听的IP不对 模板的是10 我用的 192.168
 
 
</pre>
 
</pre>
  
=单机版集群=
+
=trouble=
 
<pre>
 
<pre>
version: '3.1' 
 
services:
 
  rabbitmq01:
 
    image: rabbitmq:3.6.10-management
 
    ports:
 
      - "5672:5672"
 
        #- "4369:4369"
 
      - "15672:15672"
 
        #- "25672:25672"
 
    container_name: rabbitmqCluster01
 
    hostname: rabbitmq01
 
    environment:
 
      RABBITMQ_ERLANG_COOKIE: 'rabbitmqCookie' 
 
      RABBITMQ_DEFAULT_VHOST: /
 
      RABBITMQ_DEFAULT_USER: lxtxadmin
 
      RABBITMQ_DEFAULT_PASS: tSNTTo886Gq
 
      RABBITMQ_LOGS: /var/lib/rabbitmq/rabbitmq.log
 
      RABBITMQ_SASL_LOGS: /var/lib/rabbitmq/rabbitmq-sasl.log
 
    volumes:
 
      - ./data/rabbitmq:/var/lib/rabbitmq
 
    restart: always 
 
  
 +
mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
  
  rabbitmq02:
+
apt-get install libaio1
    image: rabbitmq:3.6.10-management
 
    ports:
 
      - "5673:5672"
 
        #- "4369:4369"
 
      - "15673:15672"
 
        #- "25672:25672"
 
    container_name: rabbitmqCluster02
 
    hostname: rabbitmq02
 
    links:
 
      - rabbitmq01
 
    environment:
 
      RABBITMQ_ERLANG_COOKIE: 'rabbitmqCookie' 
 
      RABBITMQ_DEFAULT_VHOST: /
 
      RABBITMQ_DEFAULT_USER: lxtxadmin
 
      RABBITMQ_DEFAULT_PASS: tSNTTo886Gq
 
      RABBITMQ_LOGS: /var/lib/rabbitmq/rabbitmq.log
 
      RABBITMQ_SASL_LOGS: /var/lib/rabbitmq/rabbitmq-sasl.log
 
    volumes:
 
      - ./data/rabbitmq02:/var/lib/rabbitmq
 
    restart: always 
 
  
 +
1. 应该首先去看官方文档,而不是优先看别人的博客。
  
  rabbitmq03:
 
    image: rabbitmq:3.6.10-management
 
    ports:
 
      - "5674:5672"
 
        #- "4369:4369"
 
      - "15674:15672"
 
        #- "25672:25672"
 
    container_name: rabbitmqCluster03
 
    hostname: rabbitmq03
 
    links:
 
      - rabbitmq01
 
    environment:
 
      RABBITMQ_ERLANG_COOKIE: 'rabbitmqCookie' 
 
      RABBITMQ_DEFAULT_VHOST: /
 
      RABBITMQ_DEFAULT_USER: lxtxadmin
 
      RABBITMQ_DEFAULT_PASS: tSNTTo886Gq
 
      RABBITMQ_LOGS: /var/lib/rabbitmq/rabbitmq.log
 
      RABBITMQ_SASL_LOGS: /var/lib/rabbitmq/rabbitmq-sasl.log
 
    volumes:
 
      - ./data/rabbitmq03:/var/lib/rabbitmq
 
    restart: always 
 
  
 +
</pre>
  
 
 
 
然后再加入集群 同上
 
</pre>
 
 
=see also=
 
=see also=
 
+
http://dev.mysql.com/doc/refman/5.5/en/installing.html
https://www.rabbitmq.com/clustering.html#peer-discovery-how-does-it-work
 
 
 
[http://josuelima.github.io/docker/rabbitmq/cluster/2017/04/19/setting-up-a-rabbitmq-cluster-on-docker.html Setting up a RabbitMQ Cluster on Docker]
 
 
 
[https://blog.csdn.net/qq_32488647/article/details/81941491 Docker分布式部署RabbitMQ集群]
 
 
 
[https://www.cnblogs.com/cheyunhua/p/8362200.html 多台机器 值得看 Docker:搭建RabbitMQ集群]
 
 
 
[https://michael728.github.io/2019/06/07/docker-rabbitmq-env/ docker-compose 安装搭建 RabbitMQ 集群]
 
 
 
[https://blog.csdn.net/belonghuang157405/article/details/83540148 单一台机器母机docker简易搭建RabbitMQ集群]
 
 
 
[https://blog.csdn.net/jinyidong/article/details/80003362  RabbitMQ之集群搭建]
 
 
 
也是单物理机么 ?
 
https://www.cnblogs.com/vipstone/p/9362388.html
 
 
 
[https://blog.csdn.net/belonghuang157405/article/details/83540148  docker简易搭建RabbitMQ集群]
 
 
 
 
 
[[category:ops]]
 

2020年8月27日 (四) 08:43的版本


binary install

站内信息 Docker mysql

#!/bin/bash
# Author:  linuxsa.org
# BLOG: 


mysql_install_dir=/home/apps/mysql 
mysql_data_dir=/home/apps/mysql/data
Mem=`free -m | awk '/Mem:/{print $2}'`

Install_MySQL55() {
  #pushd ${oneinstack_dir}/src > /dev/null
  #id -u mysql >/dev/null 2>&1
  [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql

  [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
  

  #if [ "${dbinstallmethod}" == "1" ]; then
    #tar xzf mysql-${mysql55_ver}-linux-glibc2.12-${SYS_BIT_b}.tar.gz
	tar xvf  mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz

    #mv mysql-${mysql55_ver}-linux-glibc2.12-${SYS_BIT_b}/* ${mysql_install_dir}
	mv  mysql-5.5.62-linux-glibc2.12-x86_64/*  ${mysql_install_dir}
	
	mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
	
	#这个没执行
    #sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe 
    sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe
	

#这个是源码的 跳过	
  elif [ "${dbinstallmethod}" == "2" ]; then
    tar xzf mysql-${mysql55_ver}.tar.gz
    pushd mysql-${mysql55_ver}
    [ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
    cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \
    -DMYSQL_DATADIR=${mysql_data_dir} \
    -DSYSCONFDIR=/etc \
    -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    -DWITH_PARTITION_STORAGE_ENGINE=1 \
    -DWITH_FEDERATED_STORAGE_ENGINE=1 \
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
    -DWITH_MYISAM_STORAGE_ENGINE=1 \
    -DWITH_READLINE=1 \
    -DWITH_EMBEDDED_SERVER=1 \
    -DENABLE_DTRACE=0 \
    -DENABLED_LOCAL_INFILE=1 \
    -DDEFAULT_CHARSET=utf8mb4 \
    -DDEFAULT_COLLATION=utf8mb4_general_ci \
    -DEXTRA_CHARSETS=all \
    -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
    make -j ${THREAD}
    make install
    popd
  fi

#这个if 不成理 
  if [ -d "${mysql_install_dir}/support-files" ]; then
    #sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
    echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
    if [ "${dbinstallmethod}" == "1" ]; then
      rm -rf mysql-${mysql55_ver}-*-${SYS_BIT_b}
    elif [ "${dbinstallmethod}" == "2" ]; then
      rm -rf mysql-${mysql55_ver}
    fi
	
  else
   # rm -rf ${mysql_install_dir}
    #echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}"
    kill -9 $$
  fi

  /bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld
  sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld
  sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld
  chmod +x /etc/init.d/mysqld
  [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
  [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
  popd

  # my.cnf
  cat > /etc/my.cnf << EOF
[client]
port = 3306
socket = /tmp/mysql.sock

[mysql]
prompt="MySQL [\\d]> "
no-auto-rehash

[mysqld]
port = 3306
socket = /tmp/mysql.sock

basedir = ${mysql_install_dir}
datadir = ${mysql_data_dir}
pid-file = ${mysql_data_dir}/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1

init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4

skip-name-resolve
#skip-networking
back_log = 300

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 500M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7

log_error = ${mysql_data_dir}/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = ${mysql_data_dir}/mysql-slow.log

performance_schema = 0

#lower_case_table_names = 1

skip-external-locking

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

[mysqldump]
quick
max_allowed_packet = 500M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
EOF

  sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
    sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
    sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
    sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
    sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
    sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
    sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
    sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
    sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
    sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
    sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
	
  elif [ ${Mem} -gt 3500 ]; then
    sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
    sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
    sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
    sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
    sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
  fi

  ${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}

echo 'export PATH=/home/apps/mysql/bin/:$PATH' >> /etc/profile && source /etc/profile

  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
  chown mysql.mysql -R ${mysql_data_dir}
  [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
  service mysqld start
  #[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile
  #[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mysql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mysql_install_dir}/bin:\1@" /etc/profile
  . /etc/profile

dbrootpwd=1234Kuycs886Q

  ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
  ${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';"
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
  rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf
  [ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf
  echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf
  ldconfig
  service mysqld stop
}



##提示的
/home/apps/mysql/bin/mysqladmin -u root password 'new-password'
/home/apps/mysql/bin/mysqladmin -u root -h 10.3.10.139
172.23.11.139 password 'new-password'

Alternatively you can run:
/home/apps/mysql/bin/mysql_secure_installation

手工

mysql5.5  os debian 10.5 buster

wget -c   https://mirrors.163.com/mysql/Downloads/MySQL-5.5/mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz

apt-get install libaio1



下载解压到 /usr/local/

比较小的配置文件 
cat /etc/my.cnf 
[mysql]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock

[mysqld]
skip-name-resolve
port = 3306
socket=/var/lib/mysql/mysql.sock

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

max_connections=200

character-set-server=utf8

default-storage-engine=INNODB

lower_case_table_name=1
max_allowed_packet=16M

cd /usr/local/mysql


 groupadd mysql
 useradd -r -g mysql -s /bin/false mysql

chown -R mysql:mysql ./

 ./scripts/mysql_install_db --user=mysql  --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
 
 
  chown -R mysql:mysql data
 chown  777 /etc/my.cnf 

cp ./support-files/mysql.server /etc/init.d/mysqld

 chmod  +x  /etc/init.d/mysqld
 
  chkconfig --add mysqld
  mkdir /var/lib/mysql
 chmod 777 /var/lib/mysql
   vim /etc/profile
#放最后面
export PATH=$PATH:/usr/local/mysql/bin

source  /etc/profile

 apt-get install libncurses5-dev libncurses5
 
 
/etc/init.d/mysqld status 
 /etc/init.d/mysqld start 


#这个版本首次没密码 
/usr/local/mysql/bin/mysql  -uroot  -p


mysql> set password=password("123457");

#这个有效果  mariadb 10 
SET password for 'root'@'localhost' = password('OPS123456#');





trouble


mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

apt-get install libaio1

1. 应该首先去看官方文档,而不是优先看别人的博客。


see also

http://dev.mysql.com/doc/refman/5.5/en/installing.html