Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<display-name>MySQL PID Dir</display-name>
<description>MySQL Pid Dir</description>
</property>
<property>
<name>mysql_data_dir</name>
<value>${mysql_home}/data</value>
<display-name>MySQL Data Dir</display-name>
<description>MySQL Data Dir</description>
</property>
<!-- my.cnf -->
<property>
<name>content</name>
Expand All @@ -40,13 +46,17 @@
[mysqld]
port=3306
basedir=${mysql_home}
datadir=${mysql_home}/data
datadir=${mysql_data_dir}
socket=/tmp/mysql.sock
pid-file = ${mysql_pid_dir}/mysqld.pid
log-error = ${mysql_log_dir}/error.log
general-log-file = ${mysql_log_dir}/general.log
slow-query-log-file = ${mysql_log_dir}/slow.log
log-bin = ${mysql_log_dir}/mysql-bin.log
default-storage-engine=INNODB

[client]
socket=/tmp/mysql.sock
]]>
</value>
<attrs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public static String generateRandomFileName() {
*/
public static void createDirectories(
String dirPath, String owner, String group, String permissions, boolean recursive) {
log.info("Creating directory: [{}]", dirPath);
if (StringUtils.isBlank(dirPath)) {
log.error("dirPath must not be null");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static ShellResult execCmd(String command, String tenant) throws IOExcept
builderParameters.add("sh");
builderParameters.add("-c");
builderParameters.add(command);
log.info("Running command: [{}], user: [{}]", command, tenant);
return ShellExecutor.execCommand(builderParameters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
@NoArgsConstructor
public class MySQLParams extends InfraParams {

private String mysqlLogDir = "/var/log/mysql";
private String mysqlPidDir = "/var/run/mysql";
private String mysqlLogDir;
private String mysqlPidDir;
private String mysqlDataDir;

private String rootPassword;
private String myCnfContent;
Expand All @@ -54,6 +55,16 @@ public MySQLParams(ComponentCommandPayload componentCommandPayload) {
common();
}

@Override
public void initGlobalParams() {
super.initGlobalParams();

Map<String, Object> map = getGlobalParamsMap();
mysqlPidDir = map.get("mysql_pid_dir").toString();
mysqlLogDir = map.get("mysql_log_dir").toString();
mysqlDataDir = map.get("mysql_data_dir").toString();
}

public Map<String, Object> common() {
Map<String, Object> common = LocalSettings.configurations(getServiceName(), "common");
rootPassword = common.get("root_password").toString();
Expand All @@ -63,8 +74,6 @@ public Map<String, Object> common() {
@GlobalParams
public Map<String, Object> myCnf() {
Map<String, Object> myCnf = LocalSettings.configurations(getServiceName(), "my.cnf");
mysqlPidDir = myCnf.get("mysql_pid_dir").toString();
mysqlLogDir = myCnf.get("mysql_log_dir").toString();
myCnfContent = myCnf.get("content").toString();
return myCnf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public ShellResult configure(Params params) {
public ShellResult init(Params params) {
String user = params.user();
String binDir = params.serviceHome() + "/bin";
runCommand(binDir + "/mysqld --initialize-insecure", user);
String confPath = params.serviceHome() + "/my.cnf";
runCommand(binDir + "/mysqld --defaults-file=" + confPath + " --initialize-insecure", user);
return ShellResult.success();
}

Expand Down Expand Up @@ -93,24 +94,28 @@ public ShellResult prepare(Params params) {
MySQLParams mysqlParams = (MySQLParams) params;
String user = params.user();
String binDir = params.serviceHome() + "/bin";
String confPath = params.serviceHome() + "/my.cnf";
String password = mysqlParams.getRootPassword();
runCommand(
MessageFormat.format(
"{0}/mysql -u root -e \"ALTER USER 'root'@'localhost' IDENTIFIED BY ''{1}'';\"",
binDir, password),
"{0}/mysql --defaults-file={1} -u root -e \"ALTER USER 'root'@'localhost' IDENTIFIED BY ''{2}'';\"",
binDir, confPath, password),
user);
runCommand(
MessageFormat.format(
"{0}/mysql -u root -p''{1}'' -e \"CREATE USER ''root''@''%'' IDENTIFIED BY ''{1}'';\"",
binDir, password),
"{0}/mysql --defaults-file={1} -u root -p''{2}'' -e \"CREATE USER ''root''@''%'' IDENTIFIED BY ''{2}'';\"",
binDir, confPath, password),
user);
runCommand(
MessageFormat.format(
"{0}/mysql -u root -p''{1}'' -e \"GRANT ALL PRIVILEGES ON *.* TO ''root''@''%'' WITH GRANT OPTION;\"",
binDir, password),
"{0}/mysql --defaults-file={1} -u root -p''{2}'' -e \"GRANT ALL PRIVILEGES ON *.* TO ''root''@''%'' WITH GRANT OPTION;\"",
binDir, confPath, password),
user);
runCommand(
MessageFormat.format("{0}/mysql -u root -p''{1}'' -e \"FLUSH PRIVILEGES;\"", binDir, password), user);
MessageFormat.format(
"{0}/mysql --defaults-file={1} -u root -p''{2}'' -e \"FLUSH PRIVILEGES;\"",
binDir, confPath, password),
user);
return ShellResult.success();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static ShellResult configure(Params params) {

LinuxFileUtils.createDirectories(mysqlParams.getMysqlLogDir(), mysqlUser, mysqlGroup, PERMISSION_755, true);
LinuxFileUtils.createDirectories(mysqlParams.getMysqlPidDir(), mysqlUser, mysqlGroup, PERMISSION_755, true);
LinuxFileUtils.createDirectories(mysqlParams.getMysqlDataDir(), mysqlUser, mysqlGroup, PERMISSION_755, true);

LinuxFileUtils.toFileByTemplate(
mysqlParams.getMyCnfContent(),
Expand Down
2 changes: 1 addition & 1 deletion dev-support/docker/image/Dockerfile.openeuler24
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
FROM openeuler/openeuler:24.03

RUN dnf install -y sudo wget openssh-clients openssh-server mariadb mariadb-server net-tools chrony krb5-server krb5-libs krb5-workstation git python3 procps-ng
RUN dnf install -y postgresql java-17-openjdk-devel vim
RUN dnf install -y postgresql java-17-openjdk-devel vim numactl

ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk
ENV PATH=$JAVA_HOME/bin:$PATH
Expand Down
2 changes: 1 addition & 1 deletion dev-support/docker/image/Dockerfile.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
FROM rockylinux/rockylinux:8

RUN yum -y install sudo wget openssh-clients openssh-server vim postgresql mariadb mariadb-server net-tools chrony krb5-server krb5-libs krb5-workstation git rpm-build python3 procps-ng
RUN dnf install -y postgresql java-17-openjdk-devel vim
RUN dnf install -y postgresql java-17-openjdk-devel vim numactl
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk
ENV PATH=$JAVA_HOME/bin:$PATH

Expand Down
Loading